Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use openmm.LangevinMiddleIntegrator #1137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/ligand_in_water/ligand_in_water.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
" pdb_stride: int = 500,\n",
" trajectory_name: str = \"trajectory.pdb\",\n",
") -> openmm.app.Simulation:\n",
" integrator = openmm.LangevinIntegrator(\n",
" integrator = openmm.LangevinMiddleIntegrator(\n",
" 300 * openmm.unit.kelvin,\n",
" 1 / openmm.unit.picosecond,\n",
" 1 * openmm.unit.femtoseconds,\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/openmm/openmm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"temperature = 300 * openmm.unit.kelvin # simulation temperature\n",
"friction = 1 / openmm.unit.picosecond # friction constant\n",
"\n",
"integrator = openmm.LangevinIntegrator(temperature, friction, time_step)"
"integrator = openmm.LangevinMiddleIntegrator(temperature, friction, time_step)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/virtual_sites/virtual_sites.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"\n",
" # interchange.minimize()\n",
"\n",
" integrator = openmm.LangevinIntegrator(\n",
" integrator = openmm.LangevinMiddleIntegrator(\n",
" 300 * openmm.unit.kelvin,\n",
" 1 / openmm.unit.picosecond,\n",
" 1 * openmm.unit.femtoseconds,\n",
Expand Down
6 changes: 5 additions & 1 deletion openff/interchange/_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,11 @@ def default_integrator():
import openmm
import openmm.unit

return openmm.VerletIntegrator(2.0 * openmm.unit.femtosecond)
return openmm.LangevinMiddleIntegrator(
300 * openmm.unit.kelvin,
1 / openmm.unit.picosecond,
2.0 * openmm.unit.femtosecond,
)

except ImportError:
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,16 @@ def test_fill_in_rigid_water_parameters(self, water_dimer, monkeypatch):
},
)

def test_only_constrained_water(self, water_dimer):
def test_only_constrained_water(
self,
water_dimer,
default_integrator,
):
water_dimer.box_vectors = Quantity([4, 4, 4], "nanometer")

interchange = ForceField("openff-2.2.1.offxml").create_interchange(water_dimer)

simulation = interchange.to_openmm_simulation(integrator=openmm.LangevinIntegrator(300, 1, 0.001))
simulation = interchange.to_openmm_simulation(integrator=default_integrator)
system = simulation.system

for index in range(system.getNumForces()):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ def test_hmr_not_applied_to_tip4p(


@pytest.mark.parametrize("hydrogen_mass", [1.1, 3.0])
def test_hmr_with_ligand_virtual_sites(sage_with_bond_charge, hydrogen_mass):
def test_hmr_with_ligand_virtual_sites(
sage_with_bond_charge,
hydrogen_mass,
default_integrator,
):
"""Test that a single-molecule sigma hole example runs"""
pytest.importorskip("openmm")
import openmm
Expand All @@ -113,7 +117,7 @@ def test_hmr_with_ligand_virtual_sites(sage_with_bond_charge, hydrogen_mass):

# should work fine with 4 fs, but be conservative and just use 3 fs
simulation = sage_with_bond_charge.create_interchange(molecule.to_topology()).to_openmm_simulation(
integrator=openmm.VerletIntegrator(3.0 * openmm.unit.femtosecond),
integrator=default_integrator,
hydrogen_mass=hydrogen_mass,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ def generate_v_site_coordinates(

context = openmm.Context(
system,
openmm.VerletIntegrator(1.0 * openmm.unit.femtosecond),
openmm.LangevinMiddleIntegrator(
300 * openmm.unit.kelvin,
1 / openmm.unit.picosecond,
2.0 * openmm.unit.femtosecond,
),
openmm.Platform.getPlatformByName("Reference"),
)

Expand Down
7 changes: 6 additions & 1 deletion openff/interchange/drivers/openmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ def _get_openmm_energies(
for index, force in enumerate(system.getForces()):
force.setForceGroup(index)

integrator = openmm.VerletIntegrator(1.0 * openmm.unit.femtoseconds)
integrator = openmm.LangevinMiddleIntegrator(
300 * openmm.unit.kelvin,
1.0 / openmm.unit.picosecond,
1.0 * openmm.unit.femtoseconds,
)

context = openmm.Context(
system,
integrator,
Expand Down
Loading