Lesson 2.1 · 12 min
Units in MD
Atoms are tiny and fast, so MD codes use special units: ångströms, femtoseconds, kcal/mol. Different codes pick different ones, which makes unit mix-ups one of the most common bugs. Reduced units avoid the problem entirely.
- The unit systems used by LAMMPS, GROMACS and others
- The conversion traps: ×4.184, ×10, ×1000
- Reduced Lennard-Jones units, and how to convert results back to real units
The idea
In SI units, an atom is 10−10 m across, vibrates every 10−14 s, and has an interaction energy of 10−21 J. Numbers like that are awkward, so MD codes use units that fit atoms.
- Length: ångström (1 Å = 0.1 nm) or nanometre.
- Time: femtosecond (1 fs = 10−15 s) or picosecond (1 ps = 1000 fs).
- Energy: kcal/mol, kJ/mol (1 kcal = 4.184 kJ) or eV.
- Mass: g/mol (atomic mass units).
Each code chooses its own. LAMMPS units real uses Å, fs and kcal/mol. units metal uses Å, ps and eV. GROMACS uses nm, ps and kJ/mol. Copy a parameter from one world to the other without converting it, and your forces are off by 4.184 or your distances by 10. The code will not complain. It will simply simulate the wrong system.
Reduced units sidestep all of this. For a Lennard-Jones system we set σ = ε = m = 1 and measure everything relative to them. Then argon, krypton and xenon all become the same simulation. Only at the end do we convert back with each gas's own σ, ε and m. This idea is called the law of corresponding states.
The algorithm
Converting a reduced-unit simulation to a real substance:
- Look up σ (Å), ε/kB (K) and m (g/mol) for your substance.
- Compute the time unit τ = σ√(m/ε). For argon this is about 2.16 ps.
- Multiply each reduced result by its unit:
- T = T*·(ε/kB)
- t = t*·τ
- ρ = ρ*·m/σ³
- P = P*·ε/σ³
- E = E*·ε
sigma, eps_K, mass = 3.405, 119.8, 39.948 # argon tau = sigma*1e-10 * sqrt(mass*amu / (eps_K*kB)) T_real = T_star * eps_K # kelvin dt_real = dt_star * tau # seconds
Unit check before every run: list each input (cutoff, ε, σ, charges, Δt, temperature) next to the unit your code expects. Most "my simulation explodes" questions end here.
See it inside LAMMPS
The same idea in the real code, run live in your browser and checked by hand.