Repository navigation
Move Structure_Factor, Soc and the cal_sk_op kernel to source_cell; drop four unused upward includes - #8234
Merged
mohanchen merged 4 commits intoOct 30, 2026
Conversation
Structure_Factor holds S(G) and the per-atom phase factors exp(-iG.tau),
the Fourier representation of the atomic positions. Soc holds the
spin-angular coupling coefficients of the pseudopotentials. Neither is
plane-wave method code, but both lived in source_pw/module_pwdft, so
source_psi, source_estate and source_hamilt included source_pw for them.
- stru_fac.{h,cpp}, stru_fac_k.cpp, soc.{h,cpp} move to source_cell/.
soc.cpp joins the cell library. stru_fac*.cpp form a separate
structure_factor object library, because they need the plane-wave
basis and the cell-only unit tests do not link planewave.
- The cal_sk_op kernel (wf_op.{h,cpp}, cuda/wf_op.cu, rocm/wf_op.hip.cu)
moves to source_cell/kernels/. Its unused include of source_psi/psi.h
is dropped; stru_fac_k.cpp now includes memory_op.h, which it used
through psi.h.
- The old headers in source_pw/module_pwdft forward to the new ones, so
higher-layer includers are unchanged. The includers in source_psi,
source_estate and source_hamilt, and the tests that compile these
files, point at the new paths.
No code inside the moved files changes apart from include lines.
Refs deepmodeling#8233
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- edm_tddft.cpp includes module_rt/gather_mat.h and propagator.h but uses neither; only edm_tddft_lapack.cpp needs them. - elecstate_pw_sdft.cpp includes xc_functional.h but uses no XC symbol. - ions_move_lbfgs.h includes esolver_ks.h, but the class only stores an ESolver*, which esolver.h already declares. Refs deepmodeling#8233 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mohanchen
reviewed
Oct 29, 2026
Point the remaining includers in source_esolver, source_io, source_lcao and source_pw at source_cell/stru_fac.h and source_cell/soc.h directly, and delete the two forwarding headers left in source_pw/module_pwdft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…re-factor-to-cell # Conflicts: # source/source_pw/module_pwdft/unittests/CMakeLists.txt
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
Fixes #8233. Part of #7601 and #7599. The second commit also removes four unused upward includes found in the same layering review (see "What's changed?", item 6).
Unit Tests and/or Case Tests for my changes
MODULE_PW_pwdft_soc,MODULE_PW_structure_factor_test,MODULE_PW_Hamilt_Kernels_UTs(cal_sk_op),MODULE_HAMILT_surchem_cal_pseudoandMODULE_PSI_init_testcover the moved code. They stay where they are and now compile the files fromsource_cell.python3 tools/03_code_analysis/agent_governance_check.py --staged --format texton each commit: warnings only, listed under Governance Notes.cmake -B build -G Ninja -DBUILD_TESTING=ON -DENABLE_LCAO=ON -DENABLE_MPI=ON -DENABLE_OPENMP=ONthencmake --build build -j15: success at both31e2afb35ande85cfd59d.abacus_basic_parareportsv3.11.0-beta11.cmake -B build_pw -G Ninja -DBUILD_TESTING=OFF -DENABLE_LCAO=OFF -DENABLE_MPI=ON -DENABLE_OPENMP=ONthen build: success at both commits (abacus_pw_para).31e2afb35:ctest -j1 -R "MODULE_PW_pwdft_soc|MODULE_PW_structure_factor_test|MODULE_PW_Hamilt_Kernels_UTs|MODULE_HAMILT_surchem_cal_pseudo|MODULE_PSI_init_test|MODULE_CELL_NEIGHBOR|MODULE_DFPT|MODULE_ESTATE_elecstate_pw$|MODULE_LCAO_tddft_snap_psibeta_half_test": 26/26 passed. These are the tests that compile the moved files, plus the ones that linkcell(MODULE_CELL_NEIGHBOR_*) ormodule_pwdft(MODULE_DFPT_*).e85cfd59d:ctest -j1 -R "MODULE_RELAX|MODULE_ESTATE|MODULE_DM|MODULE_LCAO_tddft": 49/49 passed. These cover the three files of the second commit.92289fe11(forwarding headers removed): no local build or test. I checked withgit grepthat no file still referencesmodule_pwdft/stru_fac.hormodule_pwdft/soc.h. Build and tests are left to CI.#includeline.MODULE_LCAO_deepks_*, which also compilessoc.cpp: needsENABLE_MLALGO, which the box lacks; left to CI.What's changed?
Structure_Factorholds S(G) = Σ exp(−iG·τ) and the per-atom phase factors exp(−iG·τ): the Fourier representation of the atomic positions.Socholds the spin–angular coupling coefficients of the pseudopotentials. Neither is plane-wave method code, and lower layers use both, so they move fromsource_pw/module_pwdfttosource_cell. The potential form factors (vl_pw,vnl_pw,vsep_pw) stay insource_pw.Moved files (contents unchanged apart from include lines):
stru_fac.h,stru_fac.cpp,stru_fac_k.cpp,soc.h,soc.cpp→source_cell/cal_sk_opkernelkernels/wf_op.{h,cpp},kernels/cuda/wf_op.cu,kernels/rocm/wf_op.hip.cu→source_cell/kernels/. It computes the phase factors forStructure_Factor::get_sk, and is its only user.Include fixes in the moved files.
wf_op.hno longer includessource_psi/psi.h, which it did not use. Without this,source_cellwould includesource_psi.stru_fac_k.cppnow includessource_base/module_device/memory_op.hdirectly. It uses the memory ops, and used to get them throughpsi.h.No forwarding headers (third commit, following review).
source_pw/module_pwdft/stru_fac.handsoc.hare deleted. The 21 remaining includers abovesource_cellnow includesource_cell/stru_fac.horsource_cell/soc.hdirectly:source_esolver:esolver_fp.hsource_io:module_bessel/numerical_basis.h,module_ctrl/ctrl_scf_lcao.h,module_energy/write_eband_terms.cppsource_lcao:force_stress_lcao.h,lcao_set.h,setup_nonlocal.cpp(soc.h)source_pw:module_dfpt/dfpt_pert.cpp,dfpt_pw.cpp,test/dfpt_test_mocks.cpp,test_serial/dfpt_{pert,phon,q0}_serial_test.cpp,module_proj/onsite_proj.h,module_pwdft/{force_pw,setup_pot,stress_func}.h,module_pwdft/vnl_pw.h(both headers),module_stodft/sto_stress_pw.cppwf_op.hnever had a forwarding header, because its only includers moved with it or are updated here.Lower-layer includers now use the new paths:
source_psi:psi_base.cpp,psi_init_atomic.cpp(both headers),psi_init_nao.cpp,psi_prepare.cpp,setup_psi_pw.cpp,setup_psi_pw.hsource_estate:module_charge/chg_extra.h,module_pot/potential_new.h,setup_estate_pw.hsource_hamilt:module_surchem/cal_pseudo.cpppsi_init_unit_test.cpp,test_elecstate_pw.cpp,module_surchem/test/setcell.h,test_soc.cpp,test_stru_fac.cpp,wf_op_test.cpp(names as of the latestdevelopmerge, which renamed some test files)After this, no file in
source_psi,source_estateorsource_hamiltincludesstru_fac.horsoc.hfromsource_pw.source_hamiltno longer includessource_pwat all.Build.
soc.cppjoins thecellobject library. It only needssource_base.stru_fac.cppandstru_fac_k.cppform a newstructure_factorobject library insource_cell/CMakeLists.txt, linked into the executable next tocell. They are not added tocellbecause they needplanewave, which the cell-only unit tests (MODULE_CELL_NEIGHBOR_*) linkcellwithout.source/CMakeLists.txt(CPU, CUDA, ROCm) point tosource_cell/kernels/.CMakeLists.txtfiles, point to the new paths. Thedevelopmerge also updatessource_pw/module_rt/unittests/CMakeLists.txt(new upstream in Feature: Enable noncollinear magnetism and SOC in PW RT-TDDFT with the ETRS propagator and adaptive time stepping #8223), which listedmodule_pwdft/{stru_fac,stru_fac_k,soc}.cpp.source/Makefile.Objects:./source_cell/kernelsis added toVPATH. The object names are unchanged.python/pyabacusdoes not list these files.Unused upward includes (second commit). These lines include a higher layer but use nothing from it:
source_estate/module_dm/edm_tddft.cpp:source_lcao/module_rt/gather_mat.handpropagator.h. Onlyedm_tddft_lapack.cppuses them, and it keeps its own includes.source_estate/elecstate_pw_sdft.cpp:source_hamilt/module_xc/xc_functional.h; no XC symbol is used.source_relax/ions_move_lbfgs.h:source_esolver/esolver_ks.h. The class only stores anESolver*(the code that assigned it is commented out), andesolver.h, still included, declares it. This keeps the whole KS solver header out of every includer ofions_move_lbfgs.h.After this,
edm_tddft.cppno longer includessource_lcao.Governance Notes
source_cellgainsStructure_Factor,Socand one kernel.source_psi,source_estate,source_hamilt,source_relax,source_esolver,source_io,source_lcaoandsource_pwonly change include lines.Structure_Factor::Structure_Factor()readsPARAM.inp.basis_typeandPARAM.inp.device; the lines move with the file unchanged. Passing these in explicitly is a separate cleanup.source_pw/module_pwdft/{stru_fac,soc}.hwith the same header at its new path.source_pw/module_pwdft/unittestsandkernels/test. Moving them intosource_cellis left out to keep this diff to the move itself.🤖 Generated with Claude Code