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
bf141989
Commit
bf141989
authored
Jan 27, 2016
by
Jason Swails
Browse files
Add a test for creating a Simulation from XML files.
parent
c3847685
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
wrappers/python/tests/TestSimulation.py
wrappers/python/tests/TestSimulation.py
+23
-0
No files found.
wrappers/python/tests/TestSimulation.py
View file @
bf141989
...
@@ -42,6 +42,29 @@ class TestSimulation(unittest.TestCase):
...
@@ -42,6 +42,29 @@ class TestSimulation(unittest.TestCase):
self
.
assertEqual
(
initialState
.
getVelocities
(),
state
.
getVelocities
())
self
.
assertEqual
(
initialState
.
getVelocities
(),
state
.
getVelocities
())
def
testLoadFromXML
(
self
):
""" Test creating a Simulation from XML files """
pdb
=
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
ff
=
ForceField
(
'amber99sb.xml'
,
'tip3p.xml'
)
system
=
ff
.
createSystem
(
pdb
.
topology
)
integrator
=
VerletIntegrator
(
0.001
*
picoseconds
)
context
=
Context
(
system
,
integrator
)
context
.
setPositions
(
pdb
.
positions
)
state
=
context
.
getState
(
getPositions
=
True
,
getForces
=
True
,
getVelocities
=
True
,
getEnergy
=
True
)
systemfn
=
tempfile
.
mktemp
()
integratorfn
=
tempfile
.
mktemp
()
statefn
=
tempfile
.
mktemp
()
with
open
(
systemfn
,
'w'
)
as
f
:
f
.
write
(
XmlSerializer
.
serialize
(
system
))
with
open
(
integratorfn
,
'w'
)
as
f
:
f
.
write
(
XmlSerializer
.
serialize
(
integrator
))
with
open
(
statefn
,
'w'
)
as
f
:
f
.
write
(
XmlSerializer
.
serialize
(
state
))
# Now create a Simulation
sim
=
Simulation
.
fromXmlFiles
(
systemfn
,
integratorfn
,
state
=
statefn
)
def
testSaveState
(
self
):
def
testSaveState
(
self
):
"""Test that saving States works correctly."""
"""Test that saving States works correctly."""
pdb
=
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
pdb
=
PDBFile
(
'systems/alanine-dipeptide-implicit.pdb'
)
...
...
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