12.1. Overview of Python and LAMMPS
LAMMPS can work together with Python in three ways. First, Python can wrap LAMMPS through the its library interface, so that a Python script can create one or more instances of LAMMPS and launch one or more simulations. In Python lingo, this is “extending” Python with LAMMPS.
Second, a lower-level Python interface can be used indirectly through provided PyLammps and IPyLammps wrapper classes, written in Python. These wrappers try to simplify the usage of LAMMPS in Python by providing an object-based interface to common LAMMPS functionality. They also reduces the amount of code necessary to parameterize LAMMPS scripts through Python and make variables and computes directly accessible.
Third, LAMMPS can use the Python interpreter, so that a LAMMPS input script can invoke Python code directly, and pass information back-and-forth between the input script and Python functions you write. This Python code can also callback to LAMMPS to query or change its attributes. In Python lingo, this is “embedding” Python in LAMMPS. When used in this mode, Python can perform operations that the simple LAMMPS input script syntax cannot.