From 0f3c0b4429d79231693460a64654ba24f24fe66a Mon Sep 17 00:00:00 2001 From: YuLiu98 Date: Mon, 25 Nov 2024 11:00:15 +0800 Subject: [PATCH] Refactor: remove template for get_S --- source/module_esolver/esolver.cpp | 6 +- source/module_esolver/esolver_gets.cpp | 81 +++++--------------------- source/module_esolver/esolver_gets.h | 4 +- 3 files changed, 18 insertions(+), 73 deletions(-) diff --git a/source/module_esolver/esolver.cpp b/source/module_esolver/esolver.cpp index 86cb82c38b..d865cfdbb2 100644 --- a/source/module_esolver/esolver.cpp +++ b/source/module_esolver/esolver.cpp @@ -191,7 +191,7 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) { if (PARAM.inp.calculation == "get_S") { - return new ESolver_GetS(); + ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for gamma_only"); } else { @@ -202,7 +202,7 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) { if (PARAM.inp.calculation == "get_S") { - return new ESolver_GetS, double>(); + return new ESolver_GetS(); } else { @@ -213,7 +213,7 @@ ESolver* init_esolver(const Input_para& inp, UnitCell& ucell) { if (PARAM.inp.calculation == "get_S") { - return new ESolver_GetS, std::complex>(); + ModuleBase::WARNING_QUIT("ESolver", "get_S is not implemented for npsin=4"); } else { diff --git a/source/module_esolver/esolver_gets.cpp b/source/module_esolver/esolver_gets.cpp index 60bfb983d3..059b58cd4a 100644 --- a/source/module_esolver/esolver_gets.cpp +++ b/source/module_esolver/esolver_gets.cpp @@ -12,20 +12,17 @@ namespace ModuleESolver { -template -ESolver_GetS::ESolver_GetS() +ESolver_GetS::ESolver_GetS() { this->classname = "ESolver_GetS"; this->basisname = "LCAO"; } -template -ESolver_GetS::~ESolver_GetS() +ESolver_GetS::~ESolver_GetS() { } -template -void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp) +void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp) { ModuleBase::TITLE("ESolver_GetS", "before_all_runners"); ModuleBase::timer::tick("ESolver_GetS", "before_all_runners"); @@ -51,13 +48,13 @@ void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& if (this->pelec == nullptr) { // TK stands for double and complex? - this->pelec = new elecstate::ElecStateLCAO(&(this->chr), // use which parameter? - &(this->kv), - this->kv.get_nks(), - &(this->GG), // mohan add 2024-04-01 - &(this->GK), // mohan add 2024-04-01 - this->pw_rho, - this->pw_big); + this->pelec = new elecstate::ElecStateLCAO>(&(this->chr), // use which parameter? + &(this->kv), + this->kv.get_nks(), + &(this->GG), // mohan add 2024-04-01 + &(this->GK), // mohan add 2024-04-01 + this->pw_rho, + this->pw_big); } // 3) init LCAO basis @@ -76,61 +73,13 @@ void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& // 4) initialize the density matrix // DensityMatrix is allocated here, DMK is also initialized here // DMR is not initialized here, it will be constructed in each before_scf - dynamic_cast*>(this->pelec)->init_DM(&this->kv, &(this->pv), inp.nspin); + dynamic_cast>*>(this->pelec) + ->init_DM(&this->kv, &(this->pv), inp.nspin); ModuleBase::timer::tick("ESolver_GetS", "before_all_runners"); } -template <> -void ESolver_GetS::runner(UnitCell& ucell, const int istep) -{ - ModuleBase::TITLE("ESolver_GetS", "runner"); - ModuleBase::WARNING_QUIT("ESolver_GetS::runner", "not implemented"); -} - -template <> -void ESolver_GetS, std::complex>::runner(UnitCell& ucell, const int istep) -{ - ModuleBase::TITLE("ESolver_GetS", "runner"); - ModuleBase::timer::tick("ESolver_GetS", "runner"); - - // (1) Find adjacent atoms for each atom. - double search_radius = -1.0; - search_radius = atom_arrange::set_sr_NL(GlobalV::ofs_running, - PARAM.inp.out_level, - orb_.get_rcutmax_Phi(), - ucell.infoNL.get_rcutmax_Beta(), - PARAM.globalv.gamma_only_local); - - atom_arrange::search(PARAM.inp.search_pbc, - GlobalV::ofs_running, - GlobalC::GridD, - ucell, - search_radius, - PARAM.inp.test_atom_input); - - this->RA.for_2d(this->pv, PARAM.globalv.gamma_only_local, orb_.cutoffs()); - - if (this->p_hamilt == nullptr) - { - this->p_hamilt - = new hamilt::HamiltLCAO, std::complex>(&this->pv, - this->kv, - *(two_center_bundle_.overlap_orb), - orb_.cutoffs()); - dynamic_cast, std::complex>*>(this->p_hamilt->ops) - ->contributeHR(); - } - - const std::string fn = PARAM.globalv.global_out_dir + "SR.csr"; - std::cout << " The file is saved in " << fn << std::endl; - ModuleIO::output_SR(pv, GlobalC::GridD, this->p_hamilt, fn); - - ModuleBase::timer::tick("ESolver_GetS", "runner"); -} - -template <> -void ESolver_GetS, double>::runner(UnitCell& ucell, const int istep) +void ESolver_GetS::runner(UnitCell& ucell, const int istep) { ModuleBase::TITLE("ESolver_GetS", "runner"); ModuleBase::timer::tick("ESolver_GetS", "runner"); @@ -168,8 +117,4 @@ void ESolver_GetS, double>::runner(UnitCell& ucell, const i ModuleBase::timer::tick("ESolver_GetS", "runner"); } -template class ESolver_GetS; -template class ESolver_GetS, double>; -template class ESolver_GetS, std::complex>; - } // namespace ModuleESolver diff --git a/source/module_esolver/esolver_gets.h b/source/module_esolver/esolver_gets.h index 79cc012f29..8185f7b061 100644 --- a/source/module_esolver/esolver_gets.h +++ b/source/module_esolver/esolver_gets.h @@ -11,8 +11,8 @@ namespace ModuleESolver { -template -class ESolver_GetS : public ESolver_KS + +class ESolver_GetS : public ESolver_KS> { public: ESolver_GetS();