Skip to content

Fix: correct My sign in noncollinear Mulliken magnetism - #8250

Merged
mohanchen merged 3 commits into
deepmodeling:developfrom
hujieting:fix-mulliken-my-sign
Nov 3, 2026
Merged

mohanchen merged 3 commits into
deepmodeling:developfrom
hujieting:fix-mulliken-my-sign

Conversation

@hujieting

@hujieting hujieting commented Oct 30, 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 exact verification commands run and their 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.

Summary

Fix the incorrect sign of the y-component of Mulliken magnetization (My) for noncollinear calculations (nspin=4).

The previous implementation used a sign convention inconsistent with the conjugate-first density matrix representation and Pauli-matrix decomposition in ABACUS.

The corrected expression is:
My = Im(mud_ud - mud_du)
Previously:
My_old = -Im(mud_ud) + Im(mud_du)

Changes

  • Correct the Mulliken My sign for nspin=4.
  • Extract the accumulation logic into collect_MW_nspin4().
  • Add a unit test covering positive and negative y-direction magnetization and general noncollinear spin directions.
  • Keep Mx, Mz, and the nspin=1/2 paths unchanged.
  • No INPUT parameter changes.

Verification

Unit Tests

The Mulliken unit tests passed, including the new regression test OutputMullikenSpinTest.Nspin4MyFollowsPauliConvention.

Verification command:

ctest --test-dir build-test -R MODULE_IO_mulliken_test --output-on-failure
Result: 1/1 CTest target passed.

Integration Tests

Two independent ABACUS versions were compiled and compared:

  • Before fix: 0223bfeb0
  • After fix: e2a8728f0
  • Runtime: 4 MPI ranks, OMP_NUM_THREADS=1

The converged noncollinear Fe example (examples/04_noncollinear/01_Fe_noncollinear) was tested with initial magnetization along +y and out_mul 1.
SCF converged in 11 iterations with final DRHO = 8.2125e-06.

Quantity Before Fix After Fix
Fe1 My (uB) -3.620321 +3.620321
Fe2 My (uB) -3.620321 +3.620321
Total energy (eV) -6818.010393 -6818.010393
The corrected My agrees with the prescribed magnetization direction. Mx, Mz, atomic charges, and total energy remain unchanged.

Result: PASS
The existing tests/17_DS_DFTU/02_LCAO_SPIN_S4_XYZ case was also tested. It confirmed the exact My sign reversal with unchanged other quantities, but did not reach SCF convergence due to its existing numerical stability issue.

Conclusion

The Mulliken My sign correction is verified by unit tests and a converged noncollinear Fe integration calculation. The fix affects only the reported My component and does not alter the SCF calculation.
No automated integration regression case was added.

Correct the nspin=4 Mulliken My sign for the conj-first density matrix convention.

Add a regression test covering nonzero My for several noncollinear spin directions.

Keep the nspin=1/2 paths unchanged.
@hujieting hujieting added the Bugs Bugs that only solvable with sufficient knowledge of DFT label Oct 30, 2026
@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Oct 30, 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 My sign now matches the conj-first density matrix and the production overlap contraction. No new implementation defect found. Static review only; no build or runtime tests were run.

Non-blocking: Please record the exact configure/build and test commands, including the command or sign-revert procedure used to check the old-sign failure.

@mohanchen mohanchen 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.

LGTM

@mohanchen mohanchen added the Collinear/non-collinear/SOC/delta-spin Issues related to SOC label Nov 3, 2026
@mohanchen
mohanchen merged commit f531565 into deepmodeling:develop Nov 3, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugs Bugs that only solvable with sufficient knowledge of DFT Collinear/non-collinear/SOC/delta-spin Issues related to SOC Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants