Skip to content

Commit

Permalink
fix: init exd/exc in begin_all_runners rather than beforescf
Browse files Browse the repository at this point in the history
  • Loading branch information
maki49 committed Jul 13, 2024
1 parent 796c911 commit 148c76b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
24 changes: 14 additions & 10 deletions source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,18 @@ void ESolver_KS_LCAO<TK, TR>::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<Exx_LRI<double>>(GlobalC::exx_info.info_ri);
this->exd = std::make_shared<Exx_LRI_Interface<TK, double>>(exx_lri_double);
}
else
{
this->exx_lri_complex = std::make_shared<Exx_LRI<std::complex<double>>>(GlobalC::exx_info.info_ri);
this->exc = std::make_shared<Exx_LRI_Interface<TK, std::complex<double>>>(exx_lri_complex);
}
// 7) initialize exx
// PLEASE simplify the Exx_Global interface
if (GlobalV::CALCULATION == "scf" || GlobalV::CALCULATION == "relax"
Expand All @@ -173,16 +185,8 @@ void ESolver_KS_LCAO<TK, TR>::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<Exx_LRI<double>>(GlobalC::exx_info.info_ri);
this->exx_lri_double->init(MPI_COMM_WORLD, this->kv);
}
else
{
this->exx_lri_complex = std::make_shared<Exx_LRI<std::complex<double>>>(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
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_ks_lcao_elec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,10 @@ void ESolver_KS_LCAO<TK, TR>::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_Interface<TK, double>>(exx_lri_double);
this->exd->exx_beforescf(this->kv, *this->p_chgmix);
}
else
{
this->exc = std::make_shared<Exx_LRI_Interface<TK, std::complex<double>>>(exx_lri_complex);
this->exc->exx_beforescf(this->kv, *this->p_chgmix);
}
#endif // __EXX
Expand Down
6 changes: 3 additions & 3 deletions source/module_ri/Exx_LRI_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const K_Vectors& kv, const Charg
this->mix_DMk_2D.set_mixing(nullptr);
} else {
this->mix_DMk_2D.set_mixing(chgmix.get_mixing());
}
}
// for exx two_level scf
this->two_level_step = 0;
}
// for exx two_level scf
this->two_level_step = 0;
#endif // __MPI
}

Expand Down

0 comments on commit 148c76b

Please sign in to comment.