Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions dpdata/amber/md.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,18 @@ def read_amber_traj(
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:
Expand Down