Skip to main content

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:

  1. The package will be unopinionated. All dump and dump_modify configurations will be easy to read, and all output data will be treated on equal footing.
  2. The package will be easy to install using pip.
  3. The package will have a good developer experience, including type-hinting and documentation.
  4. 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

  1. Implement read_whole_dump.
  2. Implement read_dump using what was learned.
  3. Potentially rewrite read_whole_dump, if performance improvements are expected.
  4. 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

undumper-0.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

undumper-0.0.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file undumper-0.0.2.tar.gz.

File metadata

  • Download URL: undumper-0.0.2.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

Hashes for undumper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0a358b74fec2c5b90d140cb7215a076814945f40cfefc35e6fd8c0abc6a3815a
MD5 2d5759961577eae7c06ea24944246c5f
BLAKE2b-256 f551a18d5da4e145dd8ce4035c1bdfe95cfeb9b80c15ce7865f89abd9437b4ef

See more details on using hashes here.

File details

Details for the file undumper-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: undumper-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.19

File hashes

Hashes for undumper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb4c9e243f0069d4e741e7ed186e9b0ef0d1c6fc8ddad8dab64701abd53fc16b
MD5 72ad1577fa1ccf4a064ef49105e3b86b
BLAKE2b-256 46a3b844490efad2de304d415d6153bfcafbf88b19f8ef9293b8609d27384dd2

See more details on using hashes here.

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