@@ -152,7 +152,8 @@ template <typename T, typename Device>
152152void WFInit<T, Device>::initialize_psi(Psi<std::complex <double >>* psi,
153153 psi::Psi<T, Device>* kspw_psi,
154154 hamilt::Hamilt<T, Device>* p_hamilt,
155- std::ofstream& ofs_running)
155+ std::ofstream& ofs_running,
156+ const bool is_already_initpsi)
156157{
157158 ModuleBase::timer::tick (" WFInit" , " initialize_psi" );
158159
@@ -254,20 +255,35 @@ void WFInit<T, Device>::initialize_psi(Psi<std::complex<double>>* psi,
254255 }
255256 else
256257 {
257- // if (PARAM.inp.basis_type == "pw")
258- // {
259- // for (int ik = 0; ik < this->pw_wfc->nks; ++ik)
260- // {
261- // //! Update Hamiltonian from other kpoint to the given one
262- // p_hamilt->updateHk(ik);
258+ // ! note: is_already_initpsi will be false in init_after_vc when vc changes.
259+ if (PARAM.inp .basis_type == " pw" && is_already_initpsi == false )
260+ {
261+ for (int ik = 0 ; ik < this ->pw_wfc ->nks ; ++ik)
262+ {
263+ // ! Update Hamiltonian from other kpoint to the given one
264+ p_hamilt->updateHk (ik);
263265
264- // //! Fix the wavefunction to initialize at given kpoint
265- // kspw_psi->fix_k(ik);
266+ if (PARAM.inp .esolver_type == " sdft" )
267+ {
268+ if (kspw_psi->get_nbands () > 0 && GlobalV::MY_STOGROUP == 0 )
269+ {
270+ // ! Fix the wavefunction to initialize at given kpoint
271+ kspw_psi->fix_k (ik);
266272
267- // /// for psi init guess!!!!
268- // hamilt::diago_PAO_in_pw_k2(this->ctx, ik, *kspw_psi, this->pw_wfc, this->p_wf, p_hamilt);
269- // }
270- // }
273+ // / for psi init guess!!!!
274+ hamilt::diago_PAO_in_pw_k2 (this ->ctx , ik, *(kspw_psi), this ->pw_wfc , this ->p_wf , p_hamilt);
275+ }
276+ }
277+ else
278+ {
279+ // ! Fix the wavefunction to initialize at given kpoint
280+ kspw_psi->fix_k (ik);
281+
282+ // / for psi init guess!!!!
283+ hamilt::diago_PAO_in_pw_k2 (this ->ctx , ik, *(kspw_psi), this ->pw_wfc , this ->p_wf , p_hamilt);
284+ }
285+ }
286+ }
271287 }
272288
273289 ModuleBase::timer::tick (" WFInit" , " initialize_psi" );
0 commit comments