This section describes how a LAMMPS input script is formatted and what commands are used to define a LAMMPS simulation.
3.1 LAMMPS input scriptLAMMPS 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.
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 for file names or user-specified ID strings.
Here is how each line in the input script is parsed by LAMMPS:
(1) If the line ends with a "&" character (with no trailing whitespace), 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.
(3) The line is searched repeatedly for $ characters. If the character following the $ is "a" to "z", the two-characters sequence (e.g. $x) is replaced with the corresponding variable text. See the variable command for details.
(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) An argument with spaces can be enclosed in double quotes so it will be treated as a single argument. See the dump modify command for an example.
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 this section, and animated on the LAMMPS WWW Site.
A LAMMPS input script typically has 4 parts:
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, orient, origin, 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 coefficents 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: temperature, temp_modify, neighbor, neigh_modify, group, timestep, reset_timestep, run_style.
Fixes impose a variety of boundary conditions, time integration, and diagnostic options. The fix command comes in many flavors.
Output options are set by these commands: thermo, dump, restart.
(4) Run a simulation
A molecular dynamics simulation is run using the run command. A parallel tempering (replica-exchange) simulation can be run using the temper command.
This section lists all LAMMPS commands, grouped by category. The next section lists the same commands alphabetically. Note that some commands and their style options are part of specific LAMMPS packages. All packages are included in a LAMMPS build by default, but if you excluded a specific package when building LAMMPS, you cannot use the associated commands or styles. 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, orient, origin, read_data, 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:
dipole, group, mass, neigh_modify, neighbor, reset_timestep, run_style, set, temp_modify, temperature, timestep, velocity
Fixes:
Output:
dump, dump_modify, restart, thermo, thermo_modify, thermo_style, undump, write_restart
Actions:
delete_atoms, delete_bonds, displace_atoms, run, temper
Miscellaneous:
cd, clear, echo, include, jump, log, next, variable
This section lists all LAMMPS commands alphabetically. The previous section lists the same commands, grouped by category. Note that some commands and their style options are part of specific LAMMPS packages. All packages are included in a LAMMPS build by default, but if you excluded a specific package when building LAMMPS, you cannot use the associated commands or styles. These dependencies are listed as Restrictions in the command's documentation.