Interface for reading and writing to a LAMMPS lammpstrj files. This is a file-like object, that both reading or writing depending on the mode flag. It implements the context manager protocol, so you can also use it with the python ‘with’ statement.
Parameters: | filename : str
mode : {‘r’, ‘w’}
force_overwrite : bool
|
---|
Open a LAMMPS lammpstrj file for reading/writing.
Methods
__init__(filename[, mode, force_overwrite]) | Open a LAMMPS lammpstrj file for reading/writing. |
close() | Close the lammpstrj file. |
parse_box(style) | Extract lengths and angles from a frame. |
read([n_frames, stride, atom_indices]) | Read data from a lammpstrj file. |
read_as_traj(topology[, n_frames, stride, ...]) | Read a trajectory from a lammpstrj file |
seek(offset[, whence]) | Move to a new file position. |
tell() | Current file position. |
write(xyz, cell_lengths[, cell_angles, ...]) | Write one or more frames of data to a lammpstrj file. |
write_box(lengths, angles, mins) | Write the box lines in the header of a frame. |
Attributes
distance_unit |
Close the lammpstrj file.
Read a trajectory from a lammpstrj file
Parameters: | topology : Topology
n_frames : int, optional
stride : np.ndarray, optional
atom_indices : array_like, optional
|
---|---|
Returns: | trajectory : Trajectory
|
See also
Notes
If coordinates are specified in more than one style, the first complete trio of x/y/z coordinates will be read in according to the following order:
- x,y,z (unscaled coordinates)
- xs,ys,zs (scaled atom coordinates)
- xu,yu,zu (unwrapped atom coordinates)
- xsu,ysu,zsu (scaled unwrapped atom coordinates)
Read data from a lammpstrj file.
Parameters: | n_frames : int, None
stride : np.ndarray, optional
atom_indices : array_like, optional
|
---|---|
Returns: | xyz : np.ndarray, shape=(n_frames, n_atoms, 3), dtype=np.float32 cell_lengths : np.ndarray, None
cell_angles : np.ndarray, None
|
Extract lengths and angles from a frame.
Parameters: | style : str
|
---|---|
Returns: | lengths : ndarray
|
Notes
For more info on how LAMMPS defines boxes: http://lammps.sandia.gov/doc/Section_howto.html#howto_12
Write the box lines in the header of a frame.
Parameters: | lengths : np.ndarray, dtype=np.double, shape=(3, )
angles : np.ndarray, dtype=np.double, shape=(3, )
mins : np.ndarray, dtype=np.double, shape=(3, )
|
---|
Write one or more frames of data to a lammpstrj file.
Parameters: | xyz : np.ndarray, shape=(n_frames, n_atoms, 3)
cell_lengths : np.ndarray, dtype=np.double, shape=(n_frames, 3)
cell_angles : np.ndarray, dtype=np.double, shape=(n_frames, 3)
types : np.ndarray, shape(3, ), dtype=int
unit_set : str, optional
|
---|
Move to a new file position.
Parameters: | offset : int
whence : {0, 1, 2}
|
---|
Current file position.
Returns: | offset : int
|
---|