Conversation
… basis - cal_escon(): replace is_Mi_converged gate with lambda_/Mi_ empty check to prevent segfault when uninitialized - elecstate_pw: add get_spin_constrain_energy() override so PW basis computes DeltaSpin constraint energy (previously returned 0.0) - elecstate_pw.h: declare get_spin_constrain_energy() override Note: this fix enables escon computation for PW DeltaSpin but lambda values from BFGS optimizer may differ from accel branch due to energy functional convention differences. Full convergence with accel requires lambda_loop.cpp migration.
… refs Source changes: - cal_escon(): replace is_Mi_converged guard with lambda_/Mi_ empty check to prevent segfault when uninitialized (matching accel convention) - elecstate_pw: add get_spin_constrain_energy() override so PW basis includes DeltaSpin constraint energy in total energy (was always 0) Test refs regenerated for 7 cases with significant energy changes: - 14_PW_DS_S4_XYZ, 15_PW_DS_S4_Z, 16_PW_DS_S4_XY - 18_PW_DFTU_DS_S2_Z, 19_PW_DFTU_DS_S4_XY, 21_PW_DFTU_DS_S4_Z - 41_PW_DS_S4_Thr10_XY nspin=2 tests and ReadLam/Thr1e10 tests unchanged.
…escon Source fixes: - spin_constrain.h: fix My = -Im(occ1-occ2) → Im(occ1-occ2) The magnetic moment y-component had the wrong sign in the Pauli matrix transformation, causing incorrect Mi computation for nspin=4 DeltaSpin. - cal_escon(): replace is_Mi_converged guard with lambda_/Mi_ empty check - elecstate_pw: add get_spin_constrain_energy() for PW basis DeltaSpin Refs regenerated for nspin=4 DeltaSpin cases: 14, 15, 16, 19, 21, 41 Test 18 unchanged, nspin=2 tests unchanged.
elecstate_pw.cpp now calls spinconstrain::SpinConstrain< std::complex<double>>::getScInstance()/cal_escon() via the new get_spin_constrain_energy() override. The MODULE_ESTATE_elecstate_pw unit test compiles elecstate_pw.cpp directly but did not link the deltaspin module, causing undefined-reference link errors in BUILD_TESTING builds (test.yml and cuda.yml CI jobs). Add spin_constrain.cpp to the test SOURCES, mirroring the existing MODULE_LCAO_deltaspin_spin_constrain_test pattern.
ElecStatePW::get_spin_constrain_energy() is a new virtual override that needs a definition in the vtable. Test targets (MODULE_HSOLVER_base, MODULE_HSOLVER_pw, MODULE_HSOLVER_sdft) compile a mock implementation of ElecStatePW methods instead of linking elecstate_pw.cpp, and were missing a stub for this new method, causing: undefined reference to ElecStatePW::get_spin_constrain_energy()
mohanchen
approved these changes
Aug 2, 2026
Collaborator
|
We need to include those tests in CICD. |
maki49
added a commit
to maki49/abacus-develop
that referenced
this pull request
Aug 18, 2026
Follow-up to deepmodeling#7832 (revert deepmodeling#7664 m_y convention) addressing review feedback. DeltaSpin (was left in the deepmodeling#7664 y-convention while the DM was reverted): - dspin_lcao.cpp cal_coeff_lambda: revert to lambda_ud = lambda_x + i*lambda_y. pauli_to_moment already reads the bare +Im (via deepmodeling#7748) and measures the physical +m_y from the conj-first occupation; deepmodeling#7664 flipped both the measurement and this drive (y-mirror), deepmodeling#7748 reverted only the measurement, so the constraint loop was driving the y-mirror of the target. Restoring the pre-deepmodeling#7664 drive re-pairs it with the (correct) measurement. - spin_constrain.h/.cpp: fix stale comments (occ is conj-first; My=+Im). - deltaspin_core_test.cpp: local re-impl and GeneralCase pinned My=-0.4 (deepmodeling#7664); corrected to the bare +0.4 so it stops enshrining the wrong sign. Tests: - test_soc_magnetization_roundtrip: add the <complex> (multi-k) specialization case; drop the dangling ref/MSG doc path from the comment. - symm_rho_soc_test: relabel SpinConventionCoupling — it validates spin_so3 in the PHYSICAL-rho frame, not the runtime conj-first DM path; note it does not pin the DM convention. Mulliken: - output_mulliken.cpp: comment flagging that M_y (pre-existing, since 3.7.0) likely reports -m_y from the conj-first DM and must not be used as an oracle for the DM convention; real fix + unit test deferred to a separate PR. Not covered here (need integration runs / separate PR): regenerate & report the nspin=4 reference values from post-PR code; nspin=4 DeltaSpin regression with nonzero m_y target; in-plane non-collinear symmetry integration test; nspin=4 DMR restart compatibility with deepmodeling#7664-era files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
maki49
added a commit
to maki49/abacus-develop
that referenced
this pull request
Aug 27, 2026
Follow-up to deepmodeling#7832 (revert deepmodeling#7664 m_y convention) addressing review feedback. DeltaSpin (was left in the deepmodeling#7664 y-convention while the DM was reverted): - dspin_lcao.cpp cal_coeff_lambda: revert to lambda_ud = lambda_x + i*lambda_y. pauli_to_moment already reads the bare +Im (via deepmodeling#7748) and measures the physical +m_y from the conj-first occupation; deepmodeling#7664 flipped both the measurement and this drive (y-mirror), deepmodeling#7748 reverted only the measurement, so the constraint loop was driving the y-mirror of the target. Restoring the pre-deepmodeling#7664 drive re-pairs it with the (correct) measurement. - spin_constrain.h/.cpp: fix stale comments (occ is conj-first; My=+Im). - deltaspin_core_test.cpp: local re-impl and GeneralCase pinned My=-0.4 (deepmodeling#7664); corrected to the bare +0.4 so it stops enshrining the wrong sign. Tests: - test_soc_magnetization_roundtrip: add the <complex> (multi-k) specialization case; drop the dangling ref/MSG doc path from the comment. - symm_rho_soc_test: relabel SpinConventionCoupling — it validates spin_so3 in the PHYSICAL-rho frame, not the runtime conj-first DM path; note it does not pin the DM convention. Mulliken: - output_mulliken.cpp: comment flagging that M_y (pre-existing, since 3.7.0) likely reports -m_y from the conj-first DM and must not be used as an oracle for the DM convention; real fix + unit test deferred to a separate PR. Not covered here (need integration runs / separate PR): regenerate & report the nspin=4 reference values from post-PR code; nspin=4 DeltaSpin regression with nonzero m_y target; in-plane non-collinear symmetry integration test; nspin=4 DMR restart compatibility with deepmodeling#7664-era files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mohanchen
pushed a commit
that referenced
this pull request
Sep 1, 2026
* revert #7664 m_y convention Fix comment Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * test: revert scf_*_spin4 result.ref to pre-#7664 values These nspin=4 LCAO references were updated by #7664 (1457e26) to match its m_y sign convention in func_xyz_to_updown, which sign-flips the transverse magnetization (the stored DM block is conj(P); m_y reads Im so it flips). Commit fa8492f reverts that convention and restores the correct pre-#7664 physics (verified: Mn3Sn recovers the 120-deg AFM ground state, lower energy). scf_u_spin4 (mag[111]+U): force 14.360->11.332, stress 4334.0->4697.8, etot -6789.142->-6789.282 (the #7664 bug raised the energy by ~0.14 eV). scf_out_dos_spin4 / scf_angle_spin4: tiny (1e-4) reverts, near-collinear. 099_PW_DJ_SO left unchanged (PW path, not affected by the LCAO fix). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test: add nspin=4 magnetization round-trip regression test Guards the func_xyz_to_updown m_y convention against the #7664 regression. Asserts the physical invariant: the magnetization <sigma> encoded in a DM spinor block (built with cal_dm_psi's convention DM=conj(P)) is recovered with the correct sign in ALL THREE components by func_xyz_to_updown. The m_y channel (Im) is the sensitive one; m_x/m_z (Re) are conj-invariant. Fails on the #7664 convention (m_y sign-flipped), passes after the fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(soc): reconcile DeltaSpin/tests with reverted nspin=4 m_y convention Follow-up to #7832 (revert #7664 m_y convention) addressing review feedback. DeltaSpin (was left in the #7664 y-convention while the DM was reverted): - dspin_lcao.cpp cal_coeff_lambda: revert to lambda_ud = lambda_x + i*lambda_y. pauli_to_moment already reads the bare +Im (via #7748) and measures the physical +m_y from the conj-first occupation; #7664 flipped both the measurement and this drive (y-mirror), #7748 reverted only the measurement, so the constraint loop was driving the y-mirror of the target. Restoring the pre-#7664 drive re-pairs it with the (correct) measurement. - spin_constrain.h/.cpp: fix stale comments (occ is conj-first; My=+Im). - deltaspin_core_test.cpp: local re-impl and GeneralCase pinned My=-0.4 (#7664); corrected to the bare +0.4 so it stops enshrining the wrong sign. Tests: - test_soc_magnetization_roundtrip: add the <complex> (multi-k) specialization case; drop the dangling ref/MSG doc path from the comment. - symm_rho_soc_test: relabel SpinConventionCoupling — it validates spin_so3 in the PHYSICAL-rho frame, not the runtime conj-first DM path; note it does not pin the DM convention. Mulliken: - output_mulliken.cpp: comment flagging that M_y (pre-existing, since 3.7.0) likely reports -m_y from the conj-first DM and must not be used as an oracle for the DM convention; real fix + unit test deferred to a separate PR. Not covered here (need integration runs / separate PR): regenerate & report the nspin=4 reference values from post-PR code; nspin=4 DeltaSpin regression with nonzero m_y target; in-plane non-collinear symmetry integration test; nspin=4 DMR restart compatibility with #7664-era files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * test(soc): SpinConventionCoupling now exercises the real func_xyz_to_updown Replaces the local Pauli re-implementation with the actual elecstate::DensityMatrix_Tools::func_xyz_to_updown, fed the conj-first stored DM block (DM=conj(P)) exactly as the runtime does, and asserts (a) it recovers the physical magnetization and (b) spin_so3 (the rotation psymmg_soc applies to the grid) agrees with the SU(2) block rotation + real extraction. The two conventions can no longer drift apart silently; the test fails on the #7664 m_y flip. Links density_matrix.cpp only (no io/mocks needed). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * rebase and solve conflicts --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: dyzheng <zhengdy@aisi.ac.cn>
aboys-cb
pushed a commit
to MagTheoryLab/abacus-develop
that referenced
this pull request
Sep 1, 2026
Follow-up to deepmodeling#7832 (revert deepmodeling#7664 m_y convention) addressing review feedback. DeltaSpin (was left in the deepmodeling#7664 y-convention while the DM was reverted): - dspin_lcao.cpp cal_coeff_lambda: revert to lambda_ud = lambda_x + i*lambda_y. pauli_to_moment already reads the bare +Im (via deepmodeling#7748) and measures the physical +m_y from the conj-first occupation; deepmodeling#7664 flipped both the measurement and this drive (y-mirror), deepmodeling#7748 reverted only the measurement, so the constraint loop was driving the y-mirror of the target. Restoring the pre-deepmodeling#7664 drive re-pairs it with the (correct) measurement. - spin_constrain.h/.cpp: fix stale comments (occ is conj-first; My=+Im). - deltaspin_core_test.cpp: local re-impl and GeneralCase pinned My=-0.4 (deepmodeling#7664); corrected to the bare +0.4 so it stops enshrining the wrong sign. Tests: - test_soc_magnetization_roundtrip: add the <complex> (multi-k) specialization case; drop the dangling ref/MSG doc path from the comment. - symm_rho_soc_test: relabel SpinConventionCoupling — it validates spin_so3 in the PHYSICAL-rho frame, not the runtime conj-first DM path; note it does not pin the DM convention. Mulliken: - output_mulliken.cpp: comment flagging that M_y (pre-existing, since 3.7.0) likely reports -m_y from the conj-first DM and must not be used as an oracle for the DM convention; real fix + unit test deferred to a separate PR. Not covered here (need integration runs / separate PR): regenerate & report the nspin=4 reference values from post-PR code; nspin=4 DeltaSpin regression with nonzero m_y target; in-plane non-collinear symmetry integration test; nspin=4 DMR restart compatibility with deepmodeling#7664-era files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
AroundPeking
pushed a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 24, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
AroundPeking
pushed a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 26, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
AroundPeking
pushed a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 27, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
AroundPeking
pushed a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 27, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
AroundPeking
pushed a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 29, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
AroundPeking
added a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 29, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
AroundPeking
added a commit
to AroundPeking/abacus-develop
that referenced
this pull request
Sep 30, 2026
Port deepmodeling/abacus-develop PR deepmodeling#7832 (f29968d) onto the magnetic LibRPA producer baseline. Correct both density-extraction templates and the DeltaSpin driving field. Include the prerequisite deepmodeling#7748 pauli_to_moment sign correction absent from this older baseline. Preserve the existing cubic and hexagonal spin-rotation tests and LibRPA exports. Adapt the upstream physical-spinor tests to the legacy filenames; make the DeltaSpin unit test call the production measurement helper. The old baseline has no deepmodeling#7804 yflip rotation compensation to remove. Validation on dongfang: release MPI build, 84 C++ cases in 14 CTest targets, 12 ABF Python tests, and all three deepmodeling#7832 integration references passed with unchanged acceptance thresholds. Separate material comparisons are retained in workspace/symmetry/runs/20260919-abacus-msg-upstream-r1 in the GW topic. (cherry picked from commit f29968d) (cherry picked from commit 07d0470b1610eb44b7b6cb4a8009229f3b8b6e0f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
Fix #
Unit Tests and/or Case Tests for my changes
What's changed?
Governance Notes