Move HSolverPW_SDFT into module_stodft as StoHSolverPW; rename HamiltSdftPW to StoHamiltPW - #8012
Merged
mohanchen merged 5 commits intoSep 27, 2026
Conversation
After deepmodeling#7974 inverted the hamilt/hsolver dependency through the HSOperator/HSMatrix interfaces, HSolverPW_SDFT was the only thing left in source_hsolver still reaching into source_hamilt, and the only thing left reaching into source_pw. It also closed the one real include cycle in the area: sto_elecond.h -> source_hsolver/hsolver_pw_sdft.h -> source_pw/module_stodft/{hamilt_sdft_pw.h, sto_iter.h} It is not a solver algorithm: it owns a Stochastic_Iter, takes a HamiltSdftPW*, and orchestrates the stochastic-DFT SCF step. It belongs in module_stodft, so move it there. Converting it to HSOperator instead would have dropped the hamilt include but left the source_pw edges and the cycle. Renamed to match the sibling it now sits next to, which is the same class of thing for the Hamiltonian side: hamilt_sdft_pw.h -> hamilt::HamiltSdftPW : public HamiltPW hsolver_sdft_pw.h -> hsolver::HSolverSdftPW : public HSolverPW That also drops the CamelCase/SCREAMING_SNAKE mix in HSolverPW_SDFT and puts the basis suffix last, as every other name in that directory does. The namespace stays hsolver: the class implements the HSolver role, and the directory already holds hamilt::HamiltSdftPW, so "namespace = role, directory = feature area" is the established rule here. Result, measured on the non-test sources: source_hsolver -> source_hamilt 1 file -> 0 source_hsolver -> source_pw 2 files -> 0 The cycle is gone. What remains between the two is source_pw -> source_hsolver (hsolver_pw.h, para_lin_tf.h), which is the correct direction. The unit test moves with the code and keeps __MPI via KEEP_FEATURE_DEFINITIONS, because module_stodft/test disables it and this test calls MPI_Init and has mocks taking MPI_Comm unconditionally. Its CTest target is renamed MODULE_HSOLVER_sdft -> MODULE_PW_Sto_HSolver_UTs so it groups with its new module and its two neighbours. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
module_stodft names its files sto_* and keeps its classes (StoChe,
Sto_DOS, Stochastic_Iter, ...) in the global namespace.
hamilt_sdft_pw.{h,cpp} is the leftover from when this code lived under
hamilt_stodft, so bring it in line:
hamilt_sdft_pw.{h,cpp} -> sto_hamilt_pw.{h,cpp}
hamilt::HamiltSdftPW -> StoHamiltPW (global namespace)
test_hamilt_sto.cpp -> test_sto_hamilt_pw.cpp
Names that were found through the enclosing namespace (HamiltPW,
Operator, hpsi_norm_op) are now qualified with hamilt::. The timer and
classname labels follow the class name. No logic change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…lver
Same treatment as StoHamiltPW in the previous commit, so both classes
this PR brings into module_stodft follow the directory's sto_* file
naming and global-namespace convention:
hsolver_sdft_pw.{h,cpp} -> sto_hsolver_pw.{h,cpp}
hsolver::HSolverSdftPW -> StoHSolverPW (global namespace)
test_hsolver_sdft_pw.cpp -> test_sto_hsolver_pw.cpp
The base class is now spelled hsolver::HSolverPW. The TITLE/timer
labels and the local object in ESolver_SDFT_PW follow the class name.
The test's hsolver:: mocks stay in namespace hsolver since they mock
the base-class side. No logic change.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The mock constructor's initializer list named the base as HamiltPW, which was only found while the class lived in namespace hamilt. Spell it hamilt::HamiltPW, as sto_hamilt_pw.cpp already does. Fixes the MODULE_PW_Sto_Tool_UTs build failure in the Test and CUDA Test jobs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
source_hsolver/test, where the SDFT solver test used to live, builds without __CUDA/__ROCM. module_stodft/test did not, so after the move the CUDA build compiled the DEVICE_GPU instantiations of StoHSolverPW, HSolverPW and FFT_CUDA into MODULE_PW_Sto_HSolver_UTs without linking their GPU implementations, and the link failed. Disable both for the directory, as source_hsolver/test does. All three tests here only exercise CPU code; for Sto_Tool and Sto_Hamilt this just drops GPU template instantiations they never call. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mohanchen
approved these changes
Sep 27, 2026
Critsium-xy
added a commit
to Critsium-xy/abacus-develop
that referenced
this pull request
Sep 28, 2026
.editorconfig has required `indent_style = space` with `indent_size = 4` for the whole repository, but 339 files under source/ still indent with tabs. This converts the leading whitespace of 248 of them. 253 files were selected when this was prepared. Since then, develop has deleted source_lcao/setup_dm.h (deepmodeling#8000) and source_pw/module_stodft/hamilt_sdft_pw.cpp (deepmodeling#8012), and already converted source_base/module_out/binstream.{h,cpp} (deepmodeling#8025) and source_pw/module_stodft/sto_hamilt_pw.h (renamed from hamilt_sdft_pw.h in deepmodeling#8012), which leaves 248. The conversion follows files that develop moved, e.g. onsite_proj_tools_stress.cpp is now under module_proj/ (deepmodeling#8007). Scope. Three groups were deliberately left out: - 48 files touched by the pull requests open at the time of writing (deepmodeling#8000, deepmodeling#7924, deepmodeling#7906, deepmodeling#8005 and others), so this does not force a conflict on work in flight; - 5 vendored files: source_base/libm/ is ported from glibc-2.36 and carries its own LICENCE, and source_base/mcd.c is Softpixel MemCheckDeluxe under a BSD licence. Reformatting vendored sources makes future syncs with their upstream harder; - tabs that appear after the first non-blank character (alignment tabs, 1193 lines). Only leading indentation is converted. Method and verification. `expand -i -t4`, which rewrites the initial whitespace of a line and nothing else, followed by three checks: - `git diff -w --stat` is empty, so not one non-whitespace character changed anywhere in the diff; - of the 42 raw string literals in the changed files (222 lines, all in source_io/module_parameter/read_inp_out.cpp), none has a line that this commit touches. Leading whitespace inside `R"(...)"` is part of the string, so that was the one place a leading-whitespace rewrite could have changed behaviour; - no changed line follows a line ending in a backslash, so no backslash-continued string literal is affected either; - no file gained a CR. Effect on tools/03_code_analysis/code_quality_score.py: average score over source/ goes from 82.15 to 82.58 and the number of passing files from 1560 to 1562. Six files score 1 to 3 points lower, all through the `line_too_long` rule, because the scorer counts a tab as a single character while it renders as up to four columns. The lines were already over 120 columns on screen; the tab was hiding it. One of them, module_ri/exx_abfs_ctor_orbs.cpp, moves from 60 to 59 and so drops just below the tool's pass line. Wrapping those lines would mean editing code in a commit that is otherwise whitespace-only, so it is left for a follow-up. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Sep 28, 2026
Critsium-xy
added a commit
to Critsium-xy/abacus-develop
that referenced
this pull request
Sep 30, 2026
.editorconfig has required `indent_style = space` with `indent_size = 4` for the whole repository, but 339 files under source/ still indent with tabs. This converts the leading whitespace of 246 of them. 253 files were selected when this was prepared. Since then, develop has deleted two of them and already converted five others, which leaves 246: - deleted: source_lcao/setup_dm.h (deepmodeling#8000), source_pw/module_stodft/hamilt_sdft_pw.cpp (deepmodeling#8012); - already converted: source_base/module_out/binstream.{h,cpp} (deepmodeling#8025), source_pw/module_stodft/sto_hamilt_pw.h (renamed from hamilt_sdft_pw.h in deepmodeling#8012), source_io/module_ctrl/ctrl_output_pw.h and source_pw/module_pwdft/op_pw_nl.cpp (deepmodeling#8043). Files that develop moved are converted at their new path, e.g. onsite_proj_tools_stress.cpp is now under source_pw/module_proj/ (deepmodeling#8007). Scope. Three groups were deliberately left out: - 48 files touched by the pull requests open at the time of writing (deepmodeling#8000, deepmodeling#7924, deepmodeling#7906, deepmodeling#8005 and others), so this does not force a conflict on work in flight; - 5 vendored files: source_base/libm/ is ported from glibc-2.36 and carries its own LICENCE, and source_base/mcd.c is Softpixel MemCheckDeluxe under a BSD licence. Reformatting vendored sources makes future syncs with their upstream harder; - tabs that appear after the first non-blank character (alignment tabs, 1193 lines). Only leading indentation is converted. Method and verification. `expand -i -t4`, which rewrites the initial whitespace of a line and nothing else, followed by three checks: - `git diff -w --stat` is empty, so not one non-whitespace character changed anywhere in the diff; - of the 42 raw string literals in the changed files (222 lines, all in source_io/module_parameter/read_inp_out.cpp), none has a line that this commit touches. Leading whitespace inside `R"(...)"` is part of the string, so that was the one place a leading-whitespace rewrite could have changed behaviour; - no changed line follows a line ending in a backslash, so no backslash-continued string literal is affected either; - no file gained a CR. Effect on tools/03_code_analysis/code_quality_score.py: average score over source/ goes from 82.15 to 82.58 and the number of passing files from 1560 to 1562. Six files score 1 to 3 points lower, all through the `line_too_long` rule, because the scorer counts a tab as a single character while it renders as up to four columns. The lines were already over 120 columns on screen; the tab was hiding it. One of them, module_ri/exx_abfs_ctor_orbs.cpp, moves from 60 to 59 and so drops just below the tool's pass line. Wrapping those lines would mean editing code in a commit that is otherwise whitespace-only, so it is left for a follow-up. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
mohanchen
pushed a commit
that referenced
this pull request
Sep 30, 2026
…o spaces (#8011) * docs: fix two @file tags that name a different file Doxygen's @file takes the name of the file it documents. These two name a file that does not exist, so Doxygen attributes the block to the wrong (or to no) file: source_base/ndarray.h said NDArray.h source_lcao/module_rt/band_energy.h said bandenegy.h (also a typo) Found by tools/03_code_analysis/code_quality_score.py (rule doc_file_mismatch). The scan also flagged source_pw/module_pwdft/radial_proj.h (said radial_projection.h), but #8007 has since moved that header to source_pw/module_proj/ with the tag already corrected, so it is no longer part of this commit. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * style: convert leading tab indentation to spaces in 246 source files .editorconfig has required `indent_style = space` with `indent_size = 4` for the whole repository, but 339 files under source/ still indent with tabs. This converts the leading whitespace of 246 of them. 253 files were selected when this was prepared. Since then, develop has deleted two of them and already converted five others, which leaves 246: - deleted: source_lcao/setup_dm.h (#8000), source_pw/module_stodft/hamilt_sdft_pw.cpp (#8012); - already converted: source_base/module_out/binstream.{h,cpp} (#8025), source_pw/module_stodft/sto_hamilt_pw.h (renamed from hamilt_sdft_pw.h in #8012), source_io/module_ctrl/ctrl_output_pw.h and source_pw/module_pwdft/op_pw_nl.cpp (#8043). Files that develop moved are converted at their new path, e.g. onsite_proj_tools_stress.cpp is now under source_pw/module_proj/ (#8007). Scope. Three groups were deliberately left out: - 48 files touched by the pull requests open at the time of writing (#8000, #7924, #7906, #8005 and others), so this does not force a conflict on work in flight; - 5 vendored files: source_base/libm/ is ported from glibc-2.36 and carries its own LICENCE, and source_base/mcd.c is Softpixel MemCheckDeluxe under a BSD licence. Reformatting vendored sources makes future syncs with their upstream harder; - tabs that appear after the first non-blank character (alignment tabs, 1193 lines). Only leading indentation is converted. Method and verification. `expand -i -t4`, which rewrites the initial whitespace of a line and nothing else, followed by three checks: - `git diff -w --stat` is empty, so not one non-whitespace character changed anywhere in the diff; - of the 42 raw string literals in the changed files (222 lines, all in source_io/module_parameter/read_inp_out.cpp), none has a line that this commit touches. Leading whitespace inside `R"(...)"` is part of the string, so that was the one place a leading-whitespace rewrite could have changed behaviour; - no changed line follows a line ending in a backslash, so no backslash-continued string literal is affected either; - no file gained a CR. Effect on tools/03_code_analysis/code_quality_score.py: average score over source/ goes from 82.15 to 82.58 and the number of passing files from 1560 to 1562. Six files score 1 to 3 points lower, all through the `line_too_long` rule, because the scorer counts a tab as a single character while it renders as up to four columns. The lines were already over 120 columns on screen; the tab was hiding it. One of them, module_ri/exx_abfs_ctor_orbs.cpp, moves from 60 to 59 and so drops just below the tool's pass line. Wrapping those lines would mean editing code in a commit that is otherwise whitespace-only, so it is left for a follow-up. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (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.
Reminder
AGENTS.mdanddocs/developers_guide/agent_governance.md.source/changes.Linked Issue
No issue. Follow-up to #7920, #7948 and #7974, and the last step of getting
source_hsolverdown to a self-contained numerical module. No behaviour change.Unit Tests and/or Case Tests for my changes
The PR has five commits:
1c06770afHSolverPW_SDFTintomodule_stodft(ashsolver::HSolverSdftPW)0068fe86bhamilt_sdft_pw/hamilt::HamiltSdftPW→sto_hamilt_pw/StoHamiltPW1211e050ehsolver_sdft_pw/hsolver::HSolverSdftPW→sto_hsolver_pw/StoHSolverPWb150bda01hamilt::HamiltPWin theStoHamiltPWmock constructor oftest_sto_tool.cpp567b40e97module_stodft/testwithout__CUDA/__ROCM, assource_hsolver/testdoesCI on
567b40e97: all 17 checks pass, including every build configuration(GNU, Intel, CUDA, Makefile & Intel, without ELPA / LCAO / MPI),
Test,Test on CUDA Build,abacuslite, PyTest and Governance checks. InTest:Every other
ctest -Rgroup in that job also reports 100% passed.Commands run on
1c06770af(Linux, gcc, cmake 3.31 + ninja, 15 cores). Basecommit
4f2a39783and that commit were built and tested in the same build tree.Result summary
4f2a397831c06770afFailing sets are identical test-for-test (
diffof the sorted lists isempty) and are this sandbox's pre-existing failures. The total stays at 364, so
the moved test is still registered — it runs and passes under both names:
SDFT integration cases. A move of SDFT code deserves numerical evidence, so
I ran a spread of
tests/06_SDFTagainst their committedresult.ref:result.ref01_PW_SDFT_10S_M04_PW_SDFT_ALL08_PW_BNDKPAR_SDFT_ALL12_PW_BPCG_SDFT_5D11SAll reproduce their reference at machine precision.
08_PW_BNDKPAR_SDFT_ALLmatters in particular: it is the one that drives the
BP_WORLDMPI_Bcastinside the moved file.
Each run's own timing table confirms the moved class is what executed (these
runs predate the last rename, so the label is still
HSolverSdftPW; from1211e050eon it readsStoHSolverPW):Commands run locally on
1211e050e(the two rename commits):git grep: no remaining references to the old names.Checks not run, with reason
1c06770afwere not built or tested locally — no buildenvironment on the machine they were written on. CI is the verification for
them (see above). The first CI run on
1211e050ecaught two problems, bothfixed in follow-up commits: an unqualified
HamiltPWin a test mock that hadrelied on the old
hamiltnamespace (b150bda01), and the CUDA link failuredescribed under "The unit test moves with the code" (
567b40e97). TheSDFT integration numbers above were not re-run locally after the renames; CI's
06_SDFTgroup passes on567b40e97.Makefile.Objectsis edited here): not built locally;CI's "Build with Makefile & Intel compilers" job covers it. The edits move one
object entry from
OBJS_HSOLVERtoOBJS_SRCPWbeside the othersto_*.oand rename two entries in place; the directory is already on the Makefile's
search path.
it is a file move plus renames — and CI's CUDA job compiles it.
What's changed?
#7974 inverted the hamilt/hsolver dependency through the
HSOperator/HSMatrixinterfaces. After it,
HSolverPW_SDFTwas the only thing left insource_hsolverreaching intosource_hamilt, and the only thing left reachinginto
source_pw— and it was also what closed the one real include cycle inthis area:
It is not a solver algorithm. It owns a
Stochastic_Iter, takes the SDFTHamiltonian, and orchestrates one stochastic-DFT SCF step. So this PR moves it
into
module_stodftwhere the rest of SDFT lives.Converting it to the
HSOperatorinterface instead — the obvious alternative —would have removed the
source_hamiltinclude but left bothsource_pwedgesand the cycle intact. Moving it removes all three.
Rename.
module_stodftnames its filessto_*and keeps its classes(
StoChe,Sto_DOS,Sto_EleCond,Stochastic_Iter,Stochastic_WF, …) inthe global namespace. The moved class follows that convention, and so does the
SDFT Hamiltonian, whose
hamilt_sdft_pw.hwas the one file in the directorystill named after the layout it was originally moved in from:
StoXxxPW(asStoChe), rather than the underscore-mixedSto_Xxx_PWspelling, and the basis suffix last (assto_stress_pw).hamilt/hsolvernamespaces, matching everyother class in the directory; the
Stoprefix does the disambiguating. Namesthat were previously found through the enclosing namespace are now qualified:
the two base classes,
hamilt::Operatorandhamilt::hpsi_norm_op.kernels/hpsi_norm_opitself stays innamespace hamilt, like the other opkernels.
test_sto_hamilt_pw.cpp,test_sto_hsolver_pw.cpp. Thehsolver::mocks inside the latter stay innamespace hsolver, since they mock the base-class side.Result, measured over the non-test sources:
source_hsolver→source_hamiltsource_hsolver→source_pwThe cycle is gone. What is left between the two modules is
source_pw→source_hsolver(hsolver_pw.handpara_lin_tf.h), which is the correctdirection.
source_hsolver's remaining outward includes aresource_base134,itself 42,
source_estate13,source_psi9,source_basis9,source_io1,source_cell1.The unit test moves with the code. Two wrinkles worth calling out:
module_stodft/testdoesabacus_disable_feature_definitions(__MPI), but thistest calls
MPI_Initinmain()and its mocks takeMPI_Commargumentsoutside any
#ifdef, so it keeps the definition viaKEEP_FEATURE_DEFINITIONS __MPI— the same escape hatchMODULE_RELAX_socket_driver_testand the DFT+U tests use.source_hsolver/testbuilds without__CUDA/__ROCM;module_stodft/testdid not. With the definitions on, the CUDA build compiled the
DEVICE_GPUinstantiations of
StoHSolverPW,HSolverPWandFFT_CUDAinto the testwithout linking their GPU implementations, and the link failed. So
module_stodft/testnow disables both, likesource_hsolver/testdoes. Thedirectory's other two tests (
Sto_Tool,Sto_Hamilt) exercise CPU code only;for them this just drops GPU template instantiations they never call.
(
__EXX, also disabled insource_hsolver/test, is not referenced by anysource these tests compile, so it is left alone.)
hsolver_pw_sup.h,hsolver_supplementary_mock.h) areshared with
MODULE_HSOLVER_pw, so they stay insource_hsolver/test/and themoved test includes them by full path.
Governance Notes
Input_Item, no INPUTparameter, no output file format; the renamed classes are internal and not
referenced from
docs/.ModuleBase::TITLE/timerlabels in the timing table ofOUT.*/running_*.logfollow the classes:HSolverPW_SDFT→StoHSolverPWand
HamiltSdftPW→StoHamiltPW. Nothing intests/or anyresult.refrecords them.
MODULE_HSOLVER_sdft→MODULE_PW_Sto_HSolver_UTs, so it groups with the module it now belongs toand with its two neighbours
MODULE_PW_Sto_Tool_UTsandMODULE_PW_Sto_Hamilt_UTs.ctest -R MODULE_HSOLVERno longer selects it;ctest -R MODULE_PWdoes.logic, no signature and no arithmetic is touched.
esolver_sdft_pw.cppgainsan explicit include of the solver header it was previously getting
transitively through
sto_elecond.h. Users of the SDFT Hamiltonian(
esolver_sdft_pw,sto_dos,sto_elecond,sto_iter,sto_tooland theirtests) only change the spelled type name.
module_stodft/test/CMakeLists.txtadditionally disables__CUDA/__ROCM(see above).hsolver_pw_sdft.cppmoves fromsource_hsolver/CMakeLists.txtto
module_stodft'shamilt_stodft_srcsassto_hsolver_pw.cpp, and inMakefile.ObjectsfromOBJS_HSOLVERtoOBJS_SRCPWnext to the othersto_*.o.hamilt_sdft_pw.cpp/.ois renamed in place in both.esolver_sdft_pw.cpplines. These arethe existing
PARAM.globalv.*/GlobalV::ofs_runningarguments of theStoHamiltPWandStoHSolverPWconstructor calls and thesolvecall,re-indented because the type and object names got shorter. The check itself
reports
added=5, removed=5, net_delta=0.include for the renamed path (
sto_hamilt_pw.hinesolver_sdft_pw.h,sto_dos.h,sto_iter.h,sto_tool.h;sto_hsolver_pw.hinsto_elecond.h), or is one of the three includes of the movedsto_hsolver_pw.h, which the check sees as new because the file is new.Those point at the same headers as before;
hsolver_pw.hbecomes a fullpath now that it is no longer a sibling. No header gains a new dependency.
🤖 Generated with Claude Code