Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
{
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
}
GlobalV::ofs_running<<XC_Functional::output_info()<<std::endl;
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SETUP UNITCELL");

//! 4) setup the charge mixing parameters
Expand Down
67 changes: 60 additions & 7 deletions source/module_hamilt_general/module_xc/xc_functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,37 @@ int XC_Functional::get_func_type()
{
return func_type;
}

void XC_Functional::set_xc_first_loop(const UnitCell& ucell)
{
ModuleBase::TITLE("XC_Functional", "set_xc_first_loop");
/** 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 == "HSE"
|| ucell.atoms[0].ncpp.xc_func == "PBE0"|| ucell.atoms[0].ncpp.xc_func == "LC_PBE"
|| ucell.atoms[0].ncpp.xc_func == "LC_WPBE" || ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH"
|| ucell.atoms[0].ncpp.xc_func == "CAM_PBEH") {
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");
else if ( ucell.atoms[0].ncpp.xc_func == "LC_PBE" || ucell.atoms[0].ncpp.xc_func == "LC_WPBE"
|| ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH" || ucell.atoms[0].ncpp.xc_func == "CAM_PBEH" )
{
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP") {
// added by jghan, 2024-07-07
else if ( ucell.atoms[0].ncpp.xc_func == "MULLER" || ucell.atoms[0].ncpp.xc_func == "POWER"
|| ucell.atoms[0].ncpp.xc_func == "WP22" || ucell.atoms[0].ncpp.xc_func == "CWP22" )
{
XC_Functional::set_xc_type("pbe");
}
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP")
{
XC_Functional::set_xc_type("blyp");
}
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
Expand Down Expand Up @@ -346,4 +359,44 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
use_libxc = false;
#endif

}


std::string XC_Functional::output_info()
{
#ifdef USE_LIBXC
if(use_libxc)
{
std::stringstream ss;
ss<<" Libxc v"<<xc_version_string()<<std::endl;
ss<<"\t"<<xc_reference()<<std::endl;

std::vector<xc_func_type> funcs = XC_Functional_Libxc::init_func(func_id, XC_UNPOLARIZED);
for(const auto &func : funcs)
{
const xc_func_info_type *info = xc_func_get_info(&func);
ss<<" XC: "<<xc_func_info_get_name(info)<<std::endl;
for(int i=0; i<XC_MAX_REFERENCES; ++i)
{
const func_reference_type *ref = xc_func_info_get_references(func.info, i);
if(ref)
ss<<"\t"<<xc_func_reference_get_ref(ref)<<std::endl;
}
}
XC_Functional_Libxc::finish_func(funcs);
return ss.str();
}
else
{
std::string s = " XC:\t";
for(const auto &id: func_id)
s += std::string(xc_functional_get_name(id))+"\t";
return s;
}
#else
std::string s = " XC:\t";
for(const auto &id: func_id)
s += std::to_string(id)+"\t";
return s;
#endif
}
1 change: 1 addition & 0 deletions source/module_hamilt_general/module_xc/xc_functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class XC_Functional

public:
static std::vector<int> get_func_id() { return func_id; }
static std::string output_info();

//-------------------
// xc_functional_wrapper_xc.cpp
Expand Down
15 changes: 1 addition & 14 deletions source/module_ri/Exx_LRI_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,7 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
}
else
{
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");
}
// added by jghan, 2024-07-07
else if ( ucell.atoms[0].ncpp.xc_func == "MULLER" || ucell.atoms[0].ncpp.xc_func == "POWER"
|| ucell.atoms[0].ncpp.xc_func == "WP22" || ucell.atoms[0].ncpp.xc_func == "CWP22" )
{
XC_Functional::set_xc_type("pbe");
}
XC_Functional::set_xc_first_loop(ucell);
}

this->cal_exx_ions(ucell,PARAM.inp.out_ri_cv);
Expand Down
Loading