Skip to content

Commit

Permalink
remove wf from esolver
Browse files Browse the repository at this point in the history
  • Loading branch information
haozhihan committed Nov 22, 2024
1 parent 88468ac commit f9bfddb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
4 changes: 0 additions & 4 deletions source/module_esolver/esolver_ks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>* psi = nullptr;

Expand Down
1 change: 0 additions & 1 deletion source/module_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ void ESolver_KS_PW<T, Device>::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,
Expand Down
16 changes: 7 additions & 9 deletions source/module_hamilt_pw/hamilt_pwdft/psiinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ PSIInit<T, Device>::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;
}

Expand Down Expand Up @@ -122,16 +120,16 @@ void PSIInit<T, Device>::allocate_psi(Psi<std::complex<double>>*& 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);
}
}

Expand All @@ -143,8 +141,8 @@ void PSIInit<T, Device>::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
}
}

Expand Down Expand Up @@ -271,7 +269,7 @@ void PSIInit<T, Device>::initialize_psi(Psi<std::complex<double>>* 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
Expand All @@ -280,7 +278,7 @@ void PSIInit<T, Device>::initialize_psi(Psi<std::complex<double>>* 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);
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions source/module_hamilt_pw/hamilt_pwdft/psiinit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(){};

Expand Down Expand Up @@ -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<std::complex<double>>* psi,
Expand All @@ -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_initializer<T, Device>> 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;

Expand Down

0 comments on commit f9bfddb

Please sign in to comment.