Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
9c4766f0
Commit
9c4766f0
authored
Nov 11, 2019
by
ljmartin
Browse files
Get and scale velocities during simulated tempering using numpy, for speed
parent
5aa19c2d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
wrappers/python/simtk/openmm/app/simulatedtempering.py
wrappers/python/simtk/openmm/app/simulatedtempering.py
+9
-1
No files found.
wrappers/python/simtk/openmm/app/simulatedtempering.py
View file @
9c4766f0
...
@@ -48,6 +48,11 @@ try:
...
@@ -48,6 +48,11 @@ try:
have_gzip
=
True
have_gzip
=
True
except
:
have_gzip
=
False
except
:
have_gzip
=
False
try
:
import
numpy
have_numpy
=
True
except
:
have_numpy
=
False
class
SimulatedTempering
(
object
):
class
SimulatedTempering
(
object
):
"""SimulatedTempering implements the simulated tempering algorithm for accelerated sampling.
"""SimulatedTempering implements the simulated tempering algorithm for accelerated sampling.
...
@@ -214,7 +219,10 @@ class SimulatedTempering(object):
...
@@ -214,7 +219,10 @@ class SimulatedTempering(object):
# Rescale the velocities.
# Rescale the velocities.
scale
=
math
.
sqrt
(
self
.
temperatures
[
j
]
/
self
.
temperatures
[
self
.
currentTemperature
])
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
)]
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
)
self
.
simulation
.
context
.
setVelocities
(
velocities
)
# Select this temperature.
# Select this temperature.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment