LAMMPS from scratch · 20 min

read_data files

Real systems are rarely built with lattice commands: they are read from a data file that lists every atom, bond and angle. You write one by hand for a single water molecule, let LAMMPS read it, and check the bond and angle energies, the excluded Coulomb energy and the dipole moment by hand, then edit the file and check again.

1 · Understand: a data file is the system, written out

Instead of lattice, region, create_box and create_atoms, block 2 of the script (page A.3) can be one line: read_data water.data. The file has a header with counts and the box, then sections:

PartContainsWater
headernumbers of atoms, bonds, angles, and of their types; the box3 atoms, 2 bonds, 1 angle; 2 atom types
Massesone mass per atom typeO 15.9994, H 1.008 g/mol
Atoms # fullone line per atom; the columns depend on atom_styleid, molecule, type, charge, x, y, z
Bondsbond id, bond type, the two atom idsO–H1, O–H2
Anglesangle id, angle type, three atom ids (the middle one is the vertex)H1–O–H2
atom_stylecolumns of an Atoms line
atomicid type x y z
chargeid type q x y z
fullid molecule type q x y z

Three optional integers at the end of an Atoms line are image flags (page D.2).

2 · Modify: the data file and the script

Edit any number in the data file (for example a coordinate). The hand calculation below updates at once; then run LAMMPS.


        

3 · Predict by hand

LAMMPS's harmonic bond and angle are E = K(r − r₀)² and E = K(θ − θ₀)²: there is no ½ in front, unlike the textbook ½k x². Force fields that publish k must be divided by 2 before use.

What the molecule shows

Your turn

1. You change the header to 4 atoms but leave three Atoms lines. What happens?

2. A paper gives the O–H bond as k = 1059.2 kcal/mol/Ų in E = ½k(r − r₀)². What do you write in bond_coeff?

3. Move H2 so that the angle is exactly 109.47°. What is E_angle, and does the dipole get larger or smaller?