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.91.tar.gz (17.5 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.91-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lammps_ast-0.1.91.tar.gz
  • Upload date:
  • Size: 17.5 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.91.tar.gz
Algorithm Hash digest
SHA256 5ba7d6ebfbd1f55375a0f740d19839cf969429514dcc7238885942ce516c1620
MD5 67eee8bea6527b86f468764a8f1b745b
BLAKE2b-256 3507a6c27029b3f9c5fe47826b685f81e7b5e1d742b585bde6d24740b0b914e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lammps_ast-0.1.91-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.91-py3-none-any.whl
Algorithm Hash digest
SHA256 5beeee8719a6eaca2d55f41896e4492eca7633d0bd2bbe21cd37127e5e9ebc99
MD5 b138843a775feacc599a512adadbd0ee
BLAKE2b-256 198b4a730d4f10d203b21a5344091418b521ff5bdfab7d569148aeb6dcf1889d

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