mstk.trajectory.LammpsTrj

class mstk.trajectory.LammpsTrj(trj_file, mode='r')

Read step, cell and atomic positions (and charges if provided) from dump file of Lammps.

Velocities are ignored. Because the topology information are detailed in data file, the mol, type, element in dump file are also ignored. The cell used by Lammps is not originated at (0, 0, 0) usually. This handler will translate the positions of atoms based on the lower bound of the cell.

Writing to LammpsDump is not supported yet.

Methods

__init__(trj_file[, mode])

close()

Close the handler.

get_handler_for_file(file)

Get the appropriate handler class for a trajectory file.

get_info()

Get the number of atoms and frames in the trajectory.

read_frame(i_frame, frame)

Read a single frame.

register_format(extension, Handler)

Register a handler class for a trajectory format based on the extension name

write_frame(frame, **kwargs)

Write a frame into the trajectory file opened by the handler.

get_info()

Get the number of atoms and frames in the trajectory.

Also record the offset of lines and frames, so that we can read arbitrary frame later. It assumes all frames have the same number of atoms.

Returns:

  • n_atom (int)

  • n_frame (int)

read_frame(i_frame, frame)

Read a single frame.

Parameters:
  • i_frame (int) – The index of the frame in the trajectory

  • frame (Frame) – The information read from the trajectory will be written into this Frame