From 52d3b8765791399e9df093c3df6bb0ce9c6e409a Mon Sep 17 00:00:00 2001 From: Christopher Woods Date: Sat, 2 Dec 2023 10:55:25 +0000 Subject: [PATCH] Fixed platform issue that caused test failure on GH MacOS runner Added in an energy check so that we test for regressions in calculating the total energy for contexts with and without energy terms for constraint internals --- tests/convert/test_openmm.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/convert/test_openmm.py b/tests/convert/test_openmm.py index a34757c72..4a014ebf5 100644 --- a/tests/convert/test_openmm.py +++ b/tests/convert/test_openmm.py @@ -292,7 +292,9 @@ def test_openmm_ignore_constrained(ala_mols): def test_openmm_no_zero_sigmas(zero_lj_mols): mols = zero_lj_mols - omm = sr.convert.to(mols, "openmm", map={"constraint": "h-bonds"}) + omm = sr.convert.to(mols, "openmm", + map={"constraint": "h-bonds", + "platform": "Reference"}) from openmm import XmlSerializer @@ -312,15 +314,27 @@ def test_openmm_skipped_constrained_bonds(zero_lj_mols): omm1 = sr.convert.to( mols, "openmm", - map={"constraint": "h-bonds", "include_constrained_energies": True}, + map={"constraint": "h-bonds", + "include_constrained_energies": True, + "platform": "Reference"}, ) omm2 = sr.convert.to( mols, "openmm", - map={"constraint": "h-bonds", "include_constrained_energies": False}, + map={"constraint": "h-bonds", + "include_constrained_energies": False, + "platform": "Reference"}, ) + nrg1 = omm1.get_potential_energy().to(sr.units.kcal_per_mol) + nrg2 = omm2.get_potential_energy().to(sr.units.kcal_per_mol) + + # Check the energies haven't changed + # (regression check - here are the current values) + assert nrg1 == pytest.approx(-447.44, 1e-3) + assert nrg2 == pytest.approx(-3279.87, 1e-3) + from openmm import XmlSerializer xml1 = XmlSerializer.serialize(omm1.getSystem())