Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
loriab committed Jan 23, 2021
1 parent a70faa7 commit a3e3480
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 76 deletions.
2 changes: 1 addition & 1 deletion .azure-pipelines/azure-pipelines-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
python=$PYTHON_VER \
psi4/label/dev::gau2grid \
psi4/label/dev::libint2 \
psi4/label/dev::libxc \
psi4/label/dev::libxc=5 \
psi4/label/dev::ambit \
psi4/label/dev::chemps2 \
psi4/label/dev::dkh \
Expand Down
28 changes: 18 additions & 10 deletions psi4/driver/procrouting/dft/dft_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"alpha": 1.0, coefficient for (global) GGA exchange, by default 1.0
"omega": 0.0, range-separation parameter
"use_libxc": False whether "x_hf" parameters should be set from LibXC values for this method
"tweak": [], tweak the underlying functional
"tweak": {}, tweak the underlying functional
},
"x_hf": { definition of HF exchange for hybrid functionals
Expand All @@ -59,7 +59,7 @@
"c_functionals": { definition of C contributions
"C_METHOD_NAME": { must match a LibXC method
"alpha": 1.0, coefficient for (global) GGA correlation, by default 1.0
"tweak": [], tweak the underlying functional
"tweak": {}, tweak the underlying functional
},
"c_mp2": { definition of MP2 correlation double hybrid functionals
Expand Down Expand Up @@ -155,7 +155,8 @@ def get_functional_aliases(functional_dict):
if dispersion_functional.lower() in functional_aliases:
func = copy.deepcopy(dict_functionals[functional_name])
func["name"] += "-" + resolved_dispersion_level
func["dispersion"] = copy.deepcopy(dashcoeff[resolved_dispersion_level]['definitions'][dispersion_functional])
func["dispersion"] = copy.deepcopy(
dashcoeff[resolved_dispersion_level]['definitions'][dispersion_functional])
func["dispersion"]["type"] = resolved_dispersion_level

# this ensures that M06-2X-D3, M06-2X-D3ZERO, M062X-D3 or M062X-D3ZERO
Expand All @@ -177,9 +178,10 @@ def check_consistency(func_dictionary):
raise ValidationError("SCF: No method name was specified in functional dictionary.")
else:
name = func_dictionary["name"]
# 0b) make sure provided name is unique:
# 0b) make sure provided name is unique:
if (name.lower() in functionals.keys()) and (func_dictionary not in functionals.values()):
raise ValidationError("SCF: Provided name for a custom dft_functional matches an already defined one: %s." % (name))
raise ValidationError(
"SCF: Provided name for a custom dft_functional matches an already defined one: %s." % (name))

# 1a) sanity checks definition of xc_functionals
if "xc_functionals" in func_dictionary:
Expand Down Expand Up @@ -224,21 +226,27 @@ def check_consistency(func_dictionary):
if "citation" in func_dictionary:
cit = func_dictionary["citation"]
if cit and not (cit.startswith(' ') and cit.endswith('\n')):
raise ValidationError("SCF: All citations should have the form ' A. Student, B. Prof, J. Goodstuff Vol, Page, Year\n', not : {}".format(cit))
raise ValidationError(
f"SCF: All citations should have the form ' A. Student, B. Prof, J. Goodstuff Vol, Page, Year\n', not : {cit}"
)
if "dispersion" in func_dictionary:
disp = func_dictionary["dispersion"]
# 3b) check dispersion type present and known
# 3b) check dispersion type present and known
if "type" not in disp or disp["type"] not in _dispersion_aliases:
raise ValidationError("SCF: Dispersion type ({}) should be among ({})".format(disp['type'], _dispersion_aliases.keys()))
raise ValidationError(
f"SCF: Dispersion type ({disp['type']}) should be among ({_dispersion_aliases.keys()})")
# 3c) check dispersion params complete
allowed_params = sorted(dashcoeff[_dispersion_aliases[disp["type"]]]["default"].keys())
if "params" not in disp or sorted(disp["params"].keys()) != allowed_params:
raise ValidationError("SCF: Dispersion params ({}) must include all ({})".format(list(disp['params'].keys()), allowed_params))
raise ValidationError(
f"SCF: Dispersion params ({list(disp['params'].keys())}) must include all ({allowed_params})")
# 3d) check formatting for dispersion citation
if "citation" in disp:
cit = disp["citation"]
if cit and not (cit.startswith(' ') and cit.endswith('\n')):
raise ValidationError("SCF: All citations should have the form ' A. Student, B. Prof, J. Goodstuff Vol, Page, Year\n', not : {}".format(cit))
raise ValidationError(
f"SCF: All citations should have the form ' A. Student, B. Prof, J. Goodstuff Vol, Page, Year\n', not : {cit}"
)


def build_superfunctional_from_dictionary(func_dictionary, npoints, deriv, restricted):
Expand Down
27 changes: 8 additions & 19 deletions psi4/driver/procrouting/dft/dh_functionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
},
})


funcs.append({
"name": "MP2D",
"alias": ["MP2-D"],
Expand All @@ -66,7 +65,6 @@
},
})


funcs.append({
"name": "B2PLYP",
"x_functionals": {
Expand Down Expand Up @@ -178,9 +176,9 @@
})

funcs.append({
# note by H.Kruse: Uses the full-core parameters in the Yu paper. But my and L. Georigk's experience shows that it hardly matters.
# Use FC is recommended by S. Grimme.
# May this madness never end.
# note by H.Kruse: Uses the full-core parameters in the Yu paper. But my and L. Georigk's experience shows that it hardly matters.
# Use FC is recommended by S. Grimme.
# May this madness never end.
"name": "DSD-BLYP-NL",
"x_functionals": {
"GGA_X_B88": {
Expand Down Expand Up @@ -212,9 +210,6 @@
"description": ' DSD-BLYP-NL (D3BJ,FC parameters) VV10 SCS Double Hybrid XC Functional\n',
})




funcs.append({
"name": "CORE-DSD-BLYP",
"x_functionals": {
Expand Down Expand Up @@ -342,7 +337,7 @@
})

funcs.append({
# note: Using the D3BJ form for NL, which is sensible but not explicitly mentioned in the paper
# note: Using the D3BJ form for NL, which is sensible but not explicitly mentioned in the paper
"name": "DSD-PBEP86-NL",
"x_functionals": {
"GGA_X_PBE": {
Expand Down Expand Up @@ -373,8 +368,6 @@
"description": ' DSD-PBEP86-NL (D3BJ parameters) VV10 SCS Double Hybrid XC Functional\n',
})



funcs.append({
"name": "DSD-PBEP86-D2",
"x_functionals": {
Expand Down Expand Up @@ -496,7 +489,6 @@
},
})


funcs.append({
"name": "DSD-PBEPBE-NL",
"x_functionals": {
Expand Down Expand Up @@ -529,7 +521,6 @@
},
})


funcs.append({
"name": "DSD-BP86-D2",
"x_functionals": {
Expand Down Expand Up @@ -699,7 +690,7 @@ def get_pwpb95_tweaks():
"alpha": 0.69
},
"c_functionals": {
"MGGA_C_BC95": {
"MGGA_C_BC95": {
"alpha": 0.54
}
},
Expand All @@ -722,7 +713,7 @@ def get_pwpb95_tweaks():
"alpha": 0.65
},
"c_functionals": {
"MGGA_C_BC95": {
"MGGA_C_BC95": {
"alpha": 0.55
}
},
Expand Down Expand Up @@ -754,7 +745,7 @@ def get_pwpb95_tweaks():
"alpha": 0.66
},
"c_functionals": {
"MGGA_C_BC95": {
"MGGA_C_BC95": {
"alpha": 0.55
}
},
Expand Down Expand Up @@ -787,7 +778,7 @@ def get_pwpb95_tweaks():
"alpha": 0.66
},
"c_functionals": {
"MGGA_C_BC95": {
"MGGA_C_BC95": {
"alpha": 0.55
}
},
Expand All @@ -807,8 +798,6 @@ def get_pwpb95_tweaks():
},
})


functional_list = {}
for functional in funcs:
functional_list[functional["name"].lower()] = functional

7 changes: 2 additions & 5 deletions psi4/driver/procrouting/dft/gga_functionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@
})

funcs.append({
"name":
"BP86",
"name": "BP86",
"x_functionals": {
"GGA_X_B88": {}
},
Expand Down Expand Up @@ -336,8 +335,7 @@
"c_functionals": {
"GGA_C_PBE_SOL": {}
},
"description":
' Perdew, Burke & Ernzerhof exchange (solids)',
"description": ' Perdew, Burke & Ernzerhof exchange (solids)',
})

funcs.append({
Expand All @@ -351,7 +349,6 @@
},
"description":
' BP86 GGA Exchange-Correlation Functional based on VWN5 correlation with more accurate value for ftilde\n',

})

functional_list = {}
Expand Down
28 changes: 15 additions & 13 deletions psi4/driver/procrouting/dft/hyb_functionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def get_pw6b95_tweaks():
funcs.append({
"name": "M05",
"x_functionals": {
"HYB_MGGA_X_M05" : {
"HYB_MGGA_X_M05": {
"use_libxc": True
}
},
Expand Down Expand Up @@ -565,7 +565,7 @@ def get_pw6b95_tweaks():
"HYB_MGGA_XC_WB97M_V": {}
},
"dispersion": {
"nlc":False,
"nlc": False,
"type": "d3bj",
"citation": ' A. Najib, L. Goerigk, J. Comput. Theory Chem.,14, 5725, 2018\n',
"params": {
Expand All @@ -575,9 +575,11 @@ def get_pw6b95_tweaks():
'a2': 3.1280
},
},
"description": ' wB97M-V with D3(BJ) instead of VV10 dispersion \n',
"citation": ' A. Najib, L. Goerigk, J. Comput. Theory Chem.,14, 5725, 2018\n'+
' N. Mardirossian, M. Head-Gordon, J. Chem. Phys. 144, 214110, 2016\n'
"description":
' wB97M-V with D3(BJ) instead of VV10 dispersion \n',
"citation":
' A. Najib, L. Goerigk, J. Comput. Theory Chem.,14, 5725, 2018\n' +
' N. Mardirossian, M. Head-Gordon, J. Chem. Phys. 144, 214110, 2016\n'
})

funcs.append({
Expand All @@ -586,7 +588,7 @@ def get_pw6b95_tweaks():
"HYB_GGA_XC_WB97X_V": {}
},
"dispersion": {
"nlc":False,
"nlc": False,
"type": "d3bj",
"citation": ' A. Najib, L. Goerigk, J. Comput. Theory Chem.,14 5725, 2018\n',
"params": {
Expand All @@ -596,9 +598,11 @@ def get_pw6b95_tweaks():
'a2': 5.4959
},
},
"description": ' wB97X-V with D3(BJ) instead of VV10 dispersion \n',
"citation": ' A. Najib, L. Goerigk, J. Comput. Theory Chem., 14 5725, 2018)\n'+
' N. Mardirossian, M. Head-Gordon, Phys. Chem. Chem. Phys, 16, 9904, 2014\n'
"description":
' wB97X-V with D3(BJ) instead of VV10 dispersion \n',
"citation":
' A. Najib, L. Goerigk, J. Comput. Theory Chem., 14 5725, 2018)\n' +
' N. Mardirossian, M. Head-Gordon, Phys. Chem. Chem. Phys, 16, 9904, 2014\n'
})

funcs.append({
Expand Down Expand Up @@ -641,10 +645,8 @@ def get_pw6b95_tweaks():
"c_functionals": {
"GGA_C_BMK": {}
},
"citation":
' A. D. Boese, J. M. L. Martin, J. Chem. Phys. 121, 3405, 2004\n',
"description":
' BMK Hybrid Meta-GGA XC Functional for kinetics\n',
"citation": ' A. D. Boese, J. M. L. Martin, J. Chem. Phys. 121, 3405, 2004\n',
"description": ' BMK Hybrid Meta-GGA XC Functional for kinetics\n',
})

funcs.append({
Expand Down
11 changes: 6 additions & 5 deletions psi4/driver/procrouting/dft/mgga_functionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,13 @@
'a1': -0.0780,
'a2': 5.59460
},
"citation": ' A. Najib, L. Goerigk J. Comput. Theory Chem., 14, 5725, 2018\n',
"citation": ' A. Najib, L. Goerigk J. Comput. Theory Chem., 14, 5725, 2018\n',
},
"description": ' B97M-V with D3(BJ) instead of VV10 dispersion \n',
"citation": ' A. Najib, L. Goerigk J. Comput. Theory Chem., 14, 5725, 2018\n'+
' N. Mardirossian, M. Head-Gordon J. Chem. Phys. 142, 074111 (2015)\n',

"description":
' B97M-V with D3(BJ) instead of VV10 dispersion \n',
"citation":
' A. Najib, L. Goerigk J. Comput. Theory Chem., 14, 5725, 2018\n' +
' N. Mardirossian, M. Head-Gordon J. Chem. Phys. 142, 074111 (2015)\n',
})

funcs.append({
Expand Down
15 changes: 9 additions & 6 deletions psi4/driver/procrouting/dft/superfunctionals.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from psi4.driver.p4util.exceptions import ValidationError
from . import dft_builder


def build_superfunctional(name, restricted, npoints=None, deriv=1):
if npoints is None:
npoints = core.get_option("SCF", "DFT_BLOCK_MAX_POINTS")
Expand Down Expand Up @@ -66,8 +67,8 @@ def build_superfunctional(name, restricted, npoints=None, deriv=1):
sup = dft_builder.build_superfunctional_from_dictionary(name, npoints, deriv, restricted)
# Check for pre-defined dict-based functionals
elif name.lower() in dft_builder.functionals:
sup = dft_builder.build_superfunctional_from_dictionary(dft_builder.functionals[name.lower()],
npoints, deriv, restricted)
sup = dft_builder.build_superfunctional_from_dictionary(dft_builder.functionals[name.lower()], npoints, deriv,
restricted)
else:
raise ValidationError("SCF: Functional (%s) not found!" % name)

Expand Down Expand Up @@ -131,9 +132,11 @@ def build_superfunctional(name, restricted, npoints=None, deriv=1):
raise ValidationError("SCF: Decide between NL_DISPERSION_PARAMETERS and DFT_VV10_B !!")

# Check SCF_TYPE
if sup[0].is_x_lrc() and (core.get_global_option("SCF_TYPE") not in ["DISK_DF", "MEM_DF" ,"DIRECT", "DF", "OUT_OF_CORE", "PK"]):
if sup[0].is_x_lrc() and (core.get_global_option("SCF_TYPE")
not in ["DISK_DF", "MEM_DF", "DIRECT", "DF", "OUT_OF_CORE", "PK"]):
raise ValidationError(
"SCF: SCF_TYPE (%s) not supported for range-separated functionals, plese use SCF_TYPE = 'DF' to automatically select the correct JK build." % core.get_global_option("SCF_TYPE"))
"SCF: SCF_TYPE (%s) not supported for range-separated functionals, plese use SCF_TYPE = 'DF' to automatically select the correct JK build."
% core.get_global_option("SCF_TYPE"))

if (core.get_global_option('INTEGRAL_PACKAGE') == 'ERD') and (sup[0].is_x_lrc()):
raise ValidationError('INTEGRAL_PACKAGE ERD does not play nicely with LRC DFT functionals, so stopping.')
Expand Down Expand Up @@ -271,8 +274,8 @@ def test_ccl_functional(functional, ccl_functional):
passed = 'FAILED'
check = False

core.print_out('\t%-15s %24.16E %24.16E %24.16E %24.16E %6s\n' % (task, v_ref, v_obs, delta, epsilon,
passed))
core.print_out('\t%-15s %24.16E %24.16E %24.16E %24.16E %6s\n' %
(task, v_ref, v_obs, delta, epsilon, passed))

index = index + 1

Expand Down
Loading

0 comments on commit a3e3480

Please sign in to comment.