Skip to content

Commit

Permalink
move set_xc_first_loop to XC_Functional
Browse files Browse the repository at this point in the history
  • Loading branch information
maki49 committed Jul 11, 2024
1 parent f88bd06 commit 90fdedb
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
17 changes: 0 additions & 17 deletions source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,23 +849,6 @@ ModuleIO::Output_Potential ESolver_KS<T, Device>::create_Output_Potential(int it
//! the 16th-20th functions of ESolver_KS
//! mohan add 2024-05-12
//------------------------------------------------------------------------------
template <typename T, typename Device>
void ESolver_KS<T, Device>::set_xc_first_loop(const UnitCell& ucell)
{
/** In the special "two-level" calculation case,
the first scf iteration only calculate the functional without exact
exchange. but in "nscf" calculation, there is no need of "two-level"
method. */
if (ucell.atoms[0].ncpp.xc_func == "HF"
|| ucell.atoms[0].ncpp.xc_func == "PBE0"
|| ucell.atoms[0].ncpp.xc_func == "HSE") {
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0") {
XC_Functional::set_xc_type("scan");
}
}

//! This is for mixed-precision pw/LCAO basis sets.
template class ESolver_KS<std::complex<float>, base_device::DEVICE_CPU>;
template class ESolver_KS<std::complex<double>, base_device::DEVICE_CPU>;
Expand Down
2 changes: 0 additions & 2 deletions source/module_esolver/esolver_ks.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ class ESolver_KS : public ESolver_FP
std::string basisname; //PW or LCAO

void print_wfcfft(Input& inp, std::ofstream& ofs);

virtual void set_xc_first_loop(const UnitCell& ucell);
};
} // end of namespace
#endif
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void ESolver_KS_LCAO<TK, TR>::before_all_runners(Input& inp, UnitCell& ucell)
|| GlobalV::CALCULATION == "cell-relax"
|| GlobalV::CALCULATION == "md") {
if (GlobalC::exx_info.info_global.cal_exx) {
this->set_xc_first_loop(ucell);
XC_Functional::set_xc_first_loop(ucell);
if (GlobalC::exx_info.info_ri.real_number) {
this->exx_lri_double->init(MPI_COMM_WORLD, this->kv);
}
Expand Down
2 changes: 1 addition & 1 deletion source/module_esolver/esolver_ks_lcaopw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace ModuleESolver
|| GlobalV::CALCULATION == "md")
if (GlobalC::exx_info.info_global.cal_exx)
{
this->set_xc_first_loop(cell);
XC_Functional::set_xc_first_loop(cell);
this->exx_lip = std::unique_ptr<Exx_Lip<T>>(new Exx_Lip<T>(GlobalC::exx_info.info_lip,
cell.symm, &this->kv, this->p_wf_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec));
// this->exx_lip.init(GlobalC::exx_info.info_lip, cell.symm, &this->kv, this->p_wf_init, this->kspw_psi, this->pw_wfc, this->pw_rho, this->sf, &cell, this->pelec);
Expand Down
15 changes: 15 additions & 0 deletions source/module_hamilt_general/module_xc/xc_functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ int XC_Functional::get_func_type()
{
return func_type;
}
void XC_Functional::set_xc_first_loop(const UnitCell& ucell)
{
/** In the special "two-level" calculation case,
the first scf iteration only calculate the functional without exact
exchange. but in "nscf" calculation, there is no need of "two-level"
method. */
if (ucell.atoms[0].ncpp.xc_func == "HF"
|| ucell.atoms[0].ncpp.xc_func == "PBE0"
|| ucell.atoms[0].ncpp.xc_func == "HSE") {
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0") {
XC_Functional::set_xc_type("scan");
}
}

// The setting values of functional id according to the index in LIBXC
// for detail, refer to https://www.tddft.org/programs/libxc/functionals/
Expand Down
8 changes: 6 additions & 2 deletions source/module_hamilt_general/module_xc/xc_functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,12 @@ class XC_Functional
// 4. init_func : which converts func_id into corresponding xc_func_type vector

static int get_func_type();
static void set_xc_type(const std::string xc_func_in);
static void get_hybrid_alpha(const double alpha_in);
static void set_xc_type(const std::string xc_func_in);

// For hybrid functional
static void get_hybrid_alpha(const double alpha_in);
/// Usually in exx caculation, the first SCF loop should be converged with PBE
static void set_xc_first_loop(const UnitCell& ucell);
#ifdef USE_LIBXC
static void set_xc_type_libxc(const std::string xc_func_in);
static std::vector<xc_func_type> init_func(const int xc_polarized);
Expand Down

0 comments on commit 90fdedb

Please sign in to comment.