LAMMPS from scratch · 20 min

What an input script is

An input script is a list of commands that LAMMPS carries out one at a time, top to bottom, the moment it reads each one. You take the melt example apart six ways, predict for each whether LAMMPS stops, runs normally or runs differently, then run it live and check the numbers by hand.

1 · Understand: three rules

  1. One command per line. The first word names the command; the rest are its settings (page A.2 shows how a line is read).
  2. Top to bottom. LAMMPS never looks ahead. A command can only use what earlier lines created.
  3. Immediately. Each command is carried out as soon as it is read, before the next line is even looked at.

Commands come in two kinds. A setting is remembered and used later; an action does something now, with whatever exists at that moment.

melt linekindwhat it needs before it
units lj, atom_style atomicsettingmust come first: everything else depends on them
lattice fcc 0.8442setting
region box block …setting (a named shape)the lattice (its numbers are in lattice cells)
create_box 1 boxaction: makes the box and 1 atom typethe region
create_atoms 1 boxaction: puts 4000 atoms inthe box and the lattice
mass 1 1.0settingthe atom type
velocity all create 3.0 …action: gives velocities nowatoms and their mass
pair_style, pair_coeffsettingpair_coeff needs the atom types
neighbor, neigh_modify, fix, thermosetting
run 250action: uses every setting made so farall of the above

2 · Modify, predict, observe: six rearranged scripts

For each change, choose what you think LAMMPS will do, then run the real LAMMPS to see.

A. The force field before the box

Change: the two pair lines moved above lattice.

B. No mass

Change: the line mass 1 1.0 deleted.

C. Velocities before atoms

Change: velocity moved above create_atoms.

D. Printing set after the run

Change: thermo 50 moved below run 250.

E. Moving atoms switched on too late

Change: fix 1 all nve moved below run 250.

F. No forces at all

Change: both pair lines deleted.

3 · What the six results teach

ChangeLAMMPSLesson
A, B, Cstops with an erroran action or a setting used something that did not exist yet
Druns; fewer lines printeda setting placed after an action does not affect it
Eruns; a warning; nothing movesa missing step is not always an error
Fruns; two warnings; an ideal gasLAMMPS checks the order, never your intention: only a hand calculation catches this

The last row is the reason for the hand calculations on every page of this section. An input that runs is not the same as an input that is right.

Your turn

1. You add timestep 0.001 after run 250. What happens to the run?

2. In change F, why is the pressure exactly ρT(N−1)/N?

3. Can you put pair_style lj/cut 2.5 as the very first line?