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
0f65de7a
Unverified
Commit
0f65de7a
authored
Feb 21, 2018
by
peastman
Committed by
GitHub
Feb 21, 2018
Browse files
Merge pull request #1998 from peastman/switch
Added switchDistance option to ForceField.createSystem()
parents
d9756688
fea6d6f6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
1 deletion
+37
-1
docs-source/usersguide/application.rst
docs-source/usersguide/application.rst
+10
-0
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+12
-1
wrappers/python/tests/TestForceField.py
wrappers/python/tests/TestForceField.py
+15
-0
No files found.
docs-source/usersguide/application.rst
View file @
0f65de7a
...
@@ -792,6 +792,16 @@ The error tolerance is roughly equal to the fractional error in the forces due
...
@@ -792,6 +792,16 @@ The error tolerance is roughly equal to the fractional error in the forces due
to truncating the Ewald summation. If you do not specify it, a default value of
to truncating the Ewald summation. If you do not specify it, a default value of
0.0005 is used.
0.0005 is used.
Another optional parameter when using a cutoff is :code:`switchDistance`. This
causes Lennard-Jones interactions to smoothly go to zero over some finite range,
rather than being sharply truncated at the cutoff distance. This can improve
energy conservation. To use it, specify a distance at which the interactions
should start being reduced. For example:
::
system = prmtop.createSystem(nonbondedMethod=PME, nonbondedCutoff=1*nanometer,
switchDistance=0.9*nanometer)
Nonbonded Forces for AMOEBA
Nonbonded Forces for AMOEBA
---------------------------
---------------------------
...
...
wrappers/python/simtk/openmm/app/forcefield.py
View file @
0f65de7a
...
@@ -1011,7 +1011,7 @@ class ForceField(object):
...
@@ -1011,7 +1011,7 @@ class ForceField(object):
def
createSystem
(
self
,
topology
,
nonbondedMethod
=
NoCutoff
,
nonbondedCutoff
=
1.0
*
unit
.
nanometer
,
def
createSystem
(
self
,
topology
,
nonbondedMethod
=
NoCutoff
,
nonbondedCutoff
=
1.0
*
unit
.
nanometer
,
constraints
=
None
,
rigidWater
=
True
,
removeCMMotion
=
True
,
hydrogenMass
=
None
,
residueTemplates
=
dict
(),
constraints
=
None
,
rigidWater
=
True
,
removeCMMotion
=
True
,
hydrogenMass
=
None
,
residueTemplates
=
dict
(),
ignoreExternalBonds
=
False
,
**
args
):
ignoreExternalBonds
=
False
,
switchDistance
=
None
,
flexibleConstraints
=
False
,
**
args
):
"""Construct an OpenMM System representing a Topology with this force field.
"""Construct an OpenMM System representing a Topology with this force field.
Parameters
Parameters
...
@@ -1047,6 +1047,9 @@ class ForceField(object):
...
@@ -1047,6 +1047,9 @@ class ForceField(object):
not terminated properly. This option can create ambiguities where multiple
not terminated properly. This option can create ambiguities where multiple
templates match the same residue. If that happens, use the residueTemplates
templates match the same residue. If that happens, use the residueTemplates
argument to specify which one to use.
argument to specify which one to use.
switchDistance : float=None
The distance at which the potential energy switching function is turned on for
Lennard-Jones interactions. If this is None, no switching function will be used.
flexibleConstraints : boolean=False
flexibleConstraints : boolean=False
If True, parameters for constrained degrees of freedom will be added to the System
If True, parameters for constrained degrees of freedom will be added to the System
args
args
...
@@ -1059,6 +1062,8 @@ class ForceField(object):
...
@@ -1059,6 +1062,8 @@ class ForceField(object):
system
system
the newly created System
the newly created System
"""
"""
args
[
'switchDistance'
]
=
switchDistance
args
[
'flexibleConstraints'
]
=
flexibleConstraints
data
=
ForceField
.
_SystemData
()
data
=
ForceField
.
_SystemData
()
data
.
atoms
=
list
(
topology
.
atoms
())
data
.
atoms
=
list
(
topology
.
atoms
())
for
atom
in
data
.
atoms
:
for
atom
in
data
.
atoms
:
...
@@ -2322,6 +2327,9 @@ class NonbondedGenerator(object):
...
@@ -2322,6 +2327,9 @@ class NonbondedGenerator(object):
force
.
addParticle
(
values
[
0
],
values
[
1
],
values
[
2
])
force
.
addParticle
(
values
[
0
],
values
[
1
],
values
[
2
])
force
.
setNonbondedMethod
(
methodMap
[
nonbondedMethod
])
force
.
setNonbondedMethod
(
methodMap
[
nonbondedMethod
])
force
.
setCutoffDistance
(
nonbondedCutoff
)
force
.
setCutoffDistance
(
nonbondedCutoff
)
if
args
[
'switchDistance'
]
is
not
None
:
force
.
setUseSwitchingFunction
(
True
)
force
.
setSwitchingDistance
(
args
[
'switchDistance'
])
if
'ewaldErrorTolerance'
in
args
:
if
'ewaldErrorTolerance'
in
args
:
force
.
setEwaldErrorTolerance
(
args
[
'ewaldErrorTolerance'
])
force
.
setEwaldErrorTolerance
(
args
[
'ewaldErrorTolerance'
])
if
'useDispersionCorrection'
in
args
:
if
'useDispersionCorrection'
in
args
:
...
@@ -2439,6 +2447,9 @@ class LennardJonesGenerator(object):
...
@@ -2439,6 +2447,9 @@ class LennardJonesGenerator(object):
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
self
.
force
.
setNonbondedMethod
(
mm
.
CustomNonbondedForce
.
CutoffNonPeriodic
)
else
:
else
:
raise
AssertionError
(
'Unrecognized nonbonded method [%s]'
%
nonbondedMethod
)
raise
AssertionError
(
'Unrecognized nonbonded method [%s]'
%
nonbondedMethod
)
if
args
[
'switchDistance'
]
is
not
None
:
force
.
setUseSwitchingFunction
(
True
)
force
.
setSwitchingDistance
(
args
[
'switchDistance'
])
# Add the particles
# Add the particles
...
...
wrappers/python/tests/TestForceField.py
View file @
0f65de7a
...
@@ -76,6 +76,21 @@ class TestForceField(unittest.TestCase):
...
@@ -76,6 +76,21 @@ class TestForceField(unittest.TestCase):
cutoff_distance
=
force
.
getCutoffDistance
()
cutoff_distance
=
force
.
getCutoffDistance
()
self
.
assertEqual
(
cutoff_distance
,
cutoff_check
)
self
.
assertEqual
(
cutoff_distance
,
cutoff_check
)
def
test_SwitchingDistance
(
self
):
"""Test that the switchDistance parameter is processed correctly."""
for
switchDistance
in
[
None
,
0.9
*
nanometers
]:
system
=
self
.
forcefield1
.
createSystem
(
self
.
pdb1
.
topology
,
nonbondedMethod
=
PME
,
switchDistance
=
switchDistance
)
for
force
in
system
.
getForces
():
if
isinstance
(
force
,
NonbondedForce
):
if
switchDistance
is
None
:
self
.
assertFalse
(
force
.
getUseSwitchingFunction
())
else
:
self
.
assertTrue
(
force
.
getUseSwitchingFunction
())
self
.
assertEqual
(
switchDistance
,
force
.
getSwitchingDistance
())
def
test_RemoveCMMotion
(
self
):
def
test_RemoveCMMotion
(
self
):
"""Test both options (True and False) for the removeCMMotion parameter."""
"""Test both options (True and False) for the removeCMMotion parameter."""
for
b
in
[
True
,
False
]:
for
b
in
[
True
,
False
]:
...
...
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