Written and maintained by CASRAI Editorial Board
Last updated
What LAMMPS is used for in research
LAMMPS is, in the words of its documentation, “a classical molecular dynamics (MD) code that models ensembles of particles in a liquid, solid, or gaseous state.” It is written in C++, runs in serial or on any parallel machine that supports MPI, and handles 2d or 3d systems from a few particles up to billions. The distribution carries a GNU GPL licence file, and the documentation is copyright Sandia Corporation. For related tools in the same workflow, see the CASRAI guides to NAMD, VMD and PyMOL.
Install or access (official source only)
The official Install page lists six routes: a Linux executable, a macOS executable, a Windows executable, Conda (Linux and macOS), a source tarball, and git source. The decision that matters is this: prebuilt executables contain only the optional packages their builders chose, so if you need a package that is not included, or want to modify or extend LAMMPS, the documentation says you must build from source (Build section). Optional packages are described in the Packages section of the manual.
| You need | Route the docs point to |
|---|---|
| To run standard examples quickly | A prebuilt executable or Conda package |
| A package missing from the prebuilt binary | Build from source with that package enabled |
| To modify or extend the code | Source tarball or git source |
Check what your executable includes with the -h switch, which lists the available styles.
Running an input script
LAMMPS reads commands from an input script. Scripts are conventionally named in.*, and you run from the directory containing the script. The documented launch lines are:
- Serial:
lmp_serial -in in.fileorlmp -in in.file - Parallel with MPI:
mpirun -np 4 lmp_mpi -in in.fileormpiexec -np 4 lmp -in in.file - Always use
-inunder MPI: reading with the<redirect “will not always work” in parallel.
Command-line flags worth knowing
| Flag | What it does (per Run options page) |
|---|---|
-in file |
Reads the named input script |
-log file |
Sets the log file name (default log.lammps) |
-screen file |
Sends screen output to a file; none disables it |
-echo style |
none, screen, log or both (default log) |
-sf style (suffix) |
Uses accelerated styles: gpu, intel, kk, omp, opt or hybrid |
-var name value1 value2 ... |
Defines an index variable from the command line |
Output and how to read it
LAMMPS prints setup information, then thermodynamic output periodically, and at the end the final thermo state, total run time and CPU and storage statistics. Output goes to the screen and to log.lammps.
- Loop time: wall-clock time for the MD steps, excluding setup. The performance line next to it helps estimate how long a longer run will take.
- CPU use: should be close to 100% times the number of OpenMP threads; noticeably lower suggests a delay such as I/O.
- MPI breakdown:
%varavgshows load imbalance (near 0 is ideal) and%totalthe share of loop time for each category. - Dangerous builds: a nonzero count means the neighbour-list delay setting should be reduced.
- Minimization: output reports the stopping criterion, initial and final energy and force norms.
Troubleshooting
- Invalid command or “Invalid style” error: either a typo, or the style belongs to an optional package not compiled into your executable. Run with
-hto list available styles. To see which command failed, checklog.lammpsor use theechocommand. - Different results on different processor counts: the documentation says this is typically not a bug. Round-off and different domain decompositions make trajectories diverge after a few hundred to a few thousand steps, while statistical properties such as average energy or temperature should still agree.
- Velocities or atom IDs differ between runs: the
velocitycommand can assign a particular atom a different velocity on a different processor count (see itsloopoption), andcreate_atomsmay number atoms differently. - Physics mistakes: LAMMPS cannot detect too large a timestep, wrong force field coefficients or atoms placed on top of each other. Problems such as lost atoms may only appear mid-run.
Other molecular simulation tools
| Tool | Role relative to LAMMPS |
|---|---|
| NAMD | Another molecular dynamics engine, covered in a CASRAI guide |
| VMD | Visualisation and analysis of trajectories |
| PyMOL | Molecular graphics |
FAQ
Where do I download LAMMPS?
From the Install LAMMPS page of the official documentation, which lists prebuilt executables, Conda, the source tarball and the git repository.
Where is the documentation and are there tutorials?
The manual at docs.lammps.org includes sections on installation, building, running, errors, commands, accelerating performance, optional packages and howto discussions. Section 11 contains example scripts.
What licence does LAMMPS use?
The distribution contains a LICENSE file with the GNU GPL.







