Skip to content

Commit 51ba921

Browse files
committed
change ucell in the hsolver_pw
1 parent 5f1b128 commit 51ba921

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

source/module_esolver/esolver_ks_lcaopw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ namespace ModuleESolver
147147
}
148148

149149
hsolver::HSolverLIP<T> hsolver_lip_obj(this->pw_wfc);
150-
hsolver_lip_obj.solve(this->p_hamilt, this->kspw_psi[0], this->pelec, psig.lock().get()[0], skip_charge);
150+
hsolver_lip_obj.solve(this->p_hamilt, this->kspw_psi[0], this->pelec, ucell, psig.lock().get()[0], skip_charge);
151151

152152
// add exx
153153
#ifdef __EXX

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ void ESolver_KS_PW<T, Device>::hamilt2density_single(UnitCell& ucell,
444444
hsolver_pw_obj.solve(this->p_hamilt,
445445
this->kspw_psi[0],
446446
this->pelec,
447+
ucell,
447448
this->pelec->ekb.c,
448449
GlobalV::RANK_IN_POOL,
449450
GlobalV::NPROC_IN_POOL,

source/module_hsolver/hsolver_lcaopw.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace hsolver
2424

2525
#ifdef USE_PAW
2626
template <typename T>
27-
void HSolverLIP<T>::paw_func_in_kloop(const int ik)
27+
void HSolverLIP<T>::paw_func_in_kloop(const UnitCell& ucell, const int ik)
2828
{
2929
if (PARAM.inp.use_paw)
3030
{
@@ -83,7 +83,7 @@ void HSolverLIP<T>::paw_func_in_kloop(const int ik)
8383
}
8484

8585
template <typename T>
86-
void HSolverLIP<T>::paw_func_after_kloop(psi::Psi<T>& psi, elecstate::ElecState* pes)
86+
void HSolverLIP<T>::paw_func_after_kloop(const UnitCell& ucell, psi::Psi<T>& psi, elecstate::ElecState* pes)
8787
{
8888
if (PARAM.inp.use_paw)
8989
{
@@ -200,6 +200,7 @@ template <typename T>
200200
void HSolverLIP<T>::solve(hamilt::Hamilt<T>* pHamilt, // ESolver_KS_PW::p_hamilt
201201
psi::Psi<T>& psi, // ESolver_KS_PW::kspw_psi
202202
elecstate::ElecState* pes, // ESolver_KS_PW::pes
203+
const UnitCell& ucell,
203204
psi::Psi<T>& transform,
204205
const bool skip_charge)
205206
{
@@ -212,7 +213,7 @@ void HSolverLIP<T>::solve(hamilt::Hamilt<T>* pHamilt, // ESolver_KS_PW::p_hamilt
212213
pHamilt->updateHk(ik);
213214

214215
#ifdef USE_PAW
215-
this->paw_func_in_kloop(ik);
216+
this->paw_func_in_kloop(ucell,ik);
216217
#endif
217218

218219
psi.fix_k(ik);
@@ -282,7 +283,7 @@ void HSolverLIP<T>::solve(hamilt::Hamilt<T>* pHamilt, // ESolver_KS_PW::p_hamilt
282283
reinterpret_cast<elecstate::ElecStatePW<T>*>(pes)->psiToRho(psi);
283284

284285
#ifdef USE_PAW
285-
this->paw_func_after_kloop(psi, pes);
286+
this->paw_func_after_kloop(ucell,psi, pes);
286287
#endif
287288

288289
ModuleBase::timer::tick("HSolverLIP", "solve");

source/module_hsolver/hsolver_lcaopw.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,17 @@ class HSolverLIP
3030
void solve(hamilt::Hamilt<T>* pHamilt,
3131
psi::Psi<T>& psi,
3232
elecstate::ElecState* pes,
33+
const UnitCell& ucell,
3334
psi::Psi<T>& transform,
3435
const bool skip_charge);
3536

3637
private:
3738
ModulePW::PW_Basis_K* wfc_basis;
3839

3940
#ifdef USE_PAW
40-
void paw_func_in_kloop(const int ik);
41+
void paw_func_in_kloop(const UnitCell& ucell,const int ik);
4142

42-
void paw_func_after_kloop(psi::Psi<T>& psi, elecstate::ElecState* pes);
43+
void paw_func_after_kloop(const UnitCell& ucell, psi::Psi<T>& psi, elecstate::ElecState* pes);
4344
#endif
4445
};
4546

source/module_hsolver/hsolver_pw.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ namespace hsolver
2828

2929
#ifdef USE_PAW
3030
template <typename T, typename Device>
31-
void HSolverPW<T, Device>::paw_func_in_kloop(const int ik)
31+
void HSolverPW<T, Device>::paw_func_in_kloop(const UnitCell& ucell,
32+
const int ik)
3233
{
3334
if (this->use_paw)
3435
{
@@ -68,7 +69,7 @@ void HSolverPW<T, Device>::paw_func_in_kloop(const int ik)
6869
this->wfc_basis->get_ig2iy(ik).data(),
6970
this->wfc_basis->get_ig2iz(ik).data(),
7071
(const double**)kpg,
71-
GlobalC::ucell.tpiba,
72+
ucell.tpiba,
7273
(const double**)gcar);
7374

7475
std::vector<double>().swap(kpt);
@@ -96,7 +97,7 @@ void HSolverPW<T, Device>::call_paw_cell_set_currentk(const int ik)
9697
}
9798

9899
template <typename T, typename Device>
99-
void HSolverPW<T, Device>::paw_func_after_kloop(psi::Psi<T, Device>& psi, elecstate::ElecState* pes)
100+
void HSolverPW<T, Device>::paw_func_after_kloop(const UnitCell& ucell, psi::Psi<T, Device>& psi, elecstate::ElecState* pes)
100101
{
101102
if (this->use_paw)
102103
{
@@ -144,7 +145,7 @@ void HSolverPW<T, Device>::paw_func_after_kloop(psi::Psi<T, Device>& psi, elecst
144145
this->wfc_basis->get_ig2iy(ik).data(),
145146
this->wfc_basis->get_ig2iz(ik).data(),
146147
(const double**)kpg,
147-
GlobalC::ucell.tpiba,
148+
ucell.tpiba,
148149
(const double**)gcar);
149150

150151
std::vector<double>().swap(kpt);
@@ -177,7 +178,7 @@ void HSolverPW<T, Device>::paw_func_after_kloop(psi::Psi<T, Device>& psi, elecst
177178
{
178179
GlobalC::paw_cell.get_rhoijp(rhoijp, rhoijselect, nrhoijsel);
179180

180-
for (int iat = 0; iat < GlobalC::ucell.nat; iat++)
181+
for (int iat = 0; iat < ucell.nat; iat++)
181182
{
182183
GlobalC::paw_cell.set_rhoij(iat,
183184
nrhoijsel[iat],
@@ -189,7 +190,7 @@ void HSolverPW<T, Device>::paw_func_after_kloop(psi::Psi<T, Device>& psi, elecst
189190
#else
190191
GlobalC::paw_cell.get_rhoijp(rhoijp, rhoijselect, nrhoijsel);
191192

192-
for (int iat = 0; iat < GlobalC::ucell.nat; iat++)
193+
for (int iat = 0; iat < ucell.nat; iat++)
193194
{
194195
GlobalC::paw_cell.set_rhoij(iat,
195196
nrhoijsel[iat],
@@ -252,6 +253,7 @@ template <typename T, typename Device>
252253
void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
253254
psi::Psi<T, Device>& psi,
254255
elecstate::ElecState* pes,
256+
const UnitCell& ucell,
255257
double* out_eigenvalues,
256258
const int rank_in_pool_in,
257259
const int nproc_in_pool_in,
@@ -282,7 +284,7 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
282284
pHamilt->updateHk(ik);
283285

284286
#ifdef USE_PAW
285-
this->paw_func_in_kloop(ik);
287+
this->paw_func_in_kloop(ucell,ik);
286288
#endif
287289

288290
/// update psi pointer for each k point
@@ -341,7 +343,7 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
341343
reinterpret_cast<elecstate::ElecStatePW<T, Device>*>(pes)->psiToRho(psi);
342344

343345
#ifdef USE_PAW
344-
this->paw_func_after_kloop(psi, pes);
346+
this->paw_func_after_kloop(ucell,psi, pes);
345347
#endif
346348

347349
ModuleBase::timer::tick("HSolverPW", "solve");

source/module_hsolver/hsolver_pw.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ class HSolverPW
3939
/// @param pHamilt interface to hamilt
4040
/// @param psi reference to psi
4141
/// @param pes interface to elecstate
42+
/// @param ucell reference to unitcell
4243
/// @param method_in dav or cg
4344
/// @param skip_charge
4445
void solve(hamilt::Hamilt<T, Device>* pHamilt,
4546
psi::Psi<T, Device>& psi,
4647
elecstate::ElecState* pes,
48+
const UnitCell& ucell,
4749
double* out_eigenvalues,
4850
const int rank_in_pool_in,
4951
const int nproc_in_pool_in,
@@ -89,11 +91,11 @@ class HSolverPW
8991
std::vector<double> ethr_band;
9092

9193
#ifdef USE_PAW
92-
void paw_func_in_kloop(const int ik);
94+
void paw_func_in_kloop(const UnitCell& ucell, const int ik);
9395

9496
void call_paw_cell_set_currentk(const int ik);
9597

96-
void paw_func_after_kloop(psi::Psi<T, Device>& psi, elecstate::ElecState* pes);
98+
void paw_func_after_kloop(const UnitCell& ucell, psi::Psi<T, Device>& psi, elecstate::ElecState* pes);
9799
#endif
98100
};
99101

0 commit comments

Comments
 (0)