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
6f6bee35
Commit
6f6bee35
authored
Mar 20, 2012
by
Peter Eastman
Browse files
DCDReporter writes the current periodic box size rather than the original one
parent
2304af5d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
wrappers/python/simtk/openmm/app/dcdfile.py
wrappers/python/simtk/openmm/app/dcdfile.py
+6
-1
wrappers/python/simtk/openmm/app/dcdreporter.py
wrappers/python/simtk/openmm/app/dcdreporter.py
+3
-1
No files found.
wrappers/python/simtk/openmm/app/dcdfile.py
View file @
6f6bee35
...
...
@@ -49,11 +49,14 @@ class DCDFile(object):
header
+=
struct
.
pack
(
'<4i'
,
164
,
4
,
len
(
list
(
topology
.
atoms
())),
4
)
file
.
write
(
header
)
def
writeModel
(
self
,
positions
):
def
writeModel
(
self
,
positions
,
unitCellDimensions
=
None
):
"""Write out a model to the DCD file.
Parameters:
- positions (list) The list of atomic positions to write
- unitCellDimensions (Vec3=None) The dimensions of the crystallographic unit cell. If None, the dimensions specified in
the Topology will be used. Regardless of the value specified, no dimensions will be written if the Topology does not
represent a periodic system.
"""
if
len
(
list
(
self
.
_topology
.
atoms
()))
!=
len
(
positions
):
raise
ValueError
(
'The number of positions must match the number of atoms'
)
...
...
@@ -74,6 +77,8 @@ class DCDFile(object):
file
.
seek
(
0
,
os
.
SEEK_END
)
boxSize
=
self
.
_topology
.
getUnitCellDimensions
()
if
boxSize
is
not
None
:
if
unitCellDimensions
is
not
None
:
boxSize
=
unitCellDimensions
size
=
boxSize
.
value_in_unit
(
angstroms
)
file
.
write
(
struct
.
pack
(
'<i6di'
,
48
,
size
[
0
],
0
,
size
[
1
],
0
,
0
,
size
[
2
],
48
))
length
=
struct
.
pack
(
'<i'
,
4
*
len
(
positions
))
...
...
wrappers/python/simtk/openmm/app/dcdreporter.py
View file @
6f6bee35
...
...
@@ -6,6 +6,7 @@ __version__ = "1.0"
import
simtk.openmm
as
mm
from
simtk.openmm.app
import
DCDFile
from
simtk.unit
import
nanometer
class
DCDReporter
(
object
):
"""DCDReporter outputs a series of frames from a Simulation to a DCD file.
...
...
@@ -45,7 +46,8 @@ class DCDReporter(object):
"""
if
self
.
_dcd
is
None
:
self
.
_dcd
=
DCDFile
(
self
.
_out
,
simulation
.
topology
,
simulation
.
integrator
.
getStepSize
(),
0
,
self
.
_reportInterval
)
self
.
_dcd
.
writeModel
(
state
.
getPositions
())
a
,
b
,
c
=
state
.
getPeriodicBoxVectors
()
self
.
_dcd
.
writeModel
(
state
.
getPositions
(),
mm
.
Vec3
(
a
[
0
].
value_in_unit
(
nanometer
),
b
[
1
].
value_in_unit
(
nanometer
),
c
[
2
].
value_in_unit
(
nanometer
))
*
nanometer
)
def
__del__
(
self
):
self
.
_out
.
close
()
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