# lammps-api-and-scripting > This skill should be used when users ask about api and scripting in lammps; it prioritizes documentation references and then source inspection only for unresolved details. - Author: Tao E. Li - Repository: TEL-Research-Group/lammps - Version: 20260207223556 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-08 - Source: https://github.com/TEL-Research-Group/lammps - Web: https://mule.run/skillshub/@@TEL-Research-Group/lammps~lammps-api-and-scripting:20260207223556 --- --- name: lammps-api-and-scripting description: This skill should be used when users ask about api and scripting in lammps; it prioritizes documentation references and then source inspection only for unresolved details. --- # lammps: API and Scripting ## High-Signal Playbook ### Route the request - Use `lammps-build-and-install` for shared-library and Python-install prerequisites. - Use `lammps-simulation-workflows` for ensemble/restart sequencing once control flow is set. - Use `lammps-analysis-and-output` for structured outputs or data extraction strategies. ### Triage questions - Do you need Python to launch LAMMPS, or LAMMPS to call Python functions? - Is LAMMPS built as a shared library in this environment? - Are you running serial Python or MPI-parallel Python? - Is your use case command streaming, data extraction, or both? ### Canonical workflow - Build/install shared LAMMPS + Python module (`doc/src/Python_overview.rst`, `doc/src/Python_install.rst`). - Verify Python can import `lammps` and find shared libraries. - Create a `lammps` instance and issue commands incrementally (`doc/src/Python_run.rst`, `doc/src/Python_execute.rst`). - Use extraction/scatter APIs when direct data exchange is needed (`doc/src/Python_properties.rst`, `doc/src/Python_atoms.rst`). - Keep core simulation logic debuggable by first validating equivalent plain input scripts. ### Minimal working example - Python launch skeleton (`doc/src/Python_overview.rst`, `doc/src/Python_run.rst`): ```python from lammps import lammps lmp = lammps() lmp.command("units lj") lmp.command("atom_style atomic") lmp.command("read_data data.system") lmp.command("pair_style lj/cut 2.5") lmp.command("pair_coeff * * 1.0 1.0") lmp.command("fix int all nve") lmp.command("run 1000") ``` ### Pitfalls - Python module use without shared-library build (`doc/src/Python_overview.rst`). - Environment path issues for module/shared object discovery. - Assuming interactive parallel Python works in generic terminal setups (`doc/src/Python_overview.rst`). - Divergence between Python-generated commands and tested input scripts. ### Validation checklist - Import test passes and one short script runs successfully. - Thermodynamic output matches equivalent plain-input execution. - Data extraction returns expected dimensions/types for selected properties. ## Scope - Handle questions about language bindings, APIs, and programmatic interfaces. - Keep responses abstract and architectural for large codebases; avoid exhaustive per-function documentation unless requested. ## Primary documentation references - `doc/src/Python_overview.rst` - `doc/src/Python_run.rst` - `doc/src/Python_launch.rst` - `doc/src/Python_module.rst` - `doc/src/Python_execute.rst` - `doc/src/Python_properties.rst` - `doc/src/Python_atoms.rst` - `doc/src/Python_scatter.rst` - `doc/src/Python_neighbor.rst` - `doc/src/Python_install.rst` ## Workflow - Start with the primary references above. - If details are missing, inspect `references/doc_map.md` for additional topic documents (generated inventory plus curated anchors). - Use tutorials/examples as executable usage patterns when available. - Use tests as behavior or regression references when available. - If ambiguity remains after docs, inspect `references/source_map.md` and start with the ranked source entry points. - Cite exact documentation file paths in responses. ## Tutorials and examples - `examples` ## Test references - None discovered. ## Optional deeper inspection - `fortran` - `lib` - `python` - `src` ## Source entry points for unresolved issues - `src/library.h` - `src/library.cpp` - `src/lammps.h` - `src/lammps.cpp` - `python/lammps/core.py` - `python/lammps/numpy_wrapper.py` - `python/lammps/data.py` - `python/lammps/formats.py` - `fortran/lammps.f90` - Prefer targeted source search (for example: `rg -n "" fortran lib python src`).