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
8ce5a685
Unverified
Commit
8ce5a685
authored
Mar 01, 2019
by
peastman
Committed by
GitHub
Mar 01, 2019
Browse files
Merge pull request #2269 from tristanic/master
Avoid repeated matching of duplicate impropers
parents
dd4eed16
913410fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
19 deletions
+43
-19
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+43
-19
No files found.
wrappers/python/simtk/openmm/app/forcefield.py
View file @
8ce5a685
...
@@ -1968,36 +1968,60 @@ class PeriodicTorsionGenerator(object):
...
@@ -1968,36 +1968,60 @@ class PeriodicTorsionGenerator(object):
else
:
else
:
force
=
existing
[
0
]
force
=
existing
[
0
]
wildcard
=
self
.
ff
.
_atomClasses
[
''
]
wildcard
=
self
.
ff
.
_atomClasses
[
''
]
proper_cache
=
{}
for
torsion
in
data
.
propers
:
for
torsion
in
data
.
propers
:
type1
=
data
.
atomType
[
data
.
atoms
[
torsion
[
0
]]]
type1
,
type2
,
type3
,
type4
=
[
data
.
atomType
[
data
.
atoms
[
torsion
[
i
]]]
for
i
in
range
(
4
)]
type2
=
data
.
atomType
[
data
.
atoms
[
torsion
[
1
]]]
sig
=
(
type1
,
type2
,
type3
,
type4
)
type3
=
data
.
atomType
[
data
.
atoms
[
torsion
[
2
]]]
sig
=
frozenset
((
sig
,
sig
[::
-
1
]))
type4
=
data
.
atomType
[
data
.
atoms
[
torsion
[
3
]]]
match
=
proper_cache
.
get
(
sig
,
None
)
match
=
None
if
match
==
-
1
:
for
index
in
self
.
propersForAtomType
[
type2
]:
continue
tordef
=
self
.
proper
[
index
]
if
match
is
None
:
types1
=
tordef
.
types1
for
index
in
self
.
propersForAtomType
[
type2
]:
types2
=
tordef
.
types2
tordef
=
self
.
proper
[
index
]
types3
=
tordef
.
types3
types1
=
tordef
.
types1
types4
=
tordef
.
types4
types2
=
tordef
.
types2
if
(
type2
in
types2
and
type3
in
types3
and
type4
in
types4
and
type1
in
types1
)
or
(
type2
in
types3
and
type3
in
types2
and
type4
in
types1
and
type1
in
types4
):
types3
=
tordef
.
types3
hasWildcard
=
(
wildcard
in
(
types1
,
types2
,
types3
,
types4
))
types4
=
tordef
.
types4
if
match
is
None
or
not
hasWildcard
:
# Prefer specific definitions over ones with wildcards
if
(
type2
in
types2
and
type3
in
types3
and
type4
in
types4
and
type1
in
types1
)
or
(
type2
in
types3
and
type3
in
types2
and
type4
in
types1
and
type1
in
types4
):
match
=
tordef
hasWildcard
=
(
wildcard
in
(
types1
,
types2
,
types3
,
types4
))
if
not
hasWildcard
:
if
match
is
None
or
not
hasWildcard
:
# Prefer specific definitions over ones with wildcards
break
match
=
tordef
if
not
hasWildcard
:
break
if
match
is
None
:
proper_cache
[
sig
]
=
-
1
else
:
proper_cache
[
sig
]
=
match
if
match
is
not
None
:
if
match
is
not
None
:
for
i
in
range
(
len
(
match
.
phase
)):
for
i
in
range
(
len
(
match
.
phase
)):
if
match
.
k
[
i
]
!=
0
:
if
match
.
k
[
i
]
!=
0
:
force
.
addTorsion
(
torsion
[
0
],
torsion
[
1
],
torsion
[
2
],
torsion
[
3
],
match
.
periodicity
[
i
],
match
.
phase
[
i
],
match
.
k
[
i
])
force
.
addTorsion
(
torsion
[
0
],
torsion
[
1
],
torsion
[
2
],
torsion
[
3
],
match
.
periodicity
[
i
],
match
.
phase
[
i
],
match
.
k
[
i
])
impr_cache
=
{}
for
torsion
in
data
.
impropers
:
for
torsion
in
data
.
impropers
:
match
=
_matchImproper
(
data
,
torsion
,
self
)
t1
,
t2
,
t3
,
t4
=
tatoms
=
[
data
.
atomType
[
data
.
atoms
[
torsion
[
i
]]]
for
i
in
range
(
4
)]
sig
=
(
t1
,
t2
,
t3
,
t4
)
match
=
impr_cache
.
get
(
sig
,
None
)
if
match
==
-
1
:
# Previously checked, and doesn't appear in the database
continue
elif
match
:
i1
,
i2
,
i3
,
i4
,
tordef
=
match
a1
,
a2
,
a3
,
a4
=
(
torsion
[
i
]
for
i
in
(
i1
,
i2
,
i3
,
i4
))
match
=
(
a1
,
a2
,
a3
,
a4
,
tordef
)
if
match
is
None
:
match
=
_matchImproper
(
data
,
torsion
,
self
)
if
match
is
not
None
:
order
=
match
[:
4
]
i1
,
i2
,
i3
,
i4
=
tuple
(
torsion
.
index
(
a
)
for
a
in
order
)
impr_cache
[
sig
]
=
(
i1
,
i2
,
i3
,
i4
,
match
[
-
1
])
else
:
impr_cache
[
sig
]
=
-
1
if
match
is
not
None
:
if
match
is
not
None
:
(
a1
,
a2
,
a3
,
a4
,
tordef
)
=
match
(
a1
,
a2
,
a3
,
a4
,
tordef
)
=
match
for
i
in
range
(
len
(
tordef
.
phase
)):
for
i
in
range
(
len
(
tordef
.
phase
)):
if
tordef
.
k
[
i
]
!=
0
:
if
tordef
.
k
[
i
]
!=
0
:
force
.
addTorsion
(
a1
,
a2
,
a3
,
a4
,
tordef
.
periodicity
[
i
],
tordef
.
phase
[
i
],
tordef
.
k
[
i
])
force
.
addTorsion
(
a1
,
a2
,
a3
,
a4
,
tordef
.
periodicity
[
i
],
tordef
.
phase
[
i
],
tordef
.
k
[
i
])
parsers
[
"PeriodicTorsionForce"
]
=
PeriodicTorsionGenerator
.
parseElement
parsers
[
"PeriodicTorsionForce"
]
=
PeriodicTorsionGenerator
.
parseElement
...
...
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