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.

1 · Understand: one skeleton for every script

BlockAnswers the questionTypical commands
1 · Initializationwhat kind of world? units, 2D or 3D, what an atom carriesunits, dimension, boundary, atom_style
2 · Systemwhere are the atoms?lattice, region, create_box, create_atoms, or read_data (page A.8)
3 · Settingshow do they interact and move, and what is printed?mass, velocity, pair_style, pair_coeff, neighbor, fix, compute, thermo
4 · Rungo!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 lj
atom_style atomic
lattice fcc 0.8442
region box block 0 10 0 10 0 10
create_box 1 box
create_atoms 1 box
mass 1 1.0
velocity all create 3.0 87287 loop geom
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
neighbor 0.3 bin
neigh_modify every 20 delay 0 check no
fix 1 all nve
thermo 50
run 250

1 = 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.

# 1 · Initialization units lj dimension 2 atom_style atomic # 2 · System: a 3 x 3 square crystal, spacing 1.2 lattice sq $(1/1.2^2) region box block 0 3 0 3 -0.5 0.5 create_box 1 box create_atoms 1 box # 3 · Settings mass 1 1.0 velocity all create 0.72 87287 loop geom pair_style lj/cut 1.8 pair_coeff 1 1 1.0 1.0 1.8 fix 1 all nve fix 2 all enforce2d # 4 · Run run 0

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.

u(r) = 4(r⁻¹² − r⁻⁶) u(1.2) = 4(0.11215665 − 0.33489798) = −0.89096529 u(1.6971) = 4(0.00175245 − 0.04186225) = −0.16043920 E_pair = ½ × (4 × u(1.2) + 4 × u(1.6971)) (each pair shared by 2) = 2 × (−0.89096529 − 0.16043920) = −2.102809 in 2D an atom has 2 degrees of freedom; 2 are removed for the whole crystal: KE/N = (2N − 2)/2 × T / N = 8 × 0.72 / 9 = 0.64 TotEng = −2.102809 + 0.64 = −1.462809 area A = 3.6 × 3.6 = 12.96; pressure in 2D = (kinetic + virial)/(2A) kinetic: (2N − 2) × T /(2A) = 16 × 0.72 / 25.92 = 0.44444444 virial : N × ½ × 4 × (rF(1.2) + rF(1.6971)) /(2A) = 9 × 2 × (−2.65403201 − 0.92057644) / 25.92 = −2.48236700 Press = 0.44444444 − 2.48236700 = −2.0379225 (rF = 24(2r⁻¹² − r⁻⁶) = r times the force)

What the new system shows

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?