Skip to content

Commit

Permalink
Do not compare virtual site weights to OpenMM (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwthompson authored Nov 6, 2023
1 parent e053535 commit 90e7053
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions openff/evaluator/_tests/test_utils/test_openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from openff.units import unit
from openff.units.openmm import from_openmm, to_openmm
from openmm import unit as openmm_unit
from openmm.app import ForceField as OpenMMForceField
from openmm.app import PDBFile

from openff.evaluator.backends import ComputeResources
Expand Down Expand Up @@ -389,24 +388,11 @@ def test_system_subset_virtual_site_water(add_nonwater):
assert system.getNumForces() == 2
assert system.getNumParticles() == 4 + int(add_nonwater) * 5

# Compare to OpenMM's reference values; w1 and w2 should be halved and w0 increased by remainder
# https://github.com/openmm/openmm/blob/8.0.0/wrappers/python/openmm/app/data/tip4pfb.xml#L17

TIP4P_openmm = OpenMMForceField("tip4pfb.xml")
reference_weights = TIP4P_openmm._templates["HOH"].virtualSites[0].weights

# The virtual site (one in this topology) will be at the end, not interlaced
subset_weights = [
system.getVirtualSite(system.getNumParticles() - 1).getWeight(0),
system.getVirtualSite(system.getNumParticles() - 1).getWeight(1),
system.getVirtualSite(system.getNumParticles() - 1).getWeight(2),
]

assert sum(subset_weights) == 1.0
assert sum(reference_weights) == 1.0

assert subset_weights[1] == pytest.approx(reference_weights[1] * 0.5)
assert subset_weights[2] == pytest.approx(reference_weights[2] * 0.5)
assert isinstance(
system.getVirtualSite(system.getNumParticles() - 1),
openmm.LocalCoordinatesSite,
)

# Hack, just put the virtual site on the oxygen; not accurate but allows it to run
if add_nonwater:
Expand Down

0 comments on commit 90e7053

Please sign in to comment.