"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "9e34d39e48d3431e9e35958ed0bf7fdc97cb042b"
Commit 4572d2e3 authored by Justin MacCallum's avatar Justin MacCallum
Browse files

Changed gb settings to use strings rather than named constants.

parent 960d2010
...@@ -40,11 +40,11 @@ import simtk.unit as unit ...@@ -40,11 +40,11 @@ import simtk.unit as unit
import simtk.openmm as mm import simtk.openmm as mm
# Enumerated values for implicit solvent model # Enumerated values for implicit solvent model
# Prefer to use strings now, but these are here for backwards compatibility
HCT = object() HCT = 'HCT'
OBC1 = object() OBC1 = 'OBC1'
OBC2 = object() OBC2 = 'OBC2'
GBn = object() GBn = 'GBn'
class AmberPrmtopFile(object): class AmberPrmtopFile(object):
"""AmberPrmtopFile parses an AMBER prmtop file and constructs a Topology and (optionally) an OpenMM System from it.""" """AmberPrmtopFile parses an AMBER prmtop file and constructs a Topology and (optionally) an OpenMM System from it."""
...@@ -122,7 +122,8 @@ class AmberPrmtopFile(object): ...@@ -122,7 +122,8 @@ class AmberPrmtopFile(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
- implicitSolvent (object=None) If not None, the implicit solvent model to use. Allowed values are HCT, OBC1, OBC2, or GBn. - implicitSolvent (object=None) If not None, the implicit solvent
model to use. Allowed values are 'HCT', 'OBC1', 'OBC2', or 'GBn'.
- soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model. - soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model.
- solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model. - solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model.
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System - removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
...@@ -148,21 +149,12 @@ class AmberPrmtopFile(object): ...@@ -148,21 +149,12 @@ class AmberPrmtopFile(object):
constraintString = constraintMap[constraints] constraintString = constraintMap[constraints]
else: else:
raise ValueError('Illegal value for constraints') raise ValueError('Illegal value for constraints')
if implicitSolvent is None:
implicitString = None sys = amber_file_parser.readAmberSystem(prmtop_loader=self._prmtop, shake=constraintString,
elif implicitSolvent == HCT: nonbondedCutoff=nonbondedCutoff, nonbondedMethod=methodMap[nonbondedMethod],
implicitString = 'HCT' flexibleConstraints=False, gbmodel=implicitSolvent,
elif implicitSolvent == OBC1: soluteDielectric=soluteDielectric, solventDielectric=solventDielectric,
implicitString = 'OBC1' rigidWater=rigidWater)
elif implicitSolvent == OBC2:
implicitString = 'OBC2'
elif implicitSolvent == GBn:
implicitString = 'GBn'
else:
raise ValueError('Illegal value for implicit solvent model')
sys = amber_file_parser.readAmberSystem(prmtop_loader=self._prmtop, shake=constraintString, nonbondedCutoff=nonbondedCutoff,
nonbondedMethod=methodMap[nonbondedMethod], flexibleConstraints=False, gbmodel=implicitString,
soluteDielectric=soluteDielectric, solventDielectric=solventDielectric, rigidWater=rigidWater)
for force in sys.getForces(): for force in sys.getForces():
if isinstance(force, mm.NonbondedForce): if isinstance(force, mm.NonbondedForce):
force.setEwaldErrorTolerance(ewaldErrorTolerance) force.setEwaldErrorTolerance(ewaldErrorTolerance)
......
...@@ -45,7 +45,7 @@ HBonds = ff.HBonds ...@@ -45,7 +45,7 @@ HBonds = ff.HBonds
AllBonds = ff.AllBonds AllBonds = ff.AllBonds
HAngles = ff.HAngles HAngles = ff.HAngles
OBC2 = prmtop.OBC2 OBC2 = 'OBC2'
class GromacsTopFile(object): class GromacsTopFile(object):
"""GromacsTopFile parses a Gromacs top file and constructs a Topology and (optionally) an OpenMM System from it.""" """GromacsTopFile parses a Gromacs top file and constructs a Topology and (optionally) an OpenMM System from it."""
...@@ -426,7 +426,7 @@ class GromacsTopFile(object): ...@@ -426,7 +426,7 @@ class GromacsTopFile(object):
- constraints (object=None) Specifies which bonds and angles should be implemented with constraints. - constraints (object=None) Specifies which bonds and 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
- implicitSolvent (object=None) If not None, the implicit solvent model to use. The only allowed value is OBC2. - implicitSolvent (string=None) If not None, the implicit solvent model to use. The only allowed value is 'OBC2'.
- soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model. - soluteDielectric (float=1.0) The solute dielectric constant to use in the implicit solvent model.
- solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model. - solventDielectric (float=78.5) The solvent dielectric constant to use in the implicit solvent model.
- ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME. - ewaldErrorTolerance (float=0.0005) The error tolerance to use if nonbondedMethod is Ewald or PME.
...@@ -443,7 +443,7 @@ class GromacsTopFile(object): ...@@ -443,7 +443,7 @@ class GromacsTopFile(object):
raise ValueError('Illegal nonbonded method for a non-periodic system') raise ValueError('Illegal nonbonded method for a non-periodic system')
nb = mm.NonbondedForce() nb = mm.NonbondedForce()
sys.addForce(nb) sys.addForce(nb)
if implicitSolvent is OBC2: if implicitSolvent == 'OBC2':
gb = mm.GBSAOBCForce() gb = mm.GBSAOBCForce()
gb.setSoluteDielectric(soluteDielectric) gb.setSoluteDielectric(soluteDielectric)
gb.setSolventDielectric(solventDielectric) gb.setSolventDielectric(solventDielectric)
...@@ -656,7 +656,7 @@ class GromacsTopFile(object): ...@@ -656,7 +656,7 @@ class GromacsTopFile(object):
else: else:
q = float(params[3]) q = float(params[3])
nb.addParticle(q, float(params[5]), float(params[6])) nb.addParticle(q, float(params[5]), float(params[6]))
if implicitSolvent is OBC2: if implicitSolvent == 'OBC2':
if fields[1] not in self._implicitTypes: if fields[1] not in self._implicitTypes:
raise ValueError('No implicit solvent parameters specified for atom type: '+fields[1]) raise ValueError('No implicit solvent parameters specified for atom type: '+fields[1])
gbparams = self._implicitTypes[fields[1]] gbparams = self._implicitTypes[fields[1]]
......
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