"platforms/reference/vscode:/vscode.git/clone" did not exist on "2af004b652dc763098a344d6aaeacb02c1fa8102"
Commit 307b34cb authored by tic20's avatar tic20
Browse files

Optimisation: improper matching in PeriodicTorsionGenerator.createForce

parent 0515bdf6
...@@ -1990,14 +1990,25 @@ class PeriodicTorsionGenerator(object): ...@@ -1990,14 +1990,25 @@ class PeriodicTorsionGenerator(object):
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:
t1, t2, t3, t4 = [data.atomType[data.atoms[torsion[i]]] for i in range(4)]
sig = (t1, frozenset((t2,t3,t4)))
match = impr_cache.get(sig, None)
if match == -1:
# Previously checked, and doesn't appear in the database
continue
if match is None:
match = _matchImproper(data, torsion, self) match = _matchImproper(data, torsion, self)
if match is not None:
impr_cache[sig] = match
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment