LAMMPSDumpTrajectoryReader

class mdcraft.analysis.reader.LAMMPSDumpTrajectoryReader(filename: str, conventions: str | tuple[str] = None, unwrap: bool = False, *, extras: list[str] = None, parallel: bool = False, n_workers: int = None, **kwargs)[source]

Bases: ReaderBase

LAMMPS dump trajectory reader.

Parameters:
filenamestr

Filename of the LAMMPS dump file.

conventionsstr or tuple, optional

Coordinate conventions for the \(x\), \(y\), and \(z\)-positions. If a str is provided, the same value is used for all axes. Determined automatically if not provided.

Valid values:

  • None to ignore an axis (when coordinate information is unavailable in that axis).

  • "" for unscaled and wrapped coordinates.

  • "u" for unscaled and unwrapped coordinates.

  • "s" for scaled and wrapped coordinates.

  • "su" for scaled and unwrapped coordinates.

unwrapbool, default: False

Determines whether atom positions are unwrapped.

extraslist, optional

Extra per-atom information to be read from the dump file. Topology attributes, like type, mass, and charge, are not expected to change and are not supported.

Note

For named LAMMPS vector attributes, the stored array will always be arrays of shape \((N,\,3)\), where \(N\) is the number of atoms. If data for an axis is not found in the dump file, the corresponding column in the array will be filled with zeros.

For custom LAMMPS vector attributes, the stored array will have as many columns as there are instances of the attribute in the dump file. For example, if "c_custom" was provided to extras and the dump file contains the instances c_custom[2], c_custom[4], and c_custom[1], in that order, the array will have shape \((N,\,3)\). The instances are always sorted, such that the columns in the example array correspond to c_custom[1], c_custom[2], and c_custom[4], respectively.

Valid values:

Keyword (Reader.data key)

LAMMPS dump attribute(s)

Type

"dipole_moments"

(mux, muy, muz)

numpy.ndarray[float]

"dipole_moment_magnitudes"

mu

float

"angular_velocities"

(omegax, omegay, omegaz)

numpy.ndarray[float]

"angular_momentums"

(angmomx, angmomy, angmomz)

numpy.ndarray[float]

"torques"

(tqx, tqy, tqz)

numpy.ndarray[float]

"c_{compute_id}"

(c_{compute_id}[i], …)

numpy.ndarray[float]

"d_{name}"

(d_{name}[i], …)

numpy.ndarray[float]

"d2_{name}[i]"

(d2_{name}[i][j], …)

numpy.ndarray[float]

"f_{fix_id}"

(f_{fix_id}[i], …)

numpy.ndarray[float]

"i_{name}"

(i_{name}[i], …)

numpy.ndarray[int]

"i2_{name}[i]"

(i2_{name}[i][j], …)

numpy.ndarray[int]

"v_{name}"

(v_{name}[i], …)

numpy.ndarray[float]

Examples

First, this trajectory reader must be registered to MDAnalysis by importing this submodule or this class:

>>> from mdcraft.analysis import reader

This will overwrite the built-in MDAnalysis LAMMPS dump reader.

Then, to read a LAMMPS dump file simulation.lammpsdump and extract both the topology and trajectory:

>>> universe = mda.Universe("simulation.lammpsdump")

If the dump file contains extra information, like the per-atom dipole moments, it can be specified in the extras argument:

>>> universe = mda.Universe("simulation.lammpsdump", extras=["dipole_moments"])

The extra information will be stored in the data attribute of the trajectory object:

>>> dipole_moments = universe.trajectory.data["dipole_moments"]

If the dump file does not have the .lammpsdump extension, the format can be specified in the format argument:

>>> universe = mda.Universe("simulation.dump", format="LAMMPSDUMP")

Methods

close

Closes the LAMMPS dump file.

close() None[source]

Closes the LAMMPS dump file.