Skip to content

Commit cddace7

Browse files
committed
Refactor: split pseudopot_cell_vl and pseudopot_cell_vnl
1 parent a3a1993 commit cddace7

23 files changed

+62
-70
lines changed

source/module_esolver/cell_dependency.h

Lines changed: 0 additions & 20 deletions
This file was deleted.

source/module_esolver/esolver_fp.cpp

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

288-
this->p_locpp->init_vloc(ucell,this->pw_rhod);
288+
this->locpp.init_vloc(ucell, this->pw_rhod);
289289
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
290290

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

source/module_esolver/esolver_fp.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "module_elecstate/elecstate.h"
88
#include "module_elecstate/module_charge/charge_extra.h"
99
#include "module_hamilt_general/module_surchem/surchem.h"
10+
#include "module_hamilt_pw/hamilt_pwdft/VL_in_pw.h"
1011
#include "module_hamilt_pw/hamilt_pwdft/structure_factor.h"
1112

1213
#include <fstream>
@@ -40,8 +41,12 @@ namespace ModuleESolver
4041
//! Something to do after SCF iterations when SCF is converged or comes to the max iter step.
4142
virtual void after_scf(UnitCell& ucell, const int istep);
4243

43-
//! Electronic states
44-
elecstate::ElecState* pelec = nullptr;
44+
//! ------------------------------------------------------------------------------
45+
//! These pointers will be deleted in the free_pointers() function every ion step.
46+
//! ------------------------------------------------------------------------------
47+
elecstate::ElecState* pelec = nullptr; ///< Electronic states
48+
49+
//! ------------------------------------------------------------------------------
4550

4651
//! Electorn charge density
4752
Charge chr;
@@ -54,8 +59,8 @@ namespace ModuleESolver
5459

5560
ModulePW::PW_Basis* pw_rho;
5661

57-
//! pointer to pseudopotential
58-
pseudopot_cell_vl* p_locpp = nullptr;
62+
//! pointer to local pseudopotential
63+
pseudopot_cell_vl locpp;
5964

6065
/**
6166
* @brief same as pw_rho for ncpp. Here 'd' stands for 'dense'

source/module_esolver/esolver_ks.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ ESolver_KS<T, Device>::ESolver_KS()
6969
p_chgmix = new Charge_Mixing();
7070
p_chgmix->set_rhopw(this->pw_rho, this->pw_rhod);
7171
this->ppcell.cell_factor = PARAM.inp.cell_factor;
72-
this->p_locpp = &this->ppcell;
7372
}
7473

7574
//------------------------------------------------------------------------------

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
199199
}
200200

201201
// 8) initialize ppcell
202-
this->ppcell.init_vloc(ucell, this->pw_rho);
202+
this->locpp.init_vloc(ucell, this->pw_rho);
203203
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
204204

205205
// 9) inititlize the charge density
@@ -212,7 +212,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
212212
this->pelec->pot = new elecstate::Potential(this->pw_rhod,
213213
this->pw_rho,
214214
&ucell,
215-
&(this->ppcell.vloc),
215+
&(this->locpp.vloc),
216216
&(this->sf),
217217
&(this->solvent),
218218
&(this->pelec->f_en.etxc),
@@ -317,7 +317,7 @@ void ESolver_KS_LCAO<TK, TR>::cal_force(UnitCell& ucell, ModuleBase::matrix& for
317317
orb_,
318318
force,
319319
this->scs,
320-
this->ppcell,
320+
this->locpp,
321321
this->sf,
322322
this->kv,
323323
this->pw_rho,
@@ -465,7 +465,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
465465
this->solvent,
466466
*this->pw_rho,
467467
*this->pw_rhod,
468-
this->ppcell.vloc,
468+
this->locpp.vloc,
469469
*this->pelec->charge,
470470
this->GG,
471471
this->GK,
@@ -493,7 +493,7 @@ void ESolver_KS_LCAO<TK, TR>::after_all_runners(UnitCell& ucell)
493493
this->solvent,
494494
*this->pw_rho,
495495
*this->pw_rhod,
496-
this->ppcell.vloc,
496+
this->locpp.vloc,
497497
*this->pelec->charge,
498498
this->GG,
499499
this->GK,

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ namespace ModuleESolver
251251
*this->pw_wfc,
252252
*this->pw_rho,
253253
*this->pw_rhod,
254-
this->ppcell.vloc,
254+
this->locpp.vloc,
255255
*this->pelec->charge,
256256
this->kv,
257257
this->pelec->wg

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
179179
this->pelec->pot = new elecstate::Potential(this->pw_rhod,
180180
this->pw_rho,
181181
&ucell,
182-
&this->ppcell.vloc,
182+
&this->locpp.vloc,
183183
&(this->sf),
184184
&(this->solvent),
185185
&(this->pelec->f_en.etxc),
@@ -206,14 +206,12 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
206206
delete this->psi;
207207
}
208208

209-
//! init pseudopotential
210-
this->ppcell.init(ucell,&this->sf, this->pw_wfc);
211-
212209
//! initalize local pseudopotential
213-
this->ppcell.init_vloc(ucell,this->pw_rhod);
210+
this->locpp.init_vloc(ucell, this->pw_rhod);
214211
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
215212

216213
//! Initalize non-local pseudopotential
214+
this->ppcell.init(ucell, &this->sf, this->pw_wfc);
217215
this->ppcell.init_vnl(ucell, this->pw_rhod);
218216
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "NON-LOCAL POTENTIAL");
219217

@@ -308,7 +306,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
308306
elecstate::cal_ux(ucell);
309307

310308
//! calculate the total local pseudopotential in real space
311-
this->pelec->init_scf(istep, ucell,this->sf.strucFac, this->ppcell.numeric, ucell.symm, (void*)this->pw_wfc);
309+
this->pelec->init_scf(istep, ucell, this->sf.strucFac, this->locpp.numeric, ucell.symm, (void*)this->pw_wfc);
312310

313311
//! output the initial charge density
314312
if (PARAM.inp.out_chg[0] == 2)
@@ -780,7 +778,7 @@ void ESolver_KS_PW<T, Device>::cal_force(UnitCell& ucell, ModuleBase::matrix& fo
780778
&ucell.symm,
781779
&this->sf,
782780
this->solvent,
783-
&this->ppcell,
781+
&this->locpp,
784782
&this->ppcell,
785783
&this->kv,
786784
this->pw_wfc,
@@ -802,6 +800,7 @@ void ESolver_KS_PW<T, Device>::cal_stress(UnitCell& ucell, ModuleBase::matrix& s
802800
: reinterpret_cast<psi::Psi<std::complex<double>, Device>*>(this->kspw_psi);
803801
ss.cal_stress(stress,
804802
ucell,
803+
this->locpp,
805804
this->ppcell,
806805
this->pw_rhod,
807806
&ucell.symm,

source/module_esolver/esolver_of.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ ESolver_OF::ESolver_OF()
2323
{
2424
this->classname = "ESolver_OF";
2525
this->task_ = new char[60];
26-
this->p_locpp = &this->locpp;
2726
}
2827

2928
ESolver_OF::~ESolver_OF()

source/module_esolver/esolver_of.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class ESolver_OF : public ESolver_FP
3030
virtual void cal_force(UnitCell& ucell, ModuleBase::matrix& force) override;
3131

3232
virtual void cal_stress(UnitCell& ucell, ModuleBase::matrix& stress) override;
33-
protected:
34-
pseudopot_cell_vl locpp;
3533

3634
private:
3735
// ======================= variables ==========================

source/module_esolver/esolver_sdft_pw.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ void ESolver_SDFT_PW<T, Device>::cal_force(UnitCell& ucell, ModuleBase::matrix&
233233
&this->sf,
234234
&this->kv,
235235
this->pw_wfc,
236+
this->locpp,
236237
this->ppcell,
237238
ucell,
238239
*this->kspw_psi,
@@ -253,6 +254,7 @@ void ESolver_SDFT_PW<T, Device>::cal_stress(UnitCell& ucell, ModuleBase::matrix&
253254
*this->kspw_psi,
254255
this->stowf,
255256
this->pelec->charge,
257+
&this->locpp,
256258
&this->ppcell,
257259
ucell);
258260
}

0 commit comments

Comments
 (0)