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
module_dftu: pass nspin and onsite_radius explicitly, removing the two test access hacks it caused (#7940)
* dftu_pw_test: use the case value directly instead of driving global PARAM
The test parked its loop variable in the global Parameter singleton and read
it straight back:
PARAM.input.nspin = c.nspin;
switch (PARAM.inp.nspin) { ... }
const double diag_coeff = PARAM.inp.nspin == 4 ? 1.0 : 0.5;
It wrote the private half (`PARAM.input`) and read the public one
(`PARAM.inp`), so PARAM was serving as a scratch local -- and writing the
private half is the whole reason this file carried `#define private public`.
Nothing else reads it: the test's only production dependency,
source_pw/module_pwdft/dftu_base_tools.cpp, contains zero PARAM references.
`c.nspin` is already in scope, so use it directly.
The macro and the parameter.h include it guarded are removed with it. No
production code changes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* module_dftu: pass nspin and onsite_radius explicitly instead of reading PARAM
The DFTU LCAO operator read two INPUT values straight out of the global
Parameter singleton -- `PARAM.inp.nspin` in the constructor and
`PARAM.inp.onsite_radius` in `initialize_HR()`. That is why dftu_lcao_test.cpp
had to write `PARAM.input`, which is private, which is why it carried
`#define private public`.
Thread them through instead. `initialize_HR()` is private and called only from
the constructor, so it simply takes `onsite_radius` as an argument; the
constructor takes both and assigns the member. `dftu_nao_op.cpp` now has zero
PARAM references and no longer includes parameter.h.
All five call sites are updated explicitly -- no default arguments were added:
- hamilt_lcao.cpp, gamma-only and multi-k branches;
- force_stress_lcao.cpp, the `tmpu` force/stress instance;
- the two cases in dftu_lcao_test.cpp, which now pass the values they already
set locally.
These first three are the composition roots for LCAO operators, the same role
relax_nsync.cpp plays in #7921: the global reads concentrate there and the leaf
operator stays clean.
The test's expectations are unchanged. Both cases already set nspin explicitly
(1 and 2) and onsite_radius in SetUp (1.0), so nothing was relying on the
Input_para defaults -- the regression that cost #7921 five suites. The fixture
member `onsite_radius_test = 1.0` carries the value SetUp used to write into
PARAM.
`#define private public` in dftu_lcao_test.cpp is removed with the reason for
it. Nothing in this commit adds an `#undef private`, and no file whose macro
survives is touched.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments