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.

@misc{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},
  note         = {Manuscript in preparation}
}

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.8.tar.gz (17.0 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.8-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lammps_ast-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8bc64fd9095cbf41dd6bef1a0f25e51a53375ddcb2e5cb7cde31d9fbbbb2fc61
MD5 b62f63aee5919e7a86e6dbb76ec2557f
BLAKE2b-256 8401f002a7723a5b70e5fad86626340267130c28f302be141b6a2efd3774de92

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for lammps_ast-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 81c5ec0159156de956a947f88ec5913647d8101e23cf21912568e12d15b73c23
MD5 2ad4a0848d4fdf267d5d63ea701d0f83
BLAKE2b-256 de6f08c7964cc1320136b4d2d659310ec9aa32e47dc2e7bb7cf9e04b1eb24223

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