Skip to content

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
deepmodeling:developfrom
chengleizheng:fix/007-warning
Open

Fix 007_PW_UPF201_USPP_Fe in 01_PW: G=0 indexing in nspin=2 mixing inner products#7825
chengleizheng wants to merge 4 commits into
deepmodeling:developfrom
chengleizheng:fix/007-warning

Conversation

@chengleizheng

@chengleizheng chengleizheng commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

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).

@chengleizheng chengleizheng added the Bugs Bugs that only solvable with sufficient knowledge of DFT label Aug 16, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SCF results depend on the number of MPI processes (007_PW_UPF201_USPP_Fe, nspin=2, kpar>1)

1 participant