3. Commands

This section describes how a LAMMPS input script is formatted and the input script commands used to define a LAMMPS simulation.

3.1. LAMMPS input script

LAMMPS executes by reading commands from a input script (text file), one line at a time. When the input script ends, LAMMPS exits. Each command causes LAMMPS to take some action. It may set an internal variable, read in a file, or run a simulation. Most commands have default settings, which means you only need to use the command if you wish to change the default.

In many cases, the ordering of commands in an input script is not important. However the following rules apply:

(1) LAMMPS does not read your entire input script and then perform a simulation with all the settings. Rather, the input script is read one line at a time and each command takes effect when it is read. Thus this sequence of commands:

timestep 0.5
run      100
run      100

does something different than this sequence:

run      100
timestep 0.5
run      100

In the first case, the specified timestep (0.5 fmsec) is used for two simulations of 100 timesteps each. In the 2nd case, the default timestep (1.0 fmsec) is used for the 1st 100 step simulation and a 0.5 fmsec timestep is used for the 2nd one.

(2) Some commands are only valid when they follow other commands. For example you cannot set the temperature of a group of atoms until atoms have been defined and a group command is used to define which atoms belong to the group.

(3) Sometimes command B will use values that can be set by command A. This means command A must precede command B in the input script if it is to have the desired effect. For example, the read_data command initializes the system by setting up the simulation box and assigning atoms to processors. If default values are not desired, the processors and boundary commands need to be used before read_data to tell LAMMPS how to map processors to the simulation box.

Many input script errors are detected by LAMMPS and an ERROR or WARNING message is printed. This section gives more information on what errors mean. The documentation for each command lists restrictions on how the command can be used.


3.2. Parsing rules

Each non-blank line in the input script is treated as a command. LAMMPS commands are case sensitive. Command names are lower-case, as are specified command arguments. Upper case letters may be used in file names or user-chosen ID strings.

Here is how each line in the input script is parsed by LAMMPS:

(1) If the last printable character on the line is a “&” character (with no surrounding quotes), the command is assumed to continue on the next line. The next line is concatenated to the previous line by removing the “&” character and newline. This allows long commands to be continued across two or more lines.

(2) All characters from the first “#” character onward are treated as comment and discarded. See an exception in (6). Note that a comment after a trailing “&” character will prevent the command from continuing on the next line. Also note that for multi-line commands a single leading “#” will comment out the entire command.

(3) The line is searched repeatedly for $ characters, which indicate variables that are replaced with a text string. See an exception in (6).

If the $ is followed by curly brackets, then the variable name is the text inside the curly brackets. If no curly brackets follow the $, then the variable name is the single character immediately following the $. Thus ${myTemp} and $x refer to variable names “myTemp” and “x”.

If the $ is followed by parenthesis, then the text inside the parenthesis is treated as an “immediate” variable and evaluated as an equal-style variable. This is a way to use numeric formulas in an input script without having to assign them to variable names. For example, these 3 input script lines:

variable X equal (xlo+xhi)/2+sqrt(v_area)
region 1 block $X 2 INF INF EDGE EDGE
variable X delete

can be replaced by

region 1 block $((xlo+xhi)/2+sqrt(v_area)) 2 INF INF EDGE EDGE

so that you do not have to define (or discard) a temporary variable X.

Note that neither the curly-bracket or immediate form of variables can contain nested $ characters for other variables to substitute for. Thus you cannot do this:

variable        a equal 2
variable        b2 equal 4
print           "B2 = ${b$a}"

Nor can you specify this $($x-1.0) for an immediate variable, but you could use $(v_x-1.0), since the latter is valid syntax for an equal-style variable.

See the variable command for more details of how strings are assigned to variables and evaluated, and how they can be used in input script commands.

(4) The line is broken into “words” separated by whitespace (tabs, spaces). Note that words can thus contain letters, digits, underscores, or punctuation characters.

(5) The first word is the command name. All successive words in the line are arguments.

(6) If you want text with spaces to be treated as a single argument, it can be enclosed in either double or single quotes. E.g.

print "Volume = $v"
print 'Volume = $v'
if "$steps > 1000" then quit

The quotes are removed when the single argument is stored internally. See the dump modify format or print or if commands for examples. A “#” or “$” character that is between quotes will not be treated as a comment indicator in (2) or substituted for as a variable in (3).

Warning

If the argument is itself a command that requires a quoted argument (e.g. using a print command as part of an if or run every command), then the double and single quotes can be nested in the usual manner. See the doc pages for those commands for examples. Only one of level of nesting is allowed, but that should be sufficient for most use cases.


3.3. Input script structure

This section describes the structure of a typical LAMMPS input script. The “examples” directory in the LAMMPS distribution contains many sample input scripts; the corresponding problems are discussed in Section_example, and animated on the LAMMPS WWW Site.

A LAMMPS input script typically has 4 parts:

  1. Initialization

  2. Atom definition

  3. Settings

  4. Run a simulation

The last 2 parts can be repeated as many times as desired. I.e. run a simulation, change some settings, run some more, etc. Each of the 4 parts is now described in more detail. Remember that almost all the commands need only be used if a non-default value is desired.

  1. Initialization

Set parameters that need to be defined before atoms are created or read-in from a file.

The relevant commands are units, dimension, newton, processors, boundary, atom_style, atom_modify.

If force-field parameters appear in the files that will be read, these commands tell LAMMPS what kinds of force fields are being used: pair_style, bond_style, angle_style, dihedral_style, improper_style.

  1. Atom definition

There are 3 ways to define atoms in LAMMPS. Read them in from a data or restart file via the read_data or read_restart commands. These files can contain molecular topology information. Or create atoms on a lattice (with no molecular topology), using these commands: lattice, region, create_box, create_atoms. The entire set of atoms can be duplicated to make a larger simulation using the replicate command.

  1. Settings

Once atoms and molecular topology are defined, a variety of settings can be specified: force field coefficients, simulation parameters, output options, etc.

Force field coefficients are set by these commands (they can also be set in the read-in files): pair_coeff, bond_coeff, angle_coeff, dihedral_coeff, improper_coeff, kspace_style, dielectric, special_bonds.

Various simulation parameters are set by these commands: neighbor, neigh_modify, group, timestep, reset_timestep, run_style, min_style, min_modify.

Fixes impose a variety of boundary conditions, time integration, and diagnostic options. The fix command comes in many flavors.

Various computations can be specified for execution during a simulation using the compute, compute_modify, and variable commands.

Output options are set by the thermo, dump, and restart commands.

  1. Run a simulation

A molecular dynamics simulation is run using the run command. Energy minimization (molecular statics) is performed using the minimize command. A parallel tempering (replica-exchange) simulation can be run using the temper command.


3.4. Commands listed by category

This section lists all LAMMPS commands, grouped by category. The next section lists the same commands alphabetically. Note that some style options for some commands are part of specific LAMMPS packages, which means they cannot be used unless the package was included when LAMMPS was built. Not all packages are included in a default LAMMPS build. These dependencies are listed as Restrictions in the command’s documentation.

Initialization:

atom_modify, atom_style, boundary, dimension, newton, processors, region, units

Atom definition:

create_atoms, create_box, lattice, read_data, read_dump, read_restart, replicate

Force fields:

angle_coeff, angle_style, bond_coeff, bond_style, dielectric, dihedral_coeff, dihedral_style, improper_coeff, improper_style, kspace_modify, kspace_style, pair_coeff, pair_modify, pair_style, pair_write, special_bonds

Settings:

communicate, group, mass, min_modify, min_style, neigh_modify, neighbor, reset_timestep, run_style, set, timestep, velocity

Fixes:

fix, fix_modify, unfix

Computes:

compute, compute_modify, uncompute

Output:

dump, dump image, dump movie, dump_modify, restart, thermo, thermo_modify, thermo_style, undump, write_data, write_dump, write_restart

Actions:

delete_atoms, delete_bonds, displace_atoms, change_box, minimize, neb, prd, rerun, run, temper

Miscellaneous:

clear, echo, extract_surface, extrude_surface, if, include, jump, label, log, next, print, shell, variable


3.5. Individual commands

This section lists all LAMMPS and LIGGGHTS commands alphabetically, with a separate listing below of styles within certain commands. Note that some style options for some commands are part of specific LAMMPS packages, which means they cannot be used unless the package was included when LAMMPS was built. Not all packages are included in a default LAMMPS build. These dependencies are listed as Restrictions in the command’s documentation.

angle_coeff

angle_style

atom_modify

atom_style

balance

bond_coeff

bond_style

boundary

box

change_box

clear

coarsegraining

communicate

compute

compute_modify

create_atoms

create_box

create_multisphere_clump

delete_atoms

delete_bonds

dielectric

dihedral_coeff

dihedral_style

dimension

displace_atoms

dump

dump_modify

echo

extract_surface

extrude_surface

fix

fix_modify

group

group2ndx

if

improper_coeff

improper_style

include

jump

kspace_modify

kspace_style

label

lattice

log

mass

min_modify

min_style

minimize

modify_timing

neb

neigh_modify

neighbor

newton

next

package

pair_coeff

pair_modify

pair_style

pair_write

partition

prd

print

processors

quit

read_data

read_dump

read_restart

region

replicate

rerun

reset_timestep

restart

run

run_style

set

shell

special_bonds

suffix

tad

temper

thermo

thermo_log

thermo_modify

thermo_style

timestep

uncompute

undump

unfix

units

variable

velocity

write_data

write_dump

write_restart


3.6. angle_style potentials

See the angle_style command for an overview of angle potentials. Click on the style itself for a full description:

charmm

class2

cosine

cosine/delta

cosine/periodic

cosine/shift

cosine/shift/exp

cosine/squared

dipole

fourier

fourier/simple

harmonic

hybrid

none

quartic

sdk

table

These are accelerated angle styles, which can be used if LAMMPS is built with the appropriate accelerated package.

charmm/omp

class2/omp

cosine/delta/omp

cosine/omp

cosine/periodic/omp

cosine/shift/exp/omp

cosine/shift/omp

cosine/squared/omp

dipole/omp

fourier/omp

fourier/simple/omp

harmonic/omp

quartic/omp

table/omp


3.7. bond_style potentials

See the bond_style command for an overview of bond potentials. Click on the style itself for a full description:

class2

fene

fene/expand

harmonic

harmonic/shift

harmonic/shift/cut

hybrid

morse

none

nonlinear

quartic

table

These are accelerated bond styles, which can be used if LAMMPS is built with the appropriate accelerated package.

class2/omp

fene/expand/omp

fene/omp

harmonic/omp

harmonic/shift/cut/omp

harmonic/shift/omp

morse/omp

nonlinear/omp

quartic/omp

table/omp


3.8. compute styles

See the compute command for one-line descriptions of each style or click on the style itself for a full description:

ackland/atom

angle/local

atom/molecule

basal/atom

body/local

bond/local

centro/atom

cluster/atom

cna/atom

com

com/molecule

contact/atom

coord/atom

damage/atom

dihedral/local

displace/atom

erotate/asphere

erotate/multisphere

erotate/sphere

erotate/sphere/atom

erotate/superquadric

event/displace

group/group

gyration

gyration/molecule

heat/flux

improper/local

inertia/molecule

ke

ke/atom

ke/atom/eff

ke/eff

ke/multisphere

meso_e/atom

meso_rho/atom

meso_t/atom

msd

msd/molecule

msd/nongauss

neighbor/atom

nparticles/tracer/region

pair

pair/gran/local

pair/local

pe

pe/atom

pressure

property/atom

property/local

property/molecule

rdf

reduce

reduce/region

rigid

slice

stress/atom

temp

temp/asphere

temp/com

temp/deform

temp/deform/eff

temp/eff

temp/partial

temp/profile

temp/ramp

temp/region

temp/region/eff

temp/rotate

temp/sphere

ti

voronoi/atom

wall/gran/local

These are accelerated compute styles, which can be used if LAMMPS is built with the appropriate accelerated package.

pe/cuda

pressure/cuda

temp/cuda

temp/partial/cuda


3.9. dihedral_style potentials

See the dihedral_style command for an overview of dihedral potentials. Click on the style itself for a full description:

charmm

class2

cosine/shift/exp

fourier

harmonic

helix

hybrid

multi/harmonic

nharmonic

none

opls

quadratic

table

These are accelerated dihedral styles, which can be used if LAMMPS is built with the appropriate accelerated package.

charmm/omp

class2/omp

cosine/shift/exp/omp

fourier/omp

harmonic/omp

helix/omp

multi/harmonic/omp

nharmonic/omp

opls/omp

quadratic/omp

table/omp


3.10. dump styles

Click on the style itself for a full description:

custom/vtk

image

molfile

movie


3.11. fix styles

See the fix command for one-line descriptions of each style or click on the style itself for a full description:

adapt

addforce

addtorque

append/atoms

atc

ave/atom

ave/correlate

ave/euler

ave/euler/region

ave/euler/region/universe

ave/histo

ave/spatial

ave/time

aveforce

balance

bond/break

bond/create

bond/swap

box/relax

break/particle

buoyancy

check/timestep/gran

chem/shrink

chem/shrink/core

colvars

couple/cfd/chemistry

couple/cfd/convection

couple/cfd/deform

couple/cfd/dissolve

couple/cfd/fluidproperties

couple/cfd/recurrence

deform

deposit

drag

dt/reset

efield

enforce2d

evaporate

execute

external

forcecontrol/region

forcecontrol/region/universe

freeze

gcmc

gld

gravity

heat

heat/gran

heat/gran/conduction

heat/gran/radiation

imd

indent

insert/pack

insert/pack/dense

insert/pack/face

insert/pack/face/universe

insert/rate/region

insert/stream

insert/stream/moving

langevin

langevin/eff

lb/fluid

lb/momentum

lb/pc

lb/rigid/pc/sphere

lb/viscous

limit/property/atom

limit/vel

lineforce

massflow/mesh

massflow/mesh/face

massflow/mesh/face/universe

meanfreetime

mesh/6dof

mesh/surface

mesh/surface/planar

mesh/surface/stress

mesh/surface/stress/servo

meso

meso/stationary

momentum

move

move/mesh

msst

multisphere

neb

nph

nph/asphere

nph/eff

nph/sphere

nphug

npt

npt/asphere

npt/eff

npt/sphere

nve

nve/asphere

nve/asphere/noforce

nve/body

nve/eff

nve/limit

nve/line

nve/noforce

nve/sphere

nve/superquadric

nve/tri

nvt

nvt/asphere

nvt/eff

nvt/sllod

nvt/sllod/eff

nvt/sphere

orient/fcc

particledistribution/discrete

particletemplate/fragments

particletemplate/multiplespheres

particletemplate/multisphere

particletemplate/sphere

particletemplate/superquadric

phonon

planeforce

pour/legacy

press/berendsen

print

property/atom

property/atom/cumulativetracer

property/atom/timetracer

property/atom/tracer

property/atom/tracer/stream

property/global

qeq/comb

qeq/reax

reax/bonds

reax/c/bonds

reax/c/species

recenter

remove

restrain

rigid

rigid/nph

rigid/npt

rigid/nve

rigid/nvt

rigid/small

scale/diameter

setforce

shake

smd

speedcontrol

sph/density/continuity

sph/density/corr

sph/density/summation

sph/pressure

spring

spring/rg

spring/self

srd

store/force

store/state

temp/berendsen

temp/rescale

temp/rescale/eff

thermal/conductivity

ti/rs

ti/spring

tmd

ttm

tune/kspace

viscosity

viscous

wall/colloid

wall/gran

wall/harmonic

wall/lj1043

wall/lj126

wall/lj93

wall/piston

wall/reflect

wall/region

wall/region/sph

wall/srd

These are accelerated fix styles, which can be used if LAMMPS is built with the appropriate accelerated package.

addforce/cuda

aveforce/cuda

enforce2d/cuda

freeze/cuda

gravity/cuda

gravity/omp

nph/asphere/omp

nph/omp

nph/sphere/omp

nphug/omp

npt/asphere/omp

npt/cuda

npt/omp

npt/sphere/omp

nve/cuda

nve/omp

nve/sphere/omp

nvt/asphere/omp

nvt/cuda

nvt/omp

nvt/sllod/omp

nvt/sphere/omp

qeq/comb/omp

setforce/cuda

shake/cuda

temp/berendsen/cuda

temp/rescale/cuda

temp/rescale/limit/cuda

viscous/cuda


3.12. improper_style potentials

See the improper_style command for an overview of improper potentials. Click on the style itself for a full description:

class2

cossq

cvff

fourier

harmonic

hybrid

none

ring

umbrella

These are accelerated improper styles, which can be used if LAMMPS is built with the appropriate accelerated package.

class2/omp

cossq/omp

cvff/omp

fourier/omp

harmonic/omp

ring/omp

umbrella/omp


3.13. pair_style potentials

See the pair_style command for an overview of pair potentials. Click on the style itself for a full description:

adp

airebo

awpmd/cut

beck

body

bop

born

born/coul/long

born/coul/msm

born/coul/wolf

brownian

brownian/poly

buck

buck/coul/cut

buck/coul/long

buck/coul/msm

buck/long/coul/long

colloid

comb

comb3

coul/cut

coul/debye

coul/diel

coul/dsf

coul/long

coul/msm

coul/wolf

dpd

dpd/tstat

dsmc

eam

eam/alloy

eam/cd

eam/fs

edip

eff/cut

eim

gauss

gauss/cut

gayberne

gran

hbond/dreiding/lj

hbond/dreiding/morse

hybrid

hybrid/overlay

kim

lcbop

line/lj

list

lj/charmm/coul/charmm

lj/charmm/coul/charmm/implicit

lj/charmm/coul/long

lj/charmm/coul/msm

lj/class2

lj/class2/coul/cut

lj/class2/coul/long

lj/cubic

lj/cut

lj/cut/coul/cut

lj/cut/coul/debye

lj/cut/coul/dsf

lj/cut/coul/long

lj/cut/coul/msm

lj/cut/dipole/cut

lj/cut/dipole/long

lj/cut/tip4p/cut

lj/cut/tip4p/long

lj/expand

lj/gromacs

lj/gromacs/coul/gromacs

lj/long/coul/long

lj/long/dipole/long

lj/long/tip4p/long

lj/sdk

lj/sdk/coul/long

lj/sf

lj/sf/dipole/sf

lj/smooth

lj/smooth/linear

lj96/cut

lubricate

lubricate/poly

lubricateU

lubricateU/poly

meam

mie/cut

morse

nb3b/harmonic

nm/cut

nm/cut/coul/cut

nm/cut/coul/long

none

peri/lps

peri/pmb

peri/ves

reax

reax/c

rebo

resquared

soft

sph

sph/artVisc/tensCorr

sph/heatconduction

sph/idealgas

sph/lj

sph/rhosum

sph/taitwater

sph/taitwater/morris

sw

table

tersoff

tersoff/mod

tersoff/table

tersoff/zbl

tip4p/cut

tip4p/long

tri/lj

yukawa

yukawa/colloid

zbl

These are accelerated pair styles, which can be used if LAMMPS is built with the appropriate accelerated package.

adp/omp

airebo/omp

beck/gpu

beck/omp

born/coul/long/cuda

born/coul/long/gpu

born/coul/long/omp

born/coul/msm/omp

born/coul/wolf/gpu

born/coul/wolf/omp

born/gpu

born/omp

brownian/omp

brownian/poly/omp

buck/coul/cut/cuda

buck/coul/cut/gpu

buck/coul/cut/omp

buck/coul/long/cuda

buck/coul/long/gpu

buck/coul/long/omp

buck/coul/msm/omp

buck/cuda

buck/gpu

buck/long/coul/long/omp

buck/omp

colloid/gpu

colloid/omp

comb/omp

coul/cut/omp

coul/debye/omp

coul/dsf/gpu

coul/dsf/omp

coul/long/gpu

coul/long/omp

coul/msm/omp

coul/wolf/omp

dpd/omp

dpd/tstat/omp

eam/alloy/cuda

eam/alloy/gpu

eam/alloy/omp

eam/alloy/opt

eam/cd/omp

eam/cuda

eam/fs/cuda

eam/fs/gpu

eam/fs/omp

eam/fs/opt

eam/gpu

eam/omp

eam/opt

eim/omp

gauss/cut/omp

gauss/gpu

gauss/omp

gayberne/gpu

gayberne/omp

hbond/dreiding/lj/omp

hbond/dreiding/morse/omp

hybrid/omp

hybrid/overlay/omp

line/lj/omp

lj/charmm/coul/charmm/cuda

lj/charmm/coul/charmm/implicit/cuda

lj/charmm/coul/charmm/implicit/omp

lj/charmm/coul/charmm/omp

lj/charmm/coul/long/cuda

lj/charmm/coul/long/gpu

lj/charmm/coul/long/omp

lj/charmm/coul/long/opt

lj/charmm/coul/msm/omp

lj/class2/coul/cut/cuda

lj/class2/coul/cut/omp

lj/class2/coul/long/cuda

lj/class2/coul/long/gpu

lj/class2/coul/long/omp

lj/class2/cuda

lj/class2/gpu

lj/class2/omp

lj/cubic/omp

lj/cut/coul/cut/cuda

lj/cut/coul/cut/gpu

lj/cut/coul/cut/omp

lj/cut/coul/debye/cuda

lj/cut/coul/debye/gpu

lj/cut/coul/debye/omp

lj/cut/coul/dsf/gpu

lj/cut/coul/dsf/omp

lj/cut/coul/long/cuda

lj/cut/coul/long/gpu

lj/cut/coul/long/omp

lj/cut/coul/long/opt

lj/cut/coul/msm/gpu

lj/cut/coul/msm/omp

lj/cut/cuda

lj/cut/dipole/cut/gpu

lj/cut/dipole/cut/omp

lj/cut/experimental/cuda

lj/cut/gpu

lj/cut/omp

lj/cut/opt

lj/cut/tip4p/cut/omp

lj/cut/tip4p/long/omp

lj/cut/tip4p/long/opt

lj/expand/cuda

lj/expand/gpu

lj/expand/omp

lj/gromacs/coul/gromacs/cuda

lj/gromacs/coul/gromacs/omp

lj/gromacs/cuda

lj/gromacs/omp

lj/long/coul/long/omp

lj/long/coul/long/opt

lj/sdk/coul/long/gpu

lj/sdk/coul/long/omp

lj/sdk/gpu

lj/sdk/omp

lj/sf/dipole/sf/gpu

lj/sf/dipole/sf/omp

lj/sf/omp

lj/smooth/cuda

lj/smooth/linear/omp

lj/smooth/omp

lj96/cut/cuda

lj96/cut/gpu

lj96/cut/omp

lubricate/omp

lubricate/poly/omp

mie/cut/gpu

morse/cuda

morse/gpu

morse/omp

morse/opt

nb3b/harmonic/omp

nm/cut/coul/cut/omp

nm/cut/coul/long/omp

nm/cut/omp

peri/lps/omp

peri/pmb/omp

rebo/omp

resquared/gpu

resquared/omp

soft/gpu

soft/omp

sw/cuda

sw/gpu

sw/omp

table/gpu

table/omp

tersoff/mod/omp

tersoff/table/omp

tersoff/zbl/omp

tip4p/cut/omp

tip4p/long/omp

tri/lj/omp

yukawa/colloid/gpu

yukawa/colloid/omp

yukawa/gpu

yukawa/omp

zbl/omp