Guide to Lammps - About Lammps

LAMMPS (Large-scale Atomic/Molecular Massively Parallel Simulator) is a simulator for molecular dynamics developed by Sandia National Laboratories. The simulator makes use of MPI to accelerate calculations using parallel computation. The simulator operates as an interpreter and as such requires a simulation script. In this guide I will review the general form of a script, as well as some important and usefull commands using one of the scripts written for the project.

Below is an example of a typical Lammps script, one of the scripts used in my project:

# --------------------- Initialization --------------------------------
units metal
atom_style atomic

boundary p p s
newton on

processors * * *

# --------------------- Create Atoms ----------------------------------
lattice diamond 3.57
region diamondBox block 0 10 0 10 0 10 units lattice
create_box 1 diamondBox
create_atoms 1 region diamondBox
mass * 12.0107
velocity all create 300.0 4928459 dist gaussian

# --------------------- Regions Defs -------------------
region heatedRegion1 sphere 24.99 24.99 24.99 8.925 units box
region heatedRegion2 sphere 24.99 24.99 24.99 12.495 units box
region heatedRegion3 sphere 24.99 24.99 24.99 16.065 units box
region heatedRegion4 sphere 24.99 24.99 24.99 17.85 units box
region heatedRegion5 sphere 24.99 24.99 24.99 19.635 units box
region heatedRegion6 sphere 24.99 24.99 24.99 21.42 units box
region heatedRegion7 sphere 24.99 24.99 24.99 23.205 units box

# --------------------- Potential Defs --------------------------------
pair_style tersoff
pair_coeff * * SiC.tersoff C

# --------------------- Simulation Settings ---------------------------
neighbor 2.0 bin
neigh_modify delay 3

timestep 0.0001
thermo_style custom step pe etotal temp
thermo 10000

dump diamond all xyz 10000 out.diamond.*.xyz

# --------------------- Relaxation ------------------------------------
min_style cg
minimize 1e-6 1e-6 5000 10000

# --------------------- Dynamics --------------------------------------
fix dynamics all nve

fix reservoir all temp/berendsen 300.0 300.0 0.0001

fix 7 all temp/berendsen 400.0 400.0 0.0001
compute heatedTemp7 all temp/region heatedRegion7
fix_modify 7 temp heatedTemp7

fix 6 all temp/berendsen 500.0 500.0 0.0001
compute heatedTemp6 all temp/region heatedRegion6
fix_modify 6 temp heatedTemp6

fix 5 all temp/berendsen 1000.0 1000.0 0.0001
compute heatedTemp5 all temp/region heatedRegion5
fix_modify 5 temp heatedTemp5

fix 4 all temp/berendsen 3000.0 3000.0 0.0001
compute heatedTemp4 all temp/region heatedRegion4
fix_modify 4 temp heatedTemp4

fix 3 all temp/berendsen 5000.0 5000.0 0.0001
compute heatedTemp3 all temp/region heatedRegion3
fix_modify 3 temp heatedTemp3

fix 2 all temp/berendsen 6000.0 6000.0 0.0001
compute heatedTemp2 all temp/region heatedRegion2
fix_modify 2 temp heatedTemp2

fix 1 all temp/berendsen 7000.0 7000.0 0.0001
compute heatedTemp1 all temp/region heatedRegion1
fix_modify 1 temp heatedTemp1

run 10000000

unfix 7
unfix 6
unfix 5
unfix 4
unfix 3
unfix 2
unfix 1

run 10000000

unfix reservoir

fix freeze all temp/berendsen 0.1 0.1 0.001
run 10000000

minimize 1e-6 1e-6 5000 10000

# --------------------- Simulation End --------------------------------
unfix dynamics
undump diamond

As can be deduced from the script, lines starting with # denote a comment ignored by the interpreter. Commenting out headlines is a good way of organizing the script and improving readability. It is also a comfortable way of excluding parts of the simulation from execution, for purposes like debugging.

Running a script in lammps is done with the following line:

mpirun -np [Number of Cores] [Lammps Installation Name] < [Script Path]

For example:

mpirun -np 8 lammps < lattice.in

An example for a .pbs file, used to run a simulation on lammps using Tamnun's queueing system, can be found here. Running this job can be done using the command:

qsub lammps_queue

Monitoring progression can be done using the command:

qstat | grep "[UserName]"

In the next few pages I will review the different sections of the script above, as well as give a few tips and alternatives to some of the commands.

To continue in the LAMMPS guide, press here.
To return to the results, press here.