"platforms/opencl/vscode:/vscode.git/clone" did not exist on "5bca8d129199f6f7cfdfecdf86ed0826dc43bc83"
Commit 572abf66 authored by peastman's avatar peastman
Browse files

Merge pull request #1368 from swails/scee

Compare 1-4 scaling factors by looking at size of difference
parents ed2b92e2 bb92e3c0
...@@ -345,7 +345,7 @@ class ForceField(object): ...@@ -345,7 +345,7 @@ class ForceField(object):
index += 1 index += 1
return torsion return torsion
class _SystemData: class _SystemData(object):
"""Inner class used to encapsulate data about the system being created.""" """Inner class used to encapsulate data about the system being created."""
def __init__(self): def __init__(self):
self.atomType = {} self.atomType = {}
...@@ -371,7 +371,7 @@ class ForceField(object): ...@@ -371,7 +371,7 @@ class ForceField(object):
self.constraints[key] = distance self.constraints[key] = distance
system.addConstraint(atom1, atom2, distance) system.addConstraint(atom1, atom2, distance)
class _TemplateData: class _TemplateData(object):
"""Inner class used to encapsulate data about a residue template definition.""" """Inner class used to encapsulate data about a residue template definition."""
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
...@@ -413,7 +413,7 @@ class ForceField(object): ...@@ -413,7 +413,7 @@ class ForceField(object):
atom = self.getAtomIndexByName(atom_name) atom = self.getAtomIndexByName(atom_name)
self.addExternalBond(atom) self.addExternalBond(atom)
class _TemplateAtomData: class _TemplateAtomData(object):
"""Inner class used to encapsulate data about an atom in a residue template definition.""" """Inner class used to encapsulate data about an atom in a residue template definition."""
def __init__(self, name, type, element, parameters={}): def __init__(self, name, type, element, parameters={}):
self.name = name self.name = name
...@@ -423,7 +423,7 @@ class ForceField(object): ...@@ -423,7 +423,7 @@ class ForceField(object):
self.bondedTo = [] self.bondedTo = []
self.externalBonds = 0 self.externalBonds = 0
class _BondData: class _BondData(object):
"""Inner class used to encapsulate data about a bond.""" """Inner class used to encapsulate data about a bond."""
def __init__(self, atom1, atom2): def __init__(self, atom1, atom2):
self.atom1 = atom1 self.atom1 = atom1
...@@ -431,7 +431,7 @@ class ForceField(object): ...@@ -431,7 +431,7 @@ class ForceField(object):
self.isConstrained = False self.isConstrained = False
self.length = 0.0 self.length = 0.0
class _VirtualSiteData: class _VirtualSiteData(object):
"""Inner class used to encapsulate data about a virtual site.""" """Inner class used to encapsulate data about a virtual site."""
def __init__(self, node, atomIndices): def __init__(self, node, atomIndices):
attrib = node.attrib attrib = node.attrib
...@@ -464,7 +464,7 @@ class ForceField(object): ...@@ -464,7 +464,7 @@ class ForceField(object):
else: else:
self.excludeWith = self.atoms[0] self.excludeWith = self.atoms[0]
class _AtomType: class _AtomType(object):
"""Inner class used to record atom types and associated properties.""" """Inner class used to record atom types and associated properties."""
def __init__(self, name, atomClass, mass, element): def __init__(self, name, atomClass, mass, element):
self.name = name self.name = name
...@@ -472,7 +472,7 @@ class ForceField(object): ...@@ -472,7 +472,7 @@ class ForceField(object):
self.mass = mass self.mass = mass
self.element = element self.element = element
class _AtomTypeParameters: class _AtomTypeParameters(object):
"""Inner class used to record parameter values for atom types.""" """Inner class used to record parameter values for atom types."""
def __init__(self, forcefield, forceName, atomTag, paramNames): def __init__(self, forcefield, forceName, atomTag, paramNames):
self.ff = forcefield self.ff = forcefield
...@@ -1163,7 +1163,7 @@ def _createResidueTemplate(residue): ...@@ -1163,7 +1163,7 @@ def _createResidueTemplate(residue):
# to the System. The static method should be added to the parsers map. # to the System. The static method should be added to the parsers map.
## @private ## @private
class HarmonicBondGenerator: class HarmonicBondGenerator(object):
"""A HarmonicBondGenerator constructs a HarmonicBondForce.""" """A HarmonicBondGenerator constructs a HarmonicBondForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1214,7 +1214,7 @@ parsers["HarmonicBondForce"] = HarmonicBondGenerator.parseElement ...@@ -1214,7 +1214,7 @@ parsers["HarmonicBondForce"] = HarmonicBondGenerator.parseElement
## @private ## @private
class HarmonicAngleGenerator: class HarmonicAngleGenerator(object):
"""A HarmonicAngleGenerator constructs a HarmonicAngleForce.""" """A HarmonicAngleGenerator constructs a HarmonicAngleForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1287,7 +1287,7 @@ parsers["HarmonicAngleForce"] = HarmonicAngleGenerator.parseElement ...@@ -1287,7 +1287,7 @@ parsers["HarmonicAngleForce"] = HarmonicAngleGenerator.parseElement
## @private ## @private
class PeriodicTorsion: class PeriodicTorsion(object):
"""A PeriodicTorsion records the information for a periodic torsion definition.""" """A PeriodicTorsion records the information for a periodic torsion definition."""
def __init__(self, types): def __init__(self, types):
...@@ -1300,7 +1300,7 @@ class PeriodicTorsion: ...@@ -1300,7 +1300,7 @@ class PeriodicTorsion:
self.k = [] self.k = []
## @private ## @private
class PeriodicTorsionGenerator: class PeriodicTorsionGenerator(object):
"""A PeriodicTorsionGenerator constructs a PeriodicTorsionForce.""" """A PeriodicTorsionGenerator constructs a PeriodicTorsionForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1398,7 +1398,7 @@ parsers["PeriodicTorsionForce"] = PeriodicTorsionGenerator.parseElement ...@@ -1398,7 +1398,7 @@ parsers["PeriodicTorsionForce"] = PeriodicTorsionGenerator.parseElement
## @private ## @private
class RBTorsion: class RBTorsion(object):
"""An RBTorsion records the information for a Ryckaert-Bellemans torsion definition.""" """An RBTorsion records the information for a Ryckaert-Bellemans torsion definition."""
def __init__(self, types, c): def __init__(self, types, c):
...@@ -1409,7 +1409,7 @@ class RBTorsion: ...@@ -1409,7 +1409,7 @@ class RBTorsion:
self.c = c self.c = c
## @private ## @private
class RBTorsionGenerator: class RBTorsionGenerator(object):
"""An RBTorsionGenerator constructs an RBTorsionForce.""" """An RBTorsionGenerator constructs an RBTorsionForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1501,7 +1501,7 @@ parsers["RBTorsionForce"] = RBTorsionGenerator.parseElement ...@@ -1501,7 +1501,7 @@ parsers["RBTorsionForce"] = RBTorsionGenerator.parseElement
## @private ## @private
class CMAPTorsion: class CMAPTorsion(object):
"""A CMAPTorsion records the information for a CMAP torsion definition.""" """A CMAPTorsion records the information for a CMAP torsion definition."""
def __init__(self, types, map): def __init__(self, types, map):
...@@ -1513,7 +1513,7 @@ class CMAPTorsion: ...@@ -1513,7 +1513,7 @@ class CMAPTorsion:
self.map = map self.map = map
## @private ## @private
class CMAPTorsionGenerator: class CMAPTorsionGenerator(object):
"""A CMAPTorsionGenerator constructs a CMAPTorsionForce.""" """A CMAPTorsionGenerator constructs a CMAPTorsionForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1593,9 +1593,11 @@ parsers["CMAPTorsionForce"] = CMAPTorsionGenerator.parseElement ...@@ -1593,9 +1593,11 @@ parsers["CMAPTorsionForce"] = CMAPTorsionGenerator.parseElement
## @private ## @private
class NonbondedGenerator: class NonbondedGenerator(object):
"""A NonbondedGenerator constructs a NonbondedForce.""" """A NonbondedGenerator constructs a NonbondedForce."""
SCALETOL = 1e-5
def __init__(self, forcefield, coulomb14scale, lj14scale): def __init__(self, forcefield, coulomb14scale, lj14scale):
self.ff = forcefield self.ff = forcefield
self.coulomb14scale = coulomb14scale self.coulomb14scale = coulomb14scale
...@@ -1614,7 +1616,8 @@ class NonbondedGenerator: ...@@ -1614,7 +1616,8 @@ class NonbondedGenerator:
else: else:
# Multiple <NonbondedForce> tags were found, probably in different files. Simply add more types to the existing one. # Multiple <NonbondedForce> tags were found, probably in different files. Simply add more types to the existing one.
generator = existing[0] generator = existing[0]
if generator.coulomb14scale != float(element.attrib['coulomb14scale']) or generator.lj14scale != float(element.attrib['lj14scale']): if abs(generator.coulomb14scale - float(element.attrib['coulomb14scale'])) > NonbondedGenerator.SCALETOL or \
abs(generator.lj14scale - float(element.attrib['lj14scale'])) > NonbondedGenerator.SCALETOL:
raise ValueError('Found multiple NonbondedForce tags with different 1-4 scales') raise ValueError('Found multiple NonbondedForce tags with different 1-4 scales')
generator.params.parseDefinitions(element) generator.params.parseDefinitions(element)
...@@ -1673,7 +1676,7 @@ parsers["NonbondedForce"] = NonbondedGenerator.parseElement ...@@ -1673,7 +1676,7 @@ parsers["NonbondedForce"] = NonbondedGenerator.parseElement
## @private ## @private
class GBSAOBCGenerator: class GBSAOBCGenerator(object):
"""A GBSAOBCGenerator constructs a GBSAOBCForce.""" """A GBSAOBCGenerator constructs a GBSAOBCForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1723,7 +1726,7 @@ parsers["GBSAOBCForce"] = GBSAOBCGenerator.parseElement ...@@ -1723,7 +1726,7 @@ parsers["GBSAOBCForce"] = GBSAOBCGenerator.parseElement
## @private ## @private
class CustomBondGenerator: class CustomBondGenerator(object):
"""A CustomBondGenerator constructs a CustomBondForce.""" """A CustomBondGenerator constructs a CustomBondForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1771,7 +1774,7 @@ parsers["CustomBondForce"] = CustomBondGenerator.parseElement ...@@ -1771,7 +1774,7 @@ parsers["CustomBondForce"] = CustomBondGenerator.parseElement
## @private ## @private
class CustomAngleGenerator: class CustomAngleGenerator(object):
"""A CustomAngleGenerator constructs a CustomAngleForce.""" """A CustomAngleGenerator constructs a CustomAngleForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1823,7 +1826,7 @@ parsers["CustomAngleForce"] = CustomAngleGenerator.parseElement ...@@ -1823,7 +1826,7 @@ parsers["CustomAngleForce"] = CustomAngleGenerator.parseElement
## @private ## @private
class CustomTorsion: class CustomTorsion(object):
"""A CustomTorsion records the information for a custom torsion definition.""" """A CustomTorsion records the information for a custom torsion definition."""
def __init__(self, types, paramValues): def __init__(self, types, paramValues):
...@@ -1834,7 +1837,7 @@ class CustomTorsion: ...@@ -1834,7 +1837,7 @@ class CustomTorsion:
self.paramValues = paramValues self.paramValues = paramValues
## @private ## @private
class CustomTorsionGenerator: class CustomTorsionGenerator(object):
"""A CustomTorsionGenerator constructs a CustomTorsionForce.""" """A CustomTorsionGenerator constructs a CustomTorsionForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -1932,7 +1935,7 @@ parsers["CustomTorsionForce"] = CustomTorsionGenerator.parseElement ...@@ -1932,7 +1935,7 @@ parsers["CustomTorsionForce"] = CustomTorsionGenerator.parseElement
## @private ## @private
class CustomNonbondedGenerator: class CustomNonbondedGenerator(object):
"""A CustomNonbondedGenerator constructs a CustomNonbondedForce.""" """A CustomNonbondedGenerator constructs a CustomNonbondedForce."""
def __init__(self, forcefield, energy, bondCutoff): def __init__(self, forcefield, energy, bondCutoff):
...@@ -2020,7 +2023,7 @@ parsers["CustomNonbondedForce"] = CustomNonbondedGenerator.parseElement ...@@ -2020,7 +2023,7 @@ parsers["CustomNonbondedForce"] = CustomNonbondedGenerator.parseElement
## @private ## @private
class CustomGBGenerator: class CustomGBGenerator(object):
"""A CustomGBGenerator constructs a CustomGBForce.""" """A CustomGBGenerator constructs a CustomGBForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
...@@ -2101,7 +2104,7 @@ parsers["CustomGBForce"] = CustomGBGenerator.parseElement ...@@ -2101,7 +2104,7 @@ parsers["CustomGBForce"] = CustomGBGenerator.parseElement
## @private ## @private
class CustomManyParticleGenerator: class CustomManyParticleGenerator(object):
"""A CustomManyParticleGenerator constructs a CustomManyParticleForce.""" """A CustomManyParticleGenerator constructs a CustomManyParticleForce."""
def __init__(self, forcefield, particlesPerSet, energy, permutationMode, bondCutoff): def __init__(self, forcefield, particlesPerSet, energy, permutationMode, bondCutoff):
...@@ -2226,7 +2229,7 @@ def countConstraint(data): ...@@ -2226,7 +2229,7 @@ def countConstraint(data):
print("Constraints bond=%d angle=%d total=%d" % (bondCount, angleCount, (bondCount+angleCount))) print("Constraints bond=%d angle=%d total=%d" % (bondCount, angleCount, (bondCount+angleCount)))
## @private ## @private
class AmoebaBondGenerator: class AmoebaBondGenerator(object):
#============================================================================================= #=============================================================================================
...@@ -2329,7 +2332,7 @@ def addAngleConstraint(angle, idealAngle, data, sys): ...@@ -2329,7 +2332,7 @@ def addAngleConstraint(angle, idealAngle, data, sys):
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaAngleGenerator: class AmoebaAngleGenerator(object):
#============================================================================================= #=============================================================================================
"""An AmoebaAngleGenerator constructs a AmoebaAngleForce.""" """An AmoebaAngleGenerator constructs a AmoebaAngleForce."""
...@@ -2518,7 +2521,7 @@ parsers["AmoebaAngleForce"] = AmoebaAngleGenerator.parseElement ...@@ -2518,7 +2521,7 @@ parsers["AmoebaAngleForce"] = AmoebaAngleGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaOutOfPlaneBendGenerator: class AmoebaOutOfPlaneBendGenerator(object):
#============================================================================================= #=============================================================================================
...@@ -2792,7 +2795,7 @@ parsers["AmoebaOutOfPlaneBendForce"] = AmoebaOutOfPlaneBendGenerator.parseElemen ...@@ -2792,7 +2795,7 @@ parsers["AmoebaOutOfPlaneBendForce"] = AmoebaOutOfPlaneBendGenerator.parseElemen
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaTorsionGenerator: class AmoebaTorsionGenerator(object):
#============================================================================================= #=============================================================================================
"""An AmoebaTorsionGenerator constructs a AmoebaTorsionForce.""" """An AmoebaTorsionGenerator constructs a AmoebaTorsionForce."""
...@@ -2901,7 +2904,7 @@ parsers["AmoebaTorsionForce"] = AmoebaTorsionGenerator.parseElement ...@@ -2901,7 +2904,7 @@ parsers["AmoebaTorsionForce"] = AmoebaTorsionGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaPiTorsionGenerator: class AmoebaPiTorsionGenerator(object):
#============================================================================================= #=============================================================================================
...@@ -3015,7 +3018,7 @@ parsers["AmoebaPiTorsionForce"] = AmoebaPiTorsionGenerator.parseElement ...@@ -3015,7 +3018,7 @@ parsers["AmoebaPiTorsionForce"] = AmoebaPiTorsionGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaTorsionTorsionGenerator: class AmoebaTorsionTorsionGenerator(object):
#============================================================================================= #=============================================================================================
"""An AmoebaTorsionTorsionGenerator constructs a AmoebaTorsionTorsionForce.""" """An AmoebaTorsionTorsionGenerator constructs a AmoebaTorsionTorsionForce."""
...@@ -3257,7 +3260,7 @@ parsers["AmoebaTorsionTorsionForce"] = AmoebaTorsionTorsionGenerator.parseElemen ...@@ -3257,7 +3260,7 @@ parsers["AmoebaTorsionTorsionForce"] = AmoebaTorsionTorsionGenerator.parseElemen
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaStretchBendGenerator: class AmoebaStretchBendGenerator(object):
#============================================================================================= #=============================================================================================
"""An AmoebaStretchBendGenerator constructs a AmoebaStretchBendForce.""" """An AmoebaStretchBendGenerator constructs a AmoebaStretchBendForce."""
...@@ -3401,7 +3404,7 @@ parsers["AmoebaStretchBendForce"] = AmoebaStretchBendGenerator.parseElement ...@@ -3401,7 +3404,7 @@ parsers["AmoebaStretchBendForce"] = AmoebaStretchBendGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaVdwGenerator: class AmoebaVdwGenerator(object):
"""A AmoebaVdwGenerator constructs a AmoebaVdwForce.""" """A AmoebaVdwGenerator constructs a AmoebaVdwForce."""
...@@ -3567,7 +3570,7 @@ parsers["AmoebaVdwForce"] = AmoebaVdwGenerator.parseElement ...@@ -3567,7 +3570,7 @@ parsers["AmoebaVdwForce"] = AmoebaVdwGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaMultipoleGenerator: class AmoebaMultipoleGenerator(object):
#============================================================================================= #=============================================================================================
...@@ -4234,7 +4237,7 @@ parsers["AmoebaMultipoleForce"] = AmoebaMultipoleGenerator.parseElement ...@@ -4234,7 +4237,7 @@ parsers["AmoebaMultipoleForce"] = AmoebaMultipoleGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaWcaDispersionGenerator: class AmoebaWcaDispersionGenerator(object):
"""A AmoebaWcaDispersionGenerator constructs a AmoebaWcaDispersionForce.""" """A AmoebaWcaDispersionGenerator constructs a AmoebaWcaDispersionForce."""
...@@ -4307,7 +4310,7 @@ parsers["AmoebaWcaDispersionForce"] = AmoebaWcaDispersionGenerator.parseElement ...@@ -4307,7 +4310,7 @@ parsers["AmoebaWcaDispersionForce"] = AmoebaWcaDispersionGenerator.parseElement
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaGeneralizedKirkwoodGenerator: class AmoebaGeneralizedKirkwoodGenerator(object):
"""A AmoebaGeneralizedKirkwoodGenerator constructs a AmoebaGeneralizedKirkwoodForce.""" """A AmoebaGeneralizedKirkwoodGenerator constructs a AmoebaGeneralizedKirkwoodForce."""
...@@ -4575,7 +4578,7 @@ parsers["AmoebaGeneralizedKirkwoodForce"] = AmoebaGeneralizedKirkwoodGenerator.p ...@@ -4575,7 +4578,7 @@ parsers["AmoebaGeneralizedKirkwoodForce"] = AmoebaGeneralizedKirkwoodGenerator.p
#============================================================================================= #=============================================================================================
## @private ## @private
class AmoebaUreyBradleyGenerator: class AmoebaUreyBradleyGenerator(object):
#============================================================================================= #=============================================================================================
"""An AmoebaUreyBradleyGenerator constructs a AmoebaUreyBradleyForce.""" """An AmoebaUreyBradleyGenerator constructs a AmoebaUreyBradleyForce."""
...@@ -4649,7 +4652,7 @@ parsers["AmoebaUreyBradleyForce"] = AmoebaUreyBradleyGenerator.parseElement ...@@ -4649,7 +4652,7 @@ parsers["AmoebaUreyBradleyForce"] = AmoebaUreyBradleyGenerator.parseElement
## @private ## @private
class DrudeGenerator: class DrudeGenerator(object):
"""A DrudeGenerator constructs a DrudeForce.""" """A DrudeGenerator constructs a DrudeForce."""
def __init__(self, forcefield): def __init__(self, forcefield):
......
...@@ -6,10 +6,11 @@ from simtk.unit import * ...@@ -6,10 +6,11 @@ from simtk.unit import *
import simtk.openmm.app.element as elem import simtk.openmm.app.element as elem
import simtk.openmm.app.forcefield as forcefield import simtk.openmm.app.forcefield as forcefield
import math import math
if sys.version_info >= (3, 0): try:
from io import StringIO
else:
from cStringIO import StringIO from cStringIO import StringIO
except ImportError:
from io import StringIO
import os
class TestForceField(unittest.TestCase): class TestForceField(unittest.TestCase):
"""Test the ForceField.createSystem() method.""" """Test the ForceField.createSystem() method."""
...@@ -573,5 +574,10 @@ class AmoebaTestForceField(unittest.TestCase): ...@@ -573,5 +574,10 @@ class AmoebaTestForceField(unittest.TestCase):
self.assertEqual(len(ff._forces[0].proper), 1) self.assertEqual(len(ff._forces[0].proper), 1)
self.assertEqual(len(ff._forces[0].improper), 1) self.assertEqual(len(ff._forces[0].improper), 1)
def test_ScalingFactorCombining(self):
""" Tests that FFs can be combined if their scaling factors are very close """
forcefield = ForceField('amber99sb.xml', os.path.join('systems', 'test_amber_ff.xml'))
# This would raise an exception if it didn't work
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
This source diff could not be displayed because it is too large. You can view the blob instead.
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