Skip to content

Commit

Permalink
xtb and mrchem
Browse files Browse the repository at this point in the history
  • Loading branch information
loriab committed Sep 26, 2024
1 parent 16f6067 commit a627ee4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
22 changes: 15 additions & 7 deletions qcengine/programs/tests/test_mrchem.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from qcelemental.testing import compare_values

import qcengine as qcng
from qcengine.testing import using
from qcengine.testing import checkver_and_convert, schema_versions, using


@pytest.fixture
def h2o():
return qcel.models.Molecule(
def h2o(schema_versions):
return schema_versions[0].Molecule(
geometry=[[0, 0, -0.1250], [-1.4375, 0, 1.0250], [1.4375, 0, 1.0250]],
symbols=["O", "H", "H"],
connectivity=[[0, 1, 1], [0, 2, 1]],
Expand All @@ -29,14 +29,16 @@ def fh():


@using("mrchem")
def test_energy(h2o):
def test_energy(h2o, schema_versions, request):
models, _ = schema_versions

mr_kws = {
"world_prec": 1.0e-3,
"world_size": 6,
"world_unit": "bohr",
}

inp = qcel.models.AtomicInput(
inp = models.AtomicInput(
molecule=h2o,
driver="energy",
model={
Expand All @@ -45,7 +47,9 @@ def test_energy(h2o):
keywords=mr_kws,
)

inp = checkver_and_convert(inp, request.node.name, "pre")
res = qcng.compute(inp, "mrchem", raise_error=True, return_dict=True)
res = checkver_and_convert(res, request.node.name, "post")

# Make sure the calculation completed successfully
assert compare_values(-76.4546307, res["return_result"], atol=1e-3)
Expand All @@ -63,14 +67,16 @@ def test_energy(h2o):


@using("mrchem")
def test_dipole(h2o):
def test_dipole(h2o, schema_versions, request):
models, _ = schema_versions

mr_kws = {
"world_prec": 1.0e-3,
"world_size": 6,
"world_unit": "bohr",
}

inp = qcel.models.AtomicInput(
inp = models.AtomicInput(
molecule=h2o,
driver="properties",
model={
Expand All @@ -79,7 +85,9 @@ def test_dipole(h2o):
keywords=mr_kws,
)

inp = checkver_and_convert(inp, request.node.name, "pre")
res = qcng.compute(inp, "mrchem", raise_error=True, return_dict=True)
res = checkver_and_convert(res, request.node.name, "post")

# Make sure the calculation completed successfully
assert compare_values([-3.766420e-07, 0.0, 0.720473], res["return_result"]["dipole_moment"]["dip-1"], atol=1e-3)
Expand Down
24 changes: 12 additions & 12 deletions qcengine/programs/tests/test_xtb.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def test_xtb_task_gfn1xtb_m01(schema_versions, request):
driver="gradient",
)

atomic_input = checkver_and_convert(atomic_input, request.name, "pre")
atomic_input = checkver_and_convert(atomic_input, request.node.name, "pre")
atomic_result = qcng.compute(atomic_input, "xtb")
atomic_result = checkver_and_convert(atomic_result, request.name, "post")
atomic_result = checkver_and_convert(atomic_result, request.node.name, "post")

assert atomic_result.success
assert pytest.approx(atomic_result.return_result, abs=thr) == return_result
Expand Down Expand Up @@ -91,9 +91,9 @@ def test_xtb_task_gfn1xtb_m02(schema_versions, request):
},
)

atomic_input = checkver_and_convert(atomic_input, request.name, "pre")
atomic_input = checkver_and_convert(atomic_input, request.node.name, "pre")
atomic_result = qcng.compute(atomic_input, "xtb")
atomic_result = checkver_and_convert(atomic_result, request.name, "post")
atomic_result = checkver_and_convert(atomic_result, request.node.name, "post")

assert atomic_result.success
assert pytest.approx(atomic_result.return_result, abs=thr) == return_result
Expand Down Expand Up @@ -135,9 +135,9 @@ def test_xtb_task_gfn1xtb_m03(schema_versions, request):
},
)

atomic_input = checkver_and_convert(atomic_input, request.name, "pre")
atomic_input = checkver_and_convert(atomic_input, request.node.name, "pre")
atomic_result = qcng.compute(atomic_input, "xtb")
atomic_result = checkver_and_convert(atomic_result, request.name, "post")
atomic_result = checkver_and_convert(atomic_result, request.node.name, "post")

assert atomic_result.success
assert pytest.approx(atomic_result.return_result, abs=thr) == return_result
Expand Down Expand Up @@ -179,9 +179,9 @@ def test_xtb_task_gfn1xtb_m04(schema_versions, request):
driver="properties",
)

atomic_input = checkver_and_convert(atomic_input, request.name, "pre")
atomic_input = checkver_and_convert(atomic_input, request.node.name, "pre")
atomic_result = qcng.compute(atomic_input, "xtb")
atomic_result = checkver_and_convert(atomic_result, request.name, "post")
atomic_result = checkver_and_convert(atomic_result, request.node.name, "post")

assert atomic_result.success
assert pytest.approx(atomic_result.return_result["dipole"], abs=thr) == return_result["dipole"]
Expand All @@ -203,9 +203,9 @@ def test_xtb_task_gfn1xtb_m05(schema_versions, request):
driver="energy",
)

atomic_input = checkver_and_convert(atomic_input, request.name, "pre")
atomic_input = checkver_and_convert(atomic_input, request.node.name, "pre")
atomic_result = qcng.compute(atomic_input, "xtb")
atomic_result = checkver_and_convert(atomic_result, request.name, "post")
atomic_result = checkver_and_convert(atomic_result, request.node.name, "post")

assert atomic_result.success
assert pytest.approx(atomic_result.return_result, abs=thr) == return_result
Expand Down Expand Up @@ -245,9 +245,9 @@ def test_xtb_task_gfn2xtb_m01(schema_versions, request):
driver="gradient",
)

atomic_input = checkver_and_convert(atomic_input, request.name, "pre")
atomic_input = checkver_and_convert(atomic_input, request.node.name, "pre")
atomic_result = qcng.compute(atomic_input, "xtb")
atomic_result = checkver_and_convert(atomic_result, request.name, "post")
atomic_result = checkver_and_convert(atomic_result, request.node.name, "post")

assert atomic_result.success
assert pytest.approx(atomic_result.return_result, abs=thr) == return_result
Expand Down

0 comments on commit a627ee4

Please sign in to comment.