Skip to content
4 changes: 4 additions & 0 deletions source/source_esolver/esolver_double_xc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "esolver_double_xc.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_basis/module_pw/pw_basis.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_pot/potential_new.h" // IWYU: was transitively via elecstate.h
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_hamilt/module_ewald/H_Ewald_pw.h"
#include "source_hamilt/module_vdw/vdw.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_esolver/esolver_double_xc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define ESOLVER_DOUBLE_XC_H

#include "source_esolver/esolver_ks_lcao.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h

namespace ModuleESolver
{
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_fp.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_fp.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h

#include "source_estate/cal_ux.h"
#include "source_estate/module_charge/symmetry_rho.h"
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_fp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#define ESOLVER_FP_H

#include "esolver.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h

#include "source_base/timer_wrapper.h"

#include "source_basis/module_pw/pw_basis.h" // plane wave basis
#include "source_cell/klist.h" // K_Vectors kv value member (no longer via elecstate.h)
#include "source_estate/elecstate.h" // electronic states
#include "source_estate/module_charge/charge_extra.h" // charge extrapolation
#include "source_hamilt/module_surchem/surchem.h" // solvation model
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_gets.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_gets.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h

#include "source_base/timer.h"
#include "source_cell/module_neighbor/sltk_atom_arrange.h"
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_ks_lcao.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_base/module_external/blacs_connector.h"
#include "source_cell/module_neighbor/sltk_atom_arrange.h"
#include "source_estate/elecstate_tools.h"
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_ks_lcaopw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h

#include "source_pw/module_pwdft/elecond.h"
#include "source_io/module_parameter/input_conv.h"
Expand Down
3 changes: 3 additions & 0 deletions source/source_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "esolver_ks_pw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_pot/potential_new.h" // IWYU: was transitively via elecstate.h

#include "source_estate/cal_ux.h"
#include "source_estate/elecstate_pw.h"
Expand Down
3 changes: 3 additions & 0 deletions source/source_esolver/esolver_of.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "esolver_of.h"
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_pot/potential_new.h" // IWYU: elecstate.h no longer provides this transitively

#include "source_io/module_parameter/parameter.h"
#include "source_io/module_output/cube_io.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_esolver/esolver_of_interface.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "esolver_of.h"
#include "source_estate/module_pot/potential_new.h" // IWYU: elecstate.h no longer provides this transitively
#include "source_io/module_parameter/parameter.h"

namespace ModuleESolver
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_of_tool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_of.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_pot/potential_new.h" // IWYU: elecstate.h no longer provides this transitively
#include "source_base/formatter.h"
#include "source_base/memory_recorder.h"
#include "source_estate/module_pot/efield.h"
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/esolver_sdft_pw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_sdft_pw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h

#include "source_base/global_variable.h"
#include "source_base/memory_recorder.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_esolver/lcao_others.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "source_esolver/esolver_ks_lcao.h"
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/cal_ux.h"
#include "source_estate/module_charge/symmetry_rho.h"
#include "source_lcao/hamilt_lcao.h"
Expand Down
2 changes: 2 additions & 0 deletions source/source_esolver/pw_others.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "esolver_ks_pw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_base/module_device/device.h"
#include "source_io/module_bessel/numerical_basis.h"
#include "source_io/module_bessel/numerical_descriptor.h"
Expand Down
21 changes: 21 additions & 0 deletions source/source_estate/elecstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@
#include "source_io/module_parameter/parameter.h"
#include "source_base/parallel_reduce.h"
#include "source_base/tool_title.h"
#include "source_estate/module_charge/charge.h"
#include "module_pot/potential_new.h"
#include "source_basis/module_pw/pw_basis.h"
#include "source_basis/module_pw/pw_basis_big.h"
#include "occupy.h"

namespace elecstate
{

ElecState::ElecState(Charge* chr_in, ModulePW::PW_Basis* rhopw_in, ModulePW::PW_Basis_Big* bigpw_in)
{
this->charge = chr_in;
this->charge->set_rhopw(rhopw_in);
this->bigpw = bigpw_in;
this->eferm.two_efermi = PARAM.globalv.two_fermi;
}

ElecState::~ElecState()
{
if (this->pot != nullptr)
{
delete this->pot;
this->pot = nullptr;
}
}

const double* ElecState::getRho(int spin) const
{
return &(this->charge->rho[spin][0]);
Expand Down
57 changes: 37 additions & 20 deletions source/source_estate/elecstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,53 @@
#define ELECSTATE_H

#include "fp_energy.h"
#include "source_cell/klist.h"
#include "source_estate/module_charge/charge.h"
#include "source_io/module_parameter/parameter.h"
#include "source_psi/psi.h"
#include "module_pot/potential_new.h"
#include "source_base/matrix.h"
#include "source_psi/psi.h" // Psi<T> appears in virtual method signatures; psi.h is light (own_fan=2)
#include "source_io/module_parameter/parameter.h" // PARAM/Input_para; kept (own_fan=4, cheap) to avoid churning ~120 downstream PARAM users

// Base-layer leaf utilities (own_fan~0) that the old heavy includes used to
// pull in transitively. Kept here so the ~100 downstream files using TITLE /
// WARNING_QUIT / timer / GlobalFunc / Memory do not each need a new include;
// global_function.h also transitively provides tool_title.h and tool_quit.h.
#include "source_base/global_function.h"
#include "source_base/timer.h"
#include "source_base/memory_recorder.h"

#include <complex>
#include <string>
#include <vector>

// The heavy data headers (potential_new own_fan=58, klist=42, charge=37) are
// forward-declared instead of included; their full definitions are pulled in by
// elecstate.cpp. parameter.h is kept above because dropping it saves only 4 fan
// but would force ~120 downstream files to add their own include.
class Charge;
class K_Vectors;
class UnitCell;
class Parallel_Grid;
namespace ModuleBase
{
class ComplexMatrix;
}
namespace ModulePW
{
class PW_Basis;
class PW_Basis_Big;
} // namespace ModulePW

namespace elecstate
{

class Potential;

class ElecState
{
public:
ElecState()
{
}
ElecState(Charge* chr_in, ModulePW::PW_Basis* rhopw_in, ModulePW::PW_Basis_Big* bigpw_in)
{
this->charge = chr_in;
this->charge->set_rhopw(rhopw_in);
this->bigpw = bigpw_in;
this->eferm.two_efermi = PARAM.globalv.two_fermi;
}
virtual ~ElecState()
{
if (this->pot != nullptr)
{
delete this->pot;
this->pot = nullptr;
}
}
ElecState(Charge* chr_in, ModulePW::PW_Basis* rhopw_in, ModulePW::PW_Basis_Big* bigpw_in);
virtual ~ElecState();
void init_ks(Charge* chr_in, // pointer for class Charge
const K_Vectors* klist_in,
int nk_in, // number of k points
Expand Down
5 changes: 5 additions & 0 deletions source/source_estate/elecstate_energy.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#include "elecstate.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_basis/module_pw/pw_basis.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_base/global_variable.h"
#include "source_base/parallel_comm.h"
#include "source_base/parallel_reduce.h"
#include "makov_payne.h"
#include "source_hamilt/module_xc/xc_functional.h"
#include "source_estate/module_pot/H_Hartree_pw.h"
#include "module_pot/potential_new.h" // ElecState::pot is now fwd-declared in elecstate.h
#include "source_io/module_parameter/parameter.h"

#include <cmath>
Expand Down
3 changes: 3 additions & 0 deletions source/source_estate/elecstate_energy_terms.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "elecstate.h"
#include "source_basis/module_pw/pw_basis.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_base/parallel_reduce.h"
#include "module_pot/potential_new.h" // ElecState::pot is now fwd-declared in elecstate.h
#include "source_estate/module_pot/H_Hartree_pw.h"
#include "source_estate/module_pot/efield.h"
#include "source_estate/module_pot/gatefield.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/elecstate_lcao.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "source_estate/elecstate_lcao.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_estate/cal_dm.h"
#include "source_base/timer.h"
#include "source_estate/module_dm/cal_dm_psi.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/elecstate_print.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "elecstate.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_base/formatter.h"
#include "source_base/global_variable.h"
#include "source_base/parallel_common.h"
Expand Down
4 changes: 4 additions & 0 deletions source/source_estate/elecstate_pw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "elecstate_pw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_basis/module_pw/pw_basis.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h

#include "source_base/constants.h"
#include "source_base/libm/libm.h"
Expand Down
3 changes: 3 additions & 0 deletions source/source_estate/elecstate_pw_cal_tau.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "elecstate_pw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_charge/charge.h" // IWYU: elecstate.h no longer provides this transitively

namespace elecstate {

Expand Down
1 change: 1 addition & 0 deletions source/source_estate/elecstate_pw_sdft.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "./elecstate_pw_sdft.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h

#include "source_base/global_function.h"
#include "source_base/global_variable.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/elecstate_tools.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "elecstate_tools.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "occupy.h"
#include "source_base/parallel_reduce.h"
namespace elecstate
Expand Down
2 changes: 2 additions & 0 deletions source/source_estate/init_scf.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "elecstate.h"
#include "module_pot/potential_new.h" // ElecState::pot is now fwd-declared in elecstate.h
#include "source_estate/module_charge/charge.h" // ElecState::charge is now fwd-declared in elecstate.h
#include "source_io/module_chgpot/write_init.h"

namespace elecstate
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/module_dm/init_dm.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "source_estate/module_dm/init_dm.h"
#include "source_estate/module_pot/potential_new.h" // IWYU: elecstate.h no longer provides this transitively
#include "source_estate/module_dm/cal_dm_psi.h"
#include "source_estate/elecstate_tools.h"
#include "source_estate/cal_ux.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/module_pot/pot_ml_exx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifdef __MLALGO

#include "pot_base.h"
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "source_io/module_ml/cal_mlkedf_descriptors.h"
#include "source_pw/module_ofdft/ml_base.h"

Expand Down
2 changes: 2 additions & 0 deletions source/source_estate/setup_estate_pw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "source_estate/setup_estate_pw.h"
#include "source_estate/module_pot/potential_new.h" // new elecstate::Potential (was transitively via elecstate.h)
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/elecstate_pw.h"
#include "source_estate/elecstate_pw_sdft.h"
#include "source_estate/elecstate_tools.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/setup_estate_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "source_pw/module_pwdft/vsep_pw.h"

class pseudopot_cell_vnl;
class surchem; // used only as a reference param below (was transitively via elecstate.h)

namespace elecstate
{
Expand Down
3 changes: 3 additions & 0 deletions source/source_estate/test/elecstate_base_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "gmock/gmock.h"
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "gtest/gtest.h"
#include <string>
#define private public
#define protected public
#include "source_estate/elecstate.h"
#include "source_estate/elecstate_tools.h"
#include "source_estate/module_charge/charge.h" // new Charge / charge->rho (no longer via elecstate.h)
#include "source_estate/module_pot/potential_new.h" // Potential (no longer via elecstate.h)
#include "source_estate/occupy.h"
#include "source_io/module_parameter/parameter.h"
#include "source_base/module_fft/fft_bundle.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/test/elecstate_print_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <string>

#include "gmock/gmock.h"
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "gtest/gtest.h"
#define private public
#include "source_cell/klist.h"
Expand Down
2 changes: 2 additions & 0 deletions source/source_estate/test/elecstate_pw_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <string>

#include "gmock/gmock.h"
#include "source_cell/unitcell.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_charge/charge.h" // IWYU: was transitively via elecstate.h
#include "gtest/gtest.h"
#define private public
#define protected public
Expand Down
1 change: 1 addition & 0 deletions source/source_estate/update_pot.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "source_estate/update_pot.h"
#include "source_estate/module_pot/potential_new.h" // IWYU: elecstate.h no longer provides this transitively
#include "source_estate/cal_ux.h"

void elecstate::update_pot(UnitCell& ucell, // unitcell
Expand Down
5 changes: 5 additions & 0 deletions source/source_hsolver/hsolver_lcaopw.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include "source_estate/elecstate.h"
#include "source_hamilt/hamilt.h"
#include "source_base/macros.h"

// Used only as a pointer member/param; forward-declared instead of including
// pw_basis_k.h. Was previously reachable transitively through elecstate.h.
namespace ModulePW { class PW_Basis_K; }

namespace hsolver
{

Expand Down
2 changes: 2 additions & 0 deletions source/source_hsolver/hsolver_pw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "hsolver_pw.h"
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_estate/module_pot/potential_new.h" // IWYU: elecstate.h no longer provides this transitively

#include "source_base/parallel_comm.h"
#include "source_base/global_variable.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_hsolver/hsolver_pw_sdft.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "hsolver_pw_sdft.h"
#include "source_estate/module_pot/potential_new.h" // IWYU: was transitively via elecstate.h

#include "source_base/global_function.h"
#include "source_base/parallel_device.h"
Expand Down
1 change: 1 addition & 0 deletions source/source_hsolver/test/hsolver_supplementary_mock.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "source_estate/elecstate_pw.h"
#include "source_estate/module_charge/charge.h" // IWYU: elecstate.h no longer provides this transitively

namespace elecstate
{
Expand Down
2 changes: 2 additions & 0 deletions source/source_hsolver/test/test_hsolver_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define private public
#define protected public
#include "source_io/module_parameter/parameter.h"
#include "source_estate/module_pot/potential_new.h" // new elecstate::Potential (was transitively via elecstate.h)
#include "source_cell/klist.h" // IWYU: was transitively via elecstate.h
#include "source_hsolver/hsolver_pw.h"
#include "source_hsolver/hsolver_lcaopw.h"
#include "hsolver_supplementary_mock.h"
Expand Down
Loading
Loading