Commit 6c159d06 authored by Peter Eastman's avatar Peter Eastman
Browse files

Made it easier to stop a simulation by pressing control-c

parent 01726081
...@@ -67,7 +67,11 @@ class Simulation(object): ...@@ -67,7 +67,11 @@ class Simulation(object):
if nextReport[i][0] > 0 and nextReport[i][0] <= nextSteps: if nextReport[i][0] > 0 and nextReport[i][0] <= nextSteps:
nextSteps = nextReport[i][0] nextSteps = nextReport[i][0]
anyReport = True anyReport = True
self.integrator.step(nextSteps) stepsToGo = nextSteps
while stepsToGo > 10:
self.integrator.step(10) # Only take 10 steps at a time, to give Python more chances to respond to a control-c.
stepsToGo -= 10
self.integrator.step(stepsToGo)
self.currentStep += nextSteps self.currentStep += nextSteps
if anyReport: if anyReport:
getPositions = False getPositions = False
......
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