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

Fix a bug in which the switching function would not get toggled if requested via

the switchDistance argument to CharmmPsfFile.createSystem().

Also add a check to protect against negative switching distances.
parent f5cbd31e
......@@ -1185,8 +1185,11 @@ class CharmmPsfFile(object):
if switchDistance >= nonbondedCutoff:
raise ValueError('switchDistance is too large compared '
'to the cutoff!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
if abs(switchDistance) != switchDistance:
# Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
else: # periodic
# Set up box vectors (from inpcrd if available, or fall back to
......@@ -1226,8 +1229,11 @@ class CharmmPsfFile(object):
if switchDistance >= nonbondedCutoff:
raise ValueError('switchDistance is too large compared '
'to the cutoff!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
if abs(switchDistance) != switchDistance:
# Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
if ewaldErrorTolerance is not None:
force.setEwaldErrorTolerance(ewaldErrorTolerance)
......
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