1+ #ifndef DFTD3_XC_PARAM_H_
2+ #define DFTD3_XC_PARAM_H_
13/* *
4+ * Intro
5+ * -----
26 * This file stores XC dependent DFT-D3 parameters for Grimme-D3
37 * dispersion correction.
48 *
913 * DFT-D3M(0): zero-damping with modified damping function
1014 * DFT-D3M(BJ): Becke-Johnson damping with modified damping function
1115 *
16+ * A detailed introduction of undamped, and BJ damping, the modified
17+ * damping can be found in DFT-D3 software manual, see:
18+ * https://www.chemie.uni-bonn.de/grimme/de/software/dft-d3/man.pdf
19+ *
20+ * Other excellent learning materials (where you can find expression
21+ * of both DFT-D2 and DFT-D3):
22+ * DFT-D2: https://www.vasp.at/wiki/index.php/DFT-D2
23+ * DFT-D3: https://www.vasp.at/wiki/index.php/DFT-D3
24+ *
1225 * Usage
1326 * -----
1427 * call function DFTD3::search(xc, method, param) to get the DFT-D3 parameters
1528 * for the given XC functional. The obtained param should be a std::vector<double>,
1629 * in which the first 9 elements are the DFT-D3 parameters:
1730 * 's6', 'sr6', 'a1', 's8', 'sr8', 'a2', 's9', 'alp', 'bet'
1831 *
19- * Fall-back
20- * ---------
21- * If the DFT-D3 parameters are not found:
32+ * ParamNotFoundError
33+ * ------------------
34+ * If the requested D3 parameters of XC are not found, then the ABACUS will
35+ * WARNING_QUIT with the message "DFT-D3 parameters for XC not found".
36+ *
37+ * Other dispersion correction
38+ * ---------------------------
39+ * there are other kinds of dispersion correction, such as the xc VV09, VV10,
40+ * and rVV10, and the vdw-DF family nonlocal dispersion correction. They will
41+ * be mixed directly with the correlation and exchange part, which act
42+ * differently from the DFT-D2 and D3 methods.
2243 *
23- * DFT-D3M(BJ) -> DFT-D3(BJ) -> PBE-D3(BJ)
24- * DFT-D3M(0) -> DFT-D3(0) -> PBE-D3(0)
44+ * Special: Omega-B97 family
45+ * -------------------------
46+ * (thanks for help and discussion with @hhebrewsnabla and @moolawooda)
47+ * wB97 XC family is special, their DFT-D3 supports are quite complicated.
48+ *
49+ * wB97 long-range exx with B97
50+ * wB97X wB97 with additional short-range exx
51+ * wB97X-D wB97X_D from libXC with DFTD2, not in DFTD3 framework
52+ * wB97X-D3 wB97X_D3 from libXC with DFTD3(0)
53+ * wB97X-D3(BJ) wB97X_V from libXC with DFTD3(BJ)
54+ * wB97X-V with VV10, not in DFTD3 framework
55+ * wB97M-V with VV10, not in DFTD3 framework
56+ *
57+ * Recommended: http://bbs.keinsci.com/thread-19076-1-1.html
58+ * Related information from Pyscf Github repo:
59+ * https://github.com/pyscf/pyscf/issues/2069
2560 *
26- * Please always look the warnning message to check the fall-back.
2761 */
28- #ifndef DFTD3_XC_PARAM_H_
29- #define DFTD3_XC_PARAM_H_
3062#include < map>
3163#include < string>
3264#include < vector>
@@ -42,7 +74,7 @@ namespace DFTD3 {
4274 {" blyp" , {1.0 , 0.4298 , 0.4298 , 2.6996 , 4.2359 , 4.2359 , 1.0 , 14.0 , 0.0 }},
4375 {" revpbe" , {1.0 , 0.5238 , 0.5238 , 2.355 , 3.5016 , 3.5016 , 1.0 , 14.0 , 0.0 }},
4476 {" rpbe" , {1.0 , 0.182 , 0.182 , 0.8318 , 4.0094 , 4.0094 , 1.0 , 14.0 , 0.0 }},
45- {" b97d " , {1.0 , 0.5545 , 0.5545 , 2.2609 , 3.2297 , 3.2297 , 1.0 , 14.0 , 0.0 }},
77+ {" b97_d " , {1.0 , 0.5545 , 0.5545 , 2.2609 , 3.2297 , 3.2297 , 1.0 , 14.0 , 0.0 }},
4678 {" b973c" , {1.0 , 0.37 , 0.37 , 1.5 , 4.1 , 4.1 , 1.0 , 14.0 , 0.0 }},
4779 {" pbe" , {1.0 , 0.4289 , 0.4289 , 0.7875 , 4.4407 , 4.4407 , 1.0 , 14.0 , 0.0 }},
4880 {" rpw86pbe" , {1.0 , 0.4613 , 0.4613 , 1.3845 , 4.5062 , 4.5062 , 1.0 , 14.0 , 0.0 }},
@@ -201,7 +233,7 @@ namespace DFTD3 {
201233 {" blyp" , {1.0 , 1.094 , 1.094 , 1.682 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
202234 {" revpbe" , {1.0 , 0.923 , 0.923 , 1.01 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
203235 {" rpbe" , {1.0 , 0.872 , 0.872 , 0.514 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
204- {" b97d " , {1.0 , 0.892 , 0.892 , 0.909 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
236+ {" b97_d " , {1.0 , 0.892 , 0.892 , 0.909 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
205237 {" b973c" , {1.0 , 1.06 , 1.06 , 1.5 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
206238 {" pbe" , {1.0 , 1.217 , 1.217 , 0.722 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
207239 {" rpw86pbe" , {1.0 , 1.224 , 1.224 , 0.901 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
@@ -238,8 +270,7 @@ namespace DFTD3 {
238270 {" pw1pw" , {1.0 , 1.4968 , 1.4968 , 1.1786 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
239271 {" scan" , {1.0 , 1.324 , 1.324 , 0.0 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
240272 {" wb97x" , {1.0 , 1.281 , 1.281 , 1.0 , 1.094 , 1.094 , 1.0 , 14.0 , 0.0 }},
241- {" wb97xd3" , {1.0 , 1.281 , 1.281 , 1.0 , 1.094 , 1.094 , 1.0 , 14.0 , 0.0 }},
242- // wb97x_d3 is special, thanks for review from @hebrewsnabla
273+ {" wb97x_d3" , {1.0 , 1.281 , 1.281 , 1.0 , 1.094 , 1.094 , 1.0 , 14.0 , 0.0 }},
243274 {" pbehpbe" , {1.0 , 1.5703 , 1.5703 , 1.401 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
244275 {" xlyp" , {1.0 , 0.9384 , 0.9384 , 0.7447 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
245276 {" mpwpw" , {1.0 , 1.3725 , 1.3725 , 1.9467 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
@@ -284,7 +315,7 @@ namespace DFTD3 {
284315 std::map<std::string, std::vector<double >> bjm = {
285316 {" bp" , {1.0 , 0.82185 , 0.82185 , 3.140281 , 2.728151 , 2.728151 , 1.0 , 14.0 , 0.0 }},
286317 {" blyp" , {1.0 , 0.448486 , 0.448486 , 1.875007 , 3.610679 , 3.610679 , 1.0 , 14.0 , 0.0 }},
287- {" b97d " , {1.0 , 0.240184 , 0.240184 , 1.206988 , 3.864426 , 3.864426 , 1.0 , 14.0 , 0.0 }},
318+ {" b97_d " , {1.0 , 0.240184 , 0.240184 , 1.206988 , 3.864426 , 3.864426 , 1.0 , 14.0 , 0.0 }},
288319 {" pbe" , {1.0 , 0.012092 , 0.012092 , 0.35894 , 5.938951 , 5.938951 , 1.0 , 14.0 , 0.0 }},
289320 {" b3lyp" , {1.0 , 0.278672 , 0.278672 , 1.466677 , 4.606311 , 4.606311 , 1.0 , 14.0 , 0.0 }},
290321 {" pbe0" , {1.0 , 0.007912 , 0.007912 , 0.528823 , 6.162326 , 6.162326 , 1.0 , 14.0 , 0.0 }},
@@ -295,7 +326,7 @@ namespace DFTD3 {
295326 std::map<std::string, std::vector<double >> zerom = {
296327 {" bp" , {1.0 , 1.23346 , 1.23346 , 1.945174 , 1.0 , 1.0 , 1.0 , 14.0 , 0.0 }},
297328 {" blyp" , {1.0 , 1.279637 , 1.279637 , 1.841686 , 1.0 , 1.0 , 1.0 , 14.0 , 0.01437 }},
298- {" b97d " , {1.0 , 1.151808 , 1.151808 , 1.020078 , 1.0 , 1.0 , 1.0 , 14.0 , 0.035964 }},
329+ {" b97_d " , {1.0 , 1.151808 , 1.151808 , 1.020078 , 1.0 , 1.0 , 1.0 , 14.0 , 0.035964 }},
299330 {" pbe" , {1.0 , 2.340218 , 2.340218 , 0.0 , 1.0 , 1.0 , 1.0 , 14.0 , 0.129434 }},
300331 {" b3lyp" , {1.0 , 1.338153 , 1.338153 , 1.532981 , 1.0 , 1.0 , 1.0 , 14.0 , 0.013988 }},
301332 {" pbe0" , {1.0 , 2.077949 , 2.077949 , 8.1e-05 , 1.0 , 1.0 , 1.0 , 14.0 , 0.116755 }},
@@ -306,7 +337,7 @@ namespace DFTD3 {
306337 std::map<std::string, std::vector<double >> op = {
307338 {" blyp" , {1.0 , 0.425 , 0.425 , 1.31867 , 3.5 , 3.5 , 1.0 , 14.0 , 2.0 }},
308339 {" revpbe" , {1.0 , 0.6 , 0.6 , 1.44765 , 2.5 , 2.5 , 1.0 , 14.0 , 0.0 }},
309- {" b97d " , {1.0 , 0.6 , 0.6 , 1.46861 , 2.5 , 2.5 , 1.0 , 14.0 , 0.0 }},
340+ {" b97_d " , {1.0 , 0.6 , 0.6 , 1.46861 , 2.5 , 2.5 , 1.0 , 14.0 , 0.0 }},
310341 {" pbe" , {0.91826 , 0.2 , 0.2 , 0.0 , 4.75 , 4.75 , 1.0 , 14.0 , 6.0 }},
311342 {" b3lyp" , {1.0 , 0.3 , 0.3 , 0.78311 , 4.25 , 4.25 , 1.0 , 14.0 , 4.0 }},
312343 {" tpss" , {1.0 , 0.575 , 0.575 , 0.51581 , 3.0 , 3.0 , 1.0 , 14.0 , 8.0 }},
@@ -331,8 +362,8 @@ namespace DFTD3 {
331362 * @param param the dftd3 parameters, ALL_KEYS = {'s6', 'rs6', 'a1', 's8', 'rs8', 'a2', 's9', 'alp', 'bet'}
332363 */
333364 void _search (const std::string& xc,
334- const std::string& method,
335- std::vector<double >& param)
365+ const std::string& method,
366+ std::vector<double >& param)
336367 {
337368 const std::string xc_lowercase = _lowercase (xc);
338369 const std::vector<std::string> allowed_ = { " bj" , " zero" , " bjm" , " zerom" , " op" };
@@ -345,8 +376,8 @@ namespace DFTD3 {
345376 }
346377 else
347378 {
348- std::cout << " WARNING: DFT-D3 (Optimized-Power) parameter for XC ` " << xc << " ` not found, fall back to PBE-D3(0) " << std::endl;
349- _search ( " PBE " , " zero " , param );
379+ ModuleBase::WARNING_QUIT ( " ModuleHamiltGeneral::ModuleVDW::DFTD3::_search " ,
380+ " XC (` " + xc + " `)'s DFT-D3(OP) parameters not found " );
350381 }
351382 }
352383 else if (method == " bjm" )
@@ -357,8 +388,8 @@ namespace DFTD3 {
357388 }
358389 else
359390 {
360- std::cout << " WARNING: DFT-D3M(BJ) parameter for XC ` " << xc << " ` not found, fall back to DFT-D3(BJ) " << std::endl;
361- _search (xc, " bj " , param );
391+ ModuleBase::WARNING_QUIT ( " ModuleHamiltGeneral::ModuleVDW::DFTD3::_search " ,
392+ " XC (` " + xc + " `)'s DFT-D3M(BJ) parameters not found " );
362393 }
363394 }
364395 else if (method == " bj" )
@@ -369,8 +400,8 @@ namespace DFTD3 {
369400 }
370401 else
371402 {
372- std::cout << " WARNING: DFT-D3(BJ) parameter for XC ` " << xc << " ` not found, fall back to DFT-D3(0) " << std::endl;
373- _search ( " pbe " , " bj " , param );
403+ ModuleBase::WARNING_QUIT ( " ModuleHamiltGeneral::ModuleVDW::DFTD3::_search " ,
404+ " XC (` " + xc + " `)'s DFT-D3(BJ) parameters not found " );
374405 }
375406 }
376407 else if (method == " zerom" )
@@ -381,8 +412,8 @@ namespace DFTD3 {
381412 }
382413 else
383414 {
384- std::cout << " WARNING: DFT-D3M(0) parameter for XC ` " << xc << " ` not found, fall back to DFT-D3(0) " << std::endl;
385- _search (xc, " zero " , param );
415+ ModuleBase::WARNING_QUIT ( " ModuleHamiltGeneral::ModuleVDW::DFTD3::_search " ,
416+ " XC (` " + xc + " `)'s DFT-D3M(0) parameters not found " );
386417 }
387418 }
388419 else // zero
@@ -393,8 +424,8 @@ namespace DFTD3 {
393424 }
394425 else
395426 {
396- std::cout << " WARNING: DFT-D3(0) parameter for XC ` " << xc << " ` not found, fall back to PBE-D3(0) " << std::endl;
397- _search ( " PBE " , " zero " , param );
427+ ModuleBase::WARNING_QUIT ( " ModuleHamiltGeneral::ModuleVDW::DFTD3::_search " ,
428+ " XC (` " + xc + " `)'s DFT-D3(0) parameters not found " );
398429 }
399430 }
400431 }
@@ -440,20 +471,13 @@ namespace DFTD3 {
440471 double & a1,
441472 double & a2)
442473 {
443- bool search = true ;
444- const std::vector<std::string> flag = {s6_in, s8_in, a1_in, a2_in};
445474 const std::map<std::string, std::string> param_map = {
446475 {" d3_bj" , " bj" }, {" d3_0" , " zero" }, {" d3_bjm" , " bjm" }, {" d3_0m" , " zerom" },
447476 {" op" , " op" }};
448- for (const auto & f : flag)
449- {
450- if (f != " default" )
451- {
452- search = false ;
453- break ;
454- }
455- }
456- if (!search)
477+
478+ const std::vector<std::string> flag = {s6_in, s8_in, a1_in, a2_in};
479+ const bool autoset = std::any_of (flag.begin (), flag.end (), [](const std::string& s) { return s == " default" ; });
480+ if (!autoset) // all parameters are defined
457481 {
458482 s6 = std::stod (s6_in);
459483 s8 = std::stod (s8_in);
@@ -464,17 +488,22 @@ namespace DFTD3 {
464488 {
465489 std::vector<double > param;
466490 const std::string xc = DFTD3::_xcname (xc_in);
467- std::cout << " VDW: DFTD3 parameters are not provided, search based on XC ("
468- << _uppercase (xc) << " )" << std::endl;
469491 _search (xc, param_map.at (d3method), param);
470- s6 = param[0 ];
471- s8 = param[3 ];
472- a1 = param[1 ];
473- a2 = param[5 ];
492+ s6 = (s6_in == " default" ) ? param[0 ] : std::stod (s6_in);
493+ s8 = (s8_in == " default" ) ? param[3 ] : std::stod (s8_in);
494+ a1 = (a1_in == " default" ) ? param[2 ] : std::stod (a1_in);
495+ a2 = (a2_in == " default" ) ? param[5 ] : std::stod (a2_in);
496+ FmtTable ft ({" Parameters" , " Original" , " Autoset" },
497+ 4 ,
498+ {" %10s" , " %10s" , " %10.4f" });
499+ const std::vector<std::string> items = {" s6" , " s8" , " a1" , " a2" };
500+ ft << items << flag << param;
501+ std::cout << " DFT-D3 Dispersion correction parameters autoset\n " << ft.str ()
502+ << std::endl;
474503 }
475504 }
476505}
477- # endif // DFTD3_XC_PARAM_H
506+
478507/*
479508'''
480509dftd3 parameters from
@@ -548,4 +577,5 @@ if __name__ == '__main__':
548577 data[vdw_method][xc] = {k: raw[k]
549578 for k in ['s6', 'rs6', 'a1', 's8', 'rs8', 'a2', 's9', 'alp', 'bet']}
550579 make_stdmap(data)
551- */
580+ */
581+ #endif // DFTD3_XC_PARAM_H
0 commit comments