"wrappers/python/src/vscode:/vscode.git/clone" did not exist on "eb0d2463144fcf456c1ddbcd7f58162506cfb753"
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): ...@@ -1185,8 +1185,11 @@ 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!')
force.setUseSwitchingFunction(True) if abs(switchDistance) != switchDistance:
force.setSwitchingDistance(switchDistance) # Detects negatives for both Quantity and float
raise ValueError('switchDistance must be non-negative!')
force.setUseSwitchingFunction(True)
force.setSwitchingDistance(switchDistance)
else: # periodic else: # periodic
# Set up box vectors (from inpcrd if available, or fall back to # Set up box vectors (from inpcrd if available, or fall back to
...@@ -1226,8 +1229,11 @@ class CharmmPsfFile(object): ...@@ -1226,8 +1229,11 @@ 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!')
force.setUseSwitchingFunction(True) if abs(switchDistance) != switchDistance:
force.setSwitchingDistance(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: if ewaldErrorTolerance is not None:
force.setEwaldErrorTolerance(ewaldErrorTolerance) 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