Unverified Commit 8dfdd485 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2469 from peastman/steps

runForClockTime() updates currentStep correctly
parents 6024e7c0 e275bd08
......@@ -196,10 +196,11 @@ class Simulation(object):
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.currentStep += 10
if endTime is not None and datetime.now() >= endTime:
return
self.integrator.step(stepsToGo)
self.currentStep += nextSteps
self.currentStep += stepsToGo
if anyReport:
# One or more reporters are ready to generate reports. Organize them into three
# groups: ones that want wrapped positions, ones that want unwrapped positions,
......
......@@ -147,6 +147,12 @@ class TestSimulation(unittest.TestCase):
self.assertTrue(endTime >= startTime+timedelta(seconds=5))
self.assertTrue(endTime < startTime+timedelta(seconds=10))
# Check that the time and step count are consistent.
time = simulation.context.getState().getTime().value_in_unit(picoseconds)
expectedTime = simulation.currentStep*integrator.getStepSize().value_in_unit(picoseconds)
self.assertAlmostEqual(expectedTime, time)
# Load the checkpoint and state and make sure they are both correct.
velocities = simulation.context.getState(getVelocities=True).getVelocities()
......
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