Skip to content

Commit

Permalink
Merge pull request #12 from jthorton/plugin-sites
Browse files Browse the repository at this point in the history
Plugin v-sites update
  • Loading branch information
jthorton authored Aug 6, 2024
2 parents eb99f5e + 03087ba commit e491139
Show file tree
Hide file tree
Showing 6 changed files with 713 additions and 23 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
- macOS-latest
- ubuntu-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"

steps:
- uses: actions/checkout@v3
Expand All @@ -49,11 +49,6 @@ jobs:
run: |
python -m pip install .
- name: Environment Information
run: |
conda info
conda list --show-channel-urls
- name: PyTest
run: |
pytest -v deforcefields/tests/
347 changes: 347 additions & 0 deletions deforcefields/offxml/de-force-1.0.3.offxml

Large diffs are not rendered by default.

346 changes: 346 additions & 0 deletions deforcefields/offxml/de-force_unconstrained-1.0.3.offxml

Large diffs are not rendered by default.

28 changes: 15 additions & 13 deletions deforcefields/tests/test_deforcefields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
from openff.interchange.drivers.openmm import get_openmm_energies
from openff.toolkit import ForceField, Molecule, Quantity, Topology
from openmm import unit
from smirnoff_plugins.utilities.openmm import evaluate_water_energy_at_distances


@pytest.mark.parametrize(
"forcefield",
[
pytest.param("de-force-1.0.2.offxml", id="No constraints"),
pytest.param("de-force_unconstrained-1.0.2.offxml", id="Constraints"),
pytest.param("de-force-1.0.3.offxml", id="No constraints"),
pytest.param("de-force_unconstrained-1.0.3.offxml", id="Constraints"),
],
)
def test_load_de_ff(forcefield, ethanol_with_charges):
Expand Down Expand Up @@ -65,7 +66,7 @@ def test_openmm_energies_not_crazy():

de_energies = get_openmm_energies(
ForceField(
"de-force-1.0.2.offxml",
"de-force-1.0.3.offxml",
load_plugins=True,
).create_interchange(topology),
combine_nonbonded_forces=False,
Expand All @@ -85,7 +86,7 @@ def test_fails_unsupported_chemistry():
# 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",
"de-force-1.0.3.offxml",
load_plugins=True,
).create_interchange(
Molecule.from_mapped_smiles("[H:3][C:1]#[C:2][H:4]").to_topology()
Expand All @@ -95,9 +96,9 @@ def test_fails_unsupported_chemistry():
@pytest.mark.parametrize(
"forcefield, ref_energy",
[
pytest.param("de-force-1.0.2.offxml", 13.601144438830156, id="No constraints"),
pytest.param("de-force-1.0.3.offxml", 13.601144438830156, id="No constraints"),
pytest.param(
"de-force_unconstrained-1.0.2.offxml", 13.605201859835375, id="Constraints"
"de-force_unconstrained-1.0.3.offxml", 13.605201859835375, id="Constraints"
),
],
)
Expand Down Expand Up @@ -160,18 +161,19 @@ def evaluate_water_energy_at_distance(

@pytest.mark.parametrize(
("distance", "ref_energy"),
[(2, 1005.0846252441406), (3, 44.696786403656006), (4, 10.453390896320343)],
# calculated using openmm-8.1.2 August-2024
[(2, 1005.0847473144531), (3, 44.696786403656006), (4, 10.453390896320343)],
)
def test_energy_sites(distance, ref_energy):
"""
Test calculating the energy for a system with two waters with virtual sites at set distances.
"""
ff = ForceField("de-force-1.0.3.offxml", load_plugins=True, allow_cosmetic_attributes=True)

ff = ForceField("de-force-1.0.2.offxml", load_plugins=True)

found_energy = evaluate_water_energy_at_distance(
energy = evaluate_water_energy_at_distances(
force_field=ff,
distance=distance,
)
distances=[distance],
)[0]

assert energy == pytest.approx(ref_energy, abs=0.01)

assert found_energy.m_as(kj_mol) == pytest.approx(ref_energy, abs=0.01)
6 changes: 3 additions & 3 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dependencies:
- pytest

# Core-deps
- openff-toolkit >=0.15
- openff-interchange >=0.3.23
- openff-toolkit >=0.16
- openff-interchange >=0.3.25
# the above two constraints are pulled in by smirnoff-plugins;
# could just drop them, but maybe it's better to be explicit
- smirnoff-plugins >=2024.01.0
- smirnoff-plugins >=2024.07.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ filterwarnings =
ignore::PendingDeprecationWarning

[options]
python_requires = >=3.8, <=3.12
python_requires = >=3.10, <3.13

0 comments on commit e491139

Please sign in to comment.