LAMMPS logfile reader
Tool to read a logfile produced by LAMMPS into a python data structure.
Installation
From pypi (preferred/stable)
pip install lammps-logfile
Depending on your python installation, you may have to use pip3 instead of pip. This is usualy the case if you need to run python3 rather than python to run python version 3.
Install using pip directly from github to get the latest (possibly unstable) version:
pip install git+https://github.com/henriasv/lammps-logfile.git
Or by cloning the repository:
git clone https://github.com/henriasv/lammps-logfile.git
cd lammps-logfile
pip3 install .
Usage (Recommended)
The recommended way to read log files is using the read_log function, which returns a pandas DataFrame containing all thermodynamic data from all runs in the log file.
from lammps_logfile import read_log
import matplotlib.pyplot as plt
# Read the log file into a DataFrame
# This example uses the 'crack_log.lammps' file found in 'examples/logfiles/'
df = read_log("crack_log.lammps")
# The DataFrame contains data from all runs, with a 'run_num' column distinguishing them
print(df.head())
# Plot Temperature vs Step
plt.figure(figsize=(10, 6))
plt.plot(df['Step'], df['Temp'])
plt.xlabel('Step')
plt.ylabel('Temperature')
plt.show()
Benchmarks
lammps-logfile is highly optimized for large files. These benchmarks were run on a standard laptop (MacBook Pro M1).
| Simulation | Runs | Steps | Memory (MB) | Time (s) |
|---|---|---|---|---|
| 01_fcc_thermo_multi | 3 | 29 | 0.36 | 0.01 |
| 02_bcc_custom_thermo | 4 | 108 | 0.30 | 0.01 |
| 03_fcc_custom_longlog | 4 | 30004 | 21.05 | 0.07 |
| 04_bcc_multi_then_custom | 5 | 62 | 0.27 | 0.01 |
| 1 GB Log File | 1 | 23,600,000 | 2560.08 | 10.10 |
It uses a memory-mapped parser (backed by the Pandas C engine) to blazing fast performance while keeping memory usage proportional to the output data size.
Legacy Interface
The File class interface is kept for backward compatibility but is considered legacy.
import lammps_logfile
log = lammps_logfile.File("path/to/logfile")
x = log.get("Time")
y = log.get("Temp")
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()
This will give the concatenated log entries of all the runs where the style of the thermo output didn't change with respect to the last run. I.e. if the entries in the thermo_style was not changed between runs it will contain the log data for all the timesteps. If the thermo_style was changed, x and y will contain the data from all the timesteps after the thermo_style was changed for the last time.
Multiple runs in the same log file (Legacy)
If multiple run statements have been made in a simulation, these can be retrieved bu supplying the run_num keyword to the get()-function
import lammps_logfile
log = lammps_logfile.File("path/to/logfile")
x = log.get("Time", run_num=N)
y = log.get("Temp", run_num=N)
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()
In this case, x and y will contain the log data from the N'th run command in LAMMPS, counting from 0.
Any invalid call to the get()-function will result in the function returning None. This happes if the user asks for a thermo propery that does not exist in the log file, or if the user asks for a run_num larger than the number of runs in the logfile.
Metadata
Release files for lammps-logfile 1.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lammps_logfile-1.1.4.tar.gz | 27.5 kB | With provenance | Details for lammps_logfile-1.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lammps_logfile-1.1.4-py3-none-any.whl | Python 3 | none | any | Details for lammps_logfile-1.1.4-py3-none-any.whl |
Total release size: 56.2 kB
Release files / lammps_logfile-1.1.4.tar.gz
| Download URL | lammps_logfile-1.1.4.tar.gz |
|---|---|
| Size | 27.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b730ae2f3c58a1105cf07cf18824f6e1951702d5249be5eb24f6cddb9acaa101
|
|
BLAKE2b-256 checksum How to use checksums |
1d18d777c49508d5b73ac2412c08d14a3040271ae7604fd7a26fd0170644b2e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logRelease files / lammps_logfile-1.1.4-py3-none-any.whl
| Download URL | lammps_logfile-1.1.4-py3-none-any.whl |
|---|---|
| Size | 28.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbf287c4d8fc9b4202fe46e62bd70e9e10a6284154d426987c7f3424f9c96db1
|
|
BLAKE2b-256 checksum How to use checksums |
aa56336f0a0ce3971c070ade02dd0189128c8a0a5d8cb38df576d9df4a7e9b25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logSecurity for lammps-logfile 1.1.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lammps_logfile-1.1.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.