Repository navigation
Description
Summary
In PW DFT+U calculations with nspin=4 (npol=2), enabling mixing_dftu drops three quarters of each correlated on-site occupation matrix when the freshly projected matrix is flattened for charge mixing. For a d shell, the matrix has 100 values per atom, but OccupationMatrix::write_to_flat() copies only 25. The read-back path consumes all 100.
Small calculation reproducer
Use the existing two-Fe PW SOC +U fixture:
- INPUT
- STRU
- KPT
- Pseudopotential:
tests/PP_ORB/Fe.upf(the fixture's existingpseudo_dir ../../PP_ORB)
For a short, directly inspectable run, set scf_nmax 3, out_occ_mat 1, out_freq_elec 1, and mixing_dftu 1 in INPUT. Remove cal_force, cal_stress, mixing_restart, and mixing_dmr; all other fixture settings remain the same. Run with one MPI rank and OMP_NUM_THREADS=1. Repeat with only mixing_dftu 0 changed. Inspect OUT.autotest/occ_mat.txt at electronic step 3. Three steps intentionally stop before SCF convergence; the observation concerns the intermediate occupation matrix.
Observed with ABACUS v3.11.0-beta13, commit 4c8488dca (production occ_matrix.cpp identical to upstream develop at 173620a12):
| Setting | Fe atom 1 d-shell mag x y z |
Fe atom 2 d-shell mag x y z |
|---|---|---|
mixing_dftu 1 |
0.00000000 0.00000000 0.00000000 |
0.00000000 0.00000000 0.00000000 |
mixing_dftu 0 |
0.00132486 0.00129079 0.00129079 |
-0.00254390 -0.00253322 -0.00253322 |
With mixing enabled, both spin 12 re and spin 12 im 5×5 blocks are all zero, and spin 1 nelec == spin 2 nelec for both atoms. In the control run, those blocks and spin differences are nonzero. The SCF total magnetization remains nonzero even in the broken run.
Cause
OccupationMatrix::write_to_flat() uses (2*l+1)^2 for the copy length. At l=2, npol=2, the actual matrix is [(2*l+1)*npol]^2 = 100 values. OccupationMatrix::read_from_flat() reads matrix.nr * matrix.nc = 100, so the missing flat-buffer values overwrite the freshly projected Pauli blocks before the +U potential and energy are built.
Expected behavior
All 100 d-shell values should enter occupation-matrix mixing. After mixing, the on-site spin blocks and local moments should reflect the projected spinor occupation matrix. A focused nspin=4 collect() -> write_back() regression and a PW SOC +U Autotest with mixing_dftu 1 should guard the fix.
Activity
ABACUS-PR-BOT commentedon Nov 17, 2026
Confirmed at develop
3383a82: fresh spin occupation data is lost before the +U potential and energy are built. Draft #8326 targets this exact defect by copying the full allocated matrix length. It also adds a two-atom test checking all 100 values per atom and a PW SOC case with occupation mixing enabled, so the repair can be followed there.The zero-moment signature applies to fresh zero-seeded histories; nonzero restart histories can retain stale spin data instead. A nonzero local moment alone therefore does not prove correct mixing, and mixed/unmixed third-step values need not match.
This assessment covers the pinned source and saved draft diff. The reported calculation and the PR’s claimed test passes have not been independently rerun or verified here; final patch acceptance remains separate.