Fix 007_PW_UPF201_USPP_Fe in 01_PW: G=0 indexing in nspin=2 mixing inner products - #7825
Open
chengleizheng wants to merge 4 commits into
Open
Fix 007_PW_UPF201_USPP_Fe in 01_PW: G=0 indexing in nspin=2 mixing inner products#7825chengleizheng wants to merge 4 commits into
chengleizheng wants to merge 4 commits into
Conversation
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.
Fix #7824
The magnetization part of the inner product accessed the G=0 component with a hardcoded local-G-list index [0], but the local G-list is ordered by (x,y) FFT sticks, so index 0 is the first plane wave of the first owned stick rather than G=0, which actually sits at ig_gge0 and only exists on the rank that owns it. As a result, ranks that do not own G=0 added a spurious fac2 * |dm|^2 term from their first local G vector, making the inner products — and hence the DIIS/Pulay mixing coefficients and the convergence measure drho — depend on how the k-point pools are divided. This caused identical inputs to converge to slightly different total energies and stresses with different MPI process counts (reproduced on test 007_PW_UPF201_USPP_Fe: np=4/5/8 differed from np=3/6/12 by ~1e-6 to 7e-6 eV). The fix locates G=0 with ig_gge0 (only added when ig0 >= 0) and skips it in the |G|>0 sum, using
if (ig == ig0) { continue; }, so every G component is counted exactly once and G=0 is no longer doubled by the gamma-only factor; this aligns the nspin=2 code with the already-correct nspin=4 branches. After the fix, 007 converges to the same energy for np=3/4/6 (spread 1.4e-9 eV) and CPU/GPU runs agree, so its result.ref is updated accordingly.In addition, a threshold file (etot 0.001) is added to test 096_PW_PBE0_AFM, matching its FM counterpart. This test's PBE0 calculation has an intrinsic numerical noise of ~2.5e-7 eV (observed across thread counts and machines), which already exceeds the default 1e-7 eV threshold; the mixing-path change shifted its SCF trajectory just enough for CI to fail. The threshold file accounts for this inherent noise so the test passes deterministically. The abacuslite/ASE_interface test failure seen in the same CI run is unrelated to this PR (it is a nspin=1 LCAO calculation that does not touch any modified code path).