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
e2453f5e
Unverified
Commit
e2453f5e
authored
Sep 07, 2023
by
Peter Eastman
Committed by
GitHub
Sep 07, 2023
Browse files
Don't add extra bond between water hydrogens (#4219)
parent
6a09626b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
9 deletions
+26
-9
wrappers/python/openmm/app/amberprmtopfile.py
wrappers/python/openmm/app/amberprmtopfile.py
+7
-1
wrappers/python/tests/TestAmberPrmtopFile.py
wrappers/python/tests/TestAmberPrmtopFile.py
+19
-6
wrappers/python/tests/TestForceField.py
wrappers/python/tests/TestForceField.py
+0
-2
No files found.
wrappers/python/openmm/app/amberprmtopfile.py
View file @
e2453f5e
...
...
@@ -160,7 +160,13 @@ class AmberPrmtopFile(object):
atoms
=
list
(
top
.
atoms
())
for
bond
in
prmtop
.
getBondsWithH
():
top
.
addBond
(
atoms
[
bond
[
0
]],
atoms
[
bond
[
1
]])
a1
=
atoms
[
bond
[
0
]]
a2
=
atoms
[
bond
[
1
]]
if
a1
.
residue
.
name
==
'HOH'
and
a1
.
element
==
elem
.
hydrogen
and
a2
.
element
==
elem
.
hydrogen
:
# Don't add the "bond" Amber lists between the two hydrogens of a water molecule.
pass
else
:
top
.
addBond
(
a1
,
a2
)
for
bond
in
prmtop
.
getBondsNoH
():
top
.
addBond
(
atoms
[
bond
[
0
]],
atoms
[
bond
[
1
]])
...
...
wrappers/python/tests/TestAmberPrmtopFile.py
View file @
e2453f5e
...
...
@@ -78,12 +78,14 @@ class TestAmberPrmtopFile(unittest.TestCase):
"""Test all eight options for the constraints and rigidWater parameters."""
topology
=
prmtop1
.
topology
for
constraints_value
in
[
None
,
HBonds
,
AllBonds
,
HAngles
]:
for
rigidWater_value
in
[
True
,
False
]:
system
=
prmtop1
.
createSystem
(
constraints
=
constraints_value
,
rigidWater
=
rigidWater_value
)
validateConstraints
(
self
,
topology
,
system
,
constraints_value
,
rigidWater_value
)
for
constraints
in
[
None
,
HBonds
,
AllBonds
,
HAngles
]:
for
rigidWater
in
[
True
,
False
]:
system
=
prmtop1
.
createSystem
(
constraints
=
constraints
,
rigidWater
=
rigidWater
)
if
constraints
!=
None
:
# Amber adds an extra "bond" between water hydrogens, so any constraint
# method except None is equivalent to rigidWater=True.
rigidWater
=
True
validateConstraints
(
self
,
topology
,
system
,
constraints
,
rigidWater
)
def
test_ImplicitSolvent
(
self
):
"""Test the four types of implicit solvents using the implicitSolvent
...
...
@@ -460,5 +462,16 @@ class TestAmberPrmtopFile(unittest.TestCase):
# If a constraint was added to a massless particle, this will throw an exception.
context
=
Context
(
system
,
integrator
,
Platform
.
getPlatformByName
(
'Reference'
))
def
testWaterBonds
(
self
):
"""Test that water molecules have the right set of bonds"""
top
=
prmtop1
.
topology
for
residue
in
top
.
residues
():
if
residue
.
name
==
'HOH'
:
bonds
=
list
(
residue
.
bonds
())
self
.
assertEqual
(
2
,
len
(
bonds
))
for
a1
,
a2
in
bonds
:
self
.
assertTrue
(
a1
.
element
==
elem
.
oxygen
or
a2
.
element
==
elem
.
oxygen
)
self
.
assertTrue
(
a1
.
element
==
elem
.
hydrogen
or
a2
.
element
==
elem
.
hydrogen
)
if
__name__
==
'__main__'
:
unittest
.
main
()
wrappers/python/tests/TestForceField.py
View file @
e2453f5e
...
...
@@ -439,7 +439,6 @@ class TestForceField(unittest.TestCase):
<Atom name="H2" type="tip3p-H" charge="0.417"/>
<Bond from="0" to="1"/>
<Bond from="0" to="2"/>
<Bond from="1" to="2"/>
</Residue>
<Residue name="HOH2">
<Atom name="O" type="tip3p-O" charge="0.834"/>
...
...
@@ -447,7 +446,6 @@ class TestForceField(unittest.TestCase):
<Atom name="H2" type="tip3p-H" charge="-0.417"/>
<Bond from="0" to="1"/>
<Bond from="0" to="2"/>
<Bond from="1" to="2"/>
</Residue>
</Residues>
<NonbondedForce coulomb14scale="0.833333" lj14scale="0.5">
...
...
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