LAMMPS from scratch · 20 min
The four blocks of every script
Almost every LAMMPS input has the same skeleton: initialization, system, settings, run. You sort the melt lines into the four blocks, then reuse the skeleton for a different system, a two-dimensional crystal of 9 atoms, predict its first line by hand and check it.
- The four blocks and which commands belong in each
- Sort every line of the melt example into its block
- Build a new 2D system from the same skeleton and match its first line by hand
1 · Understand: one skeleton for every script
| Block | Answers the question | Typical commands |
|---|---|---|
| 1 · Initialization | what kind of world? units, 2D or 3D, what an atom carries | units, dimension, boundary, atom_style |
| 2 · System | where are the atoms? | lattice, region, create_box, create_atoms, or read_data (page A.8) |
| 3 · Settings | how do they interact and move, and what is printed? | mass, velocity, pair_style, pair_coeff, neighbor, fix, compute, thermo |
| 4 · Run | go! | run, minimize |
The order follows the rules of page A.1: block 1 changes the meaning of everything after it, so it comes first; block 3 needs the atom types created in block 2; block 4 uses everything. velocity is strictly an action, but it is usually written with the settings, just before the run.
2 · Sort the melt lines
Choose a block for each line, then check.
units ljatom_style atomiclattice fcc 0.8442region box block 0 10 0 10 0 10create_box 1 boxcreate_atoms 1 boxmass 1 1.0velocity all create 3.0 87287 loop geompair_style lj/cut 2.5pair_coeff 1 1 1.0 1.0 2.5neighbor 0.3 binneigh_modify every 20 delay 0 check nofix 1 all nvethermo 50run 2501 = Initialization, 2 = System, 3 = Settings, 4 = Run.
3 · Modify: a new system from the same skeleton
Keep the four blocks and change their contents: a flat (2D) crystal of 3 × 3 atoms on a square grid with spacing 1.2, at temperature 0.72, cutoff 1.8. These are the 9 atoms of Lab 3.9.
New commands: dimension 2 (atoms move in a plane), lattice sq (a square grid; in LJ units the number is the density 1/1.2² = 0.69444, so the spacing is 1.2) and fix enforce2d (keeps the motion exactly flat).
Predict by hand
Every atom has 4 neighbours at 1.2 and 4 on the diagonals at 1.2√2 = 1.6971; the next ones, at 2.4, are beyond the cutoff 1.8.
What the new system shows
- The skeleton did not change; only the contents of each block did. Every script in this course, and most in research, has this shape.
- A change in block 1 (
dimension 2) changed rules everywhere: 2 degrees of freedom per atom instead of 3, an area instead of a volume. - The hand calculation is the same method as for melt: shells of neighbours, half of each pair per atom.
Your turn
1. In which block do compute and dump belong?
2. Change the 2D cutoff to 1.5 (both lines). Which neighbours remain, and what is E_pair?
3. Why does the 2D kinetic energy per atom use (2N − 2)/2 and not 3N/2?