Skip to content

Commit f31c301

Browse files
committed
remove wavefunc. init_wfc mem_saver out_wfc_pw out_wfc_r in abacus
1 parent a6d0ba1 commit f31c301

File tree

7 files changed

+54
-68
lines changed

7 files changed

+54
-68
lines changed

source/module_esolver/esolver_ks.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ ESolver_KS<T, Device>::ESolver_KS()
6767
///----------------------------------------------------------
6868
p_chgmix = new Charge_Mixing();
6969
p_chgmix->set_rhopw(this->pw_rho, this->pw_rhod);
70-
71-
///----------------------------------------------------------
72-
/// wavefunc
73-
///----------------------------------------------------------
74-
this->wf.init_wfc = PARAM.inp.init_wfc;
75-
this->wf.mem_saver = PARAM.inp.mem_saver;
76-
this->wf.out_wfc_pw = PARAM.inp.out_wfc_pw;
77-
this->wf.out_wfc_r = PARAM.inp.out_wfc_r;
7870
}
7971

8072
//------------------------------------------------------------------------------

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(const int istep, const int iter)
548548
// mohan move it outside 2011-01-13
549549
// first need to calculate the weight according to
550550
// electrons number.
551-
if (istep == 0 && this->wf.init_wfc == "file")
551+
if (istep == 0 && PARAM.inp.init_wfc == "file")
552552
{
553553
if (iter == 1)
554554
{

source/module_esolver/esolver_ks_lcao_tddft.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void ESolver_KS_LCAO_TDDFT::before_all_runners(const Input_para& inp, UnitCell&
7676

7777
void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int iter, const double ethr)
7878
{
79-
if (wf.init_wfc == "file")
79+
if (PARAM.inp.init_wfc == "file")
8080
{
8181
if (istep >= 1)
8282
{
@@ -256,7 +256,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
256256
const int nlocal = PARAM.globalv.nlocal;
257257

258258
// store wfc and Hk laststep
259-
if (istep >= (wf.init_wfc == "file" ? 0 : 1) && this->conv_esolver)
259+
if (istep >= (PARAM.inp.init_wfc == "file" ? 0 : 1) && this->conv_esolver)
260260
{
261261
if (this->psi_laststep == nullptr)
262262
{
@@ -311,7 +311,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter)
311311
}
312312

313313
// calculate energy density matrix for tddft
314-
if (istep >= (wf.init_wfc == "file" ? 0 : 2) && module_tddft::Evolve_elec::td_edm == 0)
314+
if (istep >= (PARAM.inp.init_wfc == "file" ? 0 : 2) && module_tddft::Evolve_elec::td_edm == 0)
315315
{
316316
elecstate::cal_edm_tddft(this->pv, this->pelec, this->kv, this->p_hamilt);
317317
}

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ void ESolver_KS_PW<T, Device>::iter_finish(const int istep, int& iter)
500500
}
501501

502502
// 4) Print out electronic wavefunctions
503-
if (this->wf.out_wfc_pw == 1 || this->wf.out_wfc_pw == 2)
503+
if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2)
504504
{
505505
std::stringstream ssw;
506506
ssw << PARAM.globalv.global_out_dir << "WAVEFUNC";
@@ -526,7 +526,7 @@ void ESolver_KS_PW<T, Device>::after_scf(const int istep)
526526
ESolver_KS<T, Device>::after_scf(istep);
527527

528528
// 3) output wavefunctions
529-
if (this->wf.out_wfc_pw == 1 || this->wf.out_wfc_pw == 2)
529+
if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2)
530530
{
531531
std::stringstream ssw;
532532
ssw << PARAM.globalv.global_out_dir << "WAVEFUNC";
@@ -774,7 +774,7 @@ void ESolver_KS_PW<T, Device>::after_all_runners()
774774
}
775775

776776
//! 6) Print out electronic wave functions in real space
777-
if (this->wf.out_wfc_r == 1) // Peize Lin add 2021.11.21
777+
if (PARAM.inp.out_wfc_r == 1) // Peize Lin add 2021.11.21
778778
{
779779
ModuleIO::write_psi_r_1(this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv);
780780
}

source/module_esolver/lcao_others.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void ESolver_KS_LCAO<TK, TR>::others(const int istep)
152152
this->pv,
153153
this->GG,
154154
PARAM.inp.out_wfc_pw,
155-
this->wf.out_wfc_r,
155+
PARAM.inp.out_wfc_r,
156156
this->kv,
157157
PARAM.inp.nelec,
158158
PARAM.inp.nbands_istate,
@@ -172,7 +172,7 @@ void ESolver_KS_LCAO<TK, TR>::others(const int istep)
172172
this->pv,
173173
this->GK,
174174
PARAM.inp.out_wfc_pw,
175-
this->wf.out_wfc_r,
175+
PARAM.inp.out_wfc_r,
176176
this->kv,
177177
PARAM.inp.nelec,
178178
PARAM.inp.nbands_istate,

source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ psi::Psi<std::complex<double>>* wavefunc::allocate(const int nkstot, const int n
5252
const int nks2 = nks;
5353

5454
psi::Psi<std::complex<double>>* psi_out = nullptr;
55-
if (PARAM.inp.calculation == "nscf" && this->mem_saver == 1)
55+
if (PARAM.inp.calculation == "nscf" && PARAM.inp.mem_saver == 1)
5656
{
5757
// initial psi rather than evc
5858
psi_out = new psi::Psi<std::complex<double>>(1, PARAM.inp.nbands, npwx * PARAM.globalv.npol, ngk);
@@ -129,11 +129,11 @@ void wavefunc::wfcinit(psi::Psi<std::complex<double>>* psi_in, ModulePW::PW_Basi
129129

130130
int wavefunc::get_starting_nw() const
131131
{
132-
if (init_wfc == "file")
132+
if (PARAM.inp.init_wfc == "file")
133133
{
134134
return PARAM.inp.nbands;
135135
}
136-
else if (init_wfc.substr(0, 6) == "atomic")
136+
else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
137137
{
138138
if (GlobalC::ucell.natomwfc >= PARAM.inp.nbands)
139139
{
@@ -153,7 +153,7 @@ int wavefunc::get_starting_nw() const
153153
}
154154
return std::max(GlobalC::ucell.natomwfc, PARAM.inp.nbands);
155155
}
156-
else if (init_wfc == "random")
156+
else if (PARAM.inp.init_wfc == "random")
157157
{
158158
if (PARAM.inp.test_wf)
159159
{
@@ -185,7 +185,7 @@ void diago_PAO_in_pw_k2(const int& ik,
185185
const int nbands = wvf.get_nbands();
186186
const int current_nbasis = wfc_basis->npwk[ik];
187187

188-
if (p_wf->init_wfc == "file")
188+
if (PARAM.inp.init_wfc == "file")
189189
{
190190
ModuleBase::ComplexMatrix wfcatom(nbands, nbasis);
191191
std::stringstream filename;
@@ -252,7 +252,7 @@ void diago_PAO_in_pw_k2(const int& ik,
252252
}
253253
*/
254254

255-
if (p_wf->init_wfc == "random" || (p_wf->init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0))
255+
if (PARAM.inp.init_wfc == "random" || (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0))
256256
{
257257
p_wf->random(wvf.get_pointer(), 0, nbands, ik, wfc_basis);
258258

@@ -269,7 +269,7 @@ void diago_PAO_in_pw_k2(const int& ik,
269269
}
270270
}
271271
}
272-
else if (p_wf->init_wfc.substr(0, 6) == "atomic")
272+
else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
273273
{
274274
ModuleBase::ComplexMatrix wfcatom(starting_nw, nbasis); // added by zhengdy-soc
275275
if (PARAM.inp.test_wf) {
@@ -285,7 +285,7 @@ void diago_PAO_in_pw_k2(const int& ik,
285285
PARAM.globalv.nqx,
286286
PARAM.globalv.dq);
287287

288-
if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
288+
if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
289289
{
290290
p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis);
291291
}
@@ -344,7 +344,7 @@ void diago_PAO_in_pw_k2(const int& ik,
344344
const int nbands = wvf.get_nbands();
345345
const int current_nbasis = wfc_basis->npwk[ik];
346346

347-
if (p_wf->init_wfc == "file")
347+
if (PARAM.inp.init_wfc == "file")
348348
{
349349
ModuleBase::ComplexMatrix wfcatom(nbands, nbasis);
350350
std::stringstream filename;
@@ -409,7 +409,7 @@ void diago_PAO_in_pw_k2(const int& ik,
409409
assert(starting_nw > 0);
410410
std::vector<double> etatom(starting_nw, 0.0);
411411

412-
if (p_wf->init_wfc == "random" || (p_wf->init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0))
412+
if (PARAM.inp.init_wfc == "random" || (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0))
413413
{
414414
p_wf->random(wvf.get_pointer(), 0, nbands, ik, wfc_basis);
415415
if (PARAM.inp.ks_solver == "cg") // xiaohui add 2013-09-02
@@ -425,7 +425,7 @@ void diago_PAO_in_pw_k2(const int& ik,
425425
}
426426
}
427427
}
428-
else if (p_wf->init_wfc.substr(0, 6) == "atomic")
428+
else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
429429
{
430430
ModuleBase::ComplexMatrix wfcatom(starting_nw, nbasis); // added by zhengdy-soc
431431
if (PARAM.inp.test_wf)
@@ -442,7 +442,7 @@ void diago_PAO_in_pw_k2(const int& ik,
442442
PARAM.globalv.nqx,
443443
PARAM.globalv.dq);
444444

445-
if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
445+
if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
446446
{
447447
p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis);
448448
}
@@ -523,7 +523,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
523523
int starting_nw = nbands;
524524

525525
ModuleBase::ComplexMatrix wfcatom(nbands, nbasis);
526-
if (p_wf->init_wfc == "file")
526+
if (PARAM.inp.init_wfc == "file")
527527
{
528528
std::stringstream filename;
529529
int ik_tot = K_Vectors::get_ik_global(ik, p_wf->nkstot);
@@ -539,7 +539,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
539539
if (PARAM.inp.test_wf)
540540
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "starting_nw", starting_nw);
541541

542-
if (p_wf->init_wfc.substr(0, 6) == "atomic")
542+
if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
543543
{
544544
p_wf->atomic_wfc(ik,
545545
current_nbasis,
@@ -549,7 +549,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
549549
GlobalC::ppcell.tab_at,
550550
PARAM.globalv.nqx,
551551
PARAM.globalv.dq);
552-
if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
552+
if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
553553
{
554554
p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis);
555555
}
@@ -560,7 +560,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
560560
//====================================================
561561
p_wf->random(wfcatom.c, GlobalC::ucell.natomwfc, nbands, ik, wfc_basis);
562562
}
563-
else if (p_wf->init_wfc == "random")
563+
else if (PARAM.inp.init_wfc == "random")
564564
{
565565
p_wf->random(wfcatom.c, 0, nbands, ik, wfc_basis);
566566
}
@@ -627,7 +627,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
627627
int starting_nw = nbands;
628628

629629
ModuleBase::ComplexMatrix wfcatom(nbands, nbasis);
630-
if (p_wf->init_wfc == "file")
630+
if (PARAM.inp.init_wfc == "file")
631631
{
632632
std::stringstream filename;
633633
int ik_tot = K_Vectors::get_ik_global(ik, p_wf->nkstot);
@@ -642,7 +642,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
642642
wfcatom.create(starting_nw, nbasis); // added by zhengdy-soc
643643
if (PARAM.inp.test_wf)
644644
ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "starting_nw", starting_nw);
645-
if (p_wf->init_wfc.substr(0, 6) == "atomic")
645+
if (PARAM.inp.init_wfc.substr(0, 6) == "atomic")
646646
{
647647
p_wf->atomic_wfc(ik,
648648
current_nbasis,
@@ -652,7 +652,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
652652
GlobalC::ppcell.tab_at,
653653
PARAM.globalv.nqx,
654654
PARAM.globalv.dq);
655-
if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
655+
if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16
656656
{
657657
p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis);
658658
}
@@ -663,7 +663,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx,
663663
//====================================================
664664
p_wf->random(wfcatom.c, GlobalC::ucell.natomwfc, nbands, ik, wfc_basis);
665665
}
666-
else if (p_wf->init_wfc == "random")
666+
else if (PARAM.inp.init_wfc == "random")
667667
{
668668
p_wf->random(wfcatom.c, 0, nbands, ik, wfc_basis);
669669
}

source/module_hamilt_pw/hamilt_pwdft/wavefunc.h

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,44 @@
1010

1111
class wavefunc : public WF_atomic
1212
{
13-
public:
14-
13+
public:
1514
wavefunc();
1615
~wavefunc();
1716

1817
// allocate memory
1918
psi::Psi<std::complex<double>>* allocate(const int nkstot, const int nks, const int* ngk, const int npwx);
2019

21-
int out_wfc_pw = 0; //qianrui modify 2020-10-19
22-
int out_wfc_r = 0; // Peize Lin add 2021.11.21
20+
int nkstot = 0; // total number of k-points for all pools
2321

24-
// init_wfc : "random",or "atomic" or "file"
25-
std::string init_wfc;
26-
int nkstot = 0; // total number of k-points for all pools
27-
int mem_saver = 0; // 1: save evc when doing nscf calculation.
2822
void wfcinit(psi::Psi<std::complex<double>>* psi_in, ModulePW::PW_Basis_K* wfc_basis);
29-
int get_starting_nw(void)const;
3023

31-
void init_after_vc(const int nks); //LiuXh 20180515
32-
};
24+
int get_starting_nw(void) const;
3325

26+
void init_after_vc(const int nks); // LiuXh 20180515
27+
};
3428

3529
namespace hamilt
3630
{
3731

38-
void diago_PAO_in_pw_k2(const int &ik,
39-
psi::Psi<std::complex<float>> &wvf,
40-
ModulePW::PW_Basis_K *wfc_basis,
41-
wavefunc *p_wf,
42-
hamilt::Hamilt<std::complex<float>> *phm_in = nullptr);
43-
void diago_PAO_in_pw_k2(const int &ik,
44-
psi::Psi<std::complex<double>> &wvf,
45-
ModulePW::PW_Basis_K *wfc_basis,
46-
wavefunc *p_wf,
47-
hamilt::Hamilt<std::complex<double>> *phm_in = nullptr);
48-
void diago_PAO_in_pw_k2(const int &ik, ModuleBase::ComplexMatrix &wvf, wavefunc *p_wf);
32+
void diago_PAO_in_pw_k2(const int& ik,
33+
psi::Psi<std::complex<float>>& wvf,
34+
ModulePW::PW_Basis_K* wfc_basis,
35+
wavefunc* p_wf,
36+
hamilt::Hamilt<std::complex<float>>* phm_in = nullptr);
37+
void diago_PAO_in_pw_k2(const int& ik,
38+
psi::Psi<std::complex<double>>& wvf,
39+
ModulePW::PW_Basis_K* wfc_basis,
40+
wavefunc* p_wf,
41+
hamilt::Hamilt<std::complex<double>>* phm_in = nullptr);
42+
void diago_PAO_in_pw_k2(const int& ik, ModuleBase::ComplexMatrix& wvf, wavefunc* p_wf);
4943

5044
template <typename FPTYPE, typename Device>
51-
void diago_PAO_in_pw_k2(const Device *ctx,
52-
const int &ik,
53-
psi::Psi<std::complex<FPTYPE>, Device> &wvf,
54-
ModulePW::PW_Basis_K *wfc_basis,
55-
wavefunc *p_wf,
56-
hamilt::Hamilt<std::complex<FPTYPE>, Device> *phm_in = nullptr);
57-
}
58-
59-
#endif //wavefunc
45+
void diago_PAO_in_pw_k2(const Device* ctx,
46+
const int& ik,
47+
psi::Psi<std::complex<FPTYPE>, Device>& wvf,
48+
ModulePW::PW_Basis_K* wfc_basis,
49+
wavefunc* p_wf,
50+
hamilt::Hamilt<std::complex<FPTYPE>, Device>* phm_in = nullptr);
51+
} // namespace hamilt
52+
53+
#endif // wavefunc

0 commit comments

Comments
 (0)