Skip to content

Commit

Permalink
add backwards compatibility for dftd4
Browse files Browse the repository at this point in the history
  • Loading branch information
hokru committed Jan 13, 2023
1 parent 178531c commit 423b9cb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
25 changes: 20 additions & 5 deletions qcengine/programs/empirical_dispersion_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Dict, List, Optional, Union

from ..exceptions import InputError
from pkg_resources import parse_version

## ==> Dispersion Aliases and Parameters <== ##

Expand Down Expand Up @@ -901,6 +902,18 @@
},
}

try:
from dftd4 import __version__ as d4_version

new_d4_api = parse_version(d4_version) >= parse_version("3.5.0")
except ModuleNotFoundError:
new_d4_api = False

# different defaults for dftd4 versions < 3.5.0
if new_d4_api is False:
dashcoeff["d4bjeeqatm"]["default"] = collections.OrderedDict(
[("a1", 1.0), ("a2", 1.0), ("alp", 16.0), ("s6", 1.0), ("s8", 1.0), ("s9", 1.0)]
)

# for d3*atm, only skeleton entries with metadata defined above. below copies in parameters from d3*2b
for d in ["d3zero", "d3bj", "d3mzero", "d3mbj", "d3op"]:
Expand Down Expand Up @@ -974,15 +987,17 @@ def get_params(entry: dict, base: dict, defaults: list) -> dict:
except KeyError:
continue

# defaults ga, gc, wf are not in the toml parameter file and need to be provided by qcengine
if new_d4_api:
for entry in definitions.keys():
definitions[entry]["params"]["ga"] = 3.0
definitions[entry]["params"]["gc"] = 2.0
definitions[entry]["params"]["wf"] = 6.0

return definitions


dashcoeff["d4bjeeqatm"]["definitions"].update(_get_d4bj_definitions())
# defaults ga, gc, wf are not in the toml parameter file and need to be provided by qcengine
for k, v in dashcoeff["d4bjeeqatm"]["definitions"].items():
dashcoeff["d4bjeeqatm"]["definitions"][k]["params"]["ga"] = 3.0
dashcoeff["d4bjeeqatm"]["definitions"][k]["params"]["gc"] = 2.0
dashcoeff["d4bjeeqatm"]["definitions"][k]["params"]["wf"] = 6.0

try:

Expand Down
1 change: 1 addition & 0 deletions qcengine/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def get_job(self):
"dftd3": which("dftd3", return_bool=True),
"dftd3_321": is_program_new_enough("dftd3", "3.2.1"),
"dftd4": which_import("dftd4", return_bool=True),
"dftd4_350": is_program_new_enough("dftd", "3.5.0"),
"s-dftd3": which_import("dftd3", return_bool=True),
"qcore": is_program_new_enough("qcore", "0.8.9"),
"gamess": which("rungms", return_bool=True),
Expand Down

0 comments on commit 423b9cb

Please sign in to comment.