Skip to content

Commit c1cb6ac

Browse files
Refactor: remove GlobalC::solvent_model (#5735)
* Refactor: remove GlobalC::solvent_model * Test: update unittests * [pre-commit.ci lite] apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 72bd505 commit c1cb6ac

30 files changed

+240
-160
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
{

0 commit comments

Comments
 (0)