Unverified Commit 6024e7c0 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2466 from ljmartin/simtemp-scale-velocities

Get and scale velocities using numpy during simulated tempering
parents 5aa19c2d 9c4766f0
......@@ -48,6 +48,11 @@ try:
have_gzip = True
except: have_gzip = False
try:
import numpy
have_numpy = True
except: have_numpy = False
class SimulatedTempering(object):
"""SimulatedTempering implements the simulated tempering algorithm for accelerated sampling.
......@@ -214,6 +219,9 @@ class SimulatedTempering(object):
# Rescale the velocities.
scale = math.sqrt(self.temperatures[j]/self.temperatures[self.currentTemperature])
if have_numpy:
velocities = scale*state.getVelocities(asNumpy=True).value_in_unit(unit.nanometers/unit.picoseconds)
else:
velocities = [v*scale for v in state.getVelocities().value_in_unit(unit.nanometers/unit.picoseconds)]
self.simulation.context.setVelocities(velocities)
......
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