Commit 5e671019 authored by peastman's avatar peastman
Browse files

Fixed error on Python 2.7

parent 09cac167
......@@ -200,7 +200,6 @@ class SimulatedTempering(object):
def _attemptTemperatureChange(self, state):
"""Attempt to move to a different temperature."""
i = self.currentTemperature
# Compute the probability for each temperature. This is done in log space to avoid overflow.
......@@ -212,17 +211,17 @@ class SimulatedTempering(object):
for j in range(len(probability)):
if r < probability[j]:
if j != self.currentTemperature:
# Rescale the velocities.
scale = math.sqrt(self.temperatures[j]/self.temperatures[self.currentTemperature])
velocities = [v*scale for v in state.getVelocities().value_in_unit(unit.nanometers/unit.picoseconds)]
self.simulation.context.setVelocities(velocities)
# Select this temperature.
self._hasMadeTransition = True
self.currentTemperature = j
self.simulation.integrator.setTemperature(self.temperatures[j])
# Rescale the velocities.
scale = math.sqrt(self.temperatures[j]/self.temperatures[i])
velocities = [v*scale for v in state.getVelocities().value_in_unit(unit.nanometers/unit.picoseconds)]
self.simulation.context.setVelocities(velocities)
if self._updateWeights:
# Update the weight factors.
......
......@@ -35,7 +35,7 @@ class TestSimulatedTempering(unittest.TestCase):
distances = [[] for i in range(10)]
count = 0
for i in range(5000):
for i in range(7000):
st.step(5)
pos = simulation.context.getState(getPositions=True).getPositions().value_in_unit(nanometers)
r = norm(pos[0]-pos[1])
......
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