Skip to content

Commit

Permalink
Dft fixes (#1260)
Browse files Browse the repository at this point in the history
* Better document difference between Psi4 and libxc.

* wPBE0 should only have 100%, not 125% exact exchange at long range.

* Better document beta parameter.

* Maybe this is even better.

* Comment out the two HYB_CAMY and the two HYB_LCY functionals.

* Add note about functionals in future version of libxc.

* Drop unused variable.

* Fix typo from previous commit.

* Improve comment based on comment by Peter Kraus.
  • Loading branch information
susilehtola authored and andysim committed Oct 4, 2018
1 parent 6d43493 commit 7b69f9c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 19 deletions.
6 changes: 5 additions & 1 deletion psi4/driver/procrouting/dft_funcs/dict_hyb_funcs.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
funcs = [] funcs = []


funcs.append({ funcs.append({
# This should be replaced with a call to libxc's
# HYB_GGA_XC_LC_WPBEH_WHS once it's possible
"name": "wPBE0", "name": "wPBE0",
"alias": ["LC-WPBE0"], "alias": ["LC-WPBE0"],
"x_functionals": { "x_functionals": {
Expand All @@ -44,7 +46,7 @@
}, },
"x_hf": { "x_hf": {
"alpha": 0.25, "alpha": 0.25,
"beta": 1.0, "beta": 0.75,
"omega": 0.3 "omega": 0.3
}, },
"c_functionals": { "c_functionals": {
Expand All @@ -58,6 +60,8 @@
}) })


funcs.append({ funcs.append({
# This should be replaced with a call to libxc's
# HYB_GGA_XC_LC_WPBE_WHS once it's possible
"name": "wPBE", "name": "wPBE",
"alias": ["LC-WPBE", "LCWPBE"], "alias": ["LC-WPBE", "LCWPBE"],
"x_functionals": { "x_functionals": {
Expand Down
8 changes: 4 additions & 4 deletions psi4/driver/procrouting/dft_funcs/dict_xc_funcs.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -104,18 +104,18 @@
funcs.append({"name": "MB3LYP-RC04" , "xc_functionals": {"HYB_GGA_XC_MB3LYP_RC04" : {}}}) funcs.append({"name": "MB3LYP-RC04" , "xc_functionals": {"HYB_GGA_XC_MB3LYP_RC04" : {}}})
funcs.append({"name": "mPWLYP1M" , "xc_functionals": {"HYB_GGA_XC_MPWLYP1M" : {}}}) funcs.append({"name": "mPWLYP1M" , "xc_functionals": {"HYB_GGA_XC_MPWLYP1M" : {}}})
funcs.append({"name": "revB3LYP" , "xc_functionals": {"HYB_GGA_XC_REVB3LYP" : {}}}) funcs.append({"name": "revB3LYP" , "xc_functionals": {"HYB_GGA_XC_REVB3LYP" : {}}})
funcs.append({"name": "CAMY-BLYP" , "xc_functionals": {"HYB_GGA_XC_CAMY_BLYP" : {}}}) #funcs.append({"name": "CAMY-BLYP" , "xc_functionals": {"HYB_GGA_XC_CAMY_BLYP" : {}}}) # CAMY range separation not supported by psi4
funcs.append({"name": "PBE0-13" , "xc_functionals": {"HYB_GGA_XC_PBE0_13" : {}}}) funcs.append({"name": "PBE0-13" , "xc_functionals": {"HYB_GGA_XC_PBE0_13" : {}}})
funcs.append({"name": "B3LYPs" , "xc_functionals": {"HYB_GGA_XC_B3LYPs" : {}}}) funcs.append({"name": "B3LYPs" , "xc_functionals": {"HYB_GGA_XC_B3LYPs" : {}}})
funcs.append({"name": "wB97" , "xc_functionals": {"HYB_GGA_XC_WB97" : {}}}) funcs.append({"name": "wB97" , "xc_functionals": {"HYB_GGA_XC_WB97" : {}}})
funcs.append({"name": "wB97X" , "xc_functionals": {"HYB_GGA_XC_WB97X" : {}}}) funcs.append({"name": "wB97X" , "xc_functionals": {"HYB_GGA_XC_WB97X" : {}}})
funcs.append({"name": "wB97X-D" , "xc_functionals": {"HYB_GGA_XC_WB97X_D" : {}}, "dispersion": {"type": "chg", "params": {"s6": 1.0}}}) funcs.append({"name": "wB97X-D" , "xc_functionals": {"HYB_GGA_XC_WB97X_D" : {}}, "dispersion": {"type": "chg", "params": {"s6": 1.0}}})
funcs.append({"name": "LRC-wPBEh" , "xc_functionals": {"HYB_GGA_XC_LRC_WPBEH" : {}}}) funcs.append({"name": "LRC-wPBEh" , "xc_functionals": {"HYB_GGA_XC_LRC_WPBEH" : {}}})
funcs.append({"name": "wB97X-V" , "xc_functionals": {"HYB_GGA_XC_WB97X_V" : {}}, "alias": ["WB97XV"]}) funcs.append({"name": "wB97X-V" , "xc_functionals": {"HYB_GGA_XC_WB97X_V" : {}}, "alias": ["WB97XV"]})
funcs.append({"name": "LCY-PBE" , "xc_functionals": {"HYB_GGA_XC_LCY_PBE" : {}}}) #funcs.append({"name": "LCY-PBE" , "xc_functionals": {"HYB_GGA_XC_LCY_PBE" : {}}}) # LCY range separation not supported by psi4
funcs.append({"name": "LCY-BLYP" , "xc_functionals": {"HYB_GGA_XC_LCY_BLYP" : {}}}) #funcs.append({"name": "LCY-BLYP" , "xc_functionals": {"HYB_GGA_XC_LCY_BLYP" : {}}}) # LCY range separation not supported by psi4
funcs.append({"name": "LC-VV10" , "xc_functionals": {"HYB_GGA_XC_LC_VV10" : {}}}) funcs.append({"name": "LC-VV10" , "xc_functionals": {"HYB_GGA_XC_LC_VV10" : {}}})
funcs.append({"name": "CAMY-B3LYP" , "xc_functionals": {"HYB_GGA_XC_CAMY_B3LYP" : {}}}) #funcs.append({"name": "CAMY-B3LYP" , "xc_functionals": {"HYB_GGA_XC_CAMY_B3LYP" : {}}}) # CAMY range separation not supported by psi4
funcs.append({"name": "HPBEINT" , "xc_functionals": {"HYB_GGA_XC_HPBEINT" : {}}}) funcs.append({"name": "HPBEINT" , "xc_functionals": {"HYB_GGA_XC_HPBEINT" : {}}})
funcs.append({"name": "LRC-WPBE" , "xc_functionals": {"HYB_GGA_XC_LRC_WPBE" : {}}}) funcs.append({"name": "LRC-WPBE" , "xc_functionals": {"HYB_GGA_XC_LRC_WPBE" : {}}})
funcs.append({"name": "B3LYP5" , "xc_functionals": {"HYB_GGA_XC_B3LYP5" : {}}}) funcs.append({"name": "B3LYP5" , "xc_functionals": {"HYB_GGA_XC_B3LYP5" : {}}})
Expand Down
2 changes: 1 addition & 1 deletion psi4/src/export_functional.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void export_functional(py::module &m) {
.def("set_x_omega", &SuperFunctional::set_x_omega, "Sets the range-seperation exchange parameter.") .def("set_x_omega", &SuperFunctional::set_x_omega, "Sets the range-seperation exchange parameter.")
.def("set_c_omega", &SuperFunctional::set_c_omega, "Sets the range-seperation correlation parameter.") .def("set_c_omega", &SuperFunctional::set_c_omega, "Sets the range-seperation correlation parameter.")
.def("set_x_alpha", &SuperFunctional::set_x_alpha, "Sets the amount of exact global HF exchange.") .def("set_x_alpha", &SuperFunctional::set_x_alpha, "Sets the amount of exact global HF exchange.")
.def("set_x_beta", &SuperFunctional::set_x_beta, "Sets the amount of exact HF exchange at long range.") .def("set_x_beta", &SuperFunctional::set_x_beta, "Sets how much more long-range exchange than short-range exchange.")
.def("set_c_alpha", &SuperFunctional::set_c_alpha, "Sets the amount of MP2 correlation.") .def("set_c_alpha", &SuperFunctional::set_c_alpha, "Sets the amount of MP2 correlation.")
.def("set_c_ss_alpha", &SuperFunctional::set_c_ss_alpha, "Sets the amount of SS MP2 correlation.") .def("set_c_ss_alpha", &SuperFunctional::set_c_ss_alpha, "Sets the amount of SS MP2 correlation.")
.def("set_c_os_alpha", &SuperFunctional::set_c_os_alpha, "Sets the amount of OS MP2 correlation.") .def("set_c_os_alpha", &SuperFunctional::set_c_os_alpha, "Sets the amount of OS MP2 correlation.")
Expand Down
56 changes: 43 additions & 13 deletions psi4/src/psi4/libfunctional/LibXCfunctional.cc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -90,25 +90,53 @@ LibXCFunctional::LibXCFunctional(std::string xc_name, bool unpolarized) {
if (xc_functional_->info->family == XC_FAMILY_HYB_GGA || if (xc_functional_->info->family == XC_FAMILY_HYB_GGA ||
xc_functional_->info->family == XC_FAMILY_HYB_MGGA) { xc_functional_->info->family == XC_FAMILY_HYB_MGGA) {
/* Range separation? */ /* Range separation? */
int rangesep = 0; lrc_ = false;
if (xc_functional_->info->flags & XC_FLAGS_HYB_CAM) rangesep++; if (xc_functional_->info->flags & XC_FLAGS_HYB_CAMY) {
if (xc_functional_->info->flags & XC_FLAGS_HYB_CAMY) rangesep++; outfile->Printf("Functional '%d' is a HYB_CAMY functional which is not supported in Psi4\n", xc_name.c_str());
if (xc_functional_->info->flags & XC_FLAGS_HYB_LC) rangesep++; throw PSIEXCEPTION("HYB_CAMY functionals not supported in Psi4 at present");
if (xc_functional_->info->flags & XC_FLAGS_HYB_LCY) rangesep++; }
if (rangesep) { if (xc_functional_->info->flags & XC_FLAGS_HYB_LC ) {
outfile->Printf("Functional '%d' is a HYB_LC functional which is not supported in Psi4\n", xc_name.c_str());
throw PSIEXCEPTION("HYB_LC functionals not supported in Psi4 at present");
}
if (xc_functional_->info->flags & XC_FLAGS_HYB_LCY) {
outfile->Printf("Functional '%d' is a HYB_LCY functional which is not supported in Psi4\n", xc_name.c_str());
throw PSIEXCEPTION("HYB_LCY functionals not supported in Psi4 at present");
}
if (xc_functional_->info->flags & XC_FLAGS_HYB_CAM) {
lrc_ = true; lrc_ = true;

// SR = LibXC_ALPHA + LibXC_BETA = psi4.set_x_alpha
// LR = LibXC_ALPHA = psi4.set_x_alpha + psi4.set_x_beta
// LR - SR = - LibXC_BETA = psi4.set_x_beta

double alpha, beta; double alpha, beta;
xc_hyb_cam_coef(xc_functional_.get(), &omega_, &alpha, &beta); xc_hyb_cam_coef(xc_functional_.get(), &omega_, &alpha, &beta);


/*
The values alpha and beta have a different meaning in
psi4 and libxc.
In libxc, alpha is the contribution from full exact
exchange (at all ranges), and beta is the contribution
from short-range only exchange, yielding alpha exact
exchange at the long range and alpha+beta in the short
range in total.
In Psi4, alpha is the amount of exchange at all ranges,
while beta is the difference between the amount of
exchange in the long range and in the short range,
meaning alpha+beta at the long range, and alpha only at
the short range.
These differences amount to the transform
SR = LibXC_ALPHA + LibXC_BETA = Psi4_ALPHA
LR = LibXC_ALPHA = Psi4_ALPHA + Psi4_BETA
LR - SR = - LibXC_BETA = Psi4_BETA
*/

global_exch_ = alpha + beta; global_exch_ = alpha + beta;
lr_exch_ = -1.0 * beta; lr_exch_ = -1.0 * beta;
}


} else { if(!lrc_) {
// Global hybrid
global_exch_ = xc_hyb_exx_coef(xc_functional_.get()); global_exch_ = xc_hyb_exx_coef(xc_functional_.get());
} }
} }
Expand Down Expand Up @@ -200,9 +228,11 @@ std::map<std::string, double> LibXCFunctional::query_libxc(const std::string& fu
if (functional == "XC_HYB_CAM_COEF") { if (functional == "XC_HYB_CAM_COEF") {
double omega, alpha, beta; double omega, alpha, beta;
xc_hyb_cam_coef(xc_functional_.get(), &omega, &alpha, &beta); xc_hyb_cam_coef(xc_functional_.get(), &omega, &alpha, &beta);
// LibXC and Psi4 conventions for alpha and beta differ, see
// above for full description
params["OMEGA"] = omega; params["OMEGA"] = omega;
params["ALPHA"] = alpha + beta; params["ALPHA"] = alpha + beta;
params["BETA"] = -1.0 * beta; params["BETA"] = -beta;
} }
else if (functional == "XC_NLC_COEF") { else if (functional == "XC_NLC_COEF") {
double nlc_b, nlc_c; double nlc_b, nlc_c;
Expand Down

0 comments on commit 7b69f9c

Please sign in to comment.