Previous Section - LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands - Next Section

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
3.2 Parsing rules
3.3 Input script structure
3.4 Commands listed by category
3.5 Commands listed alphabetically


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).

IMPORTANT NOTE: 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.

(2) 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.

(3) 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.

(4) 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, units

Atom definition:

create_atoms, create_box, lattice, read_data, read_dump, read_restart, region, 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_modify, dump movie, 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, 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_coeffangle_styleatom_modifyatom_stylebond_coeffbond_style
boundaryboxchange_boxclearcommunicatecompute
compute_modifycreate_atomscreate_boxdelete_atomsdelete_bondsdielectric
dihedral_coeffdihedral_styledimensiondisplace_atomsdumpdump_modify
echofixfix_modifygroupgroup2ndxif
improper_coeffimproper_styleincludejumpkspace_modifykspace_style
labellatticelogmassmin_modifymin_style
minimizenebneigh_modifyneighbornewtonnext
packagepair_coeffpair_modifypair_stylepair_writepartition
prdprintprocessorsquitread_dataread_dump
read_restartregionreplicatererunreset_timesteprestart
runrun_stylesetshellspecial_bondssuffix
tadtemperthermothermo_modifythermo_styletimestep
uncomputeundumpunfixunitsvariablevelocity
write_datawrite_dumpwrite_restart

angle_style potentials

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

charmmclass2cosinecosine/delta
cosine/periodiccosine/shiftcosine/shift/expcosine/squared
dipolefourierfourier/simpleharmonic
hybridnonequarticsdk
table

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

charmm/ompclass2/ompcosine/delta/ompcosine/omp
cosine/periodic/ompcosine/shift/exp/ompcosine/shift/ompcosine/squared/omp
dipole/ompfourier/ompfourier/simple/ompharmonic/omp
quartic/omptable/omp

bond_style potentials

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

class2fenefene/expandharmonic
harmonic/shiftharmonic/shift/cuthybridmorse
nonenonlinearquartictable

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

class2/ompfene/expand/ompfene/ompharmonic/omp
harmonic/shift/cut/ompharmonic/shift/ompmorse/ompnonlinear/omp
quartic/omptable/omp

compute syles

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

ackland/atomangle/localatom/moleculebasal/atom
body/localbond/localcentro/atomcluster/atom
cna/atomcomcom/moleculecontact/atom
coord/atomdamage/atomdihedral/localdisplace/atom
erotate/asphereerotate/sphereerotate/sphere/atomevent/displace
group/groupgyrationgyration/moleculeheat/flux
improper/localinertia/moleculekeke/atom
ke/atom/effke/effmeso_e/atommeso_rho/atom
meso_t/atommsdmsd/moleculemsd/nongauss
nparticles/tracer/regionpairpair/gran/localpair/local
pepe/atompressureproperty/atom
property/localproperty/moleculerdfreduce
reduce/regionslicestress/atomtemp
temp/aspheretemp/comtemp/deformtemp/deform/eff
temp/efftemp/partialtemp/profiletemp/ramp
temp/regiontemp/region/efftemp/rotatetemp/sphere
tivoronoi/atomwall/gran/local

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

pe/cudapressure/cudatemp/cudatemp/partial/cuda

dihedral_style potentials

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

charmmclass2cosine/shift/expfourier
harmonichelixhybridmulti/harmonic
nharmonicnoneoplsquadratic
table

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

charmm/ompclass2/ompcosine/shift/exp/ompfourier/omp
harmonic/omphelix/ompmulti/harmonic/ompnharmonic/omp
opls/ompquadratic/omptable/omp

dump syles

Click on the style itself for a full description:

imagemolfilemovie

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

fix syles

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

adaptaddforceaddtorqueappend/atoms
atcave/atomave/correlateave/euler
ave/histoave/spatialave/timeaveforce
bond/breakbond/createbond/swapbox/relax
check/timestep/grancolvarsdeformdeposit
dragdt/resetefieldenforce2d
evaporateexternalfreezegcmc
gldgravityheatheat/gran
heat/gran/conductionimdindentinsert/pack
insert/rate/regioninsert/streamlangevinlangevin/eff
lb/fluidlb/momentumlb/pclb/rigid/pc/sphere
lb/viscouslineforcemassflow/meshmesh/surface
mesh/surface/planarmesh/surface/stressmesh/surface/stress/servomeso
meso/stationarymomentummovemove/mesh
msstnebnphnph/asphere
nph/effnph/spherenphugnpt
npt/aspherenpt/effnpt/spherenve
nve/aspherenve/asphere/noforcenve/bodynve/eff
nve/limitnve/linenve/noforcenve/sphere
nve/trinvtnvt/aspherenvt/eff
nvt/sllodnvt/sllod/effnvt/sphereorient/fcc
particledistribution/discreteparticletemplate/spherephononplaneforce
pour/legacypress/berendsenprintproperty/atom
property/atom/tracerproperty/atom/tracer/streamproperty/globalqeq/comb
qeq/reaxreax/bondsreax/c/bondsreax/c/species
recenterrestrainrigidrigid/nph
rigid/nptrigid/nverigid/nvtrigid/small
setforceshakesmdsph/density/continuity
sph/density/corrsph/density/summationsph/pressurespring
spring/rgspring/selfsrdstore/force
store/statetemp/berendsentemp/rescaletemp/rescale/eff
thermal/conductivityti/rsti/springtmd
ttmtune/kspaceviscosityviscous
wall/colloidwall/granwall/harmonicwall/lj1043
wall/lj126wall/lj93wall/pistonwall/reflect
wall/regionwall/region/sphwall/srd

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

addforce/cudaaveforce/cudaenforce2d/cudafreeze/cuda
gravity/cudagravity/ompnph/asphere/ompnph/omp
nph/sphere/ompnphug/ompnpt/asphere/ompnpt/cuda
npt/ompnpt/sphere/ompnve/cudanve/omp
nve/sphere/ompnvt/asphere/ompnvt/cudanvt/omp
nvt/sllod/ompnvt/sphere/ompqeq/comb/ompsetforce/cuda
shake/cudatemp/berendsen/cudatemp/rescale/cudatemp/rescale/limit/cuda
viscous/cuda

improper_style potentials

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

class2cossqcvfffourier
harmonichybridnonering
umbrella

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

class2/ompcossq/ompcvff/ompfourier/omp
harmonic/ompring/ompumbrella/omp

pair_style potentials

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

adpaireboawpmd/cutbeck
bodybopbornborn/coul/long
born/coul/msmborn/coul/wolfbrownianbrownian/poly
buckbuck/coul/cutbuck/coul/longbuck/coul/msm
buck/long/coul/longcolloidcombcomb3
coul/cutcoul/debyecoul/dielcoul/dsf
coul/longcoul/msmcoul/wolfdpd
dpd/tstatdsmceameam/alloy
eam/cdeam/fsedipeff/cut
eimgaussgauss/cutgayberne
granhbond/dreiding/ljhbond/dreiding/morsehybrid
hybrid/overlaykimlcbopline/lj
listlj/charmm/coul/charmmlj/charmm/coul/charmm/implicitlj/charmm/coul/long
lj/charmm/coul/msmlj/class2lj/class2/coul/cutlj/class2/coul/long
lj/cubiclj/cutlj/cut/coul/cutlj/cut/coul/debye
lj/cut/coul/dsflj/cut/coul/longlj/cut/coul/msmlj/cut/dipole/cut
lj/cut/dipole/longlj/cut/tip4p/cutlj/cut/tip4p/longlj/expand
lj/gromacslj/gromacs/coul/gromacslj/long/coul/longlj/long/dipole/long
lj/long/tip4p/longlj/sdklj/sdk/coul/longlj/sf
lj/sf/dipole/sflj/smoothlj/smooth/linearlj96/cut
lubricatelubricate/polylubricateUlubricateU/poly
meammie/cutmorsenb3b/harmonic
nm/cutnm/cut/coul/cutnm/cut/coul/longnone
peri/lpsperi/pmbperi/vesreax
reax/creboresquaredsoft
sphsph/artVisc/tensCorrsph/heatconductionsph/idealgas
sph/ljsph/rhosumsph/taitwatersph/taitwater/morris
swtabletersofftersoff/mod
tersoff/tabletersoff/zbltip4p/cuttip4p/long
tri/ljyukawayukawa/colloidzbl

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

adp/ompairebo/ompbeck/gpubeck/omp
born/coul/long/cudaborn/coul/long/gpuborn/coul/long/ompborn/coul/msm/omp
born/coul/wolf/gpuborn/coul/wolf/ompborn/gpuborn/omp
brownian/ompbrownian/poly/ompbuck/coul/cut/cudabuck/coul/cut/gpu
buck/coul/cut/ompbuck/coul/long/cudabuck/coul/long/gpubuck/coul/long/omp
buck/coul/msm/ompbuck/cudabuck/gpubuck/long/coul/long/omp
buck/ompcolloid/gpucolloid/ompcomb/omp
coul/cut/ompcoul/debye/ompcoul/dsf/gpucoul/dsf/omp
coul/long/gpucoul/long/ompcoul/msm/ompcoul/wolf/omp
dpd/ompdpd/tstat/ompeam/alloy/cudaeam/alloy/gpu
eam/alloy/ompeam/alloy/opteam/cd/ompeam/cuda
eam/fs/cudaeam/fs/gpueam/fs/ompeam/fs/opt
eam/gpueam/ompeam/opteim/omp
gauss/cut/ompgauss/gpugauss/ompgayberne/gpu
gayberne/omphbond/dreiding/lj/omphbond/dreiding/morse/omphybrid/omp
hybrid/overlay/ompline/lj/omplj/charmm/coul/charmm/cudalj/charmm/coul/charmm/implicit/cuda
lj/charmm/coul/charmm/implicit/omplj/charmm/coul/charmm/omplj/charmm/coul/long/cudalj/charmm/coul/long/gpu
lj/charmm/coul/long/omplj/charmm/coul/long/optlj/charmm/coul/msm/omplj/class2/coul/cut/cuda
lj/class2/coul/cut/omplj/class2/coul/long/cudalj/class2/coul/long/gpulj/class2/coul/long/omp
lj/class2/cudalj/class2/gpulj/class2/omplj/cubic/omp
lj/cut/coul/cut/cudalj/cut/coul/cut/gpulj/cut/coul/cut/omplj/cut/coul/debye/cuda
lj/cut/coul/debye/gpulj/cut/coul/debye/omplj/cut/coul/dsf/gpulj/cut/coul/dsf/omp
lj/cut/coul/long/cudalj/cut/coul/long/gpulj/cut/coul/long/omplj/cut/coul/long/opt
lj/cut/coul/msm/gpulj/cut/coul/msm/omplj/cut/cudalj/cut/dipole/cut/gpu
lj/cut/dipole/cut/omplj/cut/experimental/cudalj/cut/gpulj/cut/omp
lj/cut/optlj/cut/tip4p/cut/omplj/cut/tip4p/long/omplj/cut/tip4p/long/opt
lj/expand/cudalj/expand/gpulj/expand/omplj/gromacs/coul/gromacs/cuda
lj/gromacs/coul/gromacs/omplj/gromacs/cudalj/gromacs/omplj/long/coul/long/omp
lj/long/coul/long/optlj/sdk/coul/long/gpulj/sdk/coul/long/omplj/sdk/gpu
lj/sdk/omplj/sf/dipole/sf/gpulj/sf/dipole/sf/omplj/sf/omp
lj/smooth/cudalj/smooth/linear/omplj/smooth/omplj96/cut/cuda
lj96/cut/gpulj96/cut/omplubricate/omplubricate/poly/omp
mie/cut/gpumorse/cudamorse/gpumorse/omp
morse/optnb3b/harmonic/ompnm/cut/coul/cut/ompnm/cut/coul/long/omp
nm/cut/ompperi/lps/ompperi/pmb/omprebo/omp
resquared/gpuresquared/ompsoft/gpusoft/omp
sw/cudasw/gpusw/omptable/gpu
table/omptersoff/mod/omptersoff/table/omptersoff/zbl/omp
tip4p/cut/omptip4p/long/omptri/lj/ompyukawa/colloid/gpu
yukawa/colloid/ompyukawa/gpuyukawa/ompzbl/omp