Commit fee9a5b8 authored by Jason Swails's avatar Jason Swails
Browse files

Change the default so that NBFIX amber topology files use a long-range

correction by default. Then add a test for using the long-range correction and
_not_ using the long-range correction.  Comment out the test using the
long-range correction since it currently segfaults.  When the fix for the
segfault is added, this test can be reinstated (but the energy has to be
updated)

This change in default makes it consistent with the default behavior for the
classical NonbondedForce, and I would have set that as the default to begin with
if I had known it was supposed to work.
parent fcba92a6
......@@ -889,6 +889,7 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
if nonbondedMethod in ('PME', 'Ewald', 'CutoffPeriodic'):
cforce.setNonbondedMethod(cforce.CutoffPeriodic)
cforce.setCutoffDistance(nonbondedCutoff)
cforce.setUseLongRangeCorrection(True)
elif nonbondedMethod == 'CutoffNonPeriodic':
cforce.setNonbondedMethod(cforce.CutoffNonPeriodic)
cforce.setCutoffDistance(nonbondedCutoff)
......
......@@ -145,8 +145,38 @@ class TestAmberPrmtopFile(unittest.TestCase):
totalMass2 = sum([system2.getParticleMass(i) for i in range(system2.getNumParticles())]).value_in_unit(amu)
self.assertAlmostEqual(totalMass1, totalMass2)
def test_NBFIX(self):
"""Test that prmtop files with modified off-diagonal LJ elements are treated properly"""
# def test_NBFIX_LongRange(self):
# """Test prmtop files with NBFIX LJ modifications w/ long-range correction"""
# system = prmtop3.createSystem(nonbondedMethod=PME,
# nonbondedCutoff=8*angstroms)
# # Check the forces
# has_nonbond_force = has_custom_nonbond_force = False
# nonbond_exceptions = custom_nonbond_exclusions = 0
# for force in system.getForces():
# if isinstance(force, NonbondedForce):
# has_nonbond_force = True
# nonbond_exceptions = force.getNumExceptions()
# elif isinstance(force, CustomNonbondedForce):
# has_custom_nonbond_force = True
# custom_nonbond_exceptions = force.getNumExclusions()
# self.assertTrue(has_nonbond_force)
# self.assertTrue(has_custom_nonbond_force)
# self.assertEqual(nonbond_exceptions, custom_nonbond_exceptions)
# integrator = VerletIntegrator(1.0*femtoseconds)
# # Use reference platform, since it should always be present and
# # 'working', and the system is plenty small so this won't be too slow
# sim = Simulation(prmtop3.topology, system, integrator, Platform.getPlatformByName('Reference'))
# # Check that the energy is about what we expect it to be
# sim.context.setPeriodicBoxVectors(*inpcrd3.boxVectors)
# sim.context.setPositions(inpcrd3.positions)
# ene = sim.context.getState(getEnergy=True, enforcePeriodicBox=True).getPotentialEnergy()
# ene = ene.value_in_unit(kilocalories_per_mole)
# # Make sure the energy is relatively close to the value we get with
# # Amber using this force field.
# self.assertAlmostEqual(-7042.3903307/ene, 1, places=3)
def test_NBFIX_noLongRange(self):
"""Test prmtop files with NBFIX LJ modifications w/out long-range correction"""
system = prmtop3.createSystem(nonbondedMethod=PME,
nonbondedCutoff=8*angstroms)
# Check the forces
......@@ -159,6 +189,7 @@ class TestAmberPrmtopFile(unittest.TestCase):
elif isinstance(force, CustomNonbondedForce):
has_custom_nonbond_force = True
custom_nonbond_exceptions = force.getNumExclusions()
force.setUseLongRangeCorrection(False)
self.assertTrue(has_nonbond_force)
self.assertTrue(has_custom_nonbond_force)
self.assertEqual(nonbond_exceptions, custom_nonbond_exceptions)
......
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