Fix: DeltaSpin energy fix - #7748
Open
dyzheng wants to merge 3 commits into
Open
Conversation
added 3 commits
August 1, 2026 23:57
… 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.
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