Unverified Commit 4700c52f authored by Matt Thompson's avatar Matt Thompson Committed by GitHub
Browse files

Fix possible bug in `AmberPrmTopFile.createSystem()` (#3489)

* Only call set switching function/distance on nonbonded force(s)

* Also catch CustomNonbondedForce

* Fix logic around setEwaldErrorTolerance
parent a5e42f57
...@@ -290,19 +290,20 @@ class AmberPrmtopFile(object): ...@@ -290,19 +290,20 @@ class AmberPrmtopFile(object):
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)
if isinstance(force, (mm.NonbondedForce, mm.CustomNonbondedForce)):
if switchDistance and nonbondedMethod is not ff.NoCutoff:
# make sure it's legal
if (_strip_optunit(switchDistance, u.nanometer) >=
_strip_optunit(nonbondedCutoff, u.nanometer)):
raise ValueError('switchDistance is too large compared '
'to the cutoff!')
if _strip_optunit(switchDistance, u.nanometer) < 0:
# Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
if removeCMMotion: if removeCMMotion:
sys.addForce(mm.CMMotionRemover()) sys.addForce(mm.CMMotionRemover())
if switchDistance and nonbondedMethod is not ff.NoCutoff:
# make sure it's legal
if (_strip_optunit(switchDistance, u.nanometer) >=
_strip_optunit(nonbondedCutoff, u.nanometer)):
raise ValueError('switchDistance is too large compared '
'to the cutoff!')
if _strip_optunit(switchDistance, u.nanometer) < 0:
# Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
return sys return sys
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