From e0202e036154d4df77b86ad7c53015015f2655a7 Mon Sep 17 00:00:00 2001 From: Haozhi Han Date: Fri, 22 Nov 2024 11:57:40 +0800 Subject: [PATCH] Refactor: remove `init_wfc`&`mem_saver`&`out_wfc_pw`&`out_wfc_r` of wavefunc in abacus (#5557) * remove wavefunc. init_wfc mem_saver out_wfc_pw out_wfc_r in abacus * replace WFInit by PSIInit --- source/module_esolver/esolver_ks.cpp | 8 --- source/module_esolver/esolver_ks_lcao.cpp | 2 +- .../module_esolver/esolver_ks_lcao_tddft.cpp | 6 +- source/module_esolver/esolver_ks_pw.cpp | 18 ++--- source/module_esolver/esolver_ks_pw.h | 2 +- source/module_esolver/esolver_sdft_pw.cpp | 4 +- source/module_esolver/lcao_others.cpp | 4 +- .../hamilt_pwdft/wavefunc.cpp | 40 +++++------ .../module_hamilt_pw/hamilt_pwdft/wavefunc.h | 56 +++++++-------- .../module_hamilt_pw/hamilt_pwdft/wfinit.cpp | 72 +++++++++---------- source/module_hamilt_pw/hamilt_pwdft/wfinit.h | 16 ++--- source/module_ri/exx_lip.h | 28 ++++---- source/module_ri/exx_lip.hpp | 24 +++---- 13 files changed, 135 insertions(+), 145 deletions(-) diff --git a/source/module_esolver/esolver_ks.cpp b/source/module_esolver/esolver_ks.cpp index 254ffb513b..7981a5f433 100644 --- a/source/module_esolver/esolver_ks.cpp +++ b/source/module_esolver/esolver_ks.cpp @@ -67,14 +67,6 @@ ESolver_KS::ESolver_KS() ///---------------------------------------------------------- p_chgmix = new Charge_Mixing(); p_chgmix->set_rhopw(this->pw_rho, this->pw_rhod); - - ///---------------------------------------------------------- - /// wavefunc - ///---------------------------------------------------------- - this->wf.init_wfc = PARAM.inp.init_wfc; - this->wf.mem_saver = PARAM.inp.mem_saver; - this->wf.out_wfc_pw = PARAM.inp.out_wfc_pw; - this->wf.out_wfc_r = PARAM.inp.out_wfc_r; } //------------------------------------------------------------------------------ diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index 371218361d..e9901bedc6 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -548,7 +548,7 @@ void ESolver_KS_LCAO::iter_init(const int istep, const int iter) // mohan move it outside 2011-01-13 // first need to calculate the weight according to // electrons number. - if (istep == 0 && this->wf.init_wfc == "file") + if (istep == 0 && PARAM.inp.init_wfc == "file") { if (iter == 1) { diff --git a/source/module_esolver/esolver_ks_lcao_tddft.cpp b/source/module_esolver/esolver_ks_lcao_tddft.cpp index 942d4b6a15..731016e603 100644 --- a/source/module_esolver/esolver_ks_lcao_tddft.cpp +++ b/source/module_esolver/esolver_ks_lcao_tddft.cpp @@ -76,7 +76,7 @@ void ESolver_KS_LCAO_TDDFT::before_all_runners(const Input_para& inp, UnitCell& void ESolver_KS_LCAO_TDDFT::hamilt2density_single(const int istep, const int iter, const double ethr) { - if (wf.init_wfc == "file") + if (PARAM.inp.init_wfc == "file") { if (istep >= 1) { @@ -256,7 +256,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) const int nlocal = PARAM.globalv.nlocal; // store wfc and Hk laststep - if (istep >= (wf.init_wfc == "file" ? 0 : 1) && this->conv_esolver) + if (istep >= (PARAM.inp.init_wfc == "file" ? 0 : 1) && this->conv_esolver) { if (this->psi_laststep == nullptr) { @@ -311,7 +311,7 @@ void ESolver_KS_LCAO_TDDFT::update_pot(const int istep, const int iter) } // calculate energy density matrix for tddft - if (istep >= (wf.init_wfc == "file" ? 0 : 2) && module_tddft::Evolve_elec::td_edm == 0) + if (istep >= (PARAM.inp.init_wfc == "file" ? 0 : 2) && module_tddft::Evolve_elec::td_edm == 0) { elecstate::cal_edm_tddft(this->pv, this->pelec, this->kv, this->p_hamilt); } diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 346b487dd9..4edd7ed3c7 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -181,12 +181,12 @@ void ESolver_KS_PW::before_all_runners(const Input_para& inp, UnitCel } //! 7) prepare some parameters for electronic wave functions initilization - this->p_wf_init = new psi::WFInit(PARAM.inp.init_wfc, - PARAM.inp.ks_solver, - PARAM.inp.basis_type, - PARAM.inp.psi_initializer, - &this->wf, - this->pw_wfc); + this->p_wf_init = new psi::PSIInit(PARAM.inp.init_wfc, + PARAM.inp.ks_solver, + PARAM.inp.basis_type, + PARAM.inp.psi_initializer, + &this->wf, + this->pw_wfc); this->p_wf_init->prepare_init(&(this->sf), &ucell, 1, @@ -547,7 +547,7 @@ void ESolver_KS_PW::iter_finish(const int istep, int& iter) } // 4) Print out electronic wavefunctions - if (this->wf.out_wfc_pw == 1 || this->wf.out_wfc_pw == 2) + if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2) { std::stringstream ssw; ssw << PARAM.globalv.global_out_dir << "WAVEFUNC"; @@ -573,7 +573,7 @@ void ESolver_KS_PW::after_scf(const int istep) ESolver_KS::after_scf(istep); // 3) output wavefunctions - if (this->wf.out_wfc_pw == 1 || this->wf.out_wfc_pw == 2) + if (PARAM.inp.out_wfc_pw == 1 || PARAM.inp.out_wfc_pw == 2) { std::stringstream ssw; ssw << PARAM.globalv.global_out_dir << "WAVEFUNC"; @@ -821,7 +821,7 @@ void ESolver_KS_PW::after_all_runners() } //! 6) Print out electronic wave functions in real space - if (this->wf.out_wfc_r == 1) // Peize Lin add 2021.11.21 + if (PARAM.inp.out_wfc_r == 1) // Peize Lin add 2021.11.21 { ModuleIO::write_psi_r_1(this->psi[0], this->pw_wfc, "wfc_realspace", true, this->kv); } diff --git a/source/module_esolver/esolver_ks_pw.h b/source/module_esolver/esolver_ks_pw.h index b17b18f510..b7e37b2c59 100644 --- a/source/module_esolver/esolver_ks_pw.h +++ b/source/module_esolver/esolver_ks_pw.h @@ -53,7 +53,7 @@ class ESolver_KS_PW : public ESolver_KS psi::Psi, base_device::DEVICE_CPU>* psi = nullptr; // psi_initializer controller - psi::WFInit* p_wf_init = nullptr; + psi::PSIInit* p_wf_init = nullptr; Device* ctx = {}; diff --git a/source/module_esolver/esolver_sdft_pw.cpp b/source/module_esolver/esolver_sdft_pw.cpp index 7b5ff01028..2a7e92f917 100644 --- a/source/module_esolver/esolver_sdft_pw.cpp +++ b/source/module_esolver/esolver_sdft_pw.cpp @@ -52,7 +52,7 @@ void ESolver_SDFT_PW::before_all_runners(const Input_para& inp, UnitC // 2) run "before_all_runners" in ESolver_KS ESolver_KS_PW::before_all_runners(inp, ucell); - // 9) initialize the stochastic wave functions + // 3) initialize the stochastic wave functions this->stowf.init(&this->kv, this->pw_wfc->npwk_max); if (inp.nbands_sto != 0) { @@ -75,7 +75,7 @@ void ESolver_SDFT_PW::before_all_runners(const Input_para& inp, UnitC } this->stowf.sync_chi0(); - // 10) allocate spaces for \sqrt(f(H))|chi> and |\tilde{chi}> + // 4) allocate spaces for \sqrt(f(H))|chi> and |\tilde{chi}> size_t size = stowf.chi0->size(); this->stowf.shchi = new psi::Psi(this->kv.get_nks(), this->stowf.nchip_max, this->wf.npwx, this->kv.ngk.data()); diff --git a/source/module_esolver/lcao_others.cpp b/source/module_esolver/lcao_others.cpp index 2d70c02611..0f1ae92640 100644 --- a/source/module_esolver/lcao_others.cpp +++ b/source/module_esolver/lcao_others.cpp @@ -331,7 +331,7 @@ void ESolver_KS_LCAO::others(const int istep) this->pv, this->GG, PARAM.inp.out_wfc_pw, - this->wf.out_wfc_r, + PARAM.inp.out_wfc_r, this->kv, PARAM.inp.nelec, PARAM.inp.nbands_istate, @@ -351,7 +351,7 @@ void ESolver_KS_LCAO::others(const int istep) this->pv, this->GK, PARAM.inp.out_wfc_pw, - this->wf.out_wfc_r, + PARAM.inp.out_wfc_r, this->kv, PARAM.inp.nelec, PARAM.inp.nbands_istate, diff --git a/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp b/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp index 2fb75e9e41..87686f8edc 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/wavefunc.cpp @@ -52,7 +52,7 @@ psi::Psi>* wavefunc::allocate(const int nkstot, const int n const int nks2 = nks; psi::Psi>* psi_out = nullptr; - if (PARAM.inp.calculation == "nscf" && this->mem_saver == 1) + if (PARAM.inp.calculation == "nscf" && PARAM.inp.mem_saver == 1) { // initial psi rather than evc psi_out = new psi::Psi>(1, PARAM.inp.nbands, npwx * PARAM.globalv.npol, ngk); @@ -140,11 +140,11 @@ void wavefunc::wfcinit(psi::Psi>* psi_in, ModulePW::PW_Basi int wavefunc::get_starting_nw() const { - if (init_wfc == "file") + if (PARAM.inp.init_wfc == "file") { return PARAM.inp.nbands; } - else if (init_wfc.substr(0, 6) == "atomic") + else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") { if (GlobalC::ucell.natomwfc >= PARAM.inp.nbands) { @@ -164,7 +164,7 @@ int wavefunc::get_starting_nw() const } return std::max(GlobalC::ucell.natomwfc, PARAM.inp.nbands); } - else if (init_wfc == "random") + else if (PARAM.inp.init_wfc == "random") { if (PARAM.inp.test_wf) { @@ -196,7 +196,7 @@ void diago_PAO_in_pw_k2(const int& ik, const int nbands = wvf.get_nbands(); const int current_nbasis = wfc_basis->npwk[ik]; - if (p_wf->init_wfc == "file") + if (PARAM.inp.init_wfc == "file") { ModuleBase::ComplexMatrix wfcatom(nbands, nbasis); std::stringstream filename; @@ -263,7 +263,7 @@ void diago_PAO_in_pw_k2(const int& ik, } */ - if (p_wf->init_wfc == "random" || (p_wf->init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0)) + if (PARAM.inp.init_wfc == "random" || (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0)) { p_wf->random(wvf.get_pointer(), 0, nbands, ik, wfc_basis); @@ -280,7 +280,7 @@ void diago_PAO_in_pw_k2(const int& ik, } } } - else if (p_wf->init_wfc.substr(0, 6) == "atomic") + else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") { ModuleBase::ComplexMatrix wfcatom(starting_nw, nbasis); // added by zhengdy-soc if (PARAM.inp.test_wf) { @@ -296,7 +296,7 @@ void diago_PAO_in_pw_k2(const int& ik, PARAM.globalv.nqx, PARAM.globalv.dq); - if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 + if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 { p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis); } @@ -355,7 +355,7 @@ void diago_PAO_in_pw_k2(const int& ik, const int nbands = wvf.get_nbands(); const int current_nbasis = wfc_basis->npwk[ik]; - if (p_wf->init_wfc == "file") + if (PARAM.inp.init_wfc == "file") { ModuleBase::ComplexMatrix wfcatom(nbands, nbasis); std::stringstream filename; @@ -420,7 +420,7 @@ void diago_PAO_in_pw_k2(const int& ik, assert(starting_nw > 0); std::vector etatom(starting_nw, 0.0); - if (p_wf->init_wfc == "random" || (p_wf->init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0)) + if (PARAM.inp.init_wfc == "random" || (PARAM.inp.init_wfc.substr(0, 6) == "atomic" && GlobalC::ucell.natomwfc == 0)) { p_wf->random(wvf.get_pointer(), 0, nbands, ik, wfc_basis); if (PARAM.inp.ks_solver == "cg") // xiaohui add 2013-09-02 @@ -436,7 +436,7 @@ void diago_PAO_in_pw_k2(const int& ik, } } } - else if (p_wf->init_wfc.substr(0, 6) == "atomic") + else if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") { ModuleBase::ComplexMatrix wfcatom(starting_nw, nbasis); // added by zhengdy-soc if (PARAM.inp.test_wf) @@ -453,7 +453,7 @@ void diago_PAO_in_pw_k2(const int& ik, PARAM.globalv.nqx, PARAM.globalv.dq); - if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 + if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 { p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis); } @@ -534,7 +534,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, int starting_nw = nbands; ModuleBase::ComplexMatrix wfcatom(nbands, nbasis); - if (p_wf->init_wfc == "file") + if (PARAM.inp.init_wfc == "file") { std::stringstream filename; int ik_tot = K_Vectors::get_ik_global(ik, p_wf->nkstot); @@ -550,7 +550,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, if (PARAM.inp.test_wf) ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "starting_nw", starting_nw); - if (p_wf->init_wfc.substr(0, 6) == "atomic") + if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") { p_wf->atomic_wfc(ik, current_nbasis, @@ -560,7 +560,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, GlobalC::ppcell.tab_at, PARAM.globalv.nqx, PARAM.globalv.dq); - if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 + if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 { p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis); } @@ -571,7 +571,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, //==================================================== p_wf->random(wfcatom.c, GlobalC::ucell.natomwfc, nbands, ik, wfc_basis); } - else if (p_wf->init_wfc == "random") + else if (PARAM.inp.init_wfc == "random") { p_wf->random(wfcatom.c, 0, nbands, ik, wfc_basis); } @@ -638,7 +638,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, int starting_nw = nbands; ModuleBase::ComplexMatrix wfcatom(nbands, nbasis); - if (p_wf->init_wfc == "file") + if (PARAM.inp.init_wfc == "file") { std::stringstream filename; int ik_tot = K_Vectors::get_ik_global(ik, p_wf->nkstot); @@ -653,7 +653,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, wfcatom.create(starting_nw, nbasis); // added by zhengdy-soc if (PARAM.inp.test_wf) ModuleBase::GlobalFunc::OUT(GlobalV::ofs_running, "starting_nw", starting_nw); - if (p_wf->init_wfc.substr(0, 6) == "atomic") + if (PARAM.inp.init_wfc.substr(0, 6) == "atomic") { p_wf->atomic_wfc(ik, current_nbasis, @@ -663,7 +663,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, GlobalC::ppcell.tab_at, PARAM.globalv.nqx, PARAM.globalv.dq); - if (p_wf->init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 + if (PARAM.inp.init_wfc == "atomic+random" && starting_nw == GlobalC::ucell.natomwfc) // added by qianrui 2021-5-16 { p_wf->atomicrandom(wfcatom, 0, starting_nw, ik, wfc_basis); } @@ -674,7 +674,7 @@ void diago_PAO_in_pw_k2(const base_device::DEVICE_GPU* ctx, //==================================================== p_wf->random(wfcatom.c, GlobalC::ucell.natomwfc, nbands, ik, wfc_basis); } - else if (p_wf->init_wfc == "random") + else if (PARAM.inp.init_wfc == "random") { p_wf->random(wfcatom.c, 0, nbands, ik, wfc_basis); } diff --git a/source/module_hamilt_pw/hamilt_pwdft/wavefunc.h b/source/module_hamilt_pw/hamilt_pwdft/wavefunc.h index e9df666e37..c1d2386582 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/wavefunc.h +++ b/source/module_hamilt_pw/hamilt_pwdft/wavefunc.h @@ -10,50 +10,44 @@ class wavefunc : public WF_atomic { - public: - + public: wavefunc(); ~wavefunc(); // allocate memory psi::Psi>* allocate(const int nkstot, const int nks, const int* ngk, const int npwx); - int out_wfc_pw = 0; //qianrui modify 2020-10-19 - int out_wfc_r = 0; // Peize Lin add 2021.11.21 + int nkstot = 0; // total number of k-points for all pools - // init_wfc : "random",or "atomic" or "file" - std::string init_wfc; - int nkstot = 0; // total number of k-points for all pools - int mem_saver = 0; // 1: save evc when doing nscf calculation. void wfcinit(psi::Psi>* psi_in, ModulePW::PW_Basis_K* wfc_basis); - int get_starting_nw(void)const; - void init_after_vc(const int nks); //LiuXh 20180515 -}; + int get_starting_nw(void) const; + void init_after_vc(const int nks); // LiuXh 20180515 +}; namespace hamilt { -void diago_PAO_in_pw_k2(const int &ik, - psi::Psi> &wvf, - ModulePW::PW_Basis_K *wfc_basis, - wavefunc *p_wf, - hamilt::Hamilt> *phm_in = nullptr); -void diago_PAO_in_pw_k2(const int &ik, - psi::Psi> &wvf, - ModulePW::PW_Basis_K *wfc_basis, - wavefunc *p_wf, - hamilt::Hamilt> *phm_in = nullptr); -void diago_PAO_in_pw_k2(const int &ik, ModuleBase::ComplexMatrix &wvf, wavefunc *p_wf); +void diago_PAO_in_pw_k2(const int& ik, + psi::Psi>& wvf, + ModulePW::PW_Basis_K* wfc_basis, + wavefunc* p_wf, + hamilt::Hamilt>* phm_in = nullptr); +void diago_PAO_in_pw_k2(const int& ik, + psi::Psi>& wvf, + ModulePW::PW_Basis_K* wfc_basis, + wavefunc* p_wf, + hamilt::Hamilt>* phm_in = nullptr); +void diago_PAO_in_pw_k2(const int& ik, ModuleBase::ComplexMatrix& wvf, wavefunc* p_wf); template -void diago_PAO_in_pw_k2(const Device *ctx, - const int &ik, - psi::Psi, Device> &wvf, - ModulePW::PW_Basis_K *wfc_basis, - wavefunc *p_wf, - hamilt::Hamilt, Device> *phm_in = nullptr); -} - -#endif //wavefunc +void diago_PAO_in_pw_k2(const Device* ctx, + const int& ik, + psi::Psi, Device>& wvf, + ModulePW::PW_Basis_K* wfc_basis, + wavefunc* p_wf, + hamilt::Hamilt, Device>* phm_in = nullptr); +} // namespace hamilt + +#endif // wavefunc diff --git a/source/module_hamilt_pw/hamilt_pwdft/wfinit.cpp b/source/module_hamilt_pw/hamilt_pwdft/wfinit.cpp index 9347530c4a..9dec3dfc31 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/wfinit.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/wfinit.cpp @@ -14,12 +14,12 @@ namespace psi { template -WFInit::WFInit(const std::string& init_wfc_in, - const std::string& ks_solver_in, - const std::string& basis_type_in, - const bool& use_psiinitializer_in, - wavefunc* p_wf_in, - ModulePW::PW_Basis_K* pw_wfc_in) +PSIInit::PSIInit(const std::string& init_wfc_in, + const std::string& ks_solver_in, + const std::string& basis_type_in, + const bool& use_psiinitializer_in, + wavefunc* p_wf_in, + ModulePW::PW_Basis_K* pw_wfc_in) { this->init_wfc = init_wfc_in; this->ks_solver = ks_solver_in; @@ -30,14 +30,14 @@ WFInit::WFInit(const std::string& init_wfc_in, } template -void WFInit::prepare_init(Structure_Factor* p_sf, - UnitCell* p_ucell, - const int& random_seed, +void PSIInit::prepare_init(Structure_Factor* p_sf, + UnitCell* p_ucell, + const int& random_seed, #ifdef __MPI - Parallel_Kpoints* p_parak, - const int& rank, + Parallel_Kpoints* p_parak, + const int& rank, #endif - pseudopot_cell_vnl* p_ppcell) + pseudopot_cell_vnl* p_ppcell) { if (!this->use_psiinitializer) { @@ -45,7 +45,7 @@ void WFInit::prepare_init(Structure_Factor* p_sf, } // under restriction of C++11, std::unique_ptr can not be allocate via std::make_unique // use new instead, but will cause asymmetric allocation and deallocation, in literal aspect - ModuleBase::timer::tick("WFInit", "prepare_init"); + ModuleBase::timer::tick("PSIInit", "prepare_init"); if ((this->init_wfc.substr(0, 6) == "atomic") && (p_ucell->natomwfc == 0)) { this->psi_init = std::unique_ptr>(new psi_initializer_random()); @@ -72,7 +72,7 @@ void WFInit::prepare_init(Structure_Factor* p_sf, } else { - ModuleBase::WARNING_QUIT("WFInit::prepare_init", "for new psi initializer, init_wfc type not supported"); + ModuleBase::WARNING_QUIT("PSIInit::prepare_init", "for new psi initializer, init_wfc type not supported"); } //! function polymorphism is moved from constructor to function initialize. @@ -85,25 +85,25 @@ void WFInit::prepare_init(Structure_Factor* p_sf, // always new->initialize->tabulate->allocate->proj_ao_onkG this->psi_init->tabulate(); - ModuleBase::timer::tick("WFInit", "prepare_init"); + ModuleBase::timer::tick("PSIInit", "prepare_init"); } template -void WFInit::allocate_psi(Psi>*& psi, - const int nkstot, - const int nks, - const int* ngk, - const int npwx, - Structure_Factor* p_sf) +void PSIInit::allocate_psi(Psi>*& psi, + const int nkstot, + const int nks, + const int* ngk, + const int npwx, + Structure_Factor* p_sf) { // allocate memory for std::complex datatype psi // New psi initializer in ABACUS, Developer's note: - // Because the calling relationship between WFInit and derived class is + // Because the calling relationship between PSIInit and derived class is // complicated, up to upcoming of ABACUS 3.4, we only implement this new psi // initialization method for ksdft_pw, which means the routinely used dft theory. // For other theories like stochastic DFT, we still use the old method. - // LCAOINPW also temporarily uses WFInit workflow, but in principle, it + // LCAOINPW also temporarily uses PSIInit workflow, but in principle, it // should have its own ESolver. ESolver class is for controlling workflow for each // theory-basis combination, in the future it is also possible to seperate/decouple // the basis (representation) with operator (hamiltonian) and solver (diagonalization). @@ -136,7 +136,7 @@ void WFInit::allocate_psi(Psi>*& psi, } template -void WFInit::make_table(const int nks, Structure_Factor* p_sf) +void PSIInit::make_table(const int nks, Structure_Factor* p_sf) { if (this->use_psiinitializer) { @@ -149,13 +149,13 @@ void WFInit::make_table(const int nks, Structure_Factor* p_sf) } template -void WFInit::initialize_psi(Psi>* psi, - psi::Psi* kspw_psi, - hamilt::Hamilt* p_hamilt, - std::ofstream& ofs_running, - const bool is_already_initpsi) +void PSIInit::initialize_psi(Psi>* psi, + psi::Psi* kspw_psi, + hamilt::Hamilt* p_hamilt, + std::ofstream& ofs_running, + const bool is_already_initpsi) { - ModuleBase::timer::tick("WFInit", "initialize_psi"); + ModuleBase::timer::tick("PSIInit", "initialize_psi"); if (PARAM.inp.psi_initializer) { @@ -187,7 +187,7 @@ void WFInit::initialize_psi(Psi>* psi, if (psig.expired()) { - ModuleBase::WARNING_QUIT("WFInit::initialize_psi", "psig lifetime is expired"); + ModuleBase::WARNING_QUIT("PSIInit::initialize_psi", "psig lifetime is expired"); } //! to use psig, we need to lock it to get a shared pointer version, @@ -286,13 +286,13 @@ void WFInit::initialize_psi(Psi>* psi, } } - ModuleBase::timer::tick("WFInit", "initialize_psi"); + ModuleBase::timer::tick("PSIInit", "initialize_psi"); } -template class WFInit, base_device::DEVICE_CPU>; -template class WFInit, base_device::DEVICE_CPU>; +template class PSIInit, base_device::DEVICE_CPU>; +template class PSIInit, base_device::DEVICE_CPU>; #if ((defined __CUDA) || (defined __ROCM)) -template class WFInit, base_device::DEVICE_GPU>; -template class WFInit, base_device::DEVICE_GPU>; +template class PSIInit, base_device::DEVICE_GPU>; +template class PSIInit, base_device::DEVICE_GPU>; #endif } // namespace psi \ No newline at end of file diff --git a/source/module_hamilt_pw/hamilt_pwdft/wfinit.h b/source/module_hamilt_pw/hamilt_pwdft/wfinit.h index 91fc9a214d..6dad2324b9 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/wfinit.h +++ b/source/module_hamilt_pw/hamilt_pwdft/wfinit.h @@ -9,16 +9,16 @@ namespace psi // This class is used to initialize the wavefunction template -class WFInit +class PSIInit { public: - WFInit(const std::string& init_wfc_in, - const std::string& ks_solver_in, - const std::string& basis_type_in, - const bool& use_psiinitializer_in, - wavefunc* p_wf_in, - ModulePW::PW_Basis_K* pw_wfc_in); - ~WFInit(){}; + PSIInit(const std::string& init_wfc_in, + const std::string& ks_solver_in, + const std::string& basis_type_in, + const bool& use_psiinitializer_in, + wavefunc* p_wf_in, + ModulePW::PW_Basis_K* pw_wfc_in); + ~PSIInit(){}; // prepare the wavefunction initialization void prepare_init(Structure_Factor* p_sf, //< structure factor diff --git a/source/module_ri/exx_lip.h b/source/module_ri/exx_lip.h index 5d7916f888..307f58ab9f 100644 --- a/source/module_ri/exx_lip.h +++ b/source/module_ri/exx_lip.h @@ -19,7 +19,11 @@ namespace ModulePW{ class PW_Basis_K; } namespace ModulePW{ class PW_Basis; } namespace ModuleSymmetry{ class Symmetry; } - namespace psi{ template class WFInit; } + namespace psi + { + template + class PSIInit; + } template class Exx_Lip @@ -32,16 +36,16 @@ class Exx_Lip const Exx_Info::Exx_Info_Lip& info; Exx_Lip(const Exx_Info::Exx_Info_Lip& info_in, - const ModuleSymmetry::Symmetry& symm, - K_Vectors* kv_ptr_in, - // wavefunc* wf_ptr_in, - psi::WFInit* wf_ptr_in, - psi::Psi* kspw_psi_ptr_in, - const ModulePW::PW_Basis_K* wfc_basis_in, - const ModulePW::PW_Basis* rho_basis_in, - const Structure_Factor& sf, - const UnitCell* ucell_ptr_in, - const elecstate::ElecState* pelec_in); + const ModuleSymmetry::Symmetry& symm, + K_Vectors* kv_ptr_in, + // wavefunc* wf_ptr_in, + psi::PSIInit* wf_ptr_in, + psi::Psi* kspw_psi_ptr_in, + const ModulePW::PW_Basis_K* wfc_basis_in, + const ModulePW::PW_Basis* rho_basis_in, + const Structure_Factor& sf, + const UnitCell* ucell_ptr_in, + const elecstate::ElecState* pelec_in); // void cal_exx(const int& nks); void cal_exx(); @@ -75,7 +79,7 @@ class Exx_Lip K_Vectors* kv_ptr = nullptr; // wavefunc* wf_ptr; psi::Psi* kspw_psi_ptr = nullptr; ///< PW wavefunction - psi::WFInit* wf_ptr = nullptr; + psi::PSIInit* wf_ptr = nullptr; ModuleBase::matrix wf_wg; /// @brief LCAO wavefunction, the eigenvectors from lapack diagonalization diff --git a/source/module_ri/exx_lip.hpp b/source/module_ri/exx_lip.hpp index e21bcea66e..c5f5d3ee51 100644 --- a/source/module_ri/exx_lip.hpp +++ b/source/module_ri/exx_lip.hpp @@ -81,18 +81,18 @@ void Exx_Lip::cal_exx() } template -Exx_Lip::Exx_Lip( - const Exx_Info::Exx_Info_Lip& info_in, - const ModuleSymmetry::Symmetry& symm, - K_Vectors* kv_ptr_in, - psi::WFInit* wf_ptr_in, - psi::Psi* kspw_psi_ptr_in, - // wavefunc* wf_ptr_in, - const ModulePW::PW_Basis_K* wfc_basis_in, - const ModulePW::PW_Basis* rho_basis_in, - const Structure_Factor& sf, - const UnitCell* ucell_ptr_in, - const elecstate::ElecState* pelec_in) : info(info_in) +Exx_Lip::Exx_Lip(const Exx_Info::Exx_Info_Lip& info_in, + const ModuleSymmetry::Symmetry& symm, + K_Vectors* kv_ptr_in, + psi::PSIInit* wf_ptr_in, + psi::Psi* kspw_psi_ptr_in, + // wavefunc* wf_ptr_in, + const ModulePW::PW_Basis_K* wfc_basis_in, + const ModulePW::PW_Basis* rho_basis_in, + const Structure_Factor& sf, + const UnitCell* ucell_ptr_in, + const elecstate::ElecState* pelec_in) + : info(info_in) { ModuleBase::TITLE("Exx_Lip", "init"); ModuleBase::timer::tick("Exx_Lip", "init");