Unverified Commit 7f41337f authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

Fixed edge case in Modeller._CellList (#4120)

parent 3ef12991
...@@ -1623,11 +1623,13 @@ class _CellList(object): ...@@ -1623,11 +1623,13 @@ class _CellList(object):
return tuple((int(floor(pos[j]/self.cellSize[j]))%self.numCells[j] for j in range(3))) return tuple((int(floor(pos[j]/self.cellSize[j]))%self.numCells[j] for j in range(3)))
def neighbors(self, pos): def neighbors(self, pos):
processedCells = set()
offsets = (-1, 0, 1) offsets = (-1, 0, 1)
for i in offsets: for i in offsets:
for j in offsets: for j in offsets:
for k in offsets: for k in offsets:
cell = self.cellForPosition(Vec3(pos[0]+i*self.cellSize[0], pos[1]+j*self.cellSize[1], pos[2]+k*self.cellSize[2])) cell = self.cellForPosition(Vec3(pos[0]+i*self.cellSize[0], pos[1]+j*self.cellSize[1], pos[2]+k*self.cellSize[2]))
if cell in self.cells: if cell in self.cells and cell not in processedCells:
processedCells.add(cell)
for atom in self.cells[cell]: for atom in self.cells[cell]:
yield atom yield atom
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