Skip to main content

A LAMMPS script parser and sanitizer using Lark

Project description

LAMMPS-AST

LAMMPS-AST is a Python package for sanitizing and parsing LAMMPS input scripts into abstract syntax trees (ASTs). It is built on Lark and is intended for structural analysis, validation, comparison, and downstream workflows around LAMMPS input files.

What It Provides

  • script sanitization before parsing
  • parsing of LAMMPS input scripts into ASTs
  • AST transformation and comparison utilities
  • repository examples showing how the parser can be used in notebook and pipeline workflows

Install

Install from PyPI:

pip install lammps_ast

If you need the optional visualization tooling used in some example workflows, you may also want a local Graphviz install.

Minimal Usage

from lammps_ast.sanitizer import sanitize
from lammps_ast.parser import parse_to_AST

script = """
units metal
atom_style atomic
boundary p p p
"""

sanitized = sanitize(script)
tree, errors = parse_to_AST(sanitized, lint=True)

parse_to_AST(..., lint=True) returns a parse tree plus collected parse errors. With lint=False, it behaves like a direct parser call and returns either a tree or an exception object.

Repository Layout

  • lammps_ast/: package source, including parser, sanitizer, grammar, and AST utilities
  • examples/: small examples of using the parser directly
  • publication/: notebook-based workflow used for the publication-oriented evaluation example
  • ez-pipeline/: script-oriented evaluation pipeline built on top of lammps_ast

The PyPI distribution is focused on the lammps_ast package itself. The notebook and pipeline folders are repository examples and supporting workflows.

Development Install

To work from a local clone:

pip install -e .

Citation

If you use LAMMPS-AST or the evaluation workflow in academic work, please cite the associated publication.

@article{lammps_ast_paper,
  title        = {Evaluating LLM-generated code for domain-specific languages: molecular dynamics with LAMMPS},
  author       = {Holbrook, Ethan W. and Verduzco, Juan C. and Strachan, Alejandro},
  year         = {2026},
  eprint       = {2603.20630},
  archivePrefix = {arXiv},
  primaryClass = {cs.SE},
  url          = {https://arxiv.org/abs/2603.20630}
}

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

lammps_ast-0.1.9.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

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

lammps_ast-0.1.9-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file lammps_ast-0.1.9.tar.gz.

File metadata

  • Download URL: lammps_ast-0.1.9.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for lammps_ast-0.1.9.tar.gz
Algorithm Hash digest
SHA256 9719071a75806d9bf6393b0cd59f9dbb6d56e923f2223104b8da0b5d7837689a
MD5 0606e437edb8dbeba85e25e63e6c6791
BLAKE2b-256 0e60f988b09a36cda3c189302dcce58d00843da2322d787b9939bea6e0ffeb90

See more details on using hashes here.

File details

Details for the file lammps_ast-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: lammps_ast-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for lammps_ast-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 cc2a0b997096c18b84920851ea95ce395dc8ae6484795324edf01982ecdab5e1
MD5 df400c2573d990c8ead867726a6f1f1a
BLAKE2b-256 bd2a7b07c5d406b38d05b522dde65cbbb6f372062f15b4e7385a478e71d6a8ca

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