Skip to content

Commit 535c7f9

Browse files
authored
Fix: disable the XC in LibXC in which nonlocal dispersion correction is required (#5391)
* fix * special programming for wb97 famiy
1 parent e5768ec commit 535c7f9

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

source/module_hamilt_general/module_xc/xc_functional_libxc.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#endif
1010

1111
#include <xc.h>
12-
1312
#include <vector>
1413
bool xc_with_laplacian(const std::string& xc_func_in)
1514
{
@@ -27,6 +26,41 @@ bool xc_with_laplacian(const std::string& xc_func_in)
2726
return false;
2827
}
2928

29+
std::string _uppercase(const std::string& str)
30+
{
31+
std::string result = str;
32+
std::transform(result.begin(), result.end(), result.begin(), ::toupper);
33+
return result;
34+
}
35+
36+
bool not_supported_xc_with_nonlocal_vdw(const std::string& xc_func_in)
37+
{
38+
const std::string xc_func = _uppercase(xc_func_in);
39+
if(xc_func.find("VDW") != std::string::npos) { return true; }
40+
/* known excluded: GGA_X_OPTB86B_VDW, GGA_X_OPTB88_VDW, GGA_X_OPTPBE_VDW, GGA_X_PBEK1_VDW */
41+
42+
if(xc_func.find("VV10") != std::string::npos) { return true; }
43+
/* known excluded: GGA_XC_VV10, HYB_GGA_XC_LC_VV10, MGGA_C_REVSCAN_VV10, MGGA_C_SCAN_VV10,
44+
MGGA_C_SCANL_VV10, MGGA_XC_VCML_RVV10 */
45+
46+
const std::vector<std::string> not_supported = {"C09X", "VCML", "HYB_MGGA_XC_WB97M_V", "MGGA_XC_B97M_V"};
47+
for(const std::string& str : not_supported)
48+
{
49+
if(xc_func.find(str) != std::string::npos) { return true; }
50+
}
51+
/* known excluded: GGA_X_C09X, MGGA_X_VCML, HYB_MGGA_XC_WB97M_V, MGGA_XC_B97M_V */
52+
53+
/* There is also a functional not quite sure: HYB_GGA_XC_WB97X_V */
54+
if(xc_func.find("HYB_GGA_XC_WB97X_V") != std::string::npos)
55+
{
56+
std::cout << " WARNING: range-seperated XC omega-B97 family with nonlocal correction term is used.\n"
57+
<< " if you are not planning to use these functionals like wB97X-D3BJ that:\n"
58+
<< " XC_GGA_XC_WB97X_V with specified D3BJ DFT-D3 parameters, this is not what\n"
59+
<< " you want." << std::endl;
60+
}
61+
return false;
62+
}
63+
3064
std::pair<int,std::vector<int>> XC_Functional_Libxc::set_xc_type_libxc(std::string xc_func_in)
3165
{
3266
// determine the type (lda/gga/mgga)
@@ -36,6 +70,8 @@ std::pair<int,std::vector<int>> XC_Functional_Libxc::set_xc_type_libxc(std::stri
3670
"XC Functional involving Laplacian of rho is not implemented.");
3771
}
3872
int func_type; //0:none, 1:lda, 2:gga, 3:mgga, 4:hybrid lda/gga, 5:hybrid mgga
73+
if(not_supported_xc_with_nonlocal_vdw(xc_func_in))
74+
{ ModuleBase::WARNING_QUIT("XC_Functional::set_xc_type_libxc","functionals with non-local dispersion are not supported."); }
3975
func_type = 1;
4076
if(xc_func_in.find("GGA") != std::string::npos) { func_type = 2; }
4177
if(xc_func_in.find("MGGA") != std::string::npos) { func_type = 3; }

0 commit comments

Comments
 (0)