diff --git a/source/module_esolver/esolver_ks.h b/source/module_esolver/esolver_ks.h index 9e046c7edb..d47826739c 100644 --- a/source/module_esolver/esolver_ks.h +++ b/source/module_esolver/esolver_ks.h @@ -65,10 +65,6 @@ class ESolver_KS : public ESolver_FP //! Charge mixing method, only used in KDSFT, not in OFDFT Charge_Mixing* p_chgmix = nullptr; - //! wave functions, this one may be deleted in near future - //! mohan note 2024-11-14 - wavefunc wf; - //! Electronic wavefunctions psi::Psi* psi = nullptr; diff --git a/source/module_esolver/esolver_ks_pw.cpp b/source/module_esolver/esolver_ks_pw.cpp index 4edd7ed3c7..a053f2de95 100644 --- a/source/module_esolver/esolver_ks_pw.cpp +++ b/source/module_esolver/esolver_ks_pw.cpp @@ -185,7 +185,6 @@ void ESolver_KS_PW::before_all_runners(const Input_para& inp, UnitCel 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, diff --git a/source/module_hamilt_pw/hamilt_pwdft/psiinit.cpp b/source/module_hamilt_pw/hamilt_pwdft/psiinit.cpp index 1b7a49fffb..1fbc33811f 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/psiinit.cpp +++ b/source/module_hamilt_pw/hamilt_pwdft/psiinit.cpp @@ -18,14 +18,12 @@ 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; this->basis_type = basis_type_in; this->use_psiinitializer = use_psiinitializer_in; - this->p_wf = p_wf_in; this->pw_wfc = pw_wfc_in; } @@ -122,16 +120,16 @@ void PSIInit::allocate_psi(Psi>*& psi, // old method explicitly requires variables such as total number of kpoints, number // of bands, number of G-vectors, and so on. Comparatively in new method, these // variables are imported in function called initialize. - psi = this->p_wf->allocate(nkstot, nks, ngk, npwx); + psi = this->wf_old.allocate(nkstot, nks, ngk, npwx); // however, init_at_1 does not actually initialize the psi, instead, it is a // function to calculate a interpolate table saving overlap intergral or say // Spherical Bessel Transform of atomic orbitals. - this->p_wf->init_at_1(p_sf); + this->wf_old.init_at_1(p_sf); // similarly, wfcinit not really initialize any wavefunction, instead, it initialize // the mapping from ixy, the 1d flattened index of point on fft grid (x, y) plane, // to the index of "stick", composed of grid points. - this->p_wf->wfcinit(psi, pw_wfc); + this->wf_old.wfcinit(psi, pw_wfc); } } @@ -143,8 +141,8 @@ void PSIInit::make_table(const int nks, Structure_Factor* p_sf) } // do not need to do anything because the interpolate table is unchanged else // old initialization method, used in EXX calculation { - this->p_wf->init_after_vc(nks); // reallocate wanf2, the planewave expansion of lcao - this->p_wf->init_at_1(p_sf); // re-calculate tab_at, the overlap matrix between atomic pswfc and jlq + this->wf_old.init_after_vc(nks); // reallocate wanf2, the planewave expansion of lcao + this->wf_old.init_at_1(p_sf); // re-calculate tab_at, the overlap matrix between atomic pswfc and jlq } } @@ -271,7 +269,7 @@ void PSIInit::initialize_psi(Psi>* psi, kspw_psi->fix_k(ik); /// for psi init guess!!!! - hamilt::diago_PAO_in_pw_k2(this->ctx, ik, *(kspw_psi), this->pw_wfc, this->p_wf, p_hamilt); + hamilt::diago_PAO_in_pw_k2(this->ctx, ik, *(kspw_psi), this->pw_wfc, &this->wf_old, p_hamilt); } } else @@ -280,7 +278,7 @@ void PSIInit::initialize_psi(Psi>* psi, kspw_psi->fix_k(ik); /// for psi init guess!!!! - hamilt::diago_PAO_in_pw_k2(this->ctx, ik, *(kspw_psi), this->pw_wfc, this->p_wf, p_hamilt); + hamilt::diago_PAO_in_pw_k2(this->ctx, ik, *(kspw_psi), this->pw_wfc, &this->wf_old, p_hamilt); } } } diff --git a/source/module_hamilt_pw/hamilt_pwdft/psiinit.h b/source/module_hamilt_pw/hamilt_pwdft/psiinit.h index 6dad2324b9..077422abbb 100644 --- a/source/module_hamilt_pw/hamilt_pwdft/psiinit.h +++ b/source/module_hamilt_pw/hamilt_pwdft/psiinit.h @@ -16,7 +16,6 @@ class PSIInit 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(){}; @@ -47,7 +46,7 @@ class PSIInit * * @param psi store the wavefunction * @param p_hamilt Hamiltonian operator - * @param ofs_running output stream for running information + * @param ofs_running output stream for running information * @param is_already_initpsi whether psi has been initialized */ void initialize_psi(Psi>* psi, @@ -73,17 +72,22 @@ class PSIInit // while the std::make_unique() is not supported till C++14, // so use the new and std::unique_ptr to manage the memory, but this makes new-delete not symmetric std::unique_ptr> psi_init; - // temporary - // wavefunc pointer - wavefunc* p_wf = nullptr; + + //! temporary: wave functions, this one may be deleted in future + wavefunc wf_old; + // whether to use psi_initializer bool use_psiinitializer = false; + // wavefunction initialization type std::string init_wfc = "none"; + // Kohn-Sham solver type std::string ks_solver = "none"; + // basis type std::string basis_type = "none"; + // pw basis ModulePW::PW_Basis_K* pw_wfc = nullptr;