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
ab6cabb4
Commit
ab6cabb4
authored
Jan 20, 2016
by
peastman
Browse files
Merge pull request #1348 from rafwiewiora/forcefield_type_wildcard
Enable wildcard use for Atom Types
parents
95e05711
4e742ade
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+6
-2
wrappers/python/tests/TestForceField.py
wrappers/python/tests/TestForceField.py
+39
-0
No files found.
wrappers/python/simtk/openmm/app/forcefield.py
View file @
ab6cabb4
...
...
@@ -320,11 +320,15 @@ class ForceField(object):
types
.
append
(
None
)
# Unknown atom class
else
:
types
.
append
(
self
.
_atomClasses
[
attrib
[
classAttrib
]])
else
:
if
typeAttrib
not
in
attrib
or
attrib
[
typeAttrib
]
not
in
self
.
_atomTypes
:
elif
typeAttrib
in
attrib
:
if
attrib
[
typeAttrib
]
==
''
:
types
.
append
(
self
.
_atomClasses
[
''
])
elif
attrib
[
typeAttrib
]
not
in
self
.
_atomTypes
:
types
.
append
(
None
)
# Unknown atom type
else
:
types
.
append
([
attrib
[
typeAttrib
]])
else
:
types
.
append
(
None
)
# Unknown atom type
return
types
def
_parseTorsion
(
self
,
attrib
):
...
...
wrappers/python/tests/TestForceField.py
View file @
ab6cabb4
...
...
@@ -434,6 +434,45 @@ class AmoebaTestForceField(unittest.TestCase):
diff
=
norm
(
f1
-
f2
)
self
.
assertTrue
(
diff
<
0.1
or
diff
/
norm
(
f1
)
<
1e-3
)
def
test_Wildcard
(
self
):
"""Test that PeriodicTorsionForces using wildcard ('') for atom types / classes in the ffxml are correctly registered"""
# Use wildcards in types
xml
=
"""
<ForceField>
<AtomTypes>
<Type name="C" class="C" element="C" mass="12.010000"/>
<Type name="O" class="O" element="O" mass="16.000000"/>
</AtomTypes>
<PeriodicTorsionForce>
<Proper type1="" type2="C" type3="C" type4="" periodicity1="2" phase1="3.141593" k1="15.167000"/>
<Improper type1="C" type2="" type3="" type4="O" periodicity1="2" phase1="3.141593" k1="43.932000"/>
</PeriodicTorsionForce>
</ForceField>"""
ff
=
ForceField
(
StringIO
(
xml
))
self
.
assertEqual
(
len
(
ff
.
_forces
[
0
].
proper
),
1
)
self
.
assertEqual
(
len
(
ff
.
_forces
[
0
].
improper
),
1
)
# Use wildcards in classes
xml
=
"""
<ForceField>
<AtomTypes>
<Type name="C" class="C" element="C" mass="12.010000"/>
<Type name="O" class="O" element="O" mass="16.000000"/>
</AtomTypes>
<PeriodicTorsionForce>
<Proper class1="" class2="C" class3="C" class4="" periodicity1="2" phase1="3.141593" k1="15.167000"/>
<Improper class1="C" class2="" class3="" class4="O" periodicity1="2" phase1="3.141593" k1="43.932000"/>
</PeriodicTorsionForce>
</ForceField>"""
ff
=
ForceField
(
StringIO
(
xml
))
self
.
assertEqual
(
len
(
ff
.
_forces
[
0
].
proper
),
1
)
self
.
assertEqual
(
len
(
ff
.
_forces
[
0
].
improper
),
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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