Skip to content

fix(ofdft): apply TF weight consistently to single-spin energy - #8244

Open
zzlinpku wants to merge 2 commits into
deepmodeling:developfrom
zzlinpku:fix/ofdft-tf-energy-weight
Open

zzlinpku wants to merge 2 commits into
deepmodeling:developfrom
zzlinpku:fix/ofdft-tf-energy-weight

Conversation

@zzlinpku

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.

Linked Issue

Closes #8243.

What's changed?

With nspin=1 and of_tf_weight != 1, the TF total energy omitted the weight already used by its potential and pointwise energy density. Apply the stored weight to the energy integral so the energy, its density derivative, and the cached TF stress agree. The default weight of one and the spin-polarized energy formula are unchanged.

Add three regressions covering weighted energy/pointwise integration/stress, particle-conserving energy differences against the TF potential, and the same derivative identity through the complete TF and WT manager paths. The tests use prescribed densities and independent analytic or finite-difference expectations.

Update the existing non-unit-weight Al reference after checking the analytic identities and rerunning the material case. The previous reference reproduced the omitted energy factor. For a single MPI rank, the measured changes are:

Case Energy before → after (eV) Pressure before → after (kbar)
07_OF_KE_TF −62.654987731958 → −62.654987731958 202.046385 → 202.046385
09_OF_KE_WT −57.933855142792 → −57.933855142792 9.871139 → 9.871139
11_OF_TF_weight −59.709001731649 → −57.490028075888 −110.965399 → 40.538472

Both versions converge for the non-unit-weight case. Its README explains the new energy and the stress collector's absolute-component sum. Validation scripts and tolerances are unchanged.

Unit Tests and/or Case Tests for my changes

CPU build: Ubuntu 24.04, GCC 13.3, FFTW3, OpenBLAS/ScaLAPACK, MPI, OpenMP. Binary reports v3.11.0-beta11.

cmake -S . -B build -DBUILD_TESTING=ON -DENABLE_MPI=ON \
  -DENABLE_LCAO=OFF -DENABLE_LIBXC=OFF -DENABLE_LIBRI=OFF \
  -DENABLE_ELPA=OFF -DENABLE_FFT_TWO_CENTER=OFF \
  -DENABLE_NATIVE_OPTIMIZATION=OFF
cmake --build build --target MODULE_PW_OfDFT abacus_pw_para -j 6
OMP_NUM_THREADS=1 ctest --test-dir build -V -R '^MODULE_PW_OfDFT$'
  • On unmodified develop implementation plus the regressions: 12 existing tests pass, all 3 new tests fail, reproducing the issue.
  • After the fix: all 15 tests pass.

Material checks used the existing harness, first with one MPI rank before/after the fix, then with four ranks against the updated reference:

tf_weight_abacus="$PWD/build/abacus_pw_para"
cd tests/07_OFDFT
OMP_NUM_THREADS=1 bash ../integrate/Autotest.sh -a "$tf_weight_abacus" \
  -n 4 -o 1 -j 1 -r '^(07_OF_KE_TF|09_OF_KE_WT|11_OF_TF_weight)$'
  • All 3 selected material cases / 21 property comparisons pass with four ranks.
  • Before reference regeneration, the fixed non-unit-weight case fails the old energy/stress reference as expected; the two default-weight cases pass.
  • git diff --check: passed. Agent governance checks: no blocking findings. Both changed test files pass the repository quality-score threshold.
  • GPU/ML builds and the complete integration suite were not run; the change is confined to the CPU TF energy integral with focused OFDFT validation.

Governance Notes

  • INPUT/docs changes: no parameter/default/interface changes; restore the documented meaning of the existing weight. The affected case README documents the intentional reference change. No documentation update required in the generated INPUT reference: the existing parameter semantics and defaults remain the same.
  • Core module impact: one missing multiplication in KEDF_TF; no ESolver/HSolver interfaces, FFT implementation, global dependencies, or allocation behavior changed.
  • Exceptions requested: none.

Closes deepmodeling#8243. Align the energy with the existing weighted potential and update the verified non-unit-weight Al reference.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OFDFT] Non-unit TF weight is missing from single-spin total energy

1 participant