LAMMPS from scratch · 25 min

Units

The units command decides what every number in a script means. You see the conversion constants inside LAMMPS, derive one by hand, then run melt twice: in Lennard-Jones units and as real argon in Å, femtoseconds and kcal/mol. Converted by hand, the two runs agree at every printed step.

1 · Understand: the same number means different things

Set units before creating the simulation box or defining force-field settings, so LAMMPS interprets later values correctly. This example places it near the top. timestep 1.0 is one femtosecond in real units and one picosecond in metal units.

ljrealmetalsi
massm (set to 1)g/molg/molkg
distance叏m
timeτ = σ√(m/ε)fspss
energyεkcal/moleVJ
temperatureε/kBKKK
pressureε/σ³atmbarPa
default time step0.005 τ1 fs0.001 ps10⁻⁸ s
default neighbour skin0.3 σ2 Å2 Å0.001 m
thermo energies areper atomtotalstotalstotals

The last row matters when comparing numbers: in LJ units thermo divides energies by the number of atoms; in all other styles it prints the total.

2 · The constants inside LAMMPS

Equations of motion need a few conversion factors. LAMMPS sets them in Update::set_units(). For real units (lines 171–176 and nearby):

force->boltz = 0.0019872067; k_B in kcal/mol/K force->mvv2e = 48.88821291 * 48.88821291; mass × velocity² → energy force->ftm2v = 1.0 / 48.88821291 / 48.88821291; force / mass → acceleration force->nktv2p = 68568.415; kcal/mol/ų → atm force->qqr2e = 332.06371; charge²/distance → kcal/mol

In LJ units all five are 1. Where does 48.88821291 come from? A force of 1 kcal/mol/Å on a mass of 1 g/mol gives an acceleration of:

a = F/m = (4184 J per mol / 10⁻¹⁰ m) / (10⁻³ kg per mol) = 4.184 × 10¹⁶ m/s² = 4.184 × 10¹⁶ × 10¹⁰ Å / (10¹⁵ fs)² = 4.184 × 10⁻⁴ Å/fs² ftm2v = 1/48.88821291² = 1/2390.0574 = 4.1840 × 10⁻⁴ ✓

3 · Modify: melt as real argon

Argon is often modelled with σ = 3.405 Å, ε = 0.2381 kcal/mol (0.996 kJ/mol) and m = 39.948 g/mol. Every LJ number in melt becomes a real number by multiplying with the right combination:

# melt in real units: argon, sigma = 3.405 A, epsilon = 0.2381 kcal/mol, m = 39.948 g/mol units real variable sig equal 3.405 variable eps equal 0.2381 atom_style atomic lattice fcc $((4/0.8442)^(1/3)*v_sig) region box block 0 10 0 10 0 10 create_box 1 box create_atoms 1 box mass 1 39.948 velocity all create $(3*v_eps/0.0019872067) 87287 loop all pair_style lj/cut $(2.5*v_sig) pair_coeff 1 1 ${eps} ${sig} $(2.5*v_sig) neighbor $(0.3*v_sig) bin neigh_modify every 20 delay 0 check no timestep $(0.005*v_sig*sqrt(39.948/v_eps)*48.88821291) fix 1 all nve thermo 50 run 250

Both scripts use loop all instead of loop geom for the velocities. With loop geom the random velocity of each atom is seeded from its coordinates, and the coordinates are different numbers in Å and in σ, so the two runs would start with different (equally valid) velocities.

Predict by hand

lattice constant a = 1.6795962 σ × 3.405 Å/σ = 5.719025 Å box L = 10 a = 57.19025 Å temperature T = 3 ε/k_B = 3 × 0.2381 / 0.0019872067 = 359.44927 K time unit τ = σ √(m/ε) × 48.88821291 fs = 3.405 × 12.952924 × 48.88821291 = 2156.2003 fs time step Δt = 0.005 τ = 10.781001 fs energies are totals here: multiply the per-atom LJ value by ε × N = 0.2381 × 4000 = 952.4 E_pair = −6.77336805 × 952.4 = −6450.9557 kcal/mol TotEng = −2.27449305 × 952.4 = −2166.2272 kcal/mol pressure: ε/σ³ × nktv2p = 0.2381/39.477655 × 68568.415 = 413.55393 atm Press = −3.7033504 × 413.55393 = −1531.5351 atm

4 · Observe and match: run both

Each button runs the real LAMMPS (250 steps, about 2 seconds). After both runs, every real-unit number is converted back to LJ units by hand and compared with the LJ run.

What the two runs show

Your turn

1. A real-units run prints Temp = 200.79919 K at step 50. What is that in LJ units?

2. You copy timestep 2.0 from a real-units water script into a metal-units script. What time step do you get?

3. Why do the real-units energies look 952 times larger than the LJ ones?