Commit ed31a458 authored by peastman's avatar peastman
Browse files

ForceField supports all types of tabulated functions in CustomGBForce

parent 75c9f3d5
......@@ -4151,7 +4151,7 @@
<EnergyTerm type="ParticlePairNoExclusions">
include(chargeGroup1*numChargeGroups+chargeGroup2)*screening1*screening2*138.935456*charge1*charge2/r
</EnergyTerm>
<Function name="sigma" min="0" max="675">
<Function name="sigma" type="Discrete1D">
0.27 0.3 0.285 0.185 0.27 0.285 0.315 0.27 0.235 0.295 0.27 0.30152225 0.355862 0.2932777648 0.235 0.29253280555 0.235 0.29267889715 0.235 0.3817314 0.366188 0.47079995 0.405 0.315 0.3099 0.241
0.3 0.33 0.315 0.265 0.3 0.315 0.345 0.3 0.265 0.325 0.3 0.33152225 0.385862 0.3232777648 0.265 0.32253280555 0.265 0.32267889715 0.265 0.4117314 0.396188 0.50079995 0.435 0.345 0.3399 0.271
0.285 0.315 0.3 0.25 0.285 0.3 0.33 0.285 0.25 0.31 0.285 0.31652225 0.370862 0.3082777648 0.25 0.30753280555 0.25 0.30767889715 0.25 0.3967314 0.381188 0.48579995 0.42 0.33 0.3249 0.256
......
......@@ -1509,7 +1509,17 @@ class CustomGBGenerator:
generator.energyTerms.append((term.text, computationMap[term.attrib['type']]))
for function in element.findall("Function"):
values = [float(x) for x in function.text.split()]
generator.functions.append((function.attrib['name'], values, float(function.attrib['min']), float(function.attrib['max'])))
if 'type' in function.attrib:
type = function.attrib['type']
else:
type = 'Continuous1D'
params = {}
for key in function.attrib:
if key.endswith('size'):
params[key] = int(function.attrib[key])
elif key.endswith('min') or key.endswith('max'):
params[key] = float(function.attrib[key])
generator.functions.append((function.attrib['name'], type, values, params))
def createForce(self, sys, data, nonbondedMethod, nonbondedCutoff, args):
methodMap = {NoCutoff:mm.CustomGBForce.NoCutoff,
......@@ -1526,8 +1536,19 @@ class CustomGBGenerator:
force.addComputedValue(value[0], value[1], value[2])
for term in self.energyTerms:
force.addEnergyTerm(term[0], term[1])
for function in self.functions:
force.addFunction(function[0], function[1], function[2], function[3])
for (name, type, values, params) in self.functions:
if type == 'Continuous1D':
force.addTabulatedFunction(name, mm.Continuous1DFunction(values, params['min'], params['max']))
elif type == 'Continuous2D':
force.addTabulatedFunction(name, mm.Continuous2DFunction(params['xsize'], params['ysize'], values, params['xmin'], params['xmax'], params['ymin'], params['ymax']))
elif type == 'Continuous3D':
force.addTabulatedFunction(name, mm.Continuous2DFunction(params['xsize'], params['ysize'], params['zsize'], values, params['xmin'], params['xmax'], params['ymin'], params['ymax'], params['zmin'], params['zmax']))
elif type == 'Discrete1D':
force.addTabulatedFunction(name, mm.Discrete1DFunction(values))
elif type == 'Discrete2D':
force.addTabulatedFunction(name, mm.Discrete2DFunction(params['xsize'], params['ysize'], values))
elif type == 'Discrete3D':
force.addTabulatedFunction(name, mm.Discrete2DFunction(params['xsize'], params['ysize'], params['zsize'], values))
for atom in data.atoms:
t = data.atomType[atom]
if t in self.typeMap:
......
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