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
e5b4535d
Commit
e5b4535d
authored
Mar 16, 2015
by
peastman
Browse files
Merge pull request #850 from kyleabeauchamp/dcdbug
Fixing multiple bugs in dcdfile / dcdreporter.
parents
de04489b
9fe6cd74
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
wrappers/python/simtk/openmm/app/dcdfile.py
wrappers/python/simtk/openmm/app/dcdfile.py
+7
-5
wrappers/python/tests/TestAmberPrmtopFile.py
wrappers/python/tests/TestAmberPrmtopFile.py
+24
-0
No files found.
wrappers/python/simtk/openmm/app/dcdfile.py
View file @
e5b4535d
...
@@ -37,6 +37,8 @@ import time
...
@@ -37,6 +37,8 @@ import time
import
struct
import
struct
import
math
import
math
from
simtk.unit
import
picoseconds
,
nanometers
,
angstroms
,
is_quantity
,
norm
from
simtk.unit
import
picoseconds
,
nanometers
,
angstroms
,
is_quantity
,
norm
from
simtk.openmm
import
Vec3
from
simtk.openmm.app.internal.unitcell
import
computeLengthsAndAngles
class
DCDFile
(
object
):
class
DCDFile
(
object
):
"""DCDFile provides methods for creating DCD files.
"""DCDFile provides methods for creating DCD files.
...
@@ -112,16 +114,16 @@ class DCDFile(object):
...
@@ -112,16 +114,16 @@ class DCDFile(object):
file
.
seek
(
0
,
os
.
SEEK_END
)
file
.
seek
(
0
,
os
.
SEEK_END
)
boxVectors
=
self
.
_topology
.
getPeriodicBoxVectors
()
boxVectors
=
self
.
_topology
.
getPeriodicBoxVectors
()
if
boxVectors
is
not
None
:
if
boxVectors
is
not
None
:
if
getP
eriodicBoxVectors
is
not
None
:
if
p
eriodicBoxVectors
is
not
None
:
boxVectors
=
getP
eriodicBoxVectors
boxVectors
=
p
eriodicBoxVectors
elif
unitCellDimensions
is
not
None
:
elif
unitCellDimensions
is
not
None
:
if
is_quantity
(
unitCellDimensions
):
if
is_quantity
(
unitCellDimensions
):
unitCellDimensions
=
unitCellDimensions
.
value_in_unit
(
nanometers
)
unitCellDimensions
=
unitCellDimensions
.
value_in_unit
(
nanometers
)
boxVectors
=
(
Vec3
(
unitCellDimensions
[
0
],
0
,
0
),
Vec3
(
0
,
unitCellDimensions
[
1
],
0
),
Vec3
(
0
,
0
,
unitCellDimensions
[
2
]))
*
nanometers
boxVectors
=
(
Vec3
(
unitCellDimensions
[
0
],
0
,
0
),
Vec3
(
0
,
unitCellDimensions
[
1
],
0
),
Vec3
(
0
,
0
,
unitCellDimensions
[
2
]))
*
nanometers
(
a_length
,
b_length
,
c_length
,
alpha
,
beta
,
gamma
)
=
computeLengthsAndAngles
(
boxVectors
)
(
a_length
,
b_length
,
c_length
,
alpha
,
beta
,
gamma
)
=
computeLengthsAndAngles
(
boxVectors
)
a_length
=
a_length
.
value_in_unit
(
angstroms
)
a_length
=
a_length
*
10.
# computeLengthsAndAngles returns unitless nanometers, but need
angstroms
here.
b_length
=
b_length
.
value_in_unit
(
angstroms
)
b_length
=
b_length
*
10.
# computeLengthsAndAngles returns unitless nanometers, but need
angstroms
here.
c_length
=
c_length
.
value_in_unit
(
angstroms
)
c_length
=
c_length
*
10.
# computeLengthsAndAngles returns unitless nanometers, but need
angstroms
here.
angle1
=
math
.
sin
(
math
.
pi
/
2
-
gamma
)
angle1
=
math
.
sin
(
math
.
pi
/
2
-
gamma
)
angle2
=
math
.
sin
(
math
.
pi
/
2
-
beta
)
angle2
=
math
.
sin
(
math
.
pi
/
2
-
beta
)
angle3
=
math
.
sin
(
math
.
pi
/
2
-
alpha
)
angle3
=
math
.
sin
(
math
.
pi
/
2
-
alpha
)
...
...
wrappers/python/tests/TestAmberPrmtopFile.py
View file @
e5b4535d
import
unittest
import
unittest
import
os
import
tempfile
from
validateConstraints
import
*
from
validateConstraints
import
*
from
simtk.openmm.app
import
*
from
simtk.openmm.app
import
*
from
simtk.openmm
import
*
from
simtk.openmm
import
*
...
@@ -275,5 +277,27 @@ class TestAmberPrmtopFile(unittest.TestCase):
...
@@ -275,5 +277,27 @@ class TestAmberPrmtopFile(unittest.TestCase):
diff
=
norm
(
f1
-
f2
)
diff
=
norm
(
f1
-
f2
)
self
.
assertTrue
(
diff
<
0.1
or
diff
/
norm
(
f1
)
<
1e-4
)
self
.
assertTrue
(
diff
<
0.1
or
diff
/
norm
(
f1
)
<
1e-4
)
def
test_with_dcd_reporter
(
self
):
"""Check that an amber simulation like the docs example works with a DCD reporter."""
temperature
=
50
*
kelvin
prmtop
=
prmtop4
# Mg + water
inpcrd
=
inpcrd4
# Mg + water
system
=
prmtop
.
createSystem
(
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
,
constraints
=
HBonds
)
system
.
addForce
(
MonteCarloBarostat
(
1.0
*
atmospheres
,
temperature
,
1
))
integrator
=
LangevinIntegrator
(
temperature
,
1.0
/
picosecond
,
0.0001
*
picoseconds
)
simulation
=
Simulation
(
prmtop
.
topology
,
system
,
integrator
)
simulation
.
context
.
setPositions
(
inpcrd
.
positions
)
simulation
.
context
.
setPeriodicBoxVectors
(
*
inpcrd
.
boxVectors
)
fname
=
tempfile
.
mktemp
(
suffix
=
'.dcd'
)
simulation
.
reporters
.
append
(
DCDReporter
(
fname
,
1
))
# This is an explicit test for the bugs in issue #850
simulation
.
step
(
5
)
os
.
remove
(
fname
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
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