Updated 2023-05-03

LAMMPS

Overview

LAMMPS is a classical molecular dynamics code with a focus on materials modeling. It's an acronym for Large-scale Atomic/Molecular Massively Parallel Simulator. LAMMPS has potentials for solid-state materials (metals, semiconductors) and soft matter (biomolecules, polymers) and coarse-grained or mesoscopic systems.

Running Lammps Interactivley

Allocating Resources

  • In order to run Lammps interactivley we can use the salloc command to specify the account, partitions, time, and queue

  • Here is an example of an salloc command you can use: salloc -A [Account] -N 1 -n 8 -t 15 -q embers

  • This will allocate the proper resources to run Lammps

Using an Interactive File Example

  • The following example will show Lammps running interactively using a example interactive file

  • Here is what the interactive file lammpsexample should look like:

# This LAMMPS input script simulates LJ particles in a 2D box
# Written by Simon Gravelle (https://simongravelle.github.io/)
# Find more scripts here: https://github.com/simongravelle/lammps-input-files
# LAMMPS tutorials for beginners: https://lammpstutorials.github.io/

# main parameters
units lj
dimension 2
atom_style atomic
pair_style lj/cut 2.5
boundary p p p

# create system and insert atoms
region myreg block -30 30 -30 30 -0.5 0.5
create_box 2 myreg
create_atoms 1 random 1500 341341 myreg
create_atoms 2 random 100 127569 myreg

# atom settings
mass 1 1
mass 2 1
pair_coeff 1 1 1.0 1.0
pair_coeff 2 2 0.5 3.0
neigh_modify every 1 delay 5 check yes

# minimisation
minimize 1.0e-4 1.0e-6 1000 10000
reset_timestep 0

# dynamics
fix mynve all nve
fix mylgv all langevin 1.0 1.0 0.1 1530917
fix myefn all enforce2d
timestep 0.005

# outputs
thermo 1000
dump mydmp all atom 1000 dump.lammpstrj

# run
run 10000
  • We can do the following in order to run this file with Lammps:

  • Load module: module load lammps

  • Run the script: srun -n 8 lmp < lammpsexample

  • Your output should look something like this:

LAMMPS (7 Jan 2022)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/src/comm.cpp:98)
  using 1 OpenMP thread(s) per MPI task
Created orthogonal box = (-30 -30 -0.5) to (30 30 0.5)
  4 by 2 by 1 MPI processor grid
Created 1500 atoms
  using lattice units in orthogonal box = (-30 -30 -0.5) to (30 30 0.5)
  create_atoms CPU = 0.002 seconds
Created 100 atoms
  using lattice units in orthogonal box = (-30 -30 -0.5) to (30 30 0.5)
  create_atoms CPU = 0.000 seconds
WARNING: Using 'neigh_modify every 1 delay 0 check yes' setting during minimization (src/src/min.cpp:187)
  generated 1 of 1 mixed pair_coeff terms from geometric mixing rule
Neighbor list info ...
  update every 1 steps, delay 0 steps, check yes
  max neighbors/atom: 2000, page size: 100000
  master list distance cutoff = 2.8
  ghost atom cutoff = 2.8
  binsize = 1.4, bins = 43 43 1
  1 neighbor lists, perpetual/occasional/extra = 1 0 0
  (1) pair lj/cut, perpetual
      attributes: half, newton on
      pair build: half/bin/atomonly/newton
      stencil: half/bin/2d
      bin: standard
Setting up cg style minimization ...
  Unit style    : lj
  Current step  : 0
Per MPI rank memory allocation (min/avg/max) = 4.175 | 4.175 | 4.176 Mbytes
Step Temp E_pair E_mol TotEng Press 
       0            0 5.8997404e+14            0 5.8997404e+14 1.5732641e+15 
      81            0   -1.7518285            0   -1.7518285  -0.15730928 
Loop time of 0.0158433 on 8 procs for 81 steps with 1600 atoms

94.9% CPU use with 8 MPI tasks x 1 OpenMP threads

Minimization stats:
  Stopping criterion = energy tolerance
  Energy initial, next-to-last, final = 
       589974040194331  -1.75166415801295  -1.75182852777845
  Force two-norm initial, final = 2.5817498e+20 60.584174
  Force max component initial, final = 1.5160091e+20 11.519543
  Final line search alpha, max atom move = 6.6931485e-05 0.00077102009
  Iterations, force evaluations = 81 197

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.004087   | 0.005402   | 0.0068199  |   1.1 | 34.10
Neigh   | 0.0010192  | 0.001214   | 0.0014529  |   0.4 |  7.66
Comm    | 0.0031236  | 0.0046552  | 0.0065113  |   1.6 | 29.38
Output  | 0          | 0          | 0          |   0.0 |  0.00
Modify  | 0          | 0          | 0          |   0.0 |  0.00
Other   |            | 0.004572   |            |       | 28.86

...
...
...

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.12831    | 0.16002    | 0.20268    |   5.1 | 26.21
Neigh   | 0.053033   | 0.059641   | 0.067694   |   1.6 |  9.77
Comm    | 0.15617    | 0.21386    | 0.26393    |   6.2 | 35.03
Output  | 0.0034319  | 0.0034802  | 0.0035173  |   0.0 |  0.57
Modify  | 0.11484    | 0.12974    | 0.14675    |   2.6 | 21.25
Other   |            | 0.04378    |            |       |  7.17

Nlocal:            200 ave         224 max         186 min
Histogram: 1 1 1 3 0 1 0 0 0 1
Nghost:        122.375 ave         128 max         113 min
Histogram: 1 0 0 0 0 2 2 0 2 1
Neighs:        1064.38 ave        1292 max         911 min
Histogram: 1 0 2 2 1 1 0 0 0 1

Total # of neighbors = 8515
Ave neighs/atom = 5.321875
Neighbor list builds = 1154
Dangerous builds = 0
Total wall time: 0:00:00

Running Lammps in Batch Mode

  • We can also test this in a normal batch mode. Here is an example batch script:
#!/bin/bash
#SBATCH -J SBATCHlammpsTest
#SBATCH -A phx-pace-staff
#SBATCH -N 2 --ntasks-per-node=4
#SBATCH -t 10
#SBATCH -q inferno
#SBATCH -o Report-%j.out
#SBATCH --mail-type=BEGIN,END,FAIL
#SBATCH --mail-user=gburdell3@gatech.edu

cd $SLURM_SUBMIT_DIR
module load intel/20.0.4 mvapich2/2.3.6 lammps/20220107-mva2
srun -n 8 lmp < lammpsexample
  • Your expected output should look something like this:
---------------------------------------
Begin Slurm Prolog: Apr-28-2023 01:54:28
Job ID:    1774754
User ID:   gburdell3
Account:   [Account]
Job name:  SBATCHlammpsTest
Partition: cpu-small
QOS:       inferno
---------------------------------------

Lmod is automatically replacing "gcc/10.3.0-o57x6h" with "intel/20.0.4".


The following have been reloaded with a version change:
  1) mvapich2/2.3.6-ouywal => mvapich2/2.3.6-z2duuy

LAMMPS (7 Jan 2022)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/src/comm.cpp:98)
  using 1 OpenMP thread(s) per MPI task
Created orthogonal box = (-30 -30 -0.5) to (30 30 0.5)
  4 by 2 by 1 MPI processor grid
Created 1500 atoms
  using lattice units in orthogonal box = (-30 -30 -0.5) to (30 30 0.5)
  create_atoms CPU = 0.000 seconds
Created 100 atoms
  using lattice units in orthogonal box = (-30 -30 -0.5) to (30 30 0.5)
  create_atoms CPU = 0.000 seconds

... 
...
...

Setting up cg style minimization ...
  Unit style    : lj
  Current step  : 0
Per MPI rank memory allocation (min/avg/max) = 4.175 | 4.175 | 4.176 Mbytes
Step Temp E_pair E_mol TotEng Press
       0            0 5.8997404e+14            0 5.8997404e+14 1.5732641e+15
      81            0   -1.7518285            0   -1.7518285  -0.15730928
Loop time of 0.0144717 on 8 procs for 81 steps with 1600 atoms

92.5% CPU use with 8 MPI tasks x 1 OpenMP threads

...
...
...

Performance: 8030648.029 tau/day, 18589.463 timesteps/s
99.6% CPU use with 8 MPI tasks x 1 OpenMP threads

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 0.12372    | 0.14753    | 0.1723     |   3.5 | 27.43
Neigh   | 0.04568    | 0.05132    | 0.057268   |   1.4 |  9.54
Comm    | 0.14215    | 0.16753    | 0.20018    |   3.8 | 31.14
Output  | 0.0030461  | 0.0030819  | 0.0031159  |   0.0 |  0.57
Modify  | 0.12343    | 0.13548    | 0.14865    |   1.8 | 25.18
Other   |            | 0.03299    |            |       |  6.13

Nlocal:            200 ave         223 max         181 min
Histogram: 1 0 0 1 4 1 0 0 0 1
Nghost:        123.875 ave         131 max         113 min
Histogram: 1 0 1 1 0 0 1 1 2 1
Neighs:        1075.12 ave        1286 max         877 min
Histogram: 1 0 0 1 2 3 0 0 0 1

Total # of neighbors = 8601
Ave neighs/atom = 5.375625
Neighbor list builds = 1154
Dangerous builds = 0
Total wall time: 0:00:00
---------------------------------------
Begin Slurm Epilog: Apr-28-2023 01:54:32
Job ID:        1774754
Array Job ID:  _4294967294
User ID:      gburdell3
Account:      [Account]
Job name:      SBATCHlammpsTest
Resources:     cpu=8,mem=8G,node=2
Rsrc Used:     cput=00:01:28,vmem=336K,walltime=00:00:11,mem=0,energy_used=0
Partition:     cpu-small
QOS:           inferno
Nodes:         atl1-1-02-010-22-2,atl1-1-02-010-23-1
---------------------------------------