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
a00aa613
"...reference/tests/TestReferenceCustomExternalForce.cpp" did not exist on "1f6802f977dc8ec6533153c0366953cbf4a9edfd"
Unverified
Commit
a00aa613
authored
Jul 05, 2021
by
Peter Eastman
Committed by
GitHub
Jul 05, 2021
Browse files
Support initialization scripts in force fields (#3167)
parent
a8865f61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
wrappers/python/openmm/app/forcefield.py
wrappers/python/openmm/app/forcefield.py
+7
-1
wrappers/python/tests/TestForceField.py
wrappers/python/tests/TestForceField.py
+13
-0
No files found.
wrappers/python/openmm/app/forcefield.py
View file @
a00aa613
...
@@ -330,7 +330,7 @@ class ForceField(object):
...
@@ -330,7 +330,7 @@ class ForceField(object):
self
.
registerTemplatePatch
(
resName
,
patchName
,
0
)
self
.
registerTemplatePatch
(
resName
,
patchName
,
0
)
self
.
registerResidueTemplate
(
template
)
self
.
registerResidueTemplate
(
template
)
# Load the patch defintions.
# Load the patch defin
i
tions.
for
tree
in
trees
:
for
tree
in
trees
:
if
tree
.
getroot
().
find
(
'Patches'
)
is
not
None
:
if
tree
.
getroot
().
find
(
'Patches'
)
is
not
None
:
...
@@ -411,6 +411,12 @@ class ForceField(object):
...
@@ -411,6 +411,12 @@ class ForceField(object):
for
node
in
tree
.
getroot
().
findall
(
'Script'
):
for
node
in
tree
.
getroot
().
findall
(
'Script'
):
self
.
registerScript
(
node
.
text
)
self
.
registerScript
(
node
.
text
)
# Execute initialization scripts.
for
tree
in
trees
:
for
node
in
tree
.
getroot
().
findall
(
'InitializationScript'
):
exec
(
node
.
text
,
locals
())
def
getGenerators
(
self
):
def
getGenerators
(
self
):
"""Get the list of all registered generators."""
"""Get the list of all registered generators."""
return
self
.
_forces
return
self
.
_forces
...
...
wrappers/python/tests/TestForceField.py
View file @
a00aa613
...
@@ -1149,6 +1149,19 @@ END"""))
...
@@ -1149,6 +1149,19 @@ END"""))
self
.
assertAlmostEqual
(
26.10373
,
propers
,
delta
=
propers
*
1e-3
)
# DIHEdrals
self
.
assertAlmostEqual
(
26.10373
,
propers
,
delta
=
propers
*
1e-3
)
# DIHEdrals
self
.
assertAlmostEqual
(
0.14113
,
impropers
,
delta
=
impropers
*
1e-3
)
# IMPRopers
self
.
assertAlmostEqual
(
0.14113
,
impropers
,
delta
=
impropers
*
1e-3
)
# IMPRopers
def
test_InitializationScript
(
self
):
"""Test that <InitializationScript> tags get executed."""
xml
=
"""
<ForceField>
<InitializationScript>
self.scriptExecuted = True
</InitializationScript>
</ForceField>
"""
ff
=
ForceField
(
StringIO
(
xml
))
self
.
assertTrue
(
ff
.
scriptExecuted
)
class
AmoebaTestForceField
(
unittest
.
TestCase
):
class
AmoebaTestForceField
(
unittest
.
TestCase
):
"""Test the ForceField.createSystem() method with the AMOEBA forcefield."""
"""Test the ForceField.createSystem() method with the AMOEBA forcefield."""
...
...
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