Skip to main content

LAMMPS Data Analysis library

Project description

lada

lada (LAMMPS Data Access) is a lightweight Python package for parsing common LAMMPS output formats. It provides simple, streaming-friendly access to dump files, log files, and LAMMPS data files, with minimal dependencies.


🚀 Installation

Install using pip from PyPI:

pip install lada

Note: The package is designed to be used with Python 3.8+.


📦 Package structure

The core parser modules are located in src/lada/parsers/:

  • dump_parser.py - streaming parser for LAMMPS dump files (i.e., output from dump command) using iter_dump_frames()
  • log_parser.py - parser for LAMMPS log files using read_lammps_log()
  • data_parser.py - parser for LAMMPS data files (i.e., output form write_data command) using read_data_file()

To keep imports simple, the package exports the most common entry point:

from lada import iter_dump_frames, read_lammps_log, read_data_file

🧩 1) Parsing LAMMPS dump files (dump_parser.py)

Main API

from lada import iter_dump_frames

for frame in iter_dump_frames("path/to/dump_file.dump"):
    # metadata is a dict of "ITEM:" blocks
    timestep = frame.metadata["TIMESTEP"]          # int
    box_bounds = frame.metadata["BOX BOUNDS pp pp pp"]

    # get numeric columns by name
    ids = frame.get_column("id")
    xs  = frame.get_column("x")

    # convert the atom block into a pandas DataFrame
    df = frame.to_pandas()

Notes on metadata conversion

  • TIMESTEP is returned as an int.
  • NUMBER OF ... entries (e.g., NUMBER OF ATOMS) are converted to int.
  • BOX BOUNDS ... entries are parsed into numeric values:
    • For orthogonal boxes, you get a 2D NumPy array shape (3, 2).
    • For triclinic boxes, you get a 2D NumPy array shape (3, 3) where the 3rd column contains tilt factors (xy, xz, yz).

Column helpers

These helpers avoid manual index lookups:

ids = frame.get_column("id")
atom_ids = frame.get_column_or("id", default=None)
col_idx = frame.column_index("type")

📝 2) Parsing LAMMPS log files (log_parser.py)

Main API

from lada import read_lammps_log

thermo = read_lammps_log("log.lammps")
print(thermo.columns)        # column names (Step, Temp, E_pair, ...)
print(thermo.get("E_pair")) # numpy array of E_pair values

# Convert to pandas DataFrame
df = thermo.to_pandas()

What it parses

  • It extracts the table between the Per MPI rank memory allocation marker and the Loop time marker.
  • The first non-empty line in that section is treated as the header.

🧬 3) Parsing LAMMPS data files (data_parser.py)

Main API

from lada import read_data_file

lammps_data = read_data_file("data.lmp")

# Get a parsed section as a NumPy array
atoms = lammps_data.get("Atoms")

# Convert a section to pandas (smart infer columns for Atoms/Bonds/Velocities)
df_atoms = lammps_data.to_pandas(section="Atoms")

Notes on atom style detection

  • The parser attempts to detect the atom style from the comment in the Atoms section header, e.g. Atoms # atomic.
  • If detected, it uses the correct column layout for that style (e.g., x y z vs qx qy qz).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lada-1.0.4.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lada-1.0.4-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file lada-1.0.4.tar.gz.

File metadata

  • Download URL: lada-1.0.4.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lada-1.0.4.tar.gz
Algorithm Hash digest
SHA256 febacfa69ece3f4818ad3d96c3ec01ed5caf4310262bd5927420896fb9e343c7
MD5 e8e30e730012083885d55a1c0775d77e
BLAKE2b-256 7f9314f8dee457fa03bf7fc46211bdb858a58f7a51493f62241c178a727eb43e

See more details on using hashes here.

Provenance

The following attestation bundles were made for lada-1.0.4.tar.gz:

Publisher: publish.yml on balintmagyari/LAMMPS-Data-Analysis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lada-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: lada-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lada-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f50be190ab611b46f15dffebb120494d849cc050f3a9a9415a02eca0205450
MD5 4a57ca82fd22e0570555874119bc898c
BLAKE2b-256 6337dc82206aeda5e17a59060e9ca1d65579db604c5f6ff1c9f450b3a4821d55

See more details on using hashes here.

Provenance

The following attestation bundles were made for lada-1.0.4-py3-none-any.whl:

Publisher: publish.yml on balintmagyari/LAMMPS-Data-Analysis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page