Skip to content

Commit 111c3fb

Browse files
committed
Refactor: remove GlobaC::ppcell
1 parent 93ac7e3 commit 111c3fb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+213
-151
lines changed

source/driver.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ Driver::Driver()
1919

2020
Driver::~Driver()
2121
{
22-
// Release the device memory within singleton object GlobalC::ppcell
23-
// before the main function exits.
24-
GlobalC::ppcell.release_memory();
2522
}
2623

2724
void Driver::init()

source/module_elecstate/elecstate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,14 @@ void ElecState::calEBand()
208208

209209
void ElecState::init_scf(const int istep,
210210
const ModuleBase::ComplexMatrix& strucfac,
211+
const bool* numeric,
211212
ModuleSymmetry::Symmetry& symm,
212213
const void* wfcpw)
213214
{
214215
//! core correction potential.
215216
if (!PARAM.inp.use_paw)
216217
{
217-
this->charge->set_rho_core(strucfac);
218+
this->charge->set_rho_core(strucfac, numeric);
218219
}
219220
else
220221
{

source/module_elecstate/elecstate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class ElecState
110110
*/
111111
void init_scf(const int istep,
112112
const ModuleBase::ComplexMatrix& strucfac,
113+
const bool* numeric,
113114
ModuleSymmetry::Symmetry& symm,
114115
const void* wfcpw = nullptr);
115116
std::string classname = "elecstate";

source/module_elecstate/module_charge/charge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Charge
8484
const ModuleBase::ComplexMatrix& strucFac,
8585
const UnitCell& ucell) const;
8686

87-
void set_rho_core(const ModuleBase::ComplexMatrix &structure_factor);
87+
void set_rho_core(const ModuleBase::ComplexMatrix& structure_factor, const bool* numeric);
8888
void set_rho_core_paw();
8989

9090
void renormalize_rho();

source/module_elecstate/module_charge/charge_init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
200200
// computes the core charge on the real space 3D mesh.
201201
//==========================================================
202202
void Charge::set_rho_core(
203-
const ModuleBase::ComplexMatrix &structure_factor
203+
const ModuleBase::ComplexMatrix &structure_factor,
204+
const bool* numeric,
204205
)
205206
{
206207
ModuleBase::TITLE("Charge","set_rho_core");
@@ -249,7 +250,7 @@ void Charge::set_rho_core(
249250
// each shell of g vec
250251
//----------------------------------------------------------
251252
this->non_linear_core_correction(
252-
GlobalC::ppcell.numeric,
253+
numeric,
253254
GlobalC::ucell.atoms[it].ncpp.msh,
254255
GlobalC::ucell.atoms[it].ncpp.r.data(),
255256
GlobalC::ucell.atoms[it].ncpp.rab.data(),

source/module_elecstate/test/elecstate_base_test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void ModulePW::PW_Basis::initgrids(double, ModuleBase::Matrix3, int, int, int)
6666
void ModulePW::PW_Basis::distribute_r()
6767
{
6868
}
69-
void Charge::set_rho_core(ModuleBase::ComplexMatrix const&)
69+
void Charge::set_rho_core(ModuleBase::ComplexMatrix const&, const bool*)
7070
{
7171
}
7272
void Charge::set_rho_core_paw()
@@ -255,7 +255,7 @@ TEST_F(ElecStateTest, InitSCF)
255255
ModuleBase::ComplexMatrix strucfac;
256256
elecstate->eferm = efermi;
257257
ModuleSymmetry::Symmetry symm;
258-
EXPECT_NO_THROW(elecstate->init_scf(istep, strucfac, symm));
258+
EXPECT_NO_THROW(elecstate->init_scf(istep, strucfac, nullptr, symm));
259259
// delete elecstate->pot is done in the destructor of elecstate
260260
delete charge;
261261
}

source/module_elecstate/test/elecstate_pw_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ K_Vectors::~K_Vectors()
139139
{
140140
}
141141

142-
void Charge::set_rho_core(ModuleBase::ComplexMatrix const&)
142+
void Charge::set_rho_core(ModuleBase::ComplexMatrix const&, const bool*)
143143
{
144144
}
145145
void Charge::set_rho_core_paw()

source/module_esolver/esolver_fp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void ESolver_FP::before_scf(UnitCell& ucell, const int istep)
281281
this->pw_rhod->collect_uniqgg();
282282
}
283283

284-
GlobalC::ppcell.init_vloc(GlobalC::ppcell.vloc, pw_rhod);
284+
this->ppcell.init_vloc(pw_rhod);
285285
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
286286

287287
this->pelec->omega = ucell.omega;

source/module_esolver/esolver_ks.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ ESolver_KS<T, Device>::ESolver_KS()
6868
///----------------------------------------------------------
6969
p_chgmix = new Charge_Mixing();
7070
p_chgmix->set_rhopw(this->pw_rho, this->pw_rhod);
71+
this->ppcell.cell_factor = PARAM.inp.cell_factor;
7172
}
7273

7374
//------------------------------------------------------------------------------
@@ -81,6 +82,7 @@ ESolver_KS<T, Device>::~ESolver_KS()
8182
delete this->pw_wfc;
8283
delete this->p_hamilt;
8384
delete this->p_chgmix;
85+
this->ppcell.release_memory();
8486
}
8587

8688
//------------------------------------------------------------------------------

source/module_esolver/esolver_ks.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class ESolver_KS : public ESolver_FP
6565
//! Charge mixing method, only used in KDSFT, not in OFDFT
6666
Charge_Mixing* p_chgmix = nullptr;
6767

68+
//! nonlocal pseudo potential
69+
pseudopot_cell_vnl ppcell;
70+
6871
//! Electronic wavefunctions
6972
psi::Psi<T>* psi = nullptr;
7073

0 commit comments

Comments
 (0)