Skip to content

Fix PW DFT+U initialization lifecycle - #8203

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
lanshuyue:codex/fix-pw-dftu-init-lifecycle
Oct 23, 2026
Merged

mohanchen merged 1 commit into
deepmodeling:developfrom
lanshuyue:codex/fix-pw-dftu-init-lifecycle

Conversation

@lanshuyue

@lanshuyue lanshuyue commented Oct 22, 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.

Base update

#8196 has been merged as 370ba685e. This branch was rebased onto that commit, so the PR contains only the DFT+U lifecycle fix.

Linked Issue

Fixes #8197

Unit Tests and/or Case Tests for my changes

  • Commands run:
    • cmake --build build -j2 --target abacus_basic_para MODULE_PW_dftu_base_test
    • env OMP_NUM_THREADS=1 ctest --test-dir build --output-on-failure -R '^MODULE_PW_dftu_base_test$'
    • env OMP_NUM_THREADS=1 ../integrate/Autotest.sh -a /home/lanshuyue/abacus/ABACUS/abacus-develop/build/abacus_basic_para -r '^relax_dftu_spin[24]$' -n 4 -o 1 -j 1 (from tests/01_PW)
    • bash -n tests/integrate/validation_tools/props_basic.sh
    • git diff --check upstream/develop...HEAD
    • python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text
  • Result summary:
    • Local CPU/MPI build passed after rebasing onto the merged Refactor DFT+U compact occupation writer #8196.
    • DFT+U unit test passed.
    • Existing relax_dftu_spin2 and relax_dftu_spin4 cases passed all 8 numerical checks.
    • Shell syntax and whitespace checks passed.
    • Governance check reported warnings only: global references are migration-neutral with a net reduction of four, and the no-docs rationale is documented below.
  • Checks not run, with reason:
    • pre-commit was not run locally because it is not installed in the local environment.

What's changed?

  • Move PW Plus_U_Base::init_base() from per-ionic-step before_scf() setup to ESolver_KS_PW::before_all_runners(), matching the LCAO initialization lifecycle.
  • Read initial occupation data during run initialization instead of reconstructing DFT+U base state at every relaxation step.
  • Preserve run-lifetime state such as U-ramping, occupation mixing, and Yukawa screening across ionic steps.
  • Remove the DFT+U argument and initialization responsibility from pw::setup_pot().
  • Remove the obsolete repeated-initialization compatibility path.
  • Update unit tests to reflect the once-before-runners initialization contract. No runtime log marker or invocation-count feature check is added.

Governance Notes

  • INPUT/docs changes: none. No INPUT keyword, default, file format, or user workflow changes; this corrects an internal initialization lifecycle, so no user documentation update is needed.
  • Core module impact: PW ESolver initialization only. Per-step potential setup and DFT+U Hamiltonian/force/stress calculations remain unchanged.
  • Global dependency rationale: initialization moved to its run-lifetime owner and uses a local System_para alias. The PR removes five global references and adds one (net -4).
  • Makefile/CMake: this follow-up adds or moves no source files; existing esolver_ks_pw.o, setup_pot.o, and dftu_base.o entries in source/Makefile.Objects were verified by the successful local build.
  • Exceptions requested: none.

@lanshuyue lanshuyue added Bug DFT+U Issues related to DFT plus U function labels Oct 22, 2026 — with ChatGPT Codex Connector
@lanshuyue
lanshuyue force-pushed the codex/fix-pw-dftu-init-lifecycle branch from e0ded0a to 342033d Compare October 23, 2026 03:04

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

Static review of 342033d3 against 370ba685e: no change-induced correctness defect identified. Whitespace and governance checks completed; build/runtime/CI results were not independently verified.

Non-blocking: In source/source_pw/module_pwdft/dftu_base.h, please document that Plus_U_Base::init_base() is called once on a fresh object per solver/run. With repeated-initialization safeguards removed, the declaration’s allocation-only comment leaves that precondition implicit; a new configuration should use a fresh object. A follow-up after merge is fine.

Comment thread source/source_pw/module_pwdft/test/dftu_base_test.cpp Outdated
@mohanchen mohanchen added Bugs Bugs that only solvable with sufficient knowledge of DFT and removed Bug labels Oct 23, 2026
Comment thread tests/01_PW/relax_dftu_spin2/dftu_init_count.ref Outdated
@lanshuyue
lanshuyue force-pushed the codex/fix-pw-dftu-init-lifecycle branch from 342033d to 2e6e822 Compare October 23, 2026 07:57
@lanshuyue
lanshuyue force-pushed the codex/fix-pw-dftu-init-lifecycle branch from 2e6e822 to 6398a05 Compare October 23, 2026 09:54

@mohanchen mohanchen 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.

LGTM

@mohanchen mohanchen added the Refactor Refactor ABACUS codes label Oct 23, 2026
@mohanchen
mohanchen merged commit e08703f into deepmodeling:develop Oct 23, 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 Refactor Refactor ABACUS codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PW DFT+U base initialization is repeated at every ionic step

3 participants