[Rafactor] Remove parameter.h in rest files in source_basis#7373
Open
Critsium-xy wants to merge 7 commits into
Open
[Rafactor] Remove parameter.h in rest files in source_basis#7373Critsium-xy wants to merge 7 commits into
Critsium-xy wants to merge 7 commits into
Conversation
Decouple module_ao and module_nao from source_io/parameter.h: - ORB_atomic_lm / ORB_nonlocal_lm: replace PARAM.globalv.global_out_dir with ModuleBase::get_quit_out_dir() (new getter mirroring the existing set_quit_out_dir injection point). - two_center_bundle: thread orbital_dir as a build_orb parameter; replace the two deepks_setorb guards with ndesc>0 / alpha_ non-null checks that are equivalent under the build_alpha invariant. source_basis is now free of parameter.h. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both reads were removed without changing any function signature, because in each case the value was already recoverable from information the function already had.
The sole caller passes deepks_setorb as the ndesc argument:
build_alpha(PARAM.globalv.deepks_setorb, &ucell.descriptor_file);So the flag's value already enters the function through ndesc (bool → int). Re-reading the global inside the body is redundant. The guard becomes if (ndesc > 0), which is equivalent for the caller and is also more self-consistent: build the descriptor collection only when there are descriptors to build it from. This is the "value already lives in an existing parameter" case — zero cost to fix.
if (PARAM.globalv.deepks_setorb) { /* fill ORB.Alpha from alpha_ */ }Here the relevant invariant is alpha_'s lifecycle: the member is only constructed in build_alpha (i.e. when DeePKS is enabled) and is otherwise null. Therefore:
alpha_ != nullptr ⟺ deepks_setorb == trueThe rest of the function (and all of tabulate) already branches on if (alpha_). Replacing the global read with if (alpha_) removes the dependency, matches the surrounding style, and is safer — it null-checks the very pointer it is about to dereference. This is the "value is equivalent to existing object state" case — also zero cost.
Contrast — orbital_dir had to become a parameter
return PARAM.inp.orbital_dir + file; // path prefixorbital_dir is genuine external input (a user-specified directory). Nothing in the function's existing arguments or state can reconstruct it, so it cannot be eliminated — only pushed up the call chain. It was added as a build_orb parameter and supplied by the two callers, which already hold PARAM. This is why only one of the three PARAM uses required a signature change.