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
2b26d844
Commit
2b26d844
authored
Jan 27, 2016
by
Jason Swails
Browse files
Get rid of the fromXmlFiles constructor, but leave support for XML files there.
parent
822cc987
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
26 deletions
+10
-26
wrappers/python/simtk/openmm/app/simulation.py
wrappers/python/simtk/openmm/app/simulation.py
+9
-25
wrappers/python/tests/TestSimulation.py
wrappers/python/tests/TestSimulation.py
+1
-1
No files found.
wrappers/python/simtk/openmm/app/simulation.py
View file @
2b26d844
...
@@ -74,9 +74,12 @@ class Simulation(object):
...
@@ -74,9 +74,12 @@ class Simulation(object):
platformProperties : map=None
platformProperties : map=None
If not None, a set of platform-specific properties to pass to the
If not None, a set of platform-specific properties to pass to the
Context's constructor
Context's constructor
state : XML file name
state : XML file name=None
The name of an XML file containing a serialized State
The name of an XML file containing a serialized State. If not None,
the information stored in state will be transferred to the generated
Simulation object.
"""
"""
self
.
topology
=
topology
## The System being simulated
## The System being simulated
if
isinstance
(
system
,
string_types
):
if
isinstance
(
system
,
string_types
):
with
open
(
system
,
'r'
)
as
f
:
with
open
(
system
,
'r'
)
as
f
:
...
@@ -103,32 +106,13 @@ class Simulation(object):
...
@@ -103,32 +106,13 @@ class Simulation(object):
if
state
is
not
None
:
if
state
is
not
None
:
with
open
(
state
,
'r'
)
as
f
:
with
open
(
state
,
'r'
)
as
f
:
self
.
context
.
setState
(
mm
.
XmlSerializer
.
deserialize
(
f
.
read
()))
self
.
context
.
setState
(
mm
.
XmlSerializer
.
deserialize
(
f
.
read
()))
## Determines whether or not we are using PBC. If no Topology is provided, take it from the System
## Determines whether or not we are using PBC. Try from the System first,
if
topology
is
None
:
## fall back to Topology if that doesn't work
try
:
self
.
_usesPBC
=
self
.
system
.
usesPeriodicBoundaryConditions
()
self
.
_usesPBC
=
self
.
system
.
usesPeriodicBoundaryConditions
()
e
lse
:
e
xcept
Exception
:
# OpenMM just raises Exception if it's not implemented everywhere
self
.
_usesPBC
=
topology
.
getUnitCellDimensions
()
is
not
None
self
.
_usesPBC
=
topology
.
getUnitCellDimensions
()
is
not
None
@
classmethod
def
fromXmlFiles
(
cls
,
system
,
integrator
,
state
=
None
,
platform
=
None
,
platformProperties
=
None
):
""" Initialize a Simulation object from a set of XML files
Parameters
----------
system : str (or mm.System)
XML file name containing a serialized OpenMM System object
integrator : str (or mm.Integrator)
XML file name containing a serialized OpenMM Integrator subclass
state : str, optional
XML file name containing a serialized OpenMM State
platform : Platform=None
If not None, the OpenMM Platform to use
platformProperties : map=None
If not None, a set of platform-specific properties to pass to the
Context's constructor
"""
return
cls
(
None
,
system
,
integrator
,
platform
,
platformProperties
,
state
=
state
)
def
minimizeEnergy
(
self
,
tolerance
=
10
*
unit
.
kilojoule
/
unit
.
mole
,
maxIterations
=
0
):
def
minimizeEnergy
(
self
,
tolerance
=
10
*
unit
.
kilojoule
/
unit
.
mole
,
maxIterations
=
0
):
"""Perform a local energy minimization on the system.
"""Perform a local energy minimization on the system.
...
...
wrappers/python/tests/TestSimulation.py
View file @
2b26d844
...
@@ -63,7 +63,7 @@ class TestSimulation(unittest.TestCase):
...
@@ -63,7 +63,7 @@ class TestSimulation(unittest.TestCase):
f
.
write
(
XmlSerializer
.
serialize
(
state
))
f
.
write
(
XmlSerializer
.
serialize
(
state
))
# Now create a Simulation
# Now create a Simulation
sim
=
Simulation
.
fromXmlFiles
(
systemfn
,
integratorfn
,
state
=
statefn
)
sim
=
Simulation
(
pdb
.
topology
,
systemfn
,
integratorfn
,
state
=
statefn
)
def
testSaveState
(
self
):
def
testSaveState
(
self
):
"""Test that saving States works correctly."""
"""Test that saving States works correctly."""
...
...
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