Skip to content

Commit f8661fb

Browse files
Qianruipkupre-commit-ci-lite[bot]
authored andcommitted
Refactor : Remove GlobalC::ppcell (deepmodeling#5622)
* Refactor: remove GlobaC::ppcell * [pre-commit.ci lite] apply automatic fixes * fix compile * fix compile * fix bug * fix compile after merge --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 6cb5965 commit f8661fb

Some content is hidden

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

71 files changed

+325
-200
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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,7 @@ void Charge::init_rho(elecstate::efermi& eferm_iout,
199199
//==========================================================
200200
// computes the core charge on the real space 3D mesh.
201201
//==========================================================
202-
void Charge::set_rho_core(
203-
const ModuleBase::ComplexMatrix &structure_factor
204-
)
202+
void Charge::set_rho_core(const ModuleBase::ComplexMatrix& structure_factor, const bool* numeric)
205203
{
206204
ModuleBase::TITLE("Charge","set_rho_core");
207205
ModuleBase::timer::tick("Charge","set_rho_core");
@@ -249,7 +247,7 @@ void Charge::set_rho_core(
249247
// each shell of g vec
250248
//----------------------------------------------------------
251249
this->non_linear_core_correction(
252-
GlobalC::ppcell.numeric,
250+
numeric,
253251
GlobalC::ucell.atoms[it].ncpp.msh,
254252
GlobalC::ucell.atoms[it].ncpp.r.data(),
255253
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
@@ -60,7 +60,7 @@ void ModulePW::PW_Basis::initgrids(double, ModuleBase::Matrix3, int, int, int)
6060
void ModulePW::PW_Basis::distribute_r()
6161
{
6262
}
63-
void Charge::set_rho_core(ModuleBase::ComplexMatrix const&)
63+
void Charge::set_rho_core(ModuleBase::ComplexMatrix const&, const bool*)
6464
{
6565
}
6666
void Charge::set_rho_core_paw()
@@ -249,7 +249,7 @@ TEST_F(ElecStateTest, InitSCF)
249249
ModuleBase::ComplexMatrix strucfac;
250250
elecstate->eferm = efermi;
251251
ModuleSymmetry::Symmetry symm;
252-
EXPECT_NO_THROW(elecstate->init_scf(istep, strucfac, symm));
252+
EXPECT_NO_THROW(elecstate->init_scf(istep, strucfac, nullptr, symm));
253253
// delete elecstate->pot is done in the destructor of elecstate
254254
delete charge;
255255
}

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->p_locpp->init_vloc(this->pw_rhod);
285285
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
286286

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

source/module_esolver/esolver_fp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ namespace ModuleESolver
5353

5454
ModulePW::PW_Basis* pw_rho;
5555

56+
//! pointer to pseudopotential
57+
pseudopot_cell_vl* p_locpp = nullptr;
58+
5659
/**
5760
* @brief same as pw_rho for ncpp. Here 'd' stands for 'dense'
5861
* dense grid for for uspp, used for ultrasoft augmented charge density.

source/module_esolver/esolver_ks.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ 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;
72+
this->p_locpp = &this->ppcell;
7173
}
7274

7375
//------------------------------------------------------------------------------
@@ -81,6 +83,7 @@ ESolver_KS<T, Device>::~ESolver_KS()
8183
delete this->pw_wfc;
8284
delete this->p_hamilt;
8385
delete this->p_chgmix;
86+
this->ppcell.release_memory();
8487
}
8588

8689
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)