Skip to content

Commit

Permalink
remove useless code abaout phsol
Browse files Browse the repository at this point in the history
  • Loading branch information
haozhihan committed Aug 23, 2024
1 parent 3fe1146 commit cab05db
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 129 deletions.
1 change: 0 additions & 1 deletion source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ ESolver_KS<T, Device>::~ESolver_KS()
delete this->psi;
delete this->pw_wfc;
delete this->p_hamilt;
// delete this->phsol;
delete this->p_chgmix;
}

Expand Down
15 changes: 2 additions & 13 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,6 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(const Input_para& inp, UnitCell
// 9) initialize ppcell
GlobalC::ppcell.init_vloc(GlobalC::ppcell.vloc, this->pw_rho);

// // 10) initialize the HSolver
// if (this->phsol == nullptr)
// {
// this->phsol = new hsolver::HSolver<TK>();
// }

// 11) inititlize the charge density
this->pelec->charge->allocate(GlobalV::NSPIN);
this->pelec->omega = GlobalC::ucell.omega;
Expand Down Expand Up @@ -701,8 +695,7 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2density(int istep, int iter, double ethr)
}

// 3) solve the Hamiltonian and output band gap
// if (this->phsol != nullptr)
// {
{
// reset energy
this->pelec->f_en.eband = 0.0;
this->pelec->f_en.demet = 0.0;
Expand All @@ -722,11 +715,7 @@ void ESolver_KS_LCAO<TK, TR>::hamilt2density(int istep, int iter, double ethr)
this->pelec->cal_bandgap_updw();
}
}
// }
// else
// {
// ModuleBase::WARNING_QUIT("ESolver_KS_PW", "HSolver has not been initialed!");
// }
}

// 4) print bands for each k-point and each band
for (int ik = 0; ik < this->kv.get_nks(); ++ik)
Expand Down
9 changes: 1 addition & 8 deletions source/module_esolver/esolver_ks_lcao_tddft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,7 @@ void ESolver_KS_LCAO_TDDFT::before_all_runners(const Input_para& inp, UnitCell&
LCAO_domain::divide_HS_in_frag(GlobalV::GAMMA_ONLY_LOCAL, this->pv, kv.get_nks());

// 6) initialize Density Matrix
dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)
->init_DM(&kv, &this->pv, GlobalV::NSPIN);

// // 7) initialize Hsolver
// if (this->phsol == nullptr)
// {
// this->phsol = new hsolver::HSolver<std::complex<double>>();
// }
dynamic_cast<elecstate::ElecStateLCAO<std::complex<double>>*>(this->pelec)->init_DM(&kv, &this->pv, GlobalV::NSPIN);

// 8) initialize the charge density
this->pelec->charge->allocate(GlobalV::NSPIN);
Expand Down
28 changes: 3 additions & 25 deletions source/module_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,10 @@ namespace ModuleESolver
template <typename T>
ESolver_KS_LIP<T>::~ESolver_KS_LIP()
{
// delete HSolver and ElecState
this->deallocate_hsolver();
// delete Hamilt
this->deallocate_hamilt();
}

template <typename T>
void ESolver_KS_LIP<T>::allocate_hsolver()
{
// this->phsol = new hsolver::HSolver<T>();
}
template <typename T>
void ESolver_KS_LIP<T>::deallocate_hsolver()
{
// if (this->phsol != nullptr)
// {
// delete (this->phsol);
// this->phsol = nullptr;
// }
}
template <typename T>
void ESolver_KS_LIP<T>::allocate_hamilt()
{
Expand Down Expand Up @@ -133,8 +117,7 @@ namespace ModuleESolver
ModuleBase::TITLE("ESolver_KS_LIP", "hamilt2density");
ModuleBase::timer::tick("ESolver_KS_LIP", "hamilt2density");

// if (this->phsol != nullptr)
// {
{
// reset energy
this->pelec->f_en.eband = 0.0;
this->pelec->f_en.demet = 0.0;
Expand Down Expand Up @@ -174,13 +157,8 @@ namespace ModuleESolver
this->pelec->cal_bandgap_updw();
}
}
// }
// else
// {
// ModuleBase::WARNING_QUIT("ESolver_KS_LIP", "HSolver has not been allocated.");
// }


}

// add exx
#ifdef __EXX
if (GlobalC::exx_info.info_global.cal_exx) {
Expand Down
3 changes: 1 addition & 2 deletions source/module_esolver/esolver_ks_lcaopw.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ namespace ModuleESolver
protected:
virtual void iter_init(const int istep, const int iter) override;
virtual void iter_finish(int& iter) override;
virtual void allocate_hsolver() override;
virtual void deallocate_hsolver() override;

virtual void allocate_hamilt() override;
virtual void deallocate_hamilt() override;

Expand Down
17 changes: 2 additions & 15 deletions source/module_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ ESolver_KS_PW<T, Device>::ESolver_KS_PW()
template <typename T, typename Device>
ESolver_KS_PW<T, Device>::~ESolver_KS_PW()
{
// delete HSolver and ElecState
this->deallocate_hsolver();

// delete Hamilt
this->deallocate_hamilt();
Expand Down Expand Up @@ -110,12 +108,6 @@ void ESolver_KS_PW<T, Device>::before_all_runners(const Input_para& inp, UnitCel
// 1) call before_all_runners() of ESolver_KS
ESolver_KS<T, Device>::before_all_runners(inp, ucell);

// // 2) initialize HSolver
// if (this->phsol == nullptr)
// {
// this->allocate_hsolver();
// }

// 3) initialize ElecState,
if (this->pelec == nullptr)
{
Expand Down Expand Up @@ -348,8 +340,7 @@ void ESolver_KS_PW<T, Device>::hamilt2density(const int istep, const int iter, c
{
ModuleBase::timer::tick("ESolver_KS_PW", "hamilt2density");

// if (this->phsol != nullptr)
// {
{
// reset energy
this->pelec->f_en.eband = 0.0;
this->pelec->f_en.demet = 0.0;
Expand Down Expand Up @@ -404,11 +395,7 @@ void ESolver_KS_PW<T, Device>::hamilt2density(const int istep, const int iter, c
this->pelec->cal_bandgap_updw();
}
}
// }
// else
// {
// ModuleBase::WARNING_QUIT("ESolver_KS_PW", "HSolver has not been initialed!");
// }
}

// calculate the delta_harris energy
// according to new charge density.
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_ks_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class ESolver_KS_PW : public ESolver_KS<T, Device>
// Init Global class
void Init_GlobalC(const Input_para& inp, UnitCell& ucell, pseudopot_cell_vnl& ppcell);

virtual void allocate_hsolver();
virtual void deallocate_hsolver();
virtual void allocate_hamilt();
virtual void deallocate_hamilt();

Expand Down
4 changes: 0 additions & 4 deletions source/module_esolver/esolver_sdft_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ void ESolver_SDFT_PW::before_all_runners(const Input_para& inp, UnitCell& ucell)
ModuleBase::Memory::record("SDFT::chiortho", size * sizeof(std::complex<double>));
}

// // 9) initialize the hsolver
// // It should be removed after esolver_ks does not use phsol.
// this->phsol = new hsolver::HSolver<std::complex<double>>();

return;
}

Expand Down
7 changes: 0 additions & 7 deletions source/module_esolver/lcao_nscf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,8 @@ void ESolver_KS_LCAO<TK, TR>::nscf() {
// then when the istep is a variable of scf or nscf,
// istep becomes istep-1, this should be fixed in future
int istep = 0;
// if (this->phsol != nullptr)
// {
hsolver::HSolverLCAO<TK> hsolver_lcao_obj(&(this->pv), GlobalV::KS_SOLVER);
hsolver_lcao_obj.solve(this->p_hamilt, this->psi[0], this->pelec, GlobalV::KS_SOLVER, true);
// }
// else
// {
// ModuleBase::WARNING_QUIT("ESolver_KS_PW", "HSolver has not been initialed!");
// }

time_t time_finish = std::time(nullptr);
ModuleBase::GlobalFunc::OUT_TIME("cal_bands", time_start, time_finish);
Expand Down
79 changes: 30 additions & 49 deletions source/module_esolver/pw_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,6 @@

namespace ModuleESolver {

template <typename T, typename Device>
void ESolver_KS_PW<T, Device>::allocate_hsolver()
{
// this->phsol = new hsolver::HSolver<T, Device>();
}
template <typename T, typename Device>
void ESolver_KS_PW<T, Device>::deallocate_hsolver()
{
// if (this->phsol != nullptr)
// {
// delete this->phsol;
// this->phsol = nullptr;
// }
}
template <typename T, typename Device>
void ESolver_KS_PW<T, Device>::allocate_hamilt()
{
Expand All @@ -80,46 +66,41 @@ void ESolver_KS_PW<T, Device>::deallocate_hamilt()


template <typename T, typename Device>
void ESolver_KS_PW<T, Device>::hamilt2estates(const double ethr) {
// if (this->phsol != nullptr) {
hsolver::DiagoIterAssist<T, Device>::need_subspace = false;
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR = ethr;
void ESolver_KS_PW<T, Device>::hamilt2estates(const double ethr)
{
hsolver::DiagoIterAssist<T, Device>::need_subspace = false;
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR = ethr;

std::vector<bool> is_occupied(this->kspw_psi->get_nk() * this->kspw_psi->get_nbands(), true);
std::vector<bool> is_occupied(this->kspw_psi->get_nk() * this->kspw_psi->get_nbands(), true);

elecstate::set_is_occupied(is_occupied,
this->pelec,
hsolver::DiagoIterAssist<T, Device>::SCF_ITER,
this->kspw_psi->get_nk(),
this->kspw_psi->get_nbands(),
PARAM.inp.diago_full_acc);
elecstate::set_is_occupied(is_occupied,
this->pelec,
hsolver::DiagoIterAssist<T, Device>::SCF_ITER,
this->kspw_psi->get_nk(),
this->kspw_psi->get_nbands(),
PARAM.inp.diago_full_acc);

hsolver::HSolverPW<T, Device> hsolver_pw_obj(this->pw_wfc, &this->wf, this->init_psi);
hsolver::HSolverPW<T, Device> hsolver_pw_obj(this->pw_wfc, &this->wf, this->init_psi);

hsolver_pw_obj.solve(this->p_hamilt,
this->kspw_psi[0],
this->pelec,
this->pelec->ekb.c,
is_occupied,
PARAM.inp.ks_solver,
PARAM.inp.calculation,
PARAM.inp.basis_type,
PARAM.inp.use_paw,
GlobalV::use_uspp,
GlobalV::RANK_IN_POOL,
GlobalV::NPROC_IN_POOL,
hsolver::DiagoIterAssist<T, Device>::SCF_ITER,
hsolver::DiagoIterAssist<T, Device>::need_subspace,
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_NMAX,
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR,
true);
hsolver_pw_obj.solve(this->p_hamilt,
this->kspw_psi[0],
this->pelec,
this->pelec->ekb.c,
is_occupied,
PARAM.inp.ks_solver,
PARAM.inp.calculation,
PARAM.inp.basis_type,
PARAM.inp.use_paw,
GlobalV::use_uspp,
GlobalV::RANK_IN_POOL,
GlobalV::NPROC_IN_POOL,
hsolver::DiagoIterAssist<T, Device>::SCF_ITER,
hsolver::DiagoIterAssist<T, Device>::need_subspace,
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_NMAX,
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR,
true);

this->init_psi = true;

// } else {
// ModuleBase::WARNING_QUIT("ESolver_KS_PW",
// "HSolver has not been initialed!");
// }
this->init_psi = true;
}

template class ESolver_KS_PW<std::complex<float>, base_device::DEVICE_CPU>;
Expand Down
3 changes: 0 additions & 3 deletions source/module_esolver/pw_init_after_vc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ void ESolver_KS_PW<T, Device>::init_after_vc(const Input_para& inp, UnitCell& uc
this->pw_wfc->collect_local_pw(inp.erf_ecut,
inp.erf_height,
inp.erf_sigma);

// delete this->phsol;
this->init_psi = false;
// this->allocate_hsolver();

delete this->pelec;
this->pelec
Expand Down

0 comments on commit cab05db

Please sign in to comment.