You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
abacus_fixer
committed
test(dftu_pw): rewire 7 dftu_pw_test cases to call real free functions
Step 4d of the dftu_pw decoupling plan. The 7 tests in dftu_pw_test.cpp
previously used arithmetic re-implementations of the VU/energy/occ
formulas, meaning they could not catch bugs in the real dftu_pw
implementations (test and production code were two independent copies).
Now that the free functions live in dftu_tools_pw.{h,cpp} with minimal
dependencies (only <complex> and matrix.h), the tests can link against
the real implementations directly.
Tests rewired:
- VUPotNspin1_DiagonalLocale -> compute_vu_scalar
- VUPotNspin2_TwoSpinChannels -> compute_vu_scalar (twice, up/down)
- VUPotNspin4_PauliTransform -> pauli_to_spin_basis (in-place)
- EnergyNspin12_DiagonalLocale -> compute_vu_scalar (check return value)
- EnergyNspin4_WithOffDiagonal -> compute_vu_spinor (check return value)
- LocaleAccumNspin12 -> accumulate_occ_scalar
- LocaleAccumNspin4_PauliComponents -> accumulate_occ_spinor
Tests kept as arithmetic (out of dftu_tools_pw scope):
- EnergyWeightsAllNspin, BecpIndexNspin12vs4 (pure constants/arithmetic)
- MultiAtomSplitLayout_Nspin2 (Plus_U_Base member layout)
- OnsitePsOpKernel_Nspin2_Npol1 (onsite_op.cpp kernel)
Files changed:
- source/source_lcao/module_dftu/test/dftu_pw_test.cpp
- add includes: <vector>, source_base/matrix.h,
source_pw/module_pwdft/dftu_tools_pw.h
- replace inlined arithmetic loops with calls to the real free
functions; expected values unchanged
- VUPotNspin4_PauliTransform: m_size 3 -> 1 (the test only fills a
single (m1,m2) pair; m_size=1 matches the data layout)
- EnergyNspin4_WithOffDiagonal: pass diag_coeff=1.0 (the nspin==4
value used in cal_occ_pw)
- source/source_lcao/module_dftu/test/CMakeLists.txt
- add ../../../source_pw/module_pwdft/dftu_tools_pw.cpp to
dftu_pw_test SOURCES so the real implementations are linked
Effects:
- tests now exercise the same code path as cal_occ_pw
- arithmetic re-implementations removed (~80 lines of duplicated logic)
- any future change to the free functions is automatically covered
Verification:
- make dftu_pw_test build passed (verified by user)
- ctest -R dftu_pw_test passed (verified by user)
0 commit comments