LAMMPS from scratch · 20 min
Building the system
Four lines turn a number into a crystal: lattice, region, create_box and create_atoms. You derive the lattice spacing, box size and atom count by hand for any lattice, then let LAMMPS build it and compare its log line by line, including a box size that does not fit the crystal.
- What lattice, region, create_box and create_atoms each do, and in which units
- Predict the lattice spacing, box size and number of atoms for sc, bcc, fcc, diamond and 2D lattices
- See what happens when the box is not a whole number of lattice cells
1 · Understand: four lines, one crystal
| Line | What it does | In melt |
|---|---|---|
lattice fcc 0.8442 | describes a pattern of points: the FCC cube with 4 atoms; in LJ units the number is the density, so the cube edge is a = (4/0.8442)1/3 | a = 1.6795962 |
region box block 0 10 0 10 0 10 | a named shape; numbers are counted in lattice spacings | a cube 16.795962 on each side |
create_box 1 box | makes the simulation box with that shape and 1 atom type | box (0,0,0) to (16.795962, …) |
create_atoms 1 box | puts an atom of type 1 on every lattice point inside the region | 4 × 10³ = 4000 atoms |
In LJ units the lattice number is a density; in every other unit style it is the lattice constant itself (for copper in metal units, lattice fcc 3.615 means a = 3.615 Å). LAMMPS confirms what it built in three log lines:
2 · The rules by hand
| Lattice | atoms per cell n | spacing a (LJ units, density ρ) | nearest neighbour |
|---|---|---|---|
| sc (simple cubic) | 1 | (1/ρ)1/3 | a |
| bcc | 2 | (2/ρ)1/3 | a√3/2 |
| fcc | 4 | (4/ρ)1/3 | a/√2 |
| diamond | 8 | (8/ρ)1/3 | a√3/4 |
| sq (2D square) | 1 | (1/ρ)1/2 | a |
| hex (2D) | 2 in an a × √3a cell | (2/(ρ√3))1/2 | a |
3 · Modify, predict, observe: the lattice builder
Pick a lattice, a density and the number of cells. The page predicts the three log lines; LAMMPS then builds the system and the numbers are compared.
Predict by hand
What the builder shows
- For whole numbers of cells, three lines of arithmetic predict exactly what LAMMPS builds.
- With 2.5 cells LAMMPS still makes a box, and fills it with only the 63 lattice points that fit inside. Nothing warns you: across the periodic boundary the next copy starts half a cell too early, so atoms meet at the wrong distance and the crystal is broken. Choose whole numbers of cells for crystals.
- In 2D the hex lattice has a rectangular cell, √3 times longer in y: its spacing line shows two different numbers.
Your turn
1. How many atoms does lattice bcc 0.8442 with region box block 0 5 0 5 0 5 give, and what is the box length?
2. Count the 63 atoms of the 2.5-cell fcc box by hand.
3. In metal units you write lattice fcc 0.8442. What goes wrong?