LAMMPS Tutorials

Getting Started

Tutorials

LAMMPS uses ascii input files for setting up all simulations.

Download PDF file.

Warning

Please be aware that there may be some issues with the - symbols in the pdf. Depending on your operating system, it may be best to type out the commands rather than copying directly from the pdf.

Additional examples can be found in the online documentation.

Installation via CMake

LAMMPS is supported on Linux-based systems. On these supported systems, LAMMPS can typically be installed with just a few commands:

mkdir lammps
cd lammps

git clone -b release https://github.com/lammps/lammps.git mylammps

cd mylammps
mkdir build
cd build
cmake ../cmake -D PKG_GRANULAR=yes -D PKG_BPM=yes -D PKG_VTK=yes -D PKG_MOLECULE=yes

make -j 8

Full installation instructions can be found here. Full build instructions are here.

Note

This assumes that you already have VTK installed on your system.

Tutorial 1 - Pouring Spherical Particles

Simulates pouring two different types of particles on a rigid wall. One material is cohesionless while the other is cohesive.

Code
# pour two types of particles (cohesive and non-cohesive) on flat wall

atom_style      sphere
units           lj
boundary        p p f
comm_modify     vel yes

region          boxreg block 0 20 0 20 0 30
create_box      2 boxreg

pair_style      granular
pair_coeff      1 * jkr 1000.0 50.0 0.3 10 tangential mindlin 800.0 1.0 0.5 rolling sds 500.0 200.0 0.5 twisting marshall
pair_coeff      2 2 hertz 200.0 20.0 tangential linear_history 300.0 1.0 0.1 rolling sds 200.0 100.0 0.1 twisting marshall

region          insreg1 cylinder z 6 10 5 15 30
region          insreg2 cylinder z 14 10 5 15 30

fix             1 all nve/sphere
fix             grav all gravity 10.0 vector 0 0 -1
fix             ins1 all pour 5000 1 3123 region insreg1 diam range 0.5 1 dens 1.0 1.0
fix             ins2 all pour 5000 2 3123 region insreg2 diam range 0.5 1 dens 1.0 1.0

fix             3 all wall/gran granular hertz/material 1e5 1e3 0.3 tangential mindlin NULL 1.0 0.5 zplane 0 NULL

thermo_style    custom step atoms ke
thermo_modify   lost warn
thermo          100

timestep        0.001

dump            1 all custom 100 pour_two_types.dump id type radius mass x y z
dump            2 all vtk 100 pour_two_types*.vtk id type radius mass x y z
dump_modify     2 binary yes

run             10000

Tutorial 2 - Filling a Rotating Drum

Simulates pouring particles into a drum made from multiple rigid walls. A rotational motion is then applied to the drum.

Code
atom_style      sphere
units           lj
boundary        p p f

region          boxreg block 0 30 0 30 0 30
create_box      2 boxreg
comm_modify     vel yes

pair_style      granular
pair_coeff      1 * jkr 1e5 0.1 0.3 50 tangential mindlin NULL 1.0 0.5 rolling sds 1e3 1e3 0.1 twisting marshall 
pair_coeff      2 2 hertz/material 1e5 0.2 0.3 tangential mindlin NULL 1.0 0.5 damping tsuji

variable        theta equal 0

region          curved_wall cylinder z 15 15 15 0 20 side in rotate v_theta 15 15 0 0 0 1 open 2
region          insreg cylinder z 15 15 14 20 30 side in

fix             1 all balance 1000 1.0 shift xyz 5 1.1
fix             2 all nve/sphere
fix             grav all gravity 10 vector 0 0 -1
fix             ins1 all pour 2000 1 1234 region insreg diam range 0.5 1 dens 1 1
fix             ins2 all pour 2000 2 1234 region insreg diam range 0.5 1 dens 1 1
fix             3 all wall/gran/region granular hertz/material 1e5 0.1 0.3 tangential mindlin NULL 1.0 0.5 damping tsuji region curved_wall

thermo_style    custom step atoms ke v_theta
thermo_modify   lost warn
thermo          100

timestep        0.001

dump            1 all custom 100 rotating_drum.dump id type radius mass x y z

run             1000

#Add top lid, turn off pouring, 'turn' drum by switching the direction of gravity
region          top_wall plane 15 15 20 0 0 -1 side in rotate v_theta 15 15 0 0 0 1
fix             5 all wall/gran/region granular hertz/material 1e5 0.1 0.3 tangential mindlin NULL 1.0 0.5 damping tsuji region top_wall

unfix           grav
unfix           ins1
unfix           ins2
fix             grav all gravity 10 vector 0 -1 0

variable        theta equal 2*PI*elapsed/20000.0
run             130000

Tutorial 3 - Pouring Rod-like Particles

Simulates pouring non-spherical particles created using bonded spheres. A “molecule” template is used to define the particle shape.

Code
units           lj
dimension       3
boundary        m m m
atom_style      bpm/sphere
special_bonds   lj 0.0 1.0 1.0 coul 1.0 1.0 1.0
newton          on off
comm_modify     vel yes cutoff 3.3

region          box block -15 15 -15 15 0 60.0
create_box      1 box bond/types 1 extra/bond/per/atom 15 extra/special/per/atom 50

molecule        my_mol "rect.mol"
region          wall_cyl cylinder z 0.0 0.0 10.0 EDGE EDGE side in
region          dropzone cylinder z 0.0 0.0 10.0 40.0 50.0 side in

pair_style      gran/hertz/history 1.0 NULL 0.5 NULL 0.1 1
bond_style      bpm/rotational break no smooth no
pair_coeff      1 1
bond_coeff      1 1.0 0.2 0.01 0.01 0.0 0.0 0.0 0.0 0.2 0.04 0.002 0.002

fix             1 all wall/gran hertz/history 1.0 NULL 0.5 NULL 0.1 1 zplane 0.0 NULL
fix             2 all wall/gran/region hertz/history 1.0 NULL 0.5 NULL 0.1 1 region wall_cyl
fix             3 all gravity 1e-4 vector 0 0 -1
fix             4 all deposit 40 0 1500 712511343 mol my_mol region dropzone near 2.0 vz -0.05 -0.05
fix             5 all nve/bpm/sphere

compute         nbond all nbond/atom
compute         tbond all reduce sum c_nbond
thermo_style    custom step ke pe pxx pyy pzz c_tbond
thermo          100
dump            1 all custom 500 pour_bpm.dump id type radius mass x y z mol

timestep        0.05
run             100000

Tutorial 4 - Plate Impact

Simulates impact between a bonded particle and a bonded surface. Uses spring bond instead of rotational bonds.

Code
units           lj
dimension       3
boundary        s s s
atom_style      bond
special_bonds   lj 0.0 1.0 1.0 coul 0.0 1.0 1.0
newton          on off
comm_modify     vel yes cutoff 2.6

lattice         fcc 1.0
region          box block -25 15 -22 22 -22 22
create_box      1 box bond/types 2 extra/bond/per/atom 20 extra/special/per/atom 50

region          disk cylinder x 0.0 0.0 20.0 -0.5 0.5
create_atoms    1 region disk
group           plate region disk

region          ball sphere 8.0 0.0 0.0 6.0
create_atoms    1 region ball
group           projectile region ball
mass            1 1.0

velocity        projectile set -0.05 0.0 0.0
displace_atoms  all random 0.1 0.1 0.1 134598738

neighbor        1.0 bin
pair_style      bpm/spring
pair_coeff      1 1 1.0 1.0 1.0

fix             1 all nve

create_bonds    many plate plate 1 0.0 1.5
create_bonds    many projectile projectile 2 0.0 1.5

neighbor        0.3 bin
special_bonds   lj 0.0 1.0 1.0 coul 1.0 1.0 1.0

bond_style      bpm/spring store/local brkbond 100 time id1 id2
bond_coeff      1 1.0 0.04 1.0
bond_coeff      2 1.0 0.2 1.0

velocity        projectile set -0.05 0.0 0.0
fix             1 all nve

dump            1 all custom 100 impact_bpm.dump id type x y z
dump            2 all local 100 brokenDump f_brkbond[1] f_brkbond[2] f_brkbond[3]
dump_modify     2 header no

thermo		100
timestep        0.1
run             20000
Back to top