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
5c537b41
Commit
5c537b41
authored
May 30, 2014
by
peastman
Browse files
Merge pull request #469 from swails/fix_charmm_box
Fix the handling and units of box lengths in CHARMM files
parents
c79b07cf
d4abeb91
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
2 deletions
+35
-2
wrappers/python/simtk/openmm/app/charmmpsffile.py
wrappers/python/simtk/openmm/app/charmmpsffile.py
+35
-2
No files found.
wrappers/python/simtk/openmm/app/charmmpsffile.py
View file @
5c537b41
...
@@ -755,6 +755,12 @@ class CharmmPsfFile(object):
...
@@ -755,6 +755,12 @@ class CharmmPsfFile(object):
- alpha, beta, gamma (floats, optional) : Angles between the
- alpha, beta, gamma (floats, optional) : Angles between the
periodic cells.
periodic cells.
"""
"""
try
:
# Since we are setting the box, delete the cached box lengths if we
# have them to make sure they are recomputed if desired.
del
self
.
_boxLengths
except
AttributeError
:
pass
self
.
box_vectors
=
_box_vectors_from_lengths_angles
(
a
,
b
,
c
,
self
.
box_vectors
=
_box_vectors_from_lengths_angles
(
a
,
b
,
c
,
alpha
,
beta
,
gamma
)
alpha
,
beta
,
gamma
)
# If we already have a _topology instance, then we have possibly changed
# If we already have a _topology instance, then we have possibly changed
...
@@ -1422,9 +1428,30 @@ class CharmmPsfFile(object):
...
@@ -1422,9 +1428,30 @@ class CharmmPsfFile(object):
@
property
@
property
def
boxLengths
(
self
):
def
boxLengths
(
self
):
""" Return tuple of 3 units """
""" Return tuple of 3 units """
try
:
# See if we have a cached version
return
self
.
_boxLengths
except
AttributeError
:
pass
if
self
.
box_vectors
is
not
None
:
if
self
.
box_vectors
is
not
None
:
return
(
self
.
box_vectors
[
0
][
0
],
self
.
box_vectors
[
0
][
1
],
# Get the lengths of each vector
self
.
box_vectors
[
0
][
2
])
if
u
.
is_quantity
(
self
.
box_vectors
):
# Unlikely -- each vector is like a quantity
vecs
=
self
.
box_vectors
.
value_in_unit
(
u
.
nanometers
)
elif
u
.
is_quantity
(
self
.
box_vectors
[
0
]):
# Assume all box vectors are quantities
vecs
=
[
x
.
value_in_unit
(
u
.
nanometers
)
for
x
in
self
.
box_vectors
]
else
:
# Assume nanometers
vecs
=
self
.
box_vectors
a
=
sqrt
(
vecs
[
0
][
0
]
*
vecs
[
0
][
0
]
+
vecs
[
0
][
1
]
*
vecs
[
0
][
1
]
+
vecs
[
0
][
2
]
*
vecs
[
0
][
2
])
b
=
sqrt
(
vecs
[
1
][
0
]
*
vecs
[
1
][
0
]
+
vecs
[
1
][
1
]
*
vecs
[
1
][
1
]
+
vecs
[
1
][
2
]
*
vecs
[
1
][
2
])
c
=
sqrt
(
vecs
[
2
][
0
]
*
vecs
[
2
][
0
]
+
vecs
[
2
][
1
]
*
vecs
[
2
][
1
]
+
vecs
[
2
][
2
]
*
vecs
[
2
][
2
])
self
.
_boxLengths
=
(
a
,
b
,
c
)
*
u
.
nanometers
return
self
.
_boxLengths
return
None
return
None
@
boxLengths
.
setter
@
boxLengths
.
setter
...
@@ -1440,6 +1467,12 @@ class CharmmPsfFile(object):
...
@@ -1440,6 +1467,12 @@ class CharmmPsfFile(object):
@
boxVectors
.
setter
@
boxVectors
.
setter
def
boxVectors
(
self
,
stuff
):
def
boxVectors
(
self
,
stuff
):
""" Sets the box vectors """
""" Sets the box vectors """
try
:
# We may be changing the box, so delete the cached box lengths to
# make sure they are recomputed if desired
del
self
.
_boxLengths
except
AttributeError
:
pass
self
.
box_vectors
=
stuff
self
.
box_vectors
=
stuff
def
deleteCmap
(
self
):
def
deleteCmap
(
self
):
...
...
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