Commit a87df3ad authored by peastman's avatar peastman
Browse files

Merged upstream changes

parents 1c604fe4 9db70803
......@@ -599,14 +599,14 @@ extern "C" __global__ void computeFixedField(
// Extract the coordinates of this tile.
unsigned int x, y;
int x, y;
#ifdef USE_CUTOFF
if (numTiles <= maxTiles)
x = tiles[pos];
else
#endif
{
y = (unsigned int) floor(NUM_BLOCKS+0.5f-SQRT((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
y = (int) floor(NUM_BLOCKS+0.5f-SQRT((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
if (x < y || x >= NUM_BLOCKS) { // Occasionally happens due to roundoff error.
y += (x < y ? -1 : 1);
......
......@@ -337,14 +337,14 @@ extern "C" __global__ void computeInducedField(
// Extract the coordinates of this tile.
unsigned int x, y;
int x, y;
#ifdef USE_CUTOFF
if (numTiles <= maxTiles)
x = tiles[pos];
else
#endif
{
y = (unsigned int) floor(NUM_BLOCKS+0.5f-SQRT((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
y = (int) floor(NUM_BLOCKS+0.5f-SQRT((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
if (x < y || x >= NUM_BLOCKS) { // Occasionally happens due to roundoff error.
y += (x < y ? -1 : 1);
......
......@@ -321,14 +321,14 @@ extern "C" __global__ void computeElectrostatics(
// Extract the coordinates of this tile.
unsigned int x, y;
int x, y;
#ifdef USE_CUTOFF
if (numTiles <= maxTiles)
x = tiles[pos];
else
#endif
{
y = (unsigned int) floor(NUM_BLOCKS+0.5f-SQRT((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
y = (int) floor(NUM_BLOCKS+0.5f-SQRT((NUM_BLOCKS+0.5f)*(NUM_BLOCKS+0.5f)-2*pos));
x = (pos-y*NUM_BLOCKS+y*(y+1)/2);
if (x < y || x >= NUM_BLOCKS) { // Occasionally happens due to roundoff error.
y += (x < y ? -1 : 1);
......
......@@ -1107,6 +1107,8 @@ class NonbondedGenerator:
force.setCutoffDistance(nonbondedCutoff)
if 'ewaldErrorTolerance' in args:
force.setEwaldErrorTolerance(args['ewaldErrorTolerance'])
if 'useDispersionCorrection' in args:
force.setUseDispersionCorrection(bool(args['useDispersionCorrection']))
sys.addForce(force)
def postprocessSystem(self, sys, data, args):
......@@ -3037,7 +3039,7 @@ class AmoebaVdwGenerator:
# dispersion correction
if ('useDispersionCorrection' in args):
force.setUseDispersionCorrection(int(args['useDispersionCorrection']))
force.setUseDispersionCorrection(bool(args['useDispersionCorrection']))
if (nonbondedMethod == PME):
force.setNonbondedMethod(mm.AmoebaVdwForce.CutoffPeriodic)
......
......@@ -111,7 +111,7 @@ class GromacsTopFile(object):
if len(fields) < 2:
raise ValueError('Illegal line in .top file: '+line)
name = fields[1]
valueStart = stripped.find(name, len(command))+len(name)
valueStart = stripped.find(name, len(command))+len(name)+1
value = line[valueStart:].strip()
self._defines[name] = value
elif command == '#ifdef':
......
......@@ -19,6 +19,7 @@ class TestForceField(unittest.TestCase):
self.topology1 = self.pdb1.topology
self.topology1.setUnitCellDimensions(Vec3(2, 2, 2))
# alalnine dipeptide with implicit water
self.pdb2 = PDBFile('systems/alanine-dipeptide-implicit.pdb')
self.forcefield2 = ForceField('amber99sb.xml', 'amber99_obc.xml')
......@@ -38,6 +39,18 @@ class TestForceField(unittest.TestCase):
f.getNonbondedMethod()==methodMap[method]
for f in forces))
def test_DispersionCorrection(self):
"""Test to make sure the nonbondedCutoff parameter is passed correctly."""
for useDispersionCorrection in [True, False]:
system = self.forcefield1.createSystem(self.pdb1.topology,
nonbondedCutoff=2*nanometer,
useDispersionCorrection=useDispersionCorrection)
for force in system.getForces():
if isinstance(force, NonbondedForce):
self.assertEqual(useDispersionCorrection, force.getUseDispersionCorrection())
def test_Cutoff(self):
"""Test to make sure the nonbondedCutoff parameter is passed correctly."""
......@@ -133,6 +146,62 @@ class TestForceField(unittest.TestCase):
for f1, f2, in zip(state1.getForces().value_in_unit(kilojoules_per_mole/nanometer), state2.getForces().value_in_unit(kilojoules_per_mole/nanometer)):
self.assertTrue(norm(f1-f2) < 0.1)
class AmoebaTestForceField(unittest.TestCase):
"""Test the ForceField.createSystem() method with the AMOEBA forcefield."""
def setUp(self):
"""Set up the tests by loading the input pdb files and force field
xml files.
"""
self.pdb1 = PDBFile('systems/amoeba-ion-in-water.pdb')
self.forcefield1 = ForceField('amoeba2009.xml')
self.topology1 = self.pdb1.topology
def test_NonbondedMethod(self):
"""Test all five options for the nonbondedMethod parameter."""
methodMap = {NoCutoff:AmoebaMultipoleForce.NoCutoff,
PME:AmoebaMultipoleForce.PME}
for method in methodMap:
system = self.forcefield1.createSystem(self.pdb1.topology,
nonbondedMethod=method)
forces = system.getForces()
self.assertTrue(any(isinstance(f, AmoebaMultipoleForce) and
f.getNonbondedMethod()==methodMap[method]
for f in forces))
def test_Cutoff(self):
"""Test to make sure the nonbondedCutoff parameter is passed correctly."""
cutoff_distance = 0.7*nanometer
for method in [NoCutoff, PME]:
system = self.forcefield1.createSystem(self.pdb1.topology,
nonbondedMethod=method,
nonbondedCutoff=cutoff_distance,
constraints=None)
for force in system.getForces():
if isinstance(force, AmoebaVdwForce):
self.assertEqual(force.getCutoff(), cutoff_distance)
if isinstance(force, AmoebaMultipoleForce):
self.assertEqual(force.getCutoffDistance(), cutoff_distance)
def test_DispersionCorrection(self):
"""Test to make sure the nonbondedCutoff parameter is passed correctly."""
for useDispersionCorrection in [True, False]:
system = self.forcefield1.createSystem(self.pdb1.topology,
nonbondedMethod=PME,
useDispersionCorrection=useDispersionCorrection)
for force in system.getForces():
if isinstance(force, AmoebaVdwForce):
self.assertEqual(useDispersionCorrection, force.getUseDispersionCorrection())
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
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