Skip to content

Commit a92991a

Browse files
committed
Refactor: remove GlobalC::solvent_model
1 parent c099d03 commit a92991a

28 files changed

+180
-122
lines changed

source/module_elecstate/elecstate_energy_terms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ double ElecState::get_etot_gatefield()
2626

2727
double ElecState::get_solvent_model_Ael()
2828
{
29-
return GlobalC::solvent_model.Ael;
29+
return surchem::Ael;
3030
}
3131

3232
double ElecState::get_solvent_model_Acav()
3333
{
34-
return GlobalC::solvent_model.Acav;
34+
return surchem::Acav;
3535
}
3636

3737
double ElecState::get_dftu_energy()

source/module_elecstate/potentials/efield.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ModuleBase::matrix Efield::add_efield(const UnitCell& cell,
3434
const ModulePW::PW_Basis* rho_basis,
3535
const int& nspin,
3636
const double* const* const rho,
37-
surchem& solvent)
37+
const surchem& solvent)
3838
{
3939
ModuleBase::TITLE("Efield", "add_efield");
4040
ModuleBase::timer::tick("Efield", "add_efield");
@@ -202,7 +202,7 @@ double Efield::cal_elec_dipole(const UnitCell& cell,
202202

203203
double Efield::cal_induced_dipole(const UnitCell& cell,
204204
const ModulePW::PW_Basis* rho_basis,
205-
surchem& solvent,
205+
const surchem& solvent,
206206
const double& bmod)
207207
{
208208
double induced_dipole = 0;

source/module_elecstate/potentials/efield.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifndef EFIELD_H
22
#define EFIELD_H
33

4-
#include "module_cell/unitcell.h"
54
#include "module_basis/module_pw/pw_basis.h"
5+
#include "module_cell/unitcell.h"
66
#include "module_hamilt_general/module_surchem/surchem.h"
7+
#include "module_parameter/parameter.h"
78

89
namespace elecstate
910
{
@@ -17,7 +18,7 @@ class Efield
1718
const ModulePW::PW_Basis* rho_basis,
1819
const int& nspin,
1920
const double* const* const rho,
20-
surchem& solvent);
21+
const surchem& solvent);
2122

2223
static double cal_elec_dipole(const UnitCell& cell,
2324
const ModulePW::PW_Basis* rho_basis,
@@ -29,7 +30,7 @@ class Efield
2930

3031
static double cal_induced_dipole(const UnitCell& cell,
3132
const ModulePW::PW_Basis* rho_basis,
32-
surchem& solvent,
33+
const surchem& solvent,
3334
const double& bmod);
3435

3536
static double saw_function(const double &a, const double &b, const double &x);
@@ -59,7 +60,8 @@ namespace elecstate
5960
class PotEfield : public PotBase
6061
{
6162
public:
62-
PotEfield(const ModulePW::PW_Basis* rho_basis_in, const UnitCell* ucell_in, bool dipole) : ucell_(ucell_in)
63+
PotEfield(const ModulePW::PW_Basis* rho_basis_in, const UnitCell* ucell_in, const surchem* solvent_in, bool dipole)
64+
: ucell_(ucell_in), solvent_(solvent_in)
6365
{
6466
this->rho_basis_ = rho_basis_in;
6567
if (!dipole)
@@ -81,7 +83,7 @@ class PotEfield : public PotBase
8183
const_cast<const ModulePW::PW_Basis*>(rho_basis_),
8284
PARAM.inp.nspin,
8385
nullptr,
84-
GlobalC::solvent_model);
86+
*solvent_);
8587
for (int ir = 0; ir < rho_basis_->nrxx; ++ir)
8688
{
8789
vl_pseudo[ir] += v_efield(0, ir);
@@ -94,11 +96,12 @@ class PotEfield : public PotBase
9496
const_cast<const ModulePW::PW_Basis*>(rho_basis_),
9597
v_eff.nr,
9698
chg->rho,
97-
GlobalC::solvent_model);
99+
*solvent_);
98100
}
99101

100102
private:
101-
const UnitCell *ucell_ = nullptr;
103+
const UnitCell* ucell_ = nullptr;
104+
const surchem* solvent_ = nullptr;
102105
};
103106

104107
} // namespace elecstate

source/module_elecstate/potentials/potential_new.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ Potential::Potential(const ModulePW::PW_Basis* rho_basis_in,
2323
const UnitCell* ucell_in,
2424
const ModuleBase::matrix* vloc_in,
2525
Structure_Factor* structure_factors_in,
26+
surchem* solvent_in,
2627
double* etxc_in,
2728
double* vtxc_in)
28-
: ucell_(ucell_in), vloc_(vloc_in), structure_factors_(structure_factors_in), etxc_(etxc_in), vtxc_(vtxc_in)
29+
: ucell_(ucell_in), vloc_(vloc_in), structure_factors_(structure_factors_in), solvent_(solvent_in), etxc_(etxc_in),
30+
vtxc_(vtxc_in)
2931
{
3032
this->rho_basis_ = rho_basis_in;
3133
this->rho_basis_smooth_ = rho_basis_smooth_in;

source/module_elecstate/potentials/potential_new.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#ifndef POTENTIALNEW_H
22
#define POTENTIALNEW_H
33

4-
#include <vector>
5-
64
#include "module_base/complexmatrix.h"
5+
#include "module_hamilt_general/module_surchem/surchem.h"
76
#include "module_hamilt_pw/hamilt_pwdft/VNL_in_pw.h"
87
#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h"
98
#include "pot_base.h"
109

10+
#include <vector>
11+
1112
namespace elecstate
1213
{
1314
/**
@@ -58,6 +59,7 @@ class Potential : public PotBase
5859
const UnitCell* ucell_in,
5960
const ModuleBase::matrix* vloc_in,
6061
Structure_Factor* structure_factors_in,
62+
surchem* solvent_in,
6163
double* etxc_in,
6264
double* vtxc_in);
6365
~Potential();
@@ -211,6 +213,7 @@ class Potential : public PotBase
211213
const UnitCell* ucell_ = nullptr;
212214
const ModuleBase::matrix* vloc_ = nullptr;
213215
Structure_Factor* structure_factors_ = nullptr;
216+
surchem* solvent_ = nullptr;
214217
};
215218

216219
} // namespace elecstate

source/module_elecstate/potentials/potential_types.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ PotBase* Potential::get_pot_type(const std::string& pot_type)
4747
return new PotSurChem(this->rho_basis_,
4848
this->structure_factors_,
4949
this->v_effective_fixed.data(),
50-
&GlobalC::solvent_model);
50+
this->solvent_);
5151
}
5252
else if (pot_type == "efield")
5353
{
54-
return new PotEfield(this->rho_basis_, this->ucell_, PARAM.inp.dip_cor_flag);
54+
return new PotEfield(this->rho_basis_, this->ucell_, this->solvent_, PARAM.inp.dip_cor_flag);
5555
}
5656
else if (pot_type == "gatefield")
5757
{

source/module_esolver/esolver_fp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ void ESolver_FP::after_scf(UnitCell& ucell, const int istep)
234234
this->pw_rhod,
235235
this->pelec->charge,
236236
&(ucell),
237-
this->pelec->pot->get_fixed_v());
237+
this->pelec->pot->get_fixed_v(),
238+
this->solvent);
238239
}
239240

240241
// 5) write ELF

source/module_esolver/esolver_fp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "module_cell/module_symmetry/symmetry.h"
77
#include "module_elecstate/elecstate.h"
88
#include "module_elecstate/module_charge/charge_extra.h"
9+
#include "module_hamilt_general/module_surchem/surchem.h"
910
#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h"
1011

1112
#include <fstream>
@@ -67,6 +68,9 @@ namespace ModuleESolver
6768

6869
//! Charge extrapolation
6970
Charge_Extra CE;
71+
72+
// solvent model
73+
surchem solvent;
7074
};
7175
}
7276

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
214214
&ucell,
215215
&(this->ppcell.vloc),
216216
&(this->sf),
217+
&(this->solvent),
217218
&(this->pelec->f_en.etxc),
218219
&(this->pelec->f_en.vtxc));
219220
}
@@ -320,6 +321,7 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& for
320321
this->sf,
321322
this->kv,
322323
this->pw_rho,
324+
this->solvent,
323325
#ifdef __EXX
324326
*this->exx_lri_double,
325327
*this->exx_lri_complex,
@@ -460,6 +462,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
460462
*this->psi,
461463
ucell,
462464
this->sf,
465+
this->solvent,
463466
*this->pw_rho,
464467
*this->pw_rhod,
465468
this->ppcell.vloc,
@@ -487,6 +490,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
487490
*this->psi,
488491
ucell,
489492
this->sf,
493+
this->solvent,
490494
*this->pw_rho,
491495
*this->pw_rhod,
492496
this->ppcell.vloc,

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ namespace ModuleESolver
247247
*this->kspw_psi,
248248
ucell,
249249
this->sf,
250+
this->solvent,
250251
*this->pw_wfc,
251252
*this->pw_rho,
252253
*this->pw_rhod,

0 commit comments

Comments
 (0)