Commit 9a1b72ff authored by Peter Eastman's avatar Peter Eastman
Browse files

When creating a System, add a CMMotionRemover by default

parent 2586776f
...@@ -9,6 +9,7 @@ from simtk.openmm.app.internal import amber_file_parser ...@@ -9,6 +9,7 @@ from simtk.openmm.app.internal import amber_file_parser
import forcefield as ff import forcefield as ff
import element as elem import element as elem
import simtk.unit as unit import simtk.unit as unit
import simtk.openmm as mm
# Enumerated values for implicit solvent model # Enumerated values for implicit solvent model
...@@ -63,7 +64,7 @@ class AmberPrmtopFile(object): ...@@ -63,7 +64,7 @@ class AmberPrmtopFile(object):
top.addBond(bond[0], bond[1]) top.addBond(bond[0], bond[1])
def createSystem(self, nonbondedMethod=ff.NoCutoff, nonbondedCutoff=1.0*unit.nanometer, def createSystem(self, nonbondedMethod=ff.NoCutoff, nonbondedCutoff=1.0*unit.nanometer,
constraints=None, rigidWater=True, implicitSolvent=None): constraints=None, rigidWater=True, implicitSolvent=None, removeCMMotion=True):
"""Construct an OpenMM System representing the topology described by this prmtop file. """Construct an OpenMM System representing the topology described by this prmtop file.
Parameters: Parameters:
...@@ -74,6 +75,7 @@ class AmberPrmtopFile(object): ...@@ -74,6 +75,7 @@ class AmberPrmtopFile(object):
Allowed values are None, HBonds, AllBonds, or HAngles. Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument - rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- implicitSolvent (object=None) If not None, the implicit solvent model to use - implicitSolvent (object=None) If not None, the implicit solvent model to use
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
Returns: the newly created System Returns: the newly created System
""" """
methodMap = {ff.NoCutoff:'NoCutoff', methodMap = {ff.NoCutoff:'NoCutoff',
...@@ -103,5 +105,8 @@ class AmberPrmtopFile(object): ...@@ -103,5 +105,8 @@ class AmberPrmtopFile(object):
implicitString = 'OBC' implicitString = 'OBC'
else: else:
raise ValueError('Illegal value for implicit solvent model') raise ValueError('Illegal value for implicit solvent model')
return amber_file_parser.readAmberSystem(prmtop_loader=self.prmtop, shake=constraintString, nonbondedCutoff=nonbondedCutoff, sys = amber_file_parser.readAmberSystem(prmtop_loader=self.prmtop, shake=constraintString, nonbondedCutoff=nonbondedCutoff,
nonbondedMethod=methodMap[nonbondedMethod], flexibleConstraints=False, gbmodel=implicitString) nonbondedMethod=methodMap[nonbondedMethod], flexibleConstraints=False, gbmodel=implicitString)
\ No newline at end of file if removeCMMotion:
sys.addForce(mm.CMMotionRemover())
return sys
\ No newline at end of file
...@@ -177,7 +177,7 @@ class ForceField(object): ...@@ -177,7 +177,7 @@ class ForceField(object):
self.length = 0.0 self.length = 0.0
def createSystem(self, topology, nonbondedMethod=NoCutoff, nonbondedCutoff=1.0*unit.nanometer, def createSystem(self, topology, nonbondedMethod=NoCutoff, nonbondedCutoff=1.0*unit.nanometer,
constraints=None, rigidWater=True, **args): constraints=None, rigidWater=True, removeCMMotion=True, **args):
"""Construct an OpenMM System representing a Topology with this force field. """Construct an OpenMM System representing a Topology with this force field.
Parameters: Parameters:
...@@ -188,6 +188,7 @@ class ForceField(object): ...@@ -188,6 +188,7 @@ class ForceField(object):
- constraints (object=None) Specifies which bonds angles should be implemented with constraints. - constraints (object=None) Specifies which bonds angles should be implemented with constraints.
Allowed values are None, HBonds, AllBonds, or HAngles. Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument - rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
- Arbitrary additional keyword arguments may also be specified. This allows extra parameters to be specified that are specific to - Arbitrary additional keyword arguments may also be specified. This allows extra parameters to be specified that are specific to
particular force fields. particular force fields.
Returns: the newly created System Returns: the newly created System
...@@ -341,6 +342,8 @@ class ForceField(object): ...@@ -341,6 +342,8 @@ class ForceField(object):
for force in self._forces: for force in self._forces:
force.createForce(sys, data, nonbondedMethod, nonbondedCutoff, args) force.createForce(sys, data, nonbondedMethod, nonbondedCutoff, args)
if removeCMMotion:
sys.addForce(mm.CMMotionRemover())
return sys return sys
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment