Skip to content

Commit 4fa13e1

Browse files
Critsium-xyclaude
andauthored
Refactor: remove dead cross module includes (deepmodeling#7574)
* 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> * 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) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 548bf8f commit 4fa13e1

21 files changed

Lines changed: 0 additions & 45 deletions

source/source_cell/read_atoms.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@
88
#include "source_io/module_parameter/parameter.h"
99
#include "print_cell.h"
1010
#include "read_stru.h"
11-
#include "source_estate/read_orb.h"
1211
#include "source_base/timer.h"
1312
#include "source_base/constants.h"
1413
#include "source_base/formatter.h"
1514
#include "source_base/mathzone.h"
1615

17-
#ifdef __LCAO
18-
#include "source_basis/module_ao/ORB_read.h" // to use 'ORB' -- mohan 2021-01-30
19-
#endif
20-
2116
bool unitcell::read_atom_positions(UnitCell& ucell,
2217
std::ifstream &ifpos,
2318
std::ofstream &ofs_running,

source/source_esolver/esolver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "esolver_lj.h"
2020
#include "esolver_of.h"
2121
#include "esolver_of_tddft.h"
22-
#include "source_io/module_parameter/md_parameter.h"
2322

2423
#include <stdexcept>
2524

source/source_esolver/esolver_dm2rho.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "source_lcao/module_operator_lcao/operator_lcao.h"
1010
#include "source_io/module_output/cube_io.h"
1111
#include "source_io/module_ml/io_npz.h"
12-
#include "source_io/module_output/print_info.h"
1312
#include "source_lcao/rho_tau_lcao.h" // mohan add 2025-10-24
1413

1514
namespace ModuleESolver

source/source_esolver/esolver_double_xc.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "source_lcao/hamilt_lcao.h"
1616
#include "source_hsolver/hsolver_lcao.h"
1717
#include "source_io/module_parameter/parameter.h"
18-
#include "source_io/module_hs/write_HS.h" // use ModuleIO::write_hsk()
1918
#include "source_lcao/setup_deepks.h" // use deepks, mohan add 2025-10-10
2019

2120
namespace ModuleESolver

source/source_esolver/esolver_fp.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include "source_hamilt/module_ewald/H_Ewald_pw.h"
77
#include "source_hamilt/module_vdw/vdw.h"
88
#include "source_io/module_output/cif_io.h"
9-
#include "source_io/module_output/cube_io.h" // use write_vdata_palgrid
10-
#include "source_io/module_json/init_info.h"
11-
#include "source_io/module_json/output_info.h"
129
#include "source_io/module_output/output_log.h"
1310
#include "source_io/module_output/print_info.h"
1411
#include "source_io/module_chgpot/rhog_io.h"

source/source_esolver/esolver_ks.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "source_base/timer_wrapper.h"
33

44
// for jason output information
5-
#include "source_io/module_json/init_info.h"
65
#include "source_io/module_json/output_info.h"
76

87
#include "source_estate/update_pot.h" // mohan add 20251016
@@ -14,7 +13,6 @@
1413
#include "source_hamilt/module_xc/xc_functional.h"
1514
#include "source_io/module_output/output_log.h" // use write_head
1615
#include "source_estate/elecstate_print.h" // print_etot
17-
#include "source_io/module_output/print_info.h" // print_parameters
1816
#include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-07
1917

2018
namespace ModuleESolver

source/source_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
//----------------IO-----------------
55
#include "source_base/global_variable.h"
66
#include "source_io/module_ctrl/ctrl_output_td.h"
7-
#include "source_io/module_current/td_current_io.h"
8-
#include "source_io/module_dipole/dipole_io.h"
97
#include "source_io/module_output/output_log.h"
108
#include "source_io/module_wf/read_wfc_nao.h"
119
//------LCAO HSolver ElecState-------

source/source_esolver/esolver_ks_lcaopw.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
#include "source_pw/module_pwdft/elecond.h"
44
#include "source_io/module_parameter/input_conv.h"
5-
#include "source_io/module_output/output_log.h"
65

76
#include <iostream>
87

98
//--------------temporary----------------------------
109
#include "source_estate/module_charge/symmetry_rho.h"
1110
#include "source_estate/occupy.h"
1211
#include "source_hamilt/module_ewald/H_Ewald_pw.h"
13-
#include "source_io/module_output/print_info.h"
1412
//-----force-------------------
1513
#include "source_pw/module_pwdft/forces.h"
1614
//-----stress------------------
@@ -23,11 +21,6 @@
2321
#include "source_hsolver/hsolver_lcaopw.h"
2422
#include "source_hsolver/kernels/hegvd_op.h"
2523
#include "source_base/kernels/math_kernel_op.h"
26-
#include "source_io/module_unk/berryphase.h"
27-
#include "source_io/module_bessel/numerical_basis.h"
28-
#include "source_io/module_bessel/numerical_descriptor.h"
29-
#include "source_io/module_wannier/to_wannier90_pw.h"
30-
#include "source_io/module_chgpot/write_elecstat_pot.h"
3124
#include "source_io/module_parameter/parameter.h"
3225
#include "source_hamilt/module_xc/xc_functional.h"
3326

source/source_esolver/esolver_of.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#include "esolver_of.h"
22

33
#include "source_io/module_parameter/parameter.h"
4-
#include "source_io/module_output/cube_io.h"
5-
#include "source_io/module_output/output_log.h"
6-
#include "source_io/module_chgpot/write_elecstat_pot.h"
74
//-----------temporary-------------------------
85
#include "source_base/global_function.h"
96
#include "source_estate/module_charge/symmetry_rho.h"
107
#include "source_hamilt/module_ewald/H_Ewald_pw.h"
11-
#include "source_io/module_output/print_info.h"
128
#include "source_estate/cal_ux.h"
139
#include "source_pw/module_pwdft/forces.h"
1410
#include "source_pw/module_ofdft/of_stress_pw.h"

source/source_esolver/esolver_of_tddft.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
#include "esolver_of_tddft.h"
22

33
#include "source_io/module_parameter/parameter.h"
4-
#include "source_io/module_output/cube_io.h"
5-
#include "source_io/module_output/output_log.h"
6-
#include "source_io/module_chgpot/write_elecstat_pot.h"
74
//-----------temporary-------------------------
85
#include "source_base/global_function.h"
96
#include "source_estate/module_charge/symmetry_rho.h"
107
#include "source_hamilt/module_ewald/H_Ewald_pw.h"
11-
#include "source_io/module_output/print_info.h"
128
#include "source_estate/cal_ux.h"
139
//-----force-------------------
1410
#include "source_pw/module_pwdft/forces.h"

0 commit comments

Comments
 (0)