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
source_estate: pass Charge its nspin, nelec and verbosity explicitly, and add the two seams charge_test needed elsewhere
charge_test needed the macro for three separate reasons, in three different
modules. All three are fixed here; the module-crossing ones are called out below
because they touch modules that currently have no access hacks at all.
1) source_estate -- Charge reads three INPUT values (19 test writes, 3 keys)
charge.cpp read nspin, nelec and test_charge from the global singleton in five
methods. The obvious move -- give renormalize_rho() an nelec parameter --
cascades badly: of its six production call sites, rho_tau_lcao.cpp has no PARAM
reference at all, so the value would have to be threaded through
LCAO_domain::dm2rho (six more sites) and then ElecStateLCAO::dm2rho into
hsolver_lcao.cpp -- about fifteen sites across three modules, and it would put a
global read into a file that is clean today.
Charge already keeps nspin as state set by allocate(), so nelec is kept the same
way. allocate() takes test_charge and nelec_in; renormalize_rho() and
check_rho() read this->nelec, so their signatures are untouched and nothing
cascades. save_rho_before_sum_band() takes nspin, init_final_scf() takes nspin
and test_charge.
allocate() has nine production call sites, not the two a grep on guessed object
names suggested; the others reach it through chg1_, chr_base, chg_gs,
ptemp_rho_, chg_01 and chg_drho[d]. Seven of the nine now pass an injected inp_
or the source Charge's own nspin/nelec, so only veff_dh.cpp adds PARAM
references, and it already read PARAM.inp.nspin on the same line.
Two const getters, get_allocate_rho() and get_allocate_rho_final_scf(), cover
the 14 read-only accesses to the two allocation flags.
2) source_hamilt/module_xc -- XC_Functional::func_type and ked_flag (6 writes)
Both are private statics with public getters and no setters. Added
set_func_type() and set_ked_flag(), matching the get_func_type() /
get_ked_flag() pair and the existing set_hybrid_alpha() / set_hse_omega() style
in the same header. The test's out-of-line definitions of the two statics need
no seam -- a definition does not require access.
3) source_basis/module_pw -- PW_Basis::distribute_r() and distribute_g()
No new API. The test hand-rolled initgrids / distribute_r / initparameters /
distribute_g; pw_basis.h documents the public sequence as initgrids /
initparameters / setuptransform(), and setuptransform() performs both
distribute calls itself. The test now follows the documented order.
Three EXPECT_EQ(PARAM.input.nelec, 8) assertions guarded the 8.0 that the
renormalize/check assertions below them expect; they now assert the same thing
about the value the test configures.
The five test_charge/nspin/nelec reads left in charge.cpp are inside atomic_rho(),
which charge_test does not call, so injecting them would cost budget without
removing a macro.
No production logic changed. No expected value changed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
0 commit comments