A fast and memory-efficient LAMMPS dump file reader with great developer experience
Project description
LAMMPS Dump Reader
A fast and memory-efficient LAMMPS dump file reader with great developer experience.
Project Charter
Goal: The goal of this project is to develop an open-source Python package that can read LAMMPS dump files into Python for further analysis.
Objectives:
- The package will be unopinionated. All
dumpanddump_modifyconfigurations will be easy to read, and all output data will be treated on equal footing. - The package will be easy to install using
pip. - The package will have a good developer experience, including type-hinting and documentation.
- The package will be fast and memory-efficient (only one frame will be loaded into memory at a time).
Envisioned usage
There will be two overarching ways to use this package. The most forgiving way would be to use
import dump_reader
# Bring whole dump file into memory
data = dump_reader.read_whole_dump("dump.lammpstrj")
This will bring the entire dump file into memory, so that it can be accessed at any point.
Because dump files may be large, you may not want to bring the whole file into memory at once. In this case, you can use
import dump_reader
timesteps = []
positions = []
# Bring each snapshot in individually
for snapshot in dump_reader.read_dump("dump.lammpstrj"):
timesteps.append(snapshot["TIMESTEP"])
positions.append([])
for atom in snapshot["ATOMS"]:
if atom["element"] == "Li":
positions[-1].append([atom["xu"], atom["yu"], atom["zu"]])
You would extract the information needed at the start of the script. read_dump would return an generator object, so that each snapshot is read in only as needed.
Milestones
- Implement
read_whole_dump. - Implement
read_dumpusing what was learned. - Potentially rewrite
read_whole_dump, if performance improvements are expected. - Potentially rewrite the whole package with Rust bindings.
Current Usage
import undumper
data = undumper.read_dump(file) #where file can be a classic, grid or yaml lammps dump file
for snapshot in data:
timesteps.append(snapshot["TIMESTEP"])
positions.append([])
for atom in snapshot["ATOMS"]:
if atom["element"] == "Li":
positions[-1].append([atom["xu"], atom["yu"], atom["zu"]])
whole_data = undumper.read_whole_dump(file) #where file can be a classic, grid or yaml lammps dump file
The output data structure in each of these cases looks as follows, the only difference is that read_dump generates a dictionary representing one frame and read_whole dump generates a list of dictionaries with each being an individual frame
unDumped = [{'TIMESTEP':0, 'NUMBER OF ATOMS':1600, 'BOX BOUNDS':{x: [0,0], y: [0,0]. z: [0,0]}, 'ATOMS':{id: 1, 'Element': "Li", "xu": 1, "yu": 2, "zu": 3}]
FUll COMMAND LIST
read_dump read_whole_dump read_classic read_yaml read_grid
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file undumper-0.0.4.tar.gz.
File metadata
- Download URL: undumper-0.0.4.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ee05a415930c3f36974b1390113e9da667fd5661c8b3e729f0dedf4f306fbf8
|
|
| MD5 |
a83e2034e3caf8f1fb922a276981bb48
|
|
| BLAKE2b-256 |
0cd24926c6c803f59a0006e9e89de27b3becff56bc208f947802342fbe2283c0
|
File details
Details for the file undumper-0.0.4-py3-none-any.whl.
File metadata
- Download URL: undumper-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26593a2251ac8586d5ad9f6aa7d7f41414e84fb9b18b356c2736a5abd148e089
|
|
| MD5 |
a5b2dc9580899d69c826a7b634f6c46e
|
|
| BLAKE2b-256 |
7ecac9af64e9b09b0e575f57d886b8d199210c7615b9ecccaa4f5941a96e8416
|