From 5d93510d585addefee32b45968cfc41bdad3571c Mon Sep 17 00:00:00 2001 From: Critsium-xy Date: Wed, 1 Jul 2026 13:28:40 +0800 Subject: [PATCH 1/4] refactor(cell): remove unused cross-module includes in read_atoms.cpp Drop two dead includes that create needless reverse dependencies from source_cell onto higher layers: - source_estate/read_orb.h (elecstate::read_orb_file not used here; the real user is read_atoms_helper.cpp) - source_basis/module_ao/ORB_read.h (ORB / LCAO_Orbitals not used here) Verified by compiling the `cell` target with ENABLE_LCAO=ON so the former `#ifdef __LCAO` block was actually exercised. Co-Authored-By: Claude Opus 4.8 (1M context) --- source/source_cell/read_atoms.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/source/source_cell/read_atoms.cpp b/source/source_cell/read_atoms.cpp index 748be95c015..7da6abefae9 100644 --- a/source/source_cell/read_atoms.cpp +++ b/source/source_cell/read_atoms.cpp @@ -8,16 +8,11 @@ #include "source_io/module_parameter/parameter.h" #include "print_cell.h" #include "read_stru.h" -#include "source_estate/read_orb.h" #include "source_base/timer.h" #include "source_base/constants.h" #include "source_base/formatter.h" #include "source_base/mathzone.h" -#ifdef __LCAO -#include "source_basis/module_ao/ORB_read.h" // to use 'ORB' -- mohan 2021-01-30 -#endif - bool unitcell::read_atom_positions(UnitCell& ucell, std::ifstream &ifpos, std::ofstream &ofs_running, From e36bb3ea7201469d19cd5e3b163914c7692ef8e6 Mon Sep 17 00:00:00 2001 From: Critsium-xy Date: Wed, 1 Jul 2026 13:44:15 +0800 Subject: [PATCH 2/4] refactor: remove dead cross-module includes on reverse-dependency edges Static scan + per-target compile verification identified 9 unused includes that create reverse/lateral dependency edges between modules. Removing them weakens the coupling without any behavior change: io -> md input_conv.cpp (md_func.h) estate -> lcao elecstate_energy_terms.cpp, elecstate_print.cpp (module_deepks/LCAO_deepks.h) lcao -> pw rdmft_tools.cpp (structure_factor.h), wavefunc_in_pw.cpp (soc.h) lcao -> io FORCE_gamma.cpp, FORCE_k.cpp (module_hs/write_HS.h) pw -> io forces_cc.cpp, forces_scc.cpp (module_output/output_log.h) Verified by building io_basic, elecstate, rdmft, hamilt_lcao and module_pwdft (ENABLE_LCAO=ON) after removal; all link targets compile. Co-Authored-By: Claude Opus 4.8 (1M context) --- source/source_estate/elecstate_energy_terms.cpp | 1 - source/source_estate/elecstate_print.cpp | 1 - source/source_io/module_parameter/input_conv.cpp | 1 - source/source_lcao/FORCE_gamma.cpp | 1 - source/source_lcao/FORCE_k.cpp | 1 - source/source_lcao/module_rdmft/rdmft_tools.cpp | 1 - source/source_lcao/wavefunc_in_pw.cpp | 1 - source/source_pw/module_pwdft/forces_cc.cpp | 1 - source/source_pw/module_pwdft/forces_scc.cpp | 1 - 9 files changed, 9 deletions(-) diff --git a/source/source_estate/elecstate_energy_terms.cpp b/source/source_estate/elecstate_energy_terms.cpp index ebe0068c27b..09ea586796d 100644 --- a/source/source_estate/elecstate_energy_terms.cpp +++ b/source/source_estate/elecstate_energy_terms.cpp @@ -3,7 +3,6 @@ #include "source_estate/module_pot/H_Hartree_pw.h" #include "source_estate/module_pot/efield.h" #include "source_estate/module_pot/gatefield.h" -#include "source_lcao/module_deepks/LCAO_deepks.h" #include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06 diff --git a/source/source_estate/elecstate_print.cpp b/source/source_estate/elecstate_print.cpp index 5c61755d6ff..e7d9c9ee8e8 100644 --- a/source/source_estate/elecstate_print.cpp +++ b/source/source_estate/elecstate_print.cpp @@ -6,7 +6,6 @@ #include "source_estate/module_pot/efield.h" #include "source_estate/module_pot/gatefield.h" #include "source_hamilt/module_xc/xc_functional.h" -#include "source_lcao/module_deepks/LCAO_deepks.h" #include "source_io/module_parameter/parameter.h" #include "occupy.h" namespace elecstate diff --git a/source/source_io/module_parameter/input_conv.cpp b/source/source_io/module_parameter/input_conv.cpp index 1e57a175123..6a1d06c0d46 100644 --- a/source/source_io/module_parameter/input_conv.cpp +++ b/source/source_io/module_parameter/input_conv.cpp @@ -42,7 +42,6 @@ #include "source_estate/module_pot/gatefield.h" #include "source_hsolver/hsolver_lcao.h" #include "source_hsolver/hsolver_pw.h" -#include "source_md/md_func.h" #include "source_relax/bfgs_basic.h" #include "source_relax/ions_move_cg.h" diff --git a/source/source_lcao/FORCE_gamma.cpp b/source/source_lcao/FORCE_gamma.cpp index 379ceb29459..c7caf551adc 100644 --- a/source/source_lcao/FORCE_gamma.cpp +++ b/source/source_lcao/FORCE_gamma.cpp @@ -13,7 +13,6 @@ #include "source_estate/elecstate_lcao.h" #include "source_lcao/LCAO_domain.h" #include "source_lcao/pulay_fs.h" -#include "source_io/module_hs/write_HS.h" template <> void Force_LCAO::allocate(const UnitCell& ucell, diff --git a/source/source_lcao/FORCE_k.cpp b/source/source_lcao/FORCE_k.cpp index 475d8368884..0ac068ac027 100644 --- a/source/source_lcao/FORCE_k.cpp +++ b/source/source_lcao/FORCE_k.cpp @@ -10,7 +10,6 @@ #include "source_estate/module_dm/cal_dm_psi.h" #include "source_lcao/LCAO_domain.h" #include "source_lcao/pulay_fs.h" -#include "source_io/module_hs/write_HS.h" #include "source_io/module_parameter/parameter.h" #include diff --git a/source/source_lcao/module_rdmft/rdmft_tools.cpp b/source/source_lcao/module_rdmft/rdmft_tools.cpp index 34d6cf55e87..fc1506a8172 100644 --- a/source/source_lcao/module_rdmft/rdmft_tools.cpp +++ b/source/source_lcao/module_rdmft/rdmft_tools.cpp @@ -10,7 +10,6 @@ #include "source_estate/module_pot/H_Hartree_pw.h" #include "source_estate/module_pot/pot_local.h" #include "source_estate/module_pot/pot_xc.h" -#include "source_pw/module_pwdft/structure_factor.h" #include "source_lcao/module_gint/gint_interface.h" #include "source_io/module_parameter/parameter.h" diff --git a/source/source_lcao/wavefunc_in_pw.cpp b/source/source_lcao/wavefunc_in_pw.cpp index 3bc3711e140..ce6ea0544e5 100644 --- a/source/source_lcao/wavefunc_in_pw.cpp +++ b/source/source_lcao/wavefunc_in_pw.cpp @@ -5,7 +5,6 @@ #include "source_base/math_sphbes.h" #include "source_base/math_polyint.h" #include "source_base/math_ylmreal.h" -#include "source_pw/module_pwdft/soc.h" void Wavefunc_in_pw::make_table_q( const UnitCell &ucell, diff --git a/source/source_pw/module_pwdft/forces_cc.cpp b/source/source_pw/module_pwdft/forces_cc.cpp index 41322e62e55..ed962be3c1c 100644 --- a/source/source_pw/module_pwdft/forces_cc.cpp +++ b/source/source_pw/module_pwdft/forces_cc.cpp @@ -2,7 +2,6 @@ #include "stress_func.h" #include "source_base/parallel_reduce.h" #include "source_io/module_parameter/parameter.h" -#include "source_io/module_output/output_log.h" // new #include "source_base/complexmatrix.h" #include "source_base/libm/libm.h" diff --git a/source/source_pw/module_pwdft/forces_scc.cpp b/source/source_pw/module_pwdft/forces_scc.cpp index 3d454cf9a09..5101da36a19 100644 --- a/source/source_pw/module_pwdft/forces_scc.cpp +++ b/source/source_pw/module_pwdft/forces_scc.cpp @@ -1,6 +1,5 @@ #include "forces.h" #include "source_base/parallel_reduce.h" -#include "source_io/module_output/output_log.h" #include "stress_func.h" // new #include "source_base/complexmatrix.h" From 60840270d1148c13cb034fa22018969913756205 Mon Sep 17 00:00:00 2001 From: Critsium-xy Date: Wed, 1 Jul 2026 14:44:42 +0800 Subject: [PATCH 3/4] refactor(esolver): remove 29 dead io includes (esolver -> io hygiene) Remove unused source_io includes across the esolver drivers. These are on the allowed esolver->io direction, so this is include hygiene rather than decoupling, but it trims 29 needless includes. Verified three ways: 1. `make esolver` (ENABLE_LCAO=ON) recompiles all 21 TUs, 0 errors. 2. Feature-guarded headers checked explicitly since __RAPIDJSON, __EXX/__LIBRI and __MLALGO are OFF in this build: the json (init_info.h/output_info.h) and restart_exx_csr.h symbols are unused in their consumers (Json::add_output_scf_mag in esolver_ks.cpp comes from output_info.h, which is kept). 3. Whole-file precise-symbol sweep (incl. all #ifdef blocks) finds no specific symbol of any removed header in its consumer. Co-Authored-By: Claude Opus 4.8 (1M context) --- source/source_esolver/esolver.cpp | 1 - source/source_esolver/esolver_dm2rho.cpp | 1 - source/source_esolver/esolver_fp.cpp | 3 --- source/source_esolver/esolver_ks.cpp | 2 -- source/source_esolver/esolver_ks_lcao_tddft.cpp | 2 -- source/source_esolver/esolver_ks_lcaopw.cpp | 7 ------- source/source_esolver/esolver_of.cpp | 4 ---- source/source_esolver/esolver_of_tddft.cpp | 4 ---- source/source_esolver/lcao_others.cpp | 4 ---- source/source_esolver/pw_others.cpp | 1 - 10 files changed, 29 deletions(-) diff --git a/source/source_esolver/esolver.cpp b/source/source_esolver/esolver.cpp index 0e932465f81..fc3aab0aa46 100644 --- a/source/source_esolver/esolver.cpp +++ b/source/source_esolver/esolver.cpp @@ -19,7 +19,6 @@ #include "esolver_lj.h" #include "esolver_of.h" #include "esolver_of_tddft.h" -#include "source_io/module_parameter/md_parameter.h" #include diff --git a/source/source_esolver/esolver_dm2rho.cpp b/source/source_esolver/esolver_dm2rho.cpp index 1548d748321..017d190fe72 100644 --- a/source/source_esolver/esolver_dm2rho.cpp +++ b/source/source_esolver/esolver_dm2rho.cpp @@ -9,7 +9,6 @@ #include "source_lcao/module_operator_lcao/operator_lcao.h" #include "source_io/module_output/cube_io.h" #include "source_io/module_ml/io_npz.h" -#include "source_io/module_output/print_info.h" #include "source_lcao/rho_tau_lcao.h" // mohan add 2025-10-24 namespace ModuleESolver diff --git a/source/source_esolver/esolver_fp.cpp b/source/source_esolver/esolver_fp.cpp index 1ddb636c8ab..42719a48860 100644 --- a/source/source_esolver/esolver_fp.cpp +++ b/source/source_esolver/esolver_fp.cpp @@ -6,9 +6,6 @@ #include "source_hamilt/module_ewald/H_Ewald_pw.h" #include "source_hamilt/module_vdw/vdw.h" #include "source_io/module_output/cif_io.h" -#include "source_io/module_output/cube_io.h" // use write_vdata_palgrid -#include "source_io/module_json/init_info.h" -#include "source_io/module_json/output_info.h" #include "source_io/module_output/output_log.h" #include "source_io/module_output/print_info.h" #include "source_io/module_chgpot/rhog_io.h" diff --git a/source/source_esolver/esolver_ks.cpp b/source/source_esolver/esolver_ks.cpp index 007184773b9..286b08f8454 100644 --- a/source/source_esolver/esolver_ks.cpp +++ b/source/source_esolver/esolver_ks.cpp @@ -2,7 +2,6 @@ #include "source_base/timer_wrapper.h" // for jason output information -#include "source_io/module_json/init_info.h" #include "source_io/module_json/output_info.h" #include "source_estate/update_pot.h" // mohan add 20251016 @@ -14,7 +13,6 @@ #include "source_hamilt/module_xc/xc_functional.h" #include "source_io/module_output/output_log.h" // use write_head #include "source_estate/elecstate_print.h" // print_etot -#include "source_io/module_output/print_info.h" // print_parameters #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-07 namespace ModuleESolver diff --git a/source/source_esolver/esolver_ks_lcao_tddft.cpp b/source/source_esolver/esolver_ks_lcao_tddft.cpp index 7f7c27c90b2..c3872481db9 100644 --- a/source/source_esolver/esolver_ks_lcao_tddft.cpp +++ b/source/source_esolver/esolver_ks_lcao_tddft.cpp @@ -4,8 +4,6 @@ //----------------IO----------------- #include "source_base/global_variable.h" #include "source_io/module_ctrl/ctrl_output_td.h" -#include "source_io/module_current/td_current_io.h" -#include "source_io/module_dipole/dipole_io.h" #include "source_io/module_output/output_log.h" #include "source_io/module_wf/read_wfc_nao.h" //------LCAO HSolver ElecState------- diff --git a/source/source_esolver/esolver_ks_lcaopw.cpp b/source/source_esolver/esolver_ks_lcaopw.cpp index 6c5cb703bfa..b77a0345cf4 100644 --- a/source/source_esolver/esolver_ks_lcaopw.cpp +++ b/source/source_esolver/esolver_ks_lcaopw.cpp @@ -2,7 +2,6 @@ #include "source_pw/module_pwdft/elecond.h" #include "source_io/module_parameter/input_conv.h" -#include "source_io/module_output/output_log.h" #include @@ -10,7 +9,6 @@ #include "source_estate/module_charge/symmetry_rho.h" #include "source_estate/occupy.h" #include "source_hamilt/module_ewald/H_Ewald_pw.h" -#include "source_io/module_output/print_info.h" //-----force------------------- #include "source_pw/module_pwdft/forces.h" //-----stress------------------ @@ -23,11 +21,6 @@ #include "source_hsolver/hsolver_lcaopw.h" #include "source_hsolver/kernels/hegvd_op.h" #include "source_base/kernels/math_kernel_op.h" -#include "source_io/module_unk/berryphase.h" -#include "source_io/module_bessel/numerical_basis.h" -#include "source_io/module_bessel/numerical_descriptor.h" -#include "source_io/module_wannier/to_wannier90_pw.h" -#include "source_io/module_chgpot/write_elecstat_pot.h" #include "source_io/module_parameter/parameter.h" #include "source_hamilt/module_xc/xc_functional.h" diff --git a/source/source_esolver/esolver_of.cpp b/source/source_esolver/esolver_of.cpp index b346df60fb8..b7122428f21 100644 --- a/source/source_esolver/esolver_of.cpp +++ b/source/source_esolver/esolver_of.cpp @@ -1,14 +1,10 @@ #include "esolver_of.h" #include "source_io/module_parameter/parameter.h" -#include "source_io/module_output/cube_io.h" -#include "source_io/module_output/output_log.h" -#include "source_io/module_chgpot/write_elecstat_pot.h" //-----------temporary------------------------- #include "source_base/global_function.h" #include "source_estate/module_charge/symmetry_rho.h" #include "source_hamilt/module_ewald/H_Ewald_pw.h" -#include "source_io/module_output/print_info.h" #include "source_estate/cal_ux.h" #include "source_pw/module_pwdft/forces.h" #include "source_pw/module_ofdft/of_stress_pw.h" diff --git a/source/source_esolver/esolver_of_tddft.cpp b/source/source_esolver/esolver_of_tddft.cpp index d3bfbb28f4c..82567c3d0c5 100644 --- a/source/source_esolver/esolver_of_tddft.cpp +++ b/source/source_esolver/esolver_of_tddft.cpp @@ -1,14 +1,10 @@ #include "esolver_of_tddft.h" #include "source_io/module_parameter/parameter.h" -#include "source_io/module_output/cube_io.h" -#include "source_io/module_output/output_log.h" -#include "source_io/module_chgpot/write_elecstat_pot.h" //-----------temporary------------------------- #include "source_base/global_function.h" #include "source_estate/module_charge/symmetry_rho.h" #include "source_hamilt/module_ewald/H_Ewald_pw.h" -#include "source_io/module_output/print_info.h" #include "source_estate/cal_ux.h" //-----force------------------- #include "source_pw/module_pwdft/forces.h" diff --git a/source/source_esolver/lcao_others.cpp b/source/source_esolver/lcao_others.cpp index c8e38f2111f..4b7b37dafa0 100644 --- a/source/source_esolver/lcao_others.cpp +++ b/source/source_esolver/lcao_others.cpp @@ -10,20 +10,16 @@ #include "source_cell/module_neighbor/sltk_grid_driver.h" #include "source_estate/elecstate_lcao.h" #include "source_estate/module_dm/cal_dm_psi.h" -#include "source_io/module_unk/berryphase.h" #include "source_io/module_chgpot/get_pchg_lcao.h" #include "source_io/module_wf/get_wf_lcao.h" #include "source_io/module_parameter/parameter.h" -#include "source_io/module_wf/read_wfc_nao.h" #include "source_io/module_hs/write_HS_R.h" -#include "source_io/module_chgpot/write_elecstat_pot.h" #include "source_lcao/LCAO_domain.h" #include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_lcao/module_operator_lcao/op_exx_lcao.h" #include "source_lcao/module_operator_lcao/operator_lcao.h" #ifdef __EXX -#include "source_io/module_restart/restart_exx_csr.h" #endif // mohan add 2025-03-06 diff --git a/source/source_esolver/pw_others.cpp b/source/source_esolver/pw_others.cpp index bbacac36566..165b2307f2d 100644 --- a/source/source_esolver/pw_others.cpp +++ b/source/source_esolver/pw_others.cpp @@ -1,6 +1,5 @@ #include "esolver_ks_pw.h" #include "source_base/module_device/device.h" -#include "source_io/module_bessel/numerical_basis.h" #include "source_io/module_bessel/numerical_descriptor.h" #include "source_base/formatter.h" From 5b02d3633eb9b698c9ade3873157a756aa92fde2 Mon Sep 17 00:00:00 2001 From: Critsium-xy Date: Wed, 1 Jul 2026 16:09:48 +0800 Subject: [PATCH 4/4] refactor: remove 2 more dead cross-module includes Two dead includes missed by the first reverse-edge pass: estate -> lcao elecstate_energy_terms.cpp (module_deltaspin/spin_constrain.h; SpinConstrain is not referenced anywhere in the file) esolver -> io esolver_double_xc.cpp (module_hs/write_HS.h; only a comment mentions ModuleIO::write_hsk(), no actual call) Verified: no header symbol appears anywhere in the consumer (guards included), and `make elecstate` / `make esolver` build cleanly. Co-Authored-By: Claude Opus 4.8 (1M context) --- source/source_esolver/esolver_double_xc.cpp | 1 - source/source_estate/elecstate_energy_terms.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/source/source_esolver/esolver_double_xc.cpp b/source/source_esolver/esolver_double_xc.cpp index 2baaffb1ec5..5ea6de1e793 100644 --- a/source/source_esolver/esolver_double_xc.cpp +++ b/source/source_esolver/esolver_double_xc.cpp @@ -15,7 +15,6 @@ #include "source_lcao/hamilt_lcao.h" #include "source_hsolver/hsolver_lcao.h" #include "source_io/module_parameter/parameter.h" -#include "source_io/module_hs/write_HS.h" // use ModuleIO::write_hsk() #include "source_lcao/setup_deepks.h" // use deepks, mohan add 2025-10-10 namespace ModuleESolver diff --git a/source/source_estate/elecstate_energy_terms.cpp b/source/source_estate/elecstate_energy_terms.cpp index 09ea586796d..21407a5dcff 100644 --- a/source/source_estate/elecstate_energy_terms.cpp +++ b/source/source_estate/elecstate_energy_terms.cpp @@ -3,7 +3,6 @@ #include "source_estate/module_pot/H_Hartree_pw.h" #include "source_estate/module_pot/efield.h" #include "source_estate/module_pot/gatefield.h" -#include "source_lcao/module_deltaspin/spin_constrain.h" #include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06 namespace elecstate