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
ac25ece0
Commit
ac25ece0
authored
Mar 27, 2014
by
Robert McGibbon
Browse files
docstring
parent
c2008688
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
4 deletions
+30
-4
wrappers/python/simtk/openmm/app/checkpointreporter.py
wrappers/python/simtk/openmm/app/checkpointreporter.py
+30
-4
No files found.
wrappers/python/simtk/openmm/app/checkpointreporter.py
View file @
ac25ece0
...
...
@@ -41,19 +41,44 @@ class CheckpointReporter(object):
will be saved in the file.
To use it, create a CheckpointReporter, then add it to the Simulation's
list of reporters.
list of reporters. To load a checkpoint file a continue a simulation,
use the following recipe:
>>> with open('checkput.chk', 'rb') as f:
>>> simulation.context.loadCheckpoint(f.read())
Notes:
A checkpoint contains not only publicly visible data such as the particle
positions and velocities, but also internal data such as the states of
random number generators. Ideally, loading a checkpoint should restore the
Context to an identical state to when it was written, such that continuing
the simulation will produce an identical trajectory. This is not strictly
guaranteed to be true, however, and should not be relied on. For most
purposes, however, the internal state should be close enough to be
reasonably considered equivalent.
A checkpoint contains data that is highly specific to the Context from
which it was created. It depends on the details of the System, the
Platform being used, and the hardware and software of the computer it was
created on. If you try to load it on a computer with different hardware,
or for a System that is different in any way, loading is likely to fail.
Checkpoints created with different versions of OpenMM are also often
incompatible. If a checkpoint cannot be loaded, that is signaled by
throwing an exception.
"""
def
__init__
(
self
,
file
,
reportInterval
):
"""Create a CheckpointReporter.
Parameters:
- file (string or open file object) The file to write to
- file (string or open file object) The file to write to. Any current
contents will be overwritten.
- reportInterval (int) The interval (in time steps) at which to write checkpoints
"""
self
.
_reportInterval
=
reportInterval
if
isinstance
(
file
,
basestring
):
self
.
_out
=
open
(
file
,
'wb'
)
self
.
_out
=
open
(
file
,
'w
+
b'
)
else
:
self
.
_out
=
file
...
...
@@ -78,4 +103,5 @@ class CheckpointReporter(object):
- state (State) The current state of the simulation
"""
self
.
_out
.
seek
(
0
)
self
.
_out
.
write
(
simulation
.
context
.
createCheckpoint
())
chk
=
simulation
.
context
.
createCheckpoint
()
self
.
_out
.
write
(
chk
)
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