Skip to content

source_hsolver tests: drop the last source_pw/source_hamilt dependencies - #8044

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:test/hsolver-drop-pw-hamilt-test-deps
Sep 30, 2026
Merged

mohanchen merged 1 commit into
deepmodeling:developfrom
Critsium-xy:test/hsolver-drop-pw-hamilt-test-deps

Conversation

@Critsium-xy

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 #7603
Closes #7677
Closes #7678
Closes #7679

This is the last cleanup step of the source_hsolver decoupling series (#7683, #7920, #7948, #7974, #8012). None of those PRs linked the issues, so they stayed open. On current develop, the production code under source/source_hsolver already has no source_pw, source_lcao or source_hamilt include. Only two test-side leftovers were left, and this PR removes them:

Issue Resolved by Remaining before this PR
#7677 no source_lcao #7683 (dm2rho routed through ElecStateLCAO::dmToRho) none. The acceptance criterion was already met, and this PR only links it
#7678 no source_pw #7974 (hsolver_lcaopw no longer needs hamilt_pw.h/hamilt_lcaopw.h), #8012 (HSolverPW_SDFT moved to module_stodft as StoHSolverPW) test/hsolver_supplementary_mock.h still included source_pw/module_stodft/sto_wf.h
#7679 no source_hamilt #7920 (MatrixBlock → source_base), #7948 (LCAO direct solvers take H(k)/S(k)), #7974 (solvers depend on the hsolver::HSOperator/hsolver::HSMatrix interfaces; the hamilt side provides adapters in source_hamilt/hamilt_hs_adapter.h, injected from the ESolver) test/test_hsolver.cpp still included source_hamilt/hamilt.h
#7603 hsolver → method layer all of the above same two test leftovers

For #7679, the recorded design decision is the dependency inversion introduced in #7974. source_hsolver owns the minimal HSOperator/HSMatrix interfaces it needs, and source_hamilt implements them. source_hamilt is therefore not kept as a whitelisted exception.

Unit Tests and/or Case Tests for my changes

  • Commands run:
    • python tools/03_code_analysis/agent_governance_check.py --staged. The only finding was the docs-sync reminder on the PR body, which is answered below.
    • git grep -n -E 'source_(pw|hamilt|lcao)/' -- source/source_hsolver. The only matches left are two doc comments in hs_matrix.h/hs_operator.h that name the adapter header. There are no #includes.
  • Result summary: the affected targets are MODULE_HSOLVER_base, MODULE_HSOLVER_pw and MODULE_PW_Sto_HSolver_UTs. They are left to CI. MODULE_HSOLVER_base goes from 0 test cases (every TEST_F was commented out) to 12 tests.
  • Checks not run, with reason: no local build or ctest run. Verification is done by the PR CI.

What's changed?

Developer-facing, test-only. No production code changes.

  • source_hsolver/test/test_hsolver.cpp: every TEST_F had been commented out, and the fixture only held a hamilt::Hamilt and a Stochastic_WF that nothing used. This PR replaces the fixture with focused tests of the free functions actually declared in hsolver.h (cal_hsolve_error, set_diagethr_ks, set_diagethr_sdft, reset_diag_ethr), which had no unit test. ../hsolver.cpp is now compiled into MODULE_HSOLVER_base.
  • source_hsolver/test/hsolver_supplementary_mock.h: the Stochastic_WF mock and its source_pw/module_stodft/sto_wf.h include move to source_pw/module_stodft/test/test_sto_hsolver_pw.cpp, their only remaining user. The dead commented-out body of init is dropped.

After this PR, nothing under source/source_hsolver (production or test) includes source_pw, source_lcao or source_hamilt.

Governance Notes

  • INPUT/docs changes: none. This is a test-only change, and no INPUT parameter or user-visible behavior changes, so no documentation update is required.
  • Core module impact: HSolver unit tests only. The module_stodft test now owns the Stochastic_WF mock it uses.
  • Exceptions requested: none.

🤖 Generated with Claude Code

…r tests

- test_hsolver.cpp: every TEST_F had been commented out, and the fixture only
  held a hamilt::Hamilt and a Stochastic_WF that nothing used. Replace it with
  tests of the free functions actually declared in hsolver.h
  (cal_hsolve_error, set_diagethr_ks, set_diagethr_sdft, reset_diag_ethr),
  which had no unit test, and compile ../hsolver.cpp into MODULE_HSOLVER_base.
- hsolver_supplementary_mock.h: move the Stochastic_WF mock (and its
  source_pw/module_stodft/sto_wf.h include) into
  module_stodft/test/test_sto_hsolver_pw.cpp, its only remaining user.

After this, nothing under source/source_hsolver includes source_pw,
source_lcao or source_hamilt, production or test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels Sep 30, 2026
@mohanchen

Copy link
Copy Markdown
Collaborator

Well done!

@mohanchen
mohanchen merged commit 8b87bd5 into deepmodeling:develop Sep 30, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0

Projects

None yet

2 participants