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
202be04d
Commit
202be04d
authored
Aug 01, 2019
by
peastman
Browse files
Improved API for setting periodic box vectors in CharmmPsfFile
parent
37d4b472
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
wrappers/python/simtk/openmm/app/charmmpsffile.py
wrappers/python/simtk/openmm/app/charmmpsffile.py
+14
-2
wrappers/python/tests/TestCharmmFiles.py
wrappers/python/tests/TestCharmmFiles.py
+3
-6
No files found.
wrappers/python/simtk/openmm/app/charmmpsffile.py
View file @
202be04d
...
@@ -166,7 +166,7 @@ class CharmmPsfFile(object):
...
@@ -166,7 +166,7 @@ class CharmmPsfFile(object):
GB_FORCE_GROUP
=
6
GB_FORCE_GROUP
=
6
@
_catchindexerror
@
_catchindexerror
def
__init__
(
self
,
psf_name
):
def
__init__
(
self
,
psf_name
,
periodicBoxVectors
=
None
,
unitCellDimensions
=
None
):
"""Opens and parses a PSF file, then instantiates a CharmmPsfFile
"""Opens and parses a PSF file, then instantiates a CharmmPsfFile
instance from the data.
instance from the data.
...
@@ -174,6 +174,11 @@ class CharmmPsfFile(object):
...
@@ -174,6 +174,11 @@ class CharmmPsfFile(object):
----------
----------
psf_name : str
psf_name : str
Name of the PSF file (it must exist)
Name of the PSF file (it must exist)
periodicBoxVectors : tuple of Vec3
the vectors defining the periodic box
unitCellDimensions : Vec3
the dimensions of the crystallographic unit cell. For
non-rectangular unit cells, specify periodicBoxVectors instead.
Raises
Raises
------
------
...
@@ -449,7 +454,14 @@ class CharmmPsfFile(object):
...
@@ -449,7 +454,14 @@ class CharmmPsfFile(object):
self
.
group_list
=
group_list
self
.
group_list
=
group_list
self
.
title
=
title
self
.
title
=
title
self
.
flags
=
psf_flags
self
.
flags
=
psf_flags
self
.
box_vectors
=
None
if
unitCellDimensions
is
not
None
:
if
periodicBoxVectors
is
not
None
:
raise
ValueError
(
"specify either periodicBoxVectors or unitCellDimensions, but not both"
)
if
u
.
is_quantity
(
unitCellDimensions
):
unitCellDimensions
=
unitCellDimensions
.
value_in_unit
(
u
.
nanometers
)
self
.
box_vectors
=
(
Vec3
(
unitCellDimensions
[
0
],
0
,
0
),
Vec3
(
0
,
unitCellDimensions
[
1
],
0
),
Vec3
(
0
,
0
,
unitCellDimensions
[
2
]))
*
u
.
nanometers
else
:
self
.
box_vectors
=
periodicBoxVectors
@
staticmethod
@
staticmethod
def
_convert
(
string
,
type
,
message
):
def
_convert
(
string
,
type
,
message
):
...
...
wrappers/python/tests/TestCharmmFiles.py
View file @
202be04d
...
@@ -93,12 +93,10 @@ class TestCharmmFiles(unittest.TestCase):
...
@@ -93,12 +93,10 @@ class TestCharmmFiles(unittest.TestCase):
def
test_NBFIX
(
self
):
def
test_NBFIX
(
self
):
"""Tests CHARMM systems with NBFIX Lennard-Jones modifications"""
"""Tests CHARMM systems with NBFIX Lennard-Jones modifications"""
warnings
.
filterwarnings
(
'ignore'
,
category
=
CharmmPSFWarning
)
warnings
.
filterwarnings
(
'ignore'
,
category
=
CharmmPSFWarning
)
psf
=
CharmmPsfFile
(
'systems/ala3_solv.psf'
)
psf
=
CharmmPsfFile
(
'systems/ala3_solv.psf'
,
unitCellDimensions
=
Vec3
(
32.7119500
,
32.9959600
,
33.0071500
)
*
angstroms
)
crd
=
CharmmCrdFile
(
'systems/ala3_solv.crd'
)
crd
=
CharmmCrdFile
(
'systems/ala3_solv.crd'
)
params
=
CharmmParameterSet
(
'systems/par_all36_prot.prm'
,
params
=
CharmmParameterSet
(
'systems/par_all36_prot.prm'
,
'systems/toppar_water_ions.str'
)
'systems/toppar_water_ions.str'
)
# Box dimensions (found from bounding box)
psf
.
setBox
(
32.7119500
*
angstroms
,
32.9959600
*
angstroms
,
33.0071500
*
angstroms
)
# Turn off charges so we only test the Lennard-Jones energies
# Turn off charges so we only test the Lennard-Jones energies
for
a
in
psf
.
atom_list
:
for
a
in
psf
.
atom_list
:
...
@@ -169,12 +167,11 @@ class TestCharmmFiles(unittest.TestCase):
...
@@ -169,12 +167,11 @@ class TestCharmmFiles(unittest.TestCase):
def
testSystemOptions
(
self
):
def
testSystemOptions
(
self
):
""" Test various options in CharmmPsfFile.createSystem """
""" Test various options in CharmmPsfFile.createSystem """
warnings
.
filterwarnings
(
'ignore'
,
category
=
CharmmPSFWarning
)
warnings
.
filterwarnings
(
'ignore'
,
category
=
CharmmPSFWarning
)
psf
=
CharmmPsfFile
(
'systems/ala3_solv.psf'
)
psf
=
CharmmPsfFile
(
'systems/ala3_solv.psf'
,
periodicBoxVectors
=
(
Vec3
(
32.7119500
,
0
,
0
)
*
angstroms
,
Vec3
(
0
,
32.9959600
,
0
)
*
angstroms
,
Vec3
(
0
,
0
,
33.0071500
)
*
angstroms
))
crd
=
CharmmCrdFile
(
'systems/ala3_solv.crd'
)
crd
=
CharmmCrdFile
(
'systems/ala3_solv.crd'
)
params
=
CharmmParameterSet
(
'systems/par_all36_prot.prm'
,
params
=
CharmmParameterSet
(
'systems/par_all36_prot.prm'
,
'systems/toppar_water_ions.str'
)
'systems/toppar_water_ions.str'
)
# Box dimensions (found from bounding box)
psf
.
setBox
(
32.7119500
*
angstroms
,
32.9959600
*
angstroms
,
33.0071500
*
angstroms
)
# Check some illegal options
# Check some illegal options
self
.
assertRaises
(
ValueError
,
lambda
:
self
.
assertRaises
(
ValueError
,
lambda
:
...
...
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