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
9e934f69
Commit
9e934f69
authored
Nov 20, 2015
by
Jason Swails
Browse files
Fix unit handling in switchDistance and add tests.
parent
1c938ceb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
9 deletions
+41
-9
wrappers/python/simtk/openmm/app/amberprmtopfile.py
wrappers/python/simtk/openmm/app/amberprmtopfile.py
+9
-9
wrappers/python/tests/TestAmberPrmtopFile.py
wrappers/python/tests/TestAmberPrmtopFile.py
+32
-0
No files found.
wrappers/python/simtk/openmm/app/amberprmtopfile.py
View file @
9e934f69
...
...
@@ -38,7 +38,7 @@ from simtk.openmm.app import PDBFile
from
simtk.openmm.app.internal
import
amber_file_parser
from
.
import
forcefield
as
ff
from
.
import
element
as
elem
import
simtk.unit
as
u
nit
import
simtk.unit
as
u
import
simtk.openmm
as
mm
from
simtk.openmm.app.internal.unitcell
import
computePeriodicBoxVectors
...
...
@@ -154,13 +154,13 @@ class AmberPrmtopFile(object):
box
=
prmtop
.
getBoxBetaAndDimensions
()
top
.
setPeriodicBoxVectors
(
computePeriodicBoxVectors
(
*
(
box
[
1
:
4
]
+
box
[
0
:
1
]
*
3
)))
def
createSystem
(
self
,
nonbondedMethod
=
ff
.
NoCutoff
,
nonbondedCutoff
=
1.0
*
u
nit
.
nanometer
,
def
createSystem
(
self
,
nonbondedMethod
=
ff
.
NoCutoff
,
nonbondedCutoff
=
1.0
*
u
.
nanometer
,
constraints
=
None
,
rigidWater
=
True
,
implicitSolvent
=
None
,
implicitSolventSaltConc
=
0.0
*
(
u
nit
.
moles
/
u
nit
.
liter
),
implicitSolventKappa
=
None
,
temperature
=
298.15
*
u
nit
.
kelvin
,
implicitSolventSaltConc
=
0.0
*
(
u
.
moles
/
u
.
liter
),
implicitSolventKappa
=
None
,
temperature
=
298.15
*
u
.
kelvin
,
soluteDielectric
=
1.0
,
solventDielectric
=
78.5
,
removeCMMotion
=
True
,
hydrogenMass
=
None
,
ewaldErrorTolerance
=
0.0005
,
switchDistance
=
0.0
*
u
nit
.
nanometer
):
switchDistance
=
0.0
*
u
.
nanometer
):
"""Construct an OpenMM System representing the topology described by this
prmtop file.
...
...
@@ -252,10 +252,10 @@ class AmberPrmtopFile(object):
raise
ValueError
(
'Illegal value for implicit solvent model'
)
# If implicitSolventKappa is None, compute it from the salt concentration
if
implicitSolvent
is
not
None
and
implicitSolventKappa
is
None
:
if
u
nit
.
is_quantity
(
implicitSolventSaltConc
):
implicitSolventSaltConc
=
implicitSolventSaltConc
.
value_in_unit
(
u
nit
.
moles
/
u
nit
.
liter
)
if
u
nit
.
is_quantity
(
temperature
):
temperature
=
temperature
.
value_in_unit
(
u
nit
.
kelvin
)
if
u
.
is_quantity
(
implicitSolventSaltConc
):
implicitSolventSaltConc
=
implicitSolventSaltConc
.
value_in_unit
(
u
.
moles
/
u
.
liter
)
if
u
.
is_quantity
(
temperature
):
temperature
=
temperature
.
value_in_unit
(
u
.
kelvin
)
# The constant is 1 / sqrt( epsilon_0 * kB / (2 * NA * q^2 * 1000) )
# where NA is avogadro's number, epsilon_0 is the permittivity of
# free space, q is the elementary charge (this number matches
...
...
wrappers/python/tests/TestAmberPrmtopFile.py
View file @
9e934f69
...
...
@@ -296,6 +296,38 @@ class TestAmberPrmtopFile(unittest.TestCase):
diff
=
norm
(
f1
-
f2
)
self
.
assertTrue
(
diff
<
0.1
or
diff
/
norm
(
f1
)
<
1e-4
)
def
testSwitchFunction
(
self
):
""" Tests the switching function option in AmberPrmtopFile """
system
=
prmtop1
.
createSystem
(
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
,
switchDistance
=
0.8
*
nanometer
)
for
force
in
system
.
getForces
():
if
isinstance
(
force
,
NonbondedForce
):
self
.
assertTrue
(
force
.
getUseSwitchingFunction
())
self
.
assertEqual
(
force
.
getSwitchingDistance
(),
0.8
*
nanometer
)
break
else
:
assert
False
,
'Did not find expected nonbonded force!'
# Check error handling
system
=
prmtop1
.
createSystem
(
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
)
for
force
in
system
.
getForces
():
if
isinstance
(
force
,
NonbondedForce
):
self
.
assertFalse
(
force
.
getUseSwitchingFunction
())
break
else
:
assert
False
,
'Did not find expected nonbonded force!'
self
.
assertRaises
(
ValueError
,
lambda
:
prmtop1
.
createSystem
(
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
,
switchDistance
=-
1
)
)
self
.
assertRaises
(
ValueError
,
lambda
:
prmtop1
.
createSystem
(
nonbondedMethod
=
PME
,
nonbondedCutoff
=
1
*
nanometer
,
switchDistance
=
1.2
)
)
def
test_with_dcd_reporter
(
self
):
"""Check that an amber simulation like the docs example works with a DCD reporter."""
...
...
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