Skip to content

Commit 7f0807d

Browse files
committed
change ucell in module_psi/wavefunc.cpp
1 parent 8b54a0d commit 7f0807d

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ void ESolver_KS_PW<T, Device>::before_scf(UnitCell& ucell, const int istep)
373373
this->kspw_psi,
374374
this->p_hamilt,
375375
this->ppcell,
376+
ucell,
376377
GlobalV::ofs_running,
377378
this->already_initpsi);
378379

source/module_psi/psi_init.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ void PSIInit<T, Device>::initialize_psi(Psi<std::complex<double>>* psi,
152152
psi::Psi<T, Device>* kspw_psi,
153153
hamilt::Hamilt<T, Device>* p_hamilt,
154154
const pseudopot_cell_vnl& nlpp,
155+
const UnitCell& ucell,
155156
std::ofstream& ofs_running,
156157
const bool is_already_initpsi)
157158
{
@@ -278,6 +279,8 @@ void PSIInit<T, Device>::initialize_psi(Psi<std::complex<double>>* psi,
278279
&this->wf_old,
279280
nlpp.tab_at,
280281
nlpp.lmaxkb,
282+
ucell.natomwfc,
283+
ucell.lmax_ppwf,
281284
p_hamilt);
282285
}
283286
}
@@ -294,6 +297,8 @@ void PSIInit<T, Device>::initialize_psi(Psi<std::complex<double>>* psi,
294297
&this->wf_old,
295298
nlpp.tab_at,
296299
nlpp.lmaxkb,
300+
ucell.natomwfc,
301+
ucell.lmax_ppwf,
297302
p_hamilt);
298303
}
299304
}

source/module_psi/psi_init.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class PSIInit
5454
psi::Psi<T, Device>* kspw_psi,
5555
hamilt::Hamilt<T, Device>* p_hamilt,
5656
const pseudopot_cell_vnl& nlpp,
57+
const UnitCell& ucell,
5758
std::ofstream& ofs_running,
5859
const bool is_already_initpsi);
5960

source/module_psi/wavefunc.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,15 @@ void wavefunc::wfcinit(psi::Psi<std::complex<double>>* psi_in, ModulePW::PW_Basi
140140
return;
141141
}
142142

143-
int wavefunc::get_starting_nw() const
143+
int wavefunc::get_starting_nw(const int natomwfc) const
144144
{
145145
if (PARAM.inp.init_wfc == "file")
146146
{
147147
return PARAM.inp.nbands;
148148
}
149149
else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
150150
{
151-
if (GlobalC::ucell.natomwfc >= PARAM.inp.nbands)
151+
if (natomwfc >= PARAM.inp.nbands)
152152
{
153153
if (PARAM.inp.test_wf)
154154
{
@@ -160,11 +160,11 @@ int wavefunc::get_starting_nw() const
160160
if (PARAM.inp.test_wf)
161161
{
162162
GlobalV::ofs_running << " Start wave functions are atomic + "
163-
<< PARAM.inp.nbands - GlobalC::ucell.natomwfc << " random wave functions."
163+
<< PARAM.inp.nbands - natomwfc << " random wave functions."
164164
<< std::endl;
165165
}
166166
}
167-
return std::max(GlobalC::ucell.natomwfc, PARAM.inp.nbands);
167+
return std::max(natomwfc, PARAM.inp.nbands);
168168
}
169169
else if (PARAM.inp.init_wfc == "random")
170170
{
@@ -194,6 +194,8 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
194194
wavefunc* p_wf,
195195
const ModuleBase::realArray& tab_at,
196196
const int& lmaxkb,
197+
const int natomwfc,
198+
const int lmax_ppwf,
197199
hamilt::Hamilt<std::complex<float>, base_device::DEVICE_CPU>* phm_in)
198200
{
199201
// TODO float func
@@ -207,6 +209,8 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
207209
wavefunc* p_wf,
208210
const ModuleBase::realArray& tab_at,
209211
const int& lmaxkb,
212+
const int natomwfc,
213+
const int lmax_ppwf,
210214
hamilt::Hamilt<std::complex<double>, base_device::DEVICE_CPU>* phm_in)
211215
{
212216
ModuleBase::TITLE("wavefunc", "diago_PAO_in_pw_k2");
@@ -252,7 +256,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
252256
}
253257
}
254258
else if (PARAM.inp.init_wfc == "random"
255-
|| (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0))
259+
|| (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && natomwfc == 0))
256260
{
257261
p_wf->random(wvf.get_pointer(), 0, nbands, ik, wfc_basis);
258262

@@ -273,7 +277,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
273277
}
274278
else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
275279
{
276-
const int starting_nw = p_wf->get_starting_nw();
280+
const int starting_nw = p_wf->get_starting_nw(natomwfc);
277281
if (starting_nw == 0)
278282
{
279283
return;
@@ -289,7 +293,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
289293

290294
p_wf->atomic_wfc(ik,
291295
current_nbasis,
292-
GlobalC::ucell.lmax_ppwf,
296+
lmax_ppwf,
293297
lmaxkb,
294298
wfc_basis,
295299
wfcatom,
@@ -298,7 +302,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
298302
PARAM.globalv.dq);
299303

300304
if (PARAM.inp.init_wfc == "atomic+random"
301-
&& starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
305+
&& starting_nw == natomwfc) // added by qianrui 2021-5-16
302306
{
303307
p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis);
304308
}
@@ -307,7 +311,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_CPU* ctx,
307311
// If not enough atomic wfc are available, complete
308312
// with random wfcs
309313
//====================================================
310-
p_wf->random(wfcatom.c, GlobalC::ucell.natomwfc, nbands, ik, wfc_basis);
314+
p_wf->random(wfcatom.c, natomwfc, nbands, ik, wfc_basis);
311315

312316
// (7) Diago with cg method.
313317
// if(GlobalV::DIAGO_TYPE == "cg") xiaohui modify 2013-09-02
@@ -351,6 +355,8 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
351355
wavefunc* p_wf,
352356
const ModuleBase::realArray& tab_at,
353357
const int& lmaxkb,
358+
const int natomwfc,
359+
const int lmax_ppwf,
354360
hamilt::Hamilt<std::complex<float>, base_device::DEVICE_GPU>* phm_in)
355361
{
356362
// TODO float
@@ -364,6 +370,8 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
364370
wavefunc* p_wf,
365371
const ModuleBase::realArray& tab_at,
366372
const int& lmaxkb,
373+
const int natomwfc,
374+
const int lmax_ppwf,
367375
hamilt::Hamilt<std::complex<double>, base_device::DEVICE_GPU>* phm_in)
368376
{
369377
ModuleBase::TITLE("wavefunc", "diago_PAO_in_pw_k2");
@@ -393,15 +401,15 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
393401
{
394402
p_wf->atomic_wfc(ik,
395403
current_nbasis,
396-
GlobalC::ucell.lmax_ppwf,
404+
lmax_ppwf,
397405
lmaxkb,
398406
wfc_basis,
399407
wfcatom,
400408
tab_at,
401409
PARAM.globalv.nqx,
402410
PARAM.globalv.dq);
403411
if (PARAM.inp.init_wfc == "atomic+random"
404-
&& starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
412+
&& starting_nw == natomwfc) // added by qianrui 2021-5-16
405413
{
406414
p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis);
407415
}
@@ -410,7 +418,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
410418
// If not enough atomic wfc are available, complete
411419
// with random wfcs
412420
//====================================================
413-
p_wf->random(wfcatom.c, GlobalC::ucell.natomwfc, nbands, ik, wfc_basis);
421+
p_wf->random(wfcatom.c, natomwfc, nbands, ik, wfc_basis);
414422
}
415423
else if (PARAM.inp.init_wfc == "random")
416424
{

source/module_psi/wavefunc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class wavefunc : public WF_atomic
2121

2222
void wfcinit(psi::Psi<std::complex<double>>* psi_in, ModulePW::PW_Basis_K* wfc_basis);
2323

24-
int get_starting_nw(void) const;
24+
int get_starting_nw(const int natomwfc) const;
2525

2626
void init_after_vc(const int nks); // LiuXh 20180515
2727
};
@@ -57,6 +57,8 @@ void diago_PAO_in_pw_k2(const Device* ctx,
5757
wavefunc* p_wf,
5858
const ModuleBase::realArray& tab_at,
5959
const int& lmaxkb,
60+
const int natomwfc,
61+
const int lmax_ppwf,
6062
hamilt::Hamilt<std::complex<FPTYPE>, Device>* phm_in = nullptr);
6163
} // namespace hamilt
6264

0 commit comments

Comments
 (0)