diff --git a/deforcefields/offxml/de-force-1.0.2.offxml b/deforcefields/offxml/de-force-1.0.2.offxml new file mode 100644 index 0000000..58922ff --- /dev/null +++ b/deforcefields/offxml/de-force-1.0.2.offxml @@ -0,0 +1,347 @@ + + + Cole Group + 2023-02-17 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deforcefields/offxml/de-force_unconstrained-1.0.2.offxml b/deforcefields/offxml/de-force_unconstrained-1.0.2.offxml new file mode 100644 index 0000000..62ef060 --- /dev/null +++ b/deforcefields/offxml/de-force_unconstrained-1.0.2.offxml @@ -0,0 +1,346 @@ + + + Cole Group + 2023-02-17 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deforcefields/tests/test_deforcefields.py b/deforcefields/tests/test_deforcefields.py index de5a0eb..be9679d 100644 --- a/deforcefields/tests/test_deforcefields.py +++ b/deforcefields/tests/test_deforcefields.py @@ -1,8 +1,10 @@ """ Test loading DE-Force fields via the plugin interface through the toolkit. """ + import openmm import pytest +from openff.interchange.drivers.openmm import get_openmm_energies from openff.toolkit import ForceField, Molecule from openmm import unit @@ -10,8 +12,8 @@ @pytest.mark.parametrize( "forcefield", [ - pytest.param("de-force-1.0.1.offxml", id="No constraints"), - pytest.param("de-force_unconstrained-1.0.1.offxml", id="Constraints"), + pytest.param("de-force-1.0.2.offxml", id="No constraints"), + pytest.param("de-force_unconstrained-1.0.2.offxml", id="Constraints"), ], ) def test_load_de_ff(forcefield): @@ -47,3 +49,43 @@ def test_load_de_ff(forcefield): assert epsilon > 0 assert custom_force.getNonbondedMethod() == openmm.NonbondedForce.NoCutoff + + +def test_openmm_energies_not_crazy(): + # Could pick any ligand that's supported by both FFs + molecule = Molecule.from_smiles("NC(=O)c1cccc2c1OCCO2") + molecule.generate_conformers(n_conformers=1) + topology = molecule.to_topology() + + sage_energies = get_openmm_energies( + ForceField("openff-2.1.0.offxml").create_interchange(topology), + combine_nonbonded_forces=False, + ) + + de_energies = get_openmm_energies( + ForceField( + "de-force-1.0.2.offxml", + load_plugins=True, + ).create_interchange(topology), + combine_nonbonded_forces=False, + ) + + # Energies should differ a little bit, but be similar + assert 0.1 < sage_energies["vdW"] / de_energies["vdW"] < 10 + + # Electrostatics methods are the same, so energies should be as well + assert sage_energies["Electrostatics"].m == pytest.approx( + de_energies["Electrostatics"].m + ) + + +def test_fails_unsupported_chemistry(): + # No double exponential parameters for H bonded to C#, + # so this should error instead of assigning blank/bogus parameters + with pytest.raises(KeyError, match="atom indices .*2"): + ForceField( + "de-force-1.0.2.offxml", + load_plugins=True, + ).create_interchange( + Molecule.from_mapped_smiles("[H:3][C:1]#[C:2][H:4]").to_topology() + ).to_openmm(combine_nonbonded_forces=False) diff --git a/devtools/conda-envs/test_env.yaml b/devtools/conda-envs/test_env.yaml index 8af3d31..c79f6e8 100644 --- a/devtools/conda-envs/test_env.yaml +++ b/devtools/conda-envs/test_env.yaml @@ -12,7 +12,7 @@ dependencies: # Core-deps - openff-toolkit >=0.14.3 - - openff-interchange >=0.3.11 + - openff-interchange >=0.3.18 # the above two constraints are pulled in by smirnoff-plugins; # could just drop them, but maybe it's better to be explicit - smirnoff-plugins >=2023.08.0