Skip to content

Fix PW spinor DFT+U occupation-matrix mixing - #8326

Merged
mohanchen merged 4 commits into
deepmodeling:developfrom
lanshuyue:codex/fix-pw-soc-dftu-mixing
Nov 24, 2026
Merged

mohanchen merged 4 commits into
deepmodeling:developfrom
lanshuyue:codex/fix-pw-soc-dftu-mixing

Conversation

@lanshuyue

@lanshuyue lanshuyue commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the exact verification commands run and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below (none needed).

Linked Issue

Fix #8325

Unit Tests and/or Case Tests for my changes

  • cmake --build build --target abacus_basic_para -j 4 — passed with ENABLE_ELPA=OFF before this scope adjustment.
  • cmake --build build --target MODULE_ESTATE_occ_matrix MODULE_ESTATE_occ_mixer -j 4 — passed.
  • ctest --test-dir build --output-on-failure -R '^MODULE_ESTATE_occ_(mixer|matrix)$' — 2/2 passed after removing the integration case.
  • python3 tools/03_code_analysis/agent_governance_check.py --staged — no findings.
  • git diff --cached --check — passed.
  • python3 tools/03_code_analysis/code_quality_score.py source/source_estate/occ_matrix.cpp source/source_estate/unittests/test_occ_mixer.cpp — 2/2 files passed before this scope adjustment.

Manual reproduction for the linked issue: before the fix, a two-Fe PW SOC +U calculation with mixing_dftu 1 produced exactly zero d-shell local moments and zero spin-off-diagonal occupation blocks for both Fe atoms after three SCF steps. With the fix, both local moments were nonzero. These three-step calculations were not converged and are evidence of the mixing-path defect, not converged physical results. No integration case is included in this PR.

What's changed?

  • Copy the full allocated occupation-matrix block when flattening PW DFT+U matrices for mixing. For nspin=4, npol=2, l=2, this is 100 values per correlated atom rather than 25.
  • Add a two-atom OccMatMixer::collect() -> write_back() unit regression that checks every position of both 100-value spinor blocks.

Governance Notes

  • INPUT/docs changes: no INPUT metadata, default, or documented interface changes; mixing_dftu already exists. This PR corrects behavior for an existing option, so no generated INPUT documentation update is needed.
  • Core module impact: OccupationMatrix::write_to_flat() now uses the matrix's allocated nr * nc length. PW mixing receives all Pauli blocks; collinear dimensions are unchanged. LCAO's direct mix_plain() path is unchanged.
  • Exceptions requested: none.

@lanshuyue lanshuyue added Bugs Bugs that only solvable with sufficient knowledge of DFT DFT+U Issues related to DFT plus U function labels Nov 17, 2026

@ABACUS-PR-BOT ABACUS-PR-BOT left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The copy extent now matches the allocated SOC blocks and the existing saved/restore paths. I found no implementation defect in the inspected diff; one nonblocking cleanup is noted below.

Static review only: no build, runtime tests or CI verification. The reported tests and three-step reproduction were not independently verified.

@lanshuyue
lanshuyue marked this pull request as ready for review November 23, 2026 18:30
@mohanchen
mohanchen merged commit 503be43 into deepmodeling:develop Nov 24, 2026
18 checks passed
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 DFT+U Issues related to DFT plus U function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PW SOC DFT+U occupation-matrix mixing drops three Pauli blocks (nspin=4)

3 participants