Skip to content

Commit

Permalink
Use Interchange functionality to create openmm system (#528)
Browse files Browse the repository at this point in the history
* Use Interchange functionality to create openmm system

* Use collection.check_openmm_requirements to check for openmm incompatabilities
  • Loading branch information
aehogan committed Sep 27, 2023
1 parent ce44655 commit e95b28b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion openff/evaluator/protocols/forcefield.py
Expand Up @@ -13,6 +13,7 @@
import numpy as np
import openmm
import requests
from openff.interchange import Interchange
from openff.units import unit
from openff.units.openmm import to_openmm
from openmm import app
Expand Down Expand Up @@ -561,7 +562,23 @@ def _execute(self, directory, available_resources):
pdb_file.topology, unique_molecules=unique_molecules
)

system = force_field.create_openmm_system(topology)
interchange = Interchange.from_smirnoff(
topology=topology, force_field=force_field
)

# Check for openmm incompatibilities
combine_nonbonded_forces = True
for collection in interchange.collections.values():
try:
collection.check_openmm_requirements(
combine_nonbonded_forces=combine_nonbonded_forces
)
except AssertionError:
combine_nonbonded_forces = False

system = interchange.to_openmm(
combine_nonbonded_forces=combine_nonbonded_forces
)

if system is None:
raise RuntimeError(
Expand Down

0 comments on commit e95b28b

Please sign in to comment.