Compare commits

...

2 Commits

2 changed files with 19 additions and 5 deletions

View File

@ -156,7 +156,7 @@ def nojump(frame: CoordinateFrame, usecache: bool = True) -> CoordinateFrame:
[m[i0 : abstep + 1].sum(axis=0) for m in reader.nojump_matrices] [m[i0 : abstep + 1].sum(axis=0) for m in reader.nojump_matrices]
).T ).T
) )
* frame.box.diagonal() @ frame.box
) )
reader._nojump_cache[abstep] = delta reader._nojump_cache[abstep] = delta
@ -173,7 +173,7 @@ def nojump(frame: CoordinateFrame, usecache: bool = True) -> CoordinateFrame:
] ]
).T ).T
) )
* frame.box.diagonal() @ frame.box
) )
return frame - delta return frame - delta

View File

@ -187,19 +187,33 @@ def nojump_save_filename(reader: BaseReader):
def parse_jumps(trajectory: Coordinates): def parse_jumps(trajectory: Coordinates):
prev = trajectory[0].whole prev = trajectory[0].whole
box = prev.box.diagonal() box = prev.box
SparseData = namedtuple("SparseData", ["data", "row", "col"]) SparseData = namedtuple("SparseData", ["data", "row", "col"])
jump_data = ( 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")), 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): for i, curr in enumerate(trajectory):
if i % 500 == 0: if i % 500 == 0:
logger.debug("Parse jumps Step: %d", i) 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 prev = curr
box = prev.box
for d in range(3): for d in range(3):
(col,) = np.where(delta[:, d] != 0) (col,) = np.where(delta[:, d] != 0)
jump_data[d].col.extend(col) jump_data[d].col.extend(col)