Skip to content

Commit

Permalink
Fix BondMaker.put_atom_in_box
Browse files Browse the repository at this point in the history
Was only populating 8 out of 14 necessary boxes.

Fixes #97
  • Loading branch information
speleo3 committed Dec 2, 2020
1 parent 45aa08a commit cc8514e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions propka/bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,27 @@ def put_atom_in_box(self, x, y, z, atom):
z: box z-coordinates
atom: the atom to place in a box
"""
for box_x in [x, x+1]:
for box_y in [y, y+1]:
for box_z in [z, z+1]:
key = (box_x, box_y, box_z)
try:
self.boxes[key].append(atom)
except KeyError:
pass
for (dx, dy, dz) in [
(-1, -1, -1),
(-1, -1, 0),
(-1, -1, 1),
(-1, 0, -1),
(-1, 0, 0),
(-1, 0, 1),
(-1, 1, -1),
(-1, 1, 0),
(-1, 1, 1),
(0, -1, -1),
(0, -1, 0),
(0, -1, 1),
(0, 0, -1),
(0, 0, 0),
]:
key = (x + dx, y + dy, z + dz)
try:
self.boxes[key].append(atom)
except KeyError:
pass

@staticmethod
def has_bond(atom1, atom2):
Expand Down

0 comments on commit cc8514e

Please sign in to comment.