dpdata.lammps package#

Submodules#

dpdata.lammps.dump module#

exception dpdata.lammps.dump.UnwrapWarning[source]#

Bases: UserWarning

dpdata.lammps.dump.box2dumpbox(orig, box)[source]#
dpdata.lammps.dump.dumpbox2box(bounds, tilt)[source]#
dpdata.lammps.dump.from_system_data(system, f_idx=0, timestep=0)[source]#

Convert system data to LAMMPS dump format string.

Parameters:
systemdict

System data dictionary containing atoms, coordinates, cell, etc.

f_idxint, optional

Frame index to dump (default: 0)

timestepint, optional

Timestep number for the dump (default: 0)

Returns:
str

LAMMPS dump format string

dpdata.lammps.dump.get_atype(lines, type_idx_zero=False)[source]#
dpdata.lammps.dump.get_coordtype_and_scalefactor(keys)[source]#
dpdata.lammps.dump.get_dumpbox(lines)[source]#
dpdata.lammps.dump.get_natoms(lines)[source]#
dpdata.lammps.dump.get_natoms_vec(lines)[source]#
dpdata.lammps.dump.get_natomtypes(lines)[source]#
dpdata.lammps.dump.get_spin(lines, spin_keys)[source]#

Get the spin info from the dump file.

Parameters:
lineslist

The content of the dump file.

spin_keyslist

The keys for spin info in dump file.

the spin info is stored in sp, spx, spy, spz or spin_keys, which is the spin norm and the spin vector
1 1 0.00141160 5.64868599 0.01005602 1.54706291 0.00000000 0.00000000 1.00000000 -1.40772100 -2.03739417 -1522.64797384 -0.00397809 -0.00190426 -0.00743976
dpdata.lammps.dump.get_spin_keys(inputfile)[source]#

Read input file and get the keys for spin info in dump.

Parameters:
inputfilestr

Path to the input file.

Returns:
list or None

List of spin info keys if found, None otherwise.

dpdata.lammps.dump.load_file(fname: FileType, begin=0, step=1)[source]#
dpdata.lammps.dump.safe_get_posi(lines, cell, orig=array([0., 0., 0.]), unwrap=False)[source]#
dpdata.lammps.dump.split_traj(dump_lines)[source]#
dpdata.lammps.dump.system_data(lines, type_map=None, type_idx_zero=True, unwrap=False, input_file=None)[source]#

dpdata.lammps.lmp module#

dpdata.lammps.lmp.box2lmpbox(orig, box)[source]#
dpdata.lammps.lmp.detect_atom_style(lines: list[str]) str | None[source]#

Detect LAMMPS atom style from data file content.

Parameters:
lineslist

Lines from LAMMPS data file

Returns:
str or None

Detected atom style, or None if not detected

dpdata.lammps.lmp.from_system_data(system, f_idx=0)[source]#
dpdata.lammps.lmp.get_atoms(lines)[source]#
dpdata.lammps.lmp.get_atype(lines: list[str], type_idx_zero: bool = False, atom_style: str = 'atomic') ndarray[source]#

Get atom types from LAMMPS data file.

Parameters:
lineslist

Lines from LAMMPS data file

type_idx_zerobool

Whether to use zero-based indexing for atom types

atom_stylestr

The LAMMPS atom style

Returns:
np.ndarray

Array of atom types

dpdata.lammps.lmp.get_charges(lines: list[str], atom_style: str = 'atomic') ndarray | None[source]#

Get atomic charges from LAMMPS data file if the atom style supports charges.

Parameters:
lineslist

Lines from LAMMPS data file

atom_stylestr

The LAMMPS atom style

Returns:
np.ndarray or None

Array of atomic charges if atom style has charges, None otherwise

dpdata.lammps.lmp.get_lmpbox(lines)[source]#
dpdata.lammps.lmp.get_natoms(lines)[source]#
dpdata.lammps.lmp.get_natoms_vec(lines: list[str], atom_style: str = 'atomic') list[int][source]#

Get number of atoms for each atom type.

Parameters:
lineslist

Lines from LAMMPS data file

atom_stylestr

The LAMMPS atom style

Returns:
list

Number of atoms for each atom type

dpdata.lammps.lmp.get_natomtypes(lines)[source]#
dpdata.lammps.lmp.get_posi(lines: list[str], atom_style: str = 'atomic') ndarray[source]#

Get atomic positions from LAMMPS data file.

Parameters:
lineslist

Lines from LAMMPS data file

atom_stylestr

The LAMMPS atom style

Returns:
np.ndarray

Array of atomic positions

dpdata.lammps.lmp.get_spins(lines: list[str], atom_style: str = 'atomic') ndarray | None[source]#
dpdata.lammps.lmp.lmpbox2box(lohi, tilt)[source]#
dpdata.lammps.lmp.rotate_to_lower_triangle(cell: ndarray, coord: ndarray) tuple[ndarray, ndarray][source]#

Rotate the cell to lower triangular and ensure the diagonal elements are non-negative.

Args:

cell (np.ndarray): The original cell matrix. coord (np.ndarray): The coordinates of the atoms.

Returns:
tuple[np.ndarray, np.ndarray]: The rotated cell and adjusted coordinates.
dpdata.lammps.lmp.system_data(lines: list[str], type_map: list[str] | None = None, type_idx_zero: bool = True, atom_style: str = 'atomic') dict[source]#

Parse LAMMPS data file to system data format.

Parameters:
lineslist

Lines from LAMMPS data file

type_maplist, optional

Mapping from atom types to element names

type_idx_zerobool

Whether to use zero-based indexing for atom types

atom_stylestr

The LAMMPS atom style (atomic, full, charge, etc.)

Returns:
dict

System data dictionary

dpdata.lammps.lmp.to_system_data(lines: list[str], type_map: list[str] | None = None, type_idx_zero: bool = True, atom_style: str = 'atomic') dict[source]#

Parse LAMMPS data file to system data format.

Parameters:
lineslist

Lines from LAMMPS data file

type_maplist, optional

Mapping from atom types to element names

type_idx_zerobool

Whether to use zero-based indexing for atom types

atom_stylestr

The LAMMPS atom style. If “auto”, attempts to detect automatically from file. Default is “atomic”.

Returns:
dict

System data dictionary