lammpsio.DataFile¶
- class lammpsio.DataFile(filename, atom_style=None)¶
LAMMPS data file.
LAMMPS can both read a data file for initialization and also write a data file (e.g., for visualization or restart purposes). A
Snapshotcan be written to a data file usingcreate:snapshot = lammpsio.Snapshot( N=3, box=lammpsio.Box([-5, -5, -5], [5, 5, 5]), step=10 ) data = lammpsio.DataFile.create(tmp_path / "atoms.data", snapshot)
A data file can also be read into a
Snapshot:snap = data.read()
There are many sections that can be stored in a data file, but
lammpsiodoes not currently understand all of them. You can checkknown_headers,unknown_headers,known_bodiesandunknown_bodiesfor lists of what is currently supported.- Parameters:
Methods:
create(filename, snapshot[, atom_style])Create a LAMMPS data file from a snapshot.
read()Read a LAMMPS data file into a snapshot.
Attributes:
- classmethod create(filename, snapshot, atom_style=None)¶
Create a LAMMPS data file from a snapshot.
- Parameters:
- Returns:
The object representing the new data file.
- Return type:
- Raises:
ValueError – If all masses are not the same for a given type.
- read()¶
Read a LAMMPS data file into a snapshot.
The
atom_stylewill be read from the comment in the Atoms section of the file. If it is not present, it must be specified manually. Ifatom_styleis specified manually and also present in the file, the two must match or an error will be raised.Unknown headers and sections are silently ignored.
- Returns:
Snapshot from the data file.
- Return type: