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,6 +1185,9 @@ class CharmmPsfFile(object): ...@@ -1185,6 +1185,9 @@ class CharmmPsfFile(object):
if switchDistance >= nonbondedCutoff: if switchDistance >= nonbondedCutoff:
raise ValueError('switchDistance is too large compared ' raise ValueError('switchDistance is too large compared '
'to the cutoff!') 'to the cutoff!')
if abs(switchDistance) != switchDistance:
# Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True) force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance) force.setSwitchingDistance(switchDistance)
...@@ -1226,6 +1229,9 @@ class CharmmPsfFile(object): ...@@ -1226,6 +1229,9 @@ class CharmmPsfFile(object):
if switchDistance >= nonbondedCutoff: if switchDistance >= nonbondedCutoff:
raise ValueError('switchDistance is too large compared ' raise ValueError('switchDistance is too large compared '
'to the cutoff!') 'to the cutoff!')
if abs(switchDistance) != switchDistance:
# Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True) force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance) force.setSwitchingDistance(switchDistance)
......
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