Skip to content

Fix non-LCAO elecstate energy test mock - #7736

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Stardust0831:fix/elecstate-energy-test-mock
Aug 1, 2026
Merged

Fix non-LCAO elecstate energy test mock#7736
mohanchen merged 1 commit into
deepmodeling:developfrom
Stardust0831:fix/elecstate-energy-test-mock

Conversation

@Stardust0831

@Stardust0831 Stardust0831 commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Reminder

Linked Issue

No upstream issue linked; this is a follow-up to the non-LCAO test regression introduced by PR #5703.

Unit Tests and/or Case Tests for my changes

  • Before the change, building MODULE_ESTATE_elecstate_energy with LCAO disabled failed with an undefined reference to elecstate::ElecState::get_dftu_energy().
  • After the change, the same reduced-feature target builds successfully; its CTest entry passes and the test binary reports 13/13 GoogleTest cases passing.
  • The LCAO-enabled target also builds; its CTest entry and all 13 GoogleTest cases pass, confirming that the unconditional test replacement does not introduce a duplicate symbol.
  • git diff --check passes.
  • No full-repository test suite was run; the change is limited to one focused unit-test source.

What's changed?

PR #5703 extended DFT+U to the PW basis and removed the production __LCAO guard around ElecState::get_dftu_energy() and its call from cal_energies(). The unit test added by PR #2486 still defined its lightweight get_dftu_energy() replacement only under __LCAO.

The failure occurs with BUILD_TESTING=ON, ENABLE_MPI=ON, and ENABLE_LCAO=OFF when CMake builds the standalone MODULE_ESTATE_elecstate_energy test executable. That target compiles elecstate_energy.cpp but intentionally does not link the production elecstate_energy_terms.cpp and its DFT+U dependencies. With LCAO disabled, the stale guard removed the test replacement as well, leaving the production call unresolved at link time.

The production ABACUS target is unaffected because the source_estate module compiles both elecstate_energy.cpp and elecstate_energy_terms.cpp.

This PR makes the test replacement available in both LCAO and non-LCAO builds. It also makes both DFT+U assertions expect the replacement's 0.6 contribution, matching the PW DFT+U behavior introduced by #5703. No production source or runtime behavior changes.

Governance Notes

  • INPUT/docs changes: none; no INPUT or user-facing behavior changed.
  • Core module impact: test-only linkage and expectation maintenance.
  • Exceptions requested: none.

@Stardust0831 Stardust0831 reopened this Aug 1, 2026
@mohanchen
mohanchen merged commit 3a7ce9f into deepmodeling:develop Aug 1, 2026
31 of 33 checks passed
@mohanchen mohanchen added Tests/Examples Issues/PR related to unit tests and integrate tests Refactor Refactor ABACUS codes labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes Tests/Examples Issues/PR related to unit tests and integrate tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants