Skip to content

Commit 802d141

Browse files
committed
merge to abacus-v3.8.0 and add scaling_factor in libxc_cpp files
1 parent 5778743 commit 802d141

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

source/module_hamilt_general/module_xc/xc_functional.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
220220
}
221221
else if( xc_func == "CWP22")
222222
{
223-
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp & xc_functional_libxc_tools.cpp
223+
// BLYP_XC_lr = -BLYP_XC_sr + BLYP_XC, the realization of it is in v_xc_libxc() function, xc_functional_libxc_vxc.cpp
224224
func_id.push_back(XC_GGA_X_ITYH); // short-range of B88_X, id=529
225225
func_id.push_back(XC_GGA_C_LYPR); // short-range of LYP_C, id=624
226226
func_id.push_back(XC_GGA_X_B88); // complete B88_X, id=106
@@ -231,7 +231,7 @@ void XC_Functional::set_xc_type(const std::string xc_func_in)
231231
// scaling_factor_xc.push_back(-1.0);
232232
// scaling_factor_xc.push_back(1.0);
233233
// scaling_factor_xc.push_back(1.0);
234-
234+
235235
//
236236
scaling_factor_xc[XC_GGA_X_ITYH] = -1.0;
237237
scaling_factor_xc[XC_GGA_C_LYPR] = -1.0;

source/module_hamilt_general/module_xc/xc_functional_libxc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ namespace XC_Functional_Libxc
3838
const int &nrxx, // number of real-space grid
3939
const double &omega, // volume of cell
4040
const double tpiba,
41-
const Charge* const chr); // charge density
41+
const Charge* const chr, // charge density
42+
const std::map<xc_func_type, double>* scaling_factor = nullptr); // added by jghan, 2024-10-10
4243

4344
// for mGGA functional
4445
extern std::tuple<double,double,ModuleBase::matrix,ModuleBase::matrix> v_xc_meta(

source/module_hamilt_general/module_xc/xc_functional_libxc_vxc.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional_Libxc::v_xc_libxc( /
1818
const int &nrxx, // number of real-space grid
1919
const double &omega, // volume of cell
2020
const double tpiba,
21-
const Charge* const chr)
21+
const Charge* const chr,
22+
const std::map<xc_func_type, double>* scaling_factor)
2223
{
2324
ModuleBase::TITLE("XC_Functional_Libxc","v_xc_libxc");
2425
ModuleBase::timer::tick("XC_Functional_Libxc","v_xc_libxc");
@@ -109,14 +110,24 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional_Libxc::v_xc_libxc( /
109110
break;
110111
}
111112

112-
etxc += XC_Functional_Libxc::convert_etxc(nspin, nrxx, sgn, rho, exc);
113+
// added by jghan, 2024-10-10
114+
double factor = 1.0;
115+
if( scaling_factor == nullptr ) ;
116+
else
117+
{
118+
auto pair_factor = scaling_factor->find(func);
119+
if( pair_factor != scaling_factor->end() ) factor = pair_factor->second;
120+
}
121+
122+
// time factor is added by jghan, 2024-10-10
123+
etxc += XC_Functional_Libxc::convert_etxc(nspin, nrxx, sgn, rho, exc) * factor;
113124
const std::pair<double,ModuleBase::matrix> vtxc_v = XC_Functional_Libxc::convert_vtxc_v(
114125
func, nspin, nrxx,
115126
sgn, rho, gdr,
116127
vrho, vsigma,
117128
tpiba, chr);
118-
vtxc += std::get<0>(vtxc_v);
119-
v += std::get<1>(vtxc_v);
129+
vtxc += std::get<0>(vtxc_v) * factor;
130+
v += std::get<1>(vtxc_v) * factor;
120131
} // end for( xc_func_type &func : funcs )
121132

122133
if(4==PARAM.inp.nspin)

source/module_hamilt_general/module_xc/xc_functional_vxc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::tuple<double,double,ModuleBase::matrix> XC_Functional::v_xc(
2525
if(use_libxc)
2626
{
2727
#ifdef USE_LIBXC
28-
return XC_Functional_Libxc::v_xc_libxc(XC_Functional::get_func_id(), nrxx, ucell->omega, ucell->tpiba, chr);
28+
return XC_Functional_Libxc::v_xc_libxc(XC_Functional::get_func_id(), nrxx, ucell->omega, ucell->tpiba, chr, &(this->scaling_factor_xc));
2929
#else
3030
ModuleBase::WARNING_QUIT("v_xc","compile with LIBXC");
3131
#endif

0 commit comments

Comments
 (0)