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
c43eb6a1
Commit
c43eb6a1
authored
Mar 27, 2014
by
Robert McGibbon
Browse files
Enhance the test to ensure that the checkpoint can be loaded correctly
parent
4f858162
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
wrappers/python/tests/TestCheckpointReporter.py
wrappers/python/tests/TestCheckpointReporter.py
+15
-6
No files found.
wrappers/python/tests/TestCheckpointReporter.py
View file @
c43eb6a1
import
unittest
import
tempfile
import
numpy
as
np
from
simtk.openmm
import
app
import
simtk.openmm
as
mm
from
simtk
import
unit
...
...
@@ -7,23 +8,31 @@ from simtk import unit
class
TestCheckpointReporter
(
unittest
.
TestCase
):
def
setUp
(
self
):
pdb
=
app
.
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
with
open
(
'systems/alanine-dipeptide-implicit.pdb'
)
as
f
:
pdb
=
app
.
PDBFile
(
f
)
forcefield
=
app
.
ForceField
(
'amber99sbildn.xml'
)
system
=
forcefield
.
createSystem
(
pdb
.
topology
,
nonbondedMethod
=
app
.
CutoffNonPeriodic
,
nonbondedCutoff
=
1.0
*
unit
.
nanometers
,
system
=
forcefield
.
createSystem
(
pdb
.
topology
,
nonbondedMethod
=
app
.
CutoffNonPeriodic
,
nonbondedCutoff
=
1.0
*
unit
.
nanometers
,
constraints
=
app
.
HBonds
)
self
.
simulation
=
app
.
Simulation
(
pdb
.
topology
,
system
,
mm
.
VerletIntegrator
(
0.002
*
unit
.
picoseconds
))
self
.
simulation
.
context
.
setPositions
(
pdb
.
positions
)
def
test_1
(
self
):
file
=
tempfile
.
NamedTemporaryFile
()
self
.
simulation
.
reporters
.
append
(
app
.
CheckpointReporter
(
file
,
1
))
self
.
simulation
.
step
(
1
)
# get the current positions
positions
=
self
.
simulation
.
context
.
getState
(
getPositions
=
True
).
getPositions
(
asNumpy
=
True
).
_value
# now set the positions into junk...
self
.
simulation
.
context
.
setPositions
(
np
.
random
.
random
(
positions
.
shape
))
# then reload the right positions from the checkpoint
with
open
(
file
.
name
,
'rb'
)
as
f
:
self
.
simulation
.
context
.
loadCheckpoint
(
f
.
read
())
file
.
close
()
newPositions
=
self
.
simulation
.
context
.
getState
(
getPositions
=
True
).
getPositions
(
asNumpy
=
True
).
_value
np
.
testing
.
assert_array_equal
(
positions
,
newPositions
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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