Skip to content

test: cover nonzero Mx My Mz in spin4 Mulliken integration - #8284

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
hujieting:test-mulliken-spin4-xyz
Nov 5, 2026
Merged

mohanchen merged 1 commit into
deepmodeling:developfrom
hujieting:test-mulliken-spin4-xyz

Conversation

@hujieting

@hujieting hujieting commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the verification results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below.

Linked Issue

No new issue is required. This PR adds regression coverage for the noncollinear Mulliken My sign correction in #8250.

Unit Tests and/or Case Tests for my changes

Test case: tests/03_NAO_multik/scf_out_mul_spin4

Verification: The updated integration test was evaluated using both corrected and pre-fix CPU ABACUS binaries (4 MPI ranks, 1 OpenMP thread).

Runner invocation pattern: Autotest.sh -a ${ABACUS_BIN_PATH} -n 4 -j auto (the integration-test runner; exact executed command lines and resolved binary paths from the original runs were not retained in the available test record). The source commit and binary identity for each of the two runs still need to be recorded for exact reproduction. The test-only change in this PR is commit 35c27ffb70398da1f60c8a2f2df27f08475087a3; the production fix is tracked in #8250. These are not substitutes for the two tested binary revisions.

Version SCF iterations Test result
Corrected version 18 PASS — all 7 checks passed (exit code 0)
Pre-fix version 18 FAIL — Mulliken My reference mismatch (exit code 1)

Both versions converged in SCF, but only the corrected version reproduced the expected Mulliken magnetization components. This confirms that the updated test detects the original My sign error, rather than merely checking SCF convergence.

The existing test is already registered in both CASES_CPU.txt and CASES_GPU.txt; no case-list changes are required.

What's changed?

Background

The noncollinear (nspin=4) Mulliken magnetization contains three Cartesian components: Mx, My, and Mz.

The previous My sign error arose from the density-matrix convention used in the Mulliken magnetization calculation and was corrected in #8250.

However, the existing scf_out_mul_spin4 integration test initialized Fe magnetic moments along opposite x directions. Consequently, My was approximately zero, making the test insensitive to a sign reversal of the y component. The test could pass even if the original bug were reintroduced.

Changes

This PR strengthens the existing integration test by rotating the initial Fe magnetic moments from opposite [100] directions to opposite [111] directions. The updated reference Mulliken moments have nonzero components along all three axes:

  • Fe1: (+0.6911, +0.6911, +0.6911) μB
  • Fe2: (-0.6911, -0.6911, -0.6911) μB

Three existing test files are updated:

  1. tests/03_NAO_multik/scf_out_mul_spin4/STRU: change the initial magnetic-moment orientations while preserving the existing calculation setup.
  2. tests/03_NAO_multik/scf_out_mul_spin4/mulliken.txt.ref: update reference Mulliken outputs for nonzero Mx, My, and Mz.
  3. tests/03_NAO_multik/scf_out_mul_spin4/result.ref: update the magnetic point-group reference from C_4h to S_6 for the rotated configuration. Known test-runner limitation: the current Autotest.sh::check_out numeric comparison does not enforce string equality for this label. The S_6 reference documents the expected output but should not be considered a verified string assertion. The signed Mulliken component checks are separate and do detect the original My regression.

No new test directory, INPUT parameters, production source code, or CI configuration changes are introduced.

Regression Validation

The corrected implementation converges and passes the reference checks. The pre-fix implementation also converges, but fails the My comparison due to the incorrect sign.

Thus, the test provides regression coverage for the previously fixed My bug while retaining checks on Mx and Mz.

Governance Notes

  • INPUT/docs changes: None.
  • Core module impact: None; only existing integration-test files are modified.
  • Exceptions requested: None.

@hujieting hujieting added the Tests/Examples Issues/PR related to unit tests and integrate tests label Nov 4, 2026

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signed Mulliken comparison is sensitive to a My sign reversal with these nonzero components.

Non-blocking: Please add the exact test command and source revisions or binary identities for the corrected and pre-fix runs so the reported comparison can be reproduced.

Static review of 35c27ffb; no builds or tests were run.

@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Nov 5, 2026
@mohanchen
mohanchen merged commit 3c1ddda into deepmodeling:develop Nov 5, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants