From cc8514e3dc43d93d1fbfa5c545692451d8014806 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Wed, 2 Dec 2020 08:15:59 +0100 Subject: [PATCH] Fix BondMaker.put_atom_in_box Was only populating 8 out of 14 necessary boxes. Fixes https://github.com/jensengroup/propka/issues/97 --- propka/bonds.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/propka/bonds.py b/propka/bonds.py index 7c07f56..2978a62 100644 --- a/propka/bonds.py +++ b/propka/bonds.py @@ -392,14 +392,27 @@ class BondMaker: 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):