From 77771738ab861260e9370d560ef06f17de242a7d Mon Sep 17 00:00:00 2001 From: Sebastian Kloth Date: Tue, 30 Jan 2024 16:27:59 +0100 Subject: [PATCH] Fixed parse jumps for triclinic box case --- src/mdevaluate/reader.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/mdevaluate/reader.py b/src/mdevaluate/reader.py index d4c4ae5..98927fe 100755 --- a/src/mdevaluate/reader.py +++ b/src/mdevaluate/reader.py @@ -187,19 +187,33 @@ def nojump_save_filename(reader: BaseReader): def parse_jumps(trajectory: Coordinates): prev = trajectory[0].whole - box = prev.box.diagonal() + box = prev.box SparseData = namedtuple("SparseData", ["data", "row", "col"]) jump_data = ( SparseData(data=array("b"), row=array("l"), col=array("l")), SparseData(data=array("b"), row=array("l"), col=array("l")), SparseData(data=array("b"), row=array("l"), col=array("l")), ) - for i, curr in enumerate(trajectory): if i % 500 == 0: logger.debug("Parse jumps Step: %d", i) - delta = ((curr - prev) / box).round().astype(np.int8) + r3 = np.subtract(curr, prev) + delta_z = np.array(np.rint(np.divide(r3[:, 2], box[2][2])), dtype=np.int8) + r2 = np.subtract( + r3, + (np.rint(np.divide(r3[:, 2], box[2][2])))[:, np.newaxis] + * box[2][np.newaxis, :], + ) + delta_y = np.array(np.rint(np.divide(r2[:, 1], box[1][1])), dtype=np.int8) + r1 = np.subtract( + r2, + (np.rint(np.divide(r2[:, 1], box[1][1])))[:, np.newaxis] + * box[1][np.newaxis, :], + ) + delta_x = np.array(np.rint(np.divide(r1[:, 0], box[0][0])), dtype=np.int8) + delta = np.array([delta_x, delta_y, delta_z]).T prev = curr + box = prev.box for d in range(3): (col,) = np.where(delta[:, d] != 0) jump_data[d].col.extend(col)