Skip to content

Commit 269f43d

Browse files
committed
Feature: add xc output info
1 parent e98850a commit 269f43d

File tree

4 files changed

+64
-21
lines changed

4 files changed

+64
-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: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,44 @@ 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
5871
// for detail, refer to https://www.tddft.org/programs/libxc/functionals/
5972
void XC_Functional::set_xc_type(const std::string xc_func_in)
6073
{
74+
ModuleBase::TITLE("XC_Functional", "set_xc_type");
6175
//Note : due to the separation of gcx_spin and gcc_spin,
6276
//when you are adding new GGA functionals,
6377
//please put exchange first, followed by correlation,
@@ -346,4 +360,44 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
346360
use_libxc = false;
347361
#endif
348362

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

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)