From a272a8a61ccff54162407f1f2092bddd6ad0eea4 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Sun, 8 May 2022 19:32:20 -0400 Subject: [PATCH 1/2] supported non-orthogonal cells for amber/md --- dpdata/amber/md.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dpdata/amber/md.py b/dpdata/amber/md.py index 64227a6a..8fb3c680 100644 --- a/dpdata/amber/md.py +++ b/dpdata/amber/md.py @@ -69,15 +69,17 @@ def read_amber_traj(parm7_file, nc_file, mdfrc_file=None, mden_file = None, mdou coords = np.array(f.variables["coordinates"][:]) cell_lengths = np.array(f.variables["cell_lengths"][:]) cell_angles = np.array(f.variables["cell_angles"][:]) + shape = cell_lengths.shape + cells = np.zeros((shape[0], 3, 3)) if np.all(cell_angles > 89.99 ) and np.all(cell_angles < 90.01): # only support 90 # TODO: support other angles - shape = cell_lengths.shape - cells = np.zeros((shape[0], 3, 3)) for ii in range(3): cells[:, ii, ii] = cell_lengths[:, ii] else: - raise RuntimeError("Unsupported cells") + from ase.geometry import cellpar_to_cell + for ii in range(cell_lengths.shape[0]): + cells[ii, :, :] = cellpar_to_cell([*cell_lengths[ii], *cell_angles[ii]]) if labeled: with netcdf.netcdf_file(mdfrc_file, 'r') as f: From 14167861b79df0efe4e798b395e339387c0f0f7d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 25 Jan 2023 20:06:37 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- dpdata/amber/md.py | 1 + 1 file changed, 1 insertion(+) diff --git a/dpdata/amber/md.py b/dpdata/amber/md.py index 441c47ce..0ae0aa39 100644 --- a/dpdata/amber/md.py +++ b/dpdata/amber/md.py @@ -86,6 +86,7 @@ def read_amber_traj( cells[:, ii, ii] = cell_lengths[:, ii] else: from ase.geometry import cellpar_to_cell + for ii in range(cell_lengths.shape[0]): cells[ii, :, :] = cellpar_to_cell([*cell_lengths[ii], *cell_angles[ii]])