Skip to content

Commit 3b1fa6e

Browse files
Refactor:Remove GlobalC::ucell in module_pwdft (#5658)
* change ucell in pwdft/force.cpp * change ucell in kernels/*.h * change ucell in pwdft/stress_func_ewa.cpp * change ucell in pwdft/stress_func_gga.cpp * change ucell in pwdft/stress_func_har.cpp * change ucell in pwdft/stress_func_mgga.cpp * change ucell in pwdft/stress_func_loc.cpp * change ucell in pwdft/VL_in_pw.cpp * change ucell in pwdft/VL_grad_pw.cpp * change ucell in pwdft/VNL_in_pw.cpp * change ucell in sto_iter.cpp * fix bug in sto_iter.cpp * [pre-commit.ci lite] apply automatic fixes * change ucell in halmit_pw * change ucell in the test * [pre-commit.ci lite] apply automatic fixes * change postion of ucell * change postion of ucell in hsolver_pw_sdft --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent d11ac5e commit 3b1fa6e

Some content is hidden

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

55 files changed

+414
-331
lines changed

source/module_elecstate/elecstate_pw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void ElecStatePW<T, Device>::add_usrho(const psi::Psi<T, Device>& psi)
263263
// get |beta>
264264
if (this->ppcell->nkb > 0)
265265
{
266-
this->ppcell->getvnl(this->ctx, ik, this->vkb);
266+
this->ppcell->getvnl(this->ctx, *ucell,ik, this->vkb);
267267
}
268268

269269
// becp = <beta|psi>

source/module_elecstate/test/elecstate_pw_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,14 @@ std::complex<double>* pseudopot_cell_vnl::get_vkb_data<double>() const
115115
}
116116
template <>
117117
void pseudopot_cell_vnl::getvnl<float, base_device::DEVICE_CPU>(base_device::DEVICE_CPU*,
118+
const UnitCell&,
118119
int const&,
119120
std::complex<float>*) const
120121
{
121122
}
122123
template <>
123124
void pseudopot_cell_vnl::getvnl<double, base_device::DEVICE_CPU>(base_device::DEVICE_CPU*,
125+
const UnitCell&,
124126
int const&,
125127
std::complex<double>*) const
126128
{

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

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

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(UnitCell& ucell, const Input_pa
197197
}
198198

199199
// 8) initialize ppcell
200-
this->ppcell.init_vloc(this->pw_rho);
200+
this->ppcell.init_vloc(ucell,this->pw_rho);
201201
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
202202

203203
// 9) inititlize the charge density

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ namespace ModuleESolver
6262
}
6363

6464
template <typename T>
65-
void ESolver_KS_LIP<T>::allocate_hamilt()
65+
void ESolver_KS_LIP<T>::allocate_hamilt(const UnitCell& ucell)
6666
{
67-
this->p_hamilt = new hamilt::HamiltLIP<T>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell
67+
this->p_hamilt = new hamilt::HamiltLIP<T>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell, &ucell
6868
#ifdef __EXX
6969
, *this->exx_lip
7070
#endif

source/module_esolver/esolver_ks_lcaopw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace ModuleESolver
3333
const int iter,
3434
const double ethr) override;
3535

36-
virtual void allocate_hamilt() override;
36+
virtual void allocate_hamilt(const UnitCell& ucell) override;
3737
virtual void deallocate_hamilt() override;
3838

3939
#ifdef __EXX

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ ESolver_KS_PW<T, Device>::~ESolver_KS_PW()
115115
}
116116

117117
template <typename T, typename Device>
118-
void ESolver_KS_PW<T, Device>::allocate_hamilt()
118+
void ESolver_KS_PW<T, Device>::allocate_hamilt(const UnitCell& ucell)
119119
{
120-
this->p_hamilt = new hamilt::HamiltPW<T, Device>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell);
120+
this->p_hamilt = new hamilt::HamiltPW<T, Device>(this->pelec->pot, this->pw_wfc, &this->kv, &this->ppcell, &ucell);
121121
}
122122
template <typename T, typename Device>
123123
void ESolver_KS_PW<T, Device>::deallocate_hamilt()
@@ -202,10 +202,10 @@ void ESolver_KS_PW<T, Device>::before_all_runners(UnitCell& ucell, const Input_p
202202
}
203203

204204
//! init pseudopotential
205-
this->ppcell.init(ucell.ntype, &this->sf, this->pw_wfc);
205+
this->ppcell.init(ucell,&this->sf, this->pw_wfc);
206206

207207
//! initalize local pseudopotential
208-
this->ppcell.init_vloc(this->pw_rhod);
208+
this->ppcell.init_vloc(ucell,this->pw_rhod);
209209
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
210210

211211
//! Initalize non-local pseudopotential
@@ -279,7 +279,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
279279
this->deallocate_hamilt();
280280

281281
// allocate HamiltPW
282-
this->allocate_hamilt();
282+
this->allocate_hamilt(ucell);
283283

284284
//----------------------------------------------------------
285285
// about vdw, jiyy add vdwd3 and linpz add vdwd2
@@ -621,7 +621,8 @@ void ESolver_KS_PW<T, Device>::cal_force(UnitCell& ucell, ModuleBase::matrix& fo
621621
: reinterpret_cast<psi::Psi<std::complex<double>, Device>*>(this->kspw_psi);
622622

623623
// Calculate forces
624-
ff.cal_force(force,
624+
ff.cal_force(ucell,
625+
force,
625626
*this->pelec,
626627
this->pw_rhod,
627628
&ucell.symm,

source/module_esolver/esolver_ks_pw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>
4646

4747
virtual void hamilt2density_single(UnitCell& ucell, const int istep, const int iter, const double ethr) override;
4848

49-
virtual void allocate_hamilt();
49+
virtual void allocate_hamilt(const UnitCell& ucell);
5050
virtual void deallocate_hamilt();
5151

5252
//! hide the psi in ESolver_KS for tmp use

source/module_esolver/esolver_of.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void ESolver_OF::before_all_runners(UnitCell& ucell, const Input_para& inp)
112112
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT BASIS");
113113

114114
// initialize local pseudopotential
115-
this->locpp.init_vloc(pw_rho);
115+
this->locpp.init_vloc(ucell,pw_rho);
116116
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "LOCAL POTENTIAL");
117117

118118

@@ -538,7 +538,7 @@ double ESolver_OF::cal_energy()
538538
void ESolver_OF::cal_force(UnitCell& ucell, ModuleBase::matrix& force)
539539
{
540540
Forces<double> ff(ucell.nat);
541-
ff.cal_force(force, *pelec, this->pw_rho, &ucell.symm, &sf, &this->locpp);
541+
ff.cal_force(ucell,force, *pelec, this->pw_rho, &ucell.symm, &sf, &this->locpp);
542542
}
543543

544544
/**

source/module_esolver/esolver_sdft_pw.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void ESolver_SDFT_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
100100
this->pw_wfc,
101101
&this->kv,
102102
&this->ppcell,
103+
&ucell,
103104
PARAM.globalv.npol,
104105
&this->stoche.emin_sto,
105106
&this->stoche.emax_sto);
@@ -166,7 +167,8 @@ void ESolver_SDFT_PW<T, Device>::hamilt2density_single(UnitCell& ucell, int iste
166167
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR,
167168
hsolver::DiagoIterAssist<T, Device>::need_subspace);
168169

169-
hsolver_pw_sdft_obj.solve(this->p_hamilt,
170+
hsolver_pw_sdft_obj.solve(ucell,
171+
this->p_hamilt,
170172
this->kspw_psi[0],
171173
this->psi[0],
172174
this->pelec,

0 commit comments

Comments
 (0)