Skip to content

Commit

Permalink
update gCP levels and extend D4 defaults (#393)
Browse files Browse the repository at this point in the history
* add new gCP levels and extend D4 defaults

* add backwards compatibility for dftd4

* Update gcp.py

* Update qcengine/testing.py

Co-authored-by: Sebastian Ehlert <[email protected]>

* fix no d4 error

* Update qcengine/programs/empirical_dispersion_resources.py

Co-authored-by: Sebastian Ehlert <[email protected]>

* Update qcengine/programs/empirical_dispersion_resources.py

Co-authored-by: Sebastian Ehlert <[email protected]>

* qcel parse_version

---------

Co-authored-by: Lori A. Burns <[email protected]>
Co-authored-by: Sebastian Ehlert <[email protected]>
  • Loading branch information
3 people authored Aug 10, 2023
1 parent 5935117 commit 8c9f0ab
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
32 changes: 31 additions & 1 deletion 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 qcelemental.util import parse_version

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

Expand Down Expand Up @@ -881,7 +882,17 @@
"bibtex": "Caldeweyher:2019:154122",
"doi": "10.1063/1.5090222150",
"default": collections.OrderedDict(
[("a1", 1.0), ("a2", 1.0), ("alp", 16.0), ("s6", 1.0), ("s8", 1.0), ("s9", 1.0)]
[
("a1", 1.0),
("a2", 1.0),
("alp", 16.0),
("s6", 1.0),
("s8", 1.0),
("s9", 1.0),
("ga", 3.0),
("gc", 2.0),
("wf", 6.0),
]
),
"definitions": {
# D4 parameters loaded below from authoritative source below. Keep a couple for reference
Expand All @@ -891,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, ImportError):
new_d4_api = False

# different defaults for dftd4 versions < 3.5.0
if not new_d4_api:
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 @@ -964,6 +987,13 @@ 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


Expand Down
13 changes: 11 additions & 2 deletions qcengine/programs/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,25 @@ def build_input(
# thus code blocks with FILE below are not used yet.
# 'file',
]
# some methods not available in legacy version
mctc_gcp_levels = ["B973C", "R2SCAN3C"]

executable = self._defaults["name"].lower()
if executable == "mctc-gcp":
available_levels.extend(mctc_gcp_levels)

available_levels = [f.upper() for f in available_levels]
# temp until actual options object
method = input_model.model.method.upper()
if method not in available_levels:
raise InputError(f"GCP does not have method: {method}")
if method in mctc_gcp_levels and executable == "gcp":
raise InputError(f"GCP does not have method {method} but MCTC-GCP does.")
else:
raise InputError(f"GCP does not have method: {method}")

# Need 'real' field later and that's only guaranteed for molrec
molrec = qcel.molparse.from_schema(input_model.molecule.dict())

executable = self._defaults["name"].lower()
calldash = {"gcp": "-", "mctc-gcp": "--"}[executable]

command = [executable, "gcp_geometry.xyz", calldash + "level", method]
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("dftd4", "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 8c9f0ab

Please sign in to comment.