Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
loriab committed May 5, 2024
1 parent 0b88aaa commit 4bfade3
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 33 deletions.
12 changes: 8 additions & 4 deletions qcengine/procedures/optking.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ def found(self, raise_error: bool = False) -> bool:

return qc and dep

def build_input_model(self, data: Union[Dict[str, Any], "GeneralizedOptimizationInput"]) -> "GeneralizedOptimizationInput":
def build_input_model(
self, data: Union[Dict[str, Any], "GeneralizedOptimizationInput"]
) -> "GeneralizedOptimizationInput":
from qcmanybody.models.generalized_optimization import GeneralizedOptimizationInput

return self._build_model(data, GeneralizedOptimizationInput)

def compute(self, input_model: "GeneralizedOptimizationInput", config: "TaskConfig") -> "GeneralizedOptimizationResult":
def compute(
self, input_model: "GeneralizedOptimizationInput", config: "TaskConfig"
) -> "GeneralizedOptimizationResult":
self.found(raise_error=True)

import optking
Expand All @@ -102,13 +106,13 @@ def compute(self, input_model: "GeneralizedOptimizationInput", config: "TaskConf
# Set retries to two if zero while respecting local_config
local_config = config.dict()
local_config["retries"] = local_config.get("retries", 2) or 2
#TODO input_data["input_specification"]["extras"]["_qcengine_local_config"] = local_config
# TODO input_data["input_specification"]["extras"]["_qcengine_local_config"] = local_config

# Run the program
output_data = optking.optwrapper.optimize_qcengine(input_data)

output_data["schema_name"] = "qcschema_generalizedoptimizationresult"
#TODO output_data["input_specification"]["extras"].pop("_qcengine_local_config", None)
# TODO output_data["input_specification"]["extras"].pop("_qcengine_local_config", None)
if output_data["success"]:
output_data = GeneralizedOptimizationResult(**output_data)

Expand Down
1 change: 1 addition & 0 deletions qcengine/procedures/qcmanybody.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def found(self, raise_error: bool = False) -> bool:

def build_input_model(self, data: Union[Dict[str, Any], "ManyBodyInput"]) -> "ManyBodyInput":
from qcmanybody.models import ManyBodyInput

return self._build_model(data, ManyBodyInput)

def get_version(self) -> str:
Expand Down
67 changes: 38 additions & 29 deletions qcengine/tests/test_mbe_ne2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@


@using("qcmanybody")
@pytest.mark.parametrize("qcprog", [
pytest.param("cfour", marks=using("cfour")),
pytest.param("gamess", marks=using("gamess")),
pytest.param("nwchem", marks=using("nwchem")),
pytest.param("psi4", marks=using("psi4")),
])
@pytest.mark.parametrize(
"qcprog",
[
pytest.param("cfour", marks=using("cfour")),
pytest.param("gamess", marks=using("gamess")),
pytest.param("nwchem", marks=using("nwchem")),
pytest.param("psi4", marks=using("psi4")),
],
)
def test_tu6_cp_ne2(qcprog):
"""
from https://github.com/psi4/psi4/blob/master/tests/tu6-cp-ne2/input.dat
Expand Down Expand Up @@ -44,7 +47,7 @@ def test_tu6_cp_ne2(qcprog):
"specification": {
"model": {
"method": "ccsd(t)",
#TODO error handling cfour "basis": "aug-cc-pvdz",
# TODO error handling cfour "basis": "aug-cc-pvdz",
"basis": basis[qcprog],
},
"driver": "energy",
Expand All @@ -61,7 +64,9 @@ def test_tu6_cp_ne2(qcprog):

for R in tu6_ie_scan:
# TODO fix_symmetry='c1' propagate
nene = Molecule(symbols=["Ne", "Ne"], fragments=[[0], [1]], geometry=[0, 0, 0, 0, 0, R / constants.bohr2angstroms])
nene = Molecule(
symbols=["Ne", "Ne"], fragments=[[0], [1]], geometry=[0, 0, 0, 0, 0, R / constants.bohr2angstroms]
)
mbe_data["molecule"] = nene

mbe_model = ManyBodyInput(**mbe_data)
Expand Down Expand Up @@ -113,14 +118,15 @@ def test_mbe_error():
"driver": "energy",
"program": "cms",
},
"keywords": {
},
"keywords": {},
"driver": "energy",
},
"molecule": None,
}

nene = Molecule(symbols=["Ne", "Ne"], fragments=[[0], [1]], geometry=[0, 0, 0, 0, 0, 3.0 / constants.bohr2angstroms])
nene = Molecule(
symbols=["Ne", "Ne"], fragments=[[0], [1]], geometry=[0, 0, 0, 0, 0, 3.0 / constants.bohr2angstroms]
)
mbe_data["molecule"] = nene

mbe_model = ManyBodyInput(**mbe_data)
Expand Down Expand Up @@ -151,7 +157,8 @@ def test_mbe_error():
def test_optimization_qcmanybody(optimizer, bsse_type):
from qcmanybody.models.generalized_optimization import GeneralizedOptimizationInput

initial_molecule = Molecule.from_data("""
initial_molecule = Molecule.from_data(
"""
F -0.04288 2.78905 0.00000
H 0.59079 2.03435 0.00000
--
Expand All @@ -161,7 +168,8 @@ def test_optimization_qcmanybody(optimizer, bsse_type):
F 2.03569 -0.60531 -0.00000
H 1.06527 -0.77673 0.00000
units ang
""")
"""
)

at_spec = {
"model": {
Expand All @@ -174,20 +182,20 @@ def test_optimization_qcmanybody(optimizer, bsse_type):
}

mbe_spec = {
"specification": {
"model": {
"method": "hf",
"basis": "6-31g",
},
"driver": "energy",
"program": "psi4",
"keywords": {},
},
"keywords": {
"bsse_type": bsse_type,
},
"driver": "energy",
}
"specification": {
"model": {
"method": "hf",
"basis": "6-31g",
},
"driver": "energy",
"program": "psi4",
"keywords": {},
},
"keywords": {
"bsse_type": bsse_type,
},
"driver": "energy",
}

opt_data = {
"initial_molecule": initial_molecule,
Expand All @@ -204,11 +212,12 @@ def test_optimization_qcmanybody(optimizer, bsse_type):

ret = qcng.compute_procedure(opt_data, optimizer, raise_error=True)
import pprint

pprint.pprint(ret.dict())

r_fh_hb = {
"none": 2.18 /constants.bohr2angstroms,
"nocp": 2.18 /constants.bohr2angstroms,
"none": 2.18 / constants.bohr2angstroms,
"nocp": 2.18 / constants.bohr2angstroms,
"cp": 2.27 / constants.bohr2angstroms,
}
r_fh_computed = ret.final_molecule.measure([1, 3])
Expand Down

0 comments on commit 4bfade3

Please sign in to comment.