Unverified Commit 825751c0 authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Avoid adding duplicate exclusions to CustomNonbondedForce (#3630)

* Avoid adding duplicate exclusions to CustomNonbondedForce

* Fixed error in adding explicit constraints
parent 097c5b75
...@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of ...@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
Biological Structures at Stanford, funded under the NIH Roadmap for Biological Structures at Stanford, funded under the NIH Roadmap for
Medical Research, grant U54 GM072970. See https://simtk.org. Medical Research, grant U54 GM072970. See https://simtk.org.
Portions copyright (c) 2012-2018 Stanford University and the Authors. Portions copyright (c) 2012-2022 Stanford University and the Authors.
Authors: Peter Eastman Authors: Peter Eastman
Contributors: Jason Swails Contributors: Jason Swails
...@@ -1012,7 +1012,7 @@ class GromacsTopFile(object): ...@@ -1012,7 +1012,7 @@ class GromacsTopFile(object):
for fields in moleculeType.constraints: for fields in moleculeType.constraints:
atoms = [int(x)-1 for x in fields[:2]] atoms = [int(x)-1 for x in fields[:2]]
length = float(fields[2]) length = float(fields[3])
sys.addConstraint(baseAtomIndex+atoms[0], baseAtomIndex+atoms[1], length) sys.addConstraint(baseAtomIndex+atoms[0], baseAtomIndex+atoms[1], length)
# Create nonbonded exceptions. # Create nonbonded exceptions.
...@@ -1079,8 +1079,11 @@ class GromacsTopFile(object): ...@@ -1079,8 +1079,11 @@ class GromacsTopFile(object):
for pair in pairs: for pair in pairs:
nb.addException(pair[0], pair[1], pair[2], 1.0, 0.0, True) nb.addException(pair[0], pair[1], pair[2], 1.0, 0.0, True)
pair_bond.addBond(pair[0], pair[1], [pair[3], pair[4]]) pair_bond.addBond(pair[0], pair[1], [pair[3], pair[4]])
existing = set(tuple(lj.getExclusionParticles(i)) for i in range(lj.getNumExclusions()))
for exclusion in exclusions: for exclusion in exclusions:
lj.addExclusion(exclusion[0], exclusion[1]) if exclusion not in existing and tuple(reversed(exclusion)) not in existing:
lj.addExclusion(exclusion[0], exclusion[1])
existing.add(exclusion)
elif self._defaults[1] == '2': elif self._defaults[1] == '2':
for pair in pairs: for pair in pairs:
nb.addException(pair[0], pair[1], pair[2], pair[3], pair[4], True) nb.addException(pair[0], pair[1], pair[2], pair[3], pair[4], True)
......
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