From b355fcf130612417cecf7c33bb6bfd392357c9be Mon Sep 17 00:00:00 2001 From: maki49 <1579492865@qq.com> Date: Sat, 13 Jul 2024 13:46:45 +0800 Subject: [PATCH] fix: init exd/exc in begin_all_runners rather than beforescf --- source/module_esolver/esolver_ks_lcao.cpp | 24 +++++++++++-------- .../module_esolver/esolver_ks_lcao_elec.cpp | 2 -- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/source/module_esolver/esolver_ks_lcao.cpp b/source/module_esolver/esolver_ks_lcao.cpp index f1acab2934..c811ba773e 100644 --- a/source/module_esolver/esolver_ks_lcao.cpp +++ b/source/module_esolver/esolver_ks_lcao.cpp @@ -163,6 +163,18 @@ void ESolver_KS_LCAO::before_all_runners(Input& inp, UnitCell& ucell) LCAO_domain::divide_HS_in_frag(GlobalV::GAMMA_ONLY_LOCAL, ParaV, this->kv.get_nks()); #ifdef __EXX + // always construct but only initialize when cal_exx + // because some members like two_level_step are used outside if(cal_exx) + if (GlobalC::exx_info.info_ri.real_number) + { + this->exx_lri_double = std::make_shared>(GlobalC::exx_info.info_ri); + this->exd = std::make_shared>(exx_lri_double); + } + else + { + this->exx_lri_complex = std::make_shared>>(GlobalC::exx_info.info_ri); + this->exc = std::make_shared>>(exx_lri_complex); + } // 7) initialize exx // PLEASE simplify the Exx_Global interface if (GlobalV::CALCULATION == "scf" || GlobalV::CALCULATION == "relax" @@ -173,16 +185,8 @@ void ESolver_KS_LCAO::before_all_runners(Input& inp, UnitCell& ucell) { XC_Functional::set_xc_first_loop(ucell); // initialize 2-center radial tables for EXX-LRI - if (GlobalC::exx_info.info_ri.real_number) - { - this->exx_lri_double = std::make_shared>(GlobalC::exx_info.info_ri); - this->exx_lri_double->init(MPI_COMM_WORLD, this->kv); - } - else - { - this->exx_lri_complex = std::make_shared>>(GlobalC::exx_info.info_ri); - this->exx_lri_complex->init(MPI_COMM_WORLD, this->kv); - } + if (GlobalC::exx_info.info_ri.real_number) { this->exx_lri_double->init(MPI_COMM_WORLD, this->kv); } + else { this->exx_lri_complex->init(MPI_COMM_WORLD, this->kv); } } } #endif diff --git a/source/module_esolver/esolver_ks_lcao_elec.cpp b/source/module_esolver/esolver_ks_lcao_elec.cpp index 0bed54ff71..3699a53c7a 100644 --- a/source/module_esolver/esolver_ks_lcao_elec.cpp +++ b/source/module_esolver/esolver_ks_lcao_elec.cpp @@ -284,12 +284,10 @@ void ESolver_KS_LCAO::before_scf(const int istep) #ifdef __EXX // set xc type before the first cal of xc in pelec->init_scf if (GlobalC::exx_info.info_ri.real_number) { - this->exd = std::make_shared>(exx_lri_double); this->exd->exx_beforescf(this->kv, *this->p_chgmix); } else { - this->exc = std::make_shared>>(exx_lri_complex); this->exc->exx_beforescf(this->kv, *this->p_chgmix); } #endif // __EXX