Skip to content

Commit 5f761c7

Browse files
committed
Feature: add xc output info
1 parent e98850a commit 5f761c7

File tree

4 files changed

+63
-21
lines changed

4 files changed

+63
-21
lines changed

source/module_esolver/esolver_ks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ void ESolver_KS<T, Device>::before_all_runners(UnitCell& ucell, const Input_para
185185
{
186186
XC_Functional::set_xc_type(ucell.atoms[0].ncpp.xc_func);
187187
}
188+
GlobalV::ofs_running<<XC_Functional::output_info()<<std::endl;
188189
ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SETUP UNITCELL");
189190

190191
//! 4) setup the charge mixing parameters

source/module_hamilt_general/module_xc/xc_functional.cpp

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,37 @@ int XC_Functional::get_func_type()
3434
{
3535
return func_type;
3636
}
37+
3738
void XC_Functional::set_xc_first_loop(const UnitCell& ucell)
3839
{
40+
ModuleBase::TITLE("XC_Functional", "set_xc_first_loop");
3941
/** In the special "two-level" calculation case,
4042
the first scf iteration only calculate the functional without exact
4143
exchange. but in "nscf" calculation, there is no need of "two-level"
4244
method. */
43-
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "HSE"
44-
|| ucell.atoms[0].ncpp.xc_func == "PBE0"|| ucell.atoms[0].ncpp.xc_func == "LC_PBE"
45-
|| ucell.atoms[0].ncpp.xc_func == "LC_WPBE" || ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH"
46-
|| ucell.atoms[0].ncpp.xc_func == "CAM_PBEH") {
45+
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "PBE0" || ucell.atoms[0].ncpp.xc_func == "HSE")
46+
{
4747
XC_Functional::set_xc_type("pbe");
4848
}
49-
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0") {
50-
XC_Functional::set_xc_type("scan");
49+
else if ( ucell.atoms[0].ncpp.xc_func == "LC_PBE" || ucell.atoms[0].ncpp.xc_func == "LC_WPBE"
50+
|| ucell.atoms[0].ncpp.xc_func == "LRC_WPBEH" || ucell.atoms[0].ncpp.xc_func == "CAM_PBEH" )
51+
{
52+
XC_Functional::set_xc_type("pbe");
5153
}
52-
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP") {
54+
// added by jghan, 2024-07-07
55+
else if ( ucell.atoms[0].ncpp.xc_func == "MULLER" || ucell.atoms[0].ncpp.xc_func == "POWER"
56+
|| ucell.atoms[0].ncpp.xc_func == "WP22" || ucell.atoms[0].ncpp.xc_func == "CWP22" )
57+
{
58+
XC_Functional::set_xc_type("pbe");
59+
}
60+
else if (ucell.atoms[0].ncpp.xc_func == "B3LYP")
61+
{
5362
XC_Functional::set_xc_type("blyp");
5463
}
64+
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0")
65+
{
66+
XC_Functional::set_xc_type("scan");
67+
}
5568
}
5669

5770
// The setting values of functional id according to the index in LIBXC
@@ -346,4 +359,44 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
346359
use_libxc = false;
347360
#endif
348361

362+
}
363+
364+
365+
std::string XC_Functional::output_info()
366+
{
367+
#ifdef USE_LIBXC
368+
if(use_libxc)
369+
{
370+
std::stringstream ss;
371+
ss<<" Libxc v"<<xc_version_string()<<std::endl;
372+
ss<<"\t"<<xc_reference()<<std::endl;
373+
374+
std::vector<xc_func_type> funcs = XC_Functional_Libxc::init_func(func_id, XC_UNPOLARIZED);
375+
for(const auto &func : funcs)
376+
{
377+
const xc_func_info_type *info = xc_func_get_info(&func);
378+
ss<<" XC: "<<xc_func_info_get_name(info)<<std::endl;
379+
for(int i=0; i<XC_MAX_REFERENCES; ++i)
380+
{
381+
const func_reference_type *ref = xc_func_info_get_references(func.info, i);
382+
if(ref)
383+
ss<<"\t"<<xc_func_reference_get_ref(ref)<<std::endl;
384+
}
385+
}
386+
XC_Functional_Libxc::finish_func(funcs);
387+
return ss.str();
388+
}
389+
else
390+
{
391+
std::string s = " XC:\t";
392+
for(const auto &id: func_id)
393+
s += std::string(xc_functional_get_name(id))+"\t";
394+
return s;
395+
}
396+
#else
397+
std::string s = " XC:\t";
398+
for(const auto &id: func_id)
399+
s += std::to_string(id)+"\t";
400+
return s;
401+
#endif
349402
}

source/module_hamilt_general/module_xc/xc_functional.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class XC_Functional
8888

8989
public:
9090
static std::vector<int> get_func_id() { return func_id; }
91+
static std::string output_info();
9192

9293
//-------------------
9394
// xc_functional_wrapper_xc.cpp

source/module_ri/Exx_LRI_interface.hpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,7 @@ void Exx_LRI_Interface<T, Tdata>::exx_beforescf(const int istep,
147147
}
148148
else
149149
{
150-
if (ucell.atoms[0].ncpp.xc_func == "HF" || ucell.atoms[0].ncpp.xc_func == "PBE0" || ucell.atoms[0].ncpp.xc_func == "HSE")
151-
{
152-
XC_Functional::set_xc_type("pbe");
153-
}
154-
else if (ucell.atoms[0].ncpp.xc_func == "SCAN0")
155-
{
156-
XC_Functional::set_xc_type("scan");
157-
}
158-
// added by jghan, 2024-07-07
159-
else if ( ucell.atoms[0].ncpp.xc_func == "MULLER" || ucell.atoms[0].ncpp.xc_func == "POWER"
160-
|| ucell.atoms[0].ncpp.xc_func == "WP22" || ucell.atoms[0].ncpp.xc_func == "CWP22" )
161-
{
162-
XC_Functional::set_xc_type("pbe");
163-
}
150+
XC_Functional::set_xc_first_loop(ucell);
164151
}
165152

166153
this->cal_exx_ions(ucell,PARAM.inp.out_ri_cv);

0 commit comments

Comments
 (0)