LAMMPS
In this section:
Description
According to the LAMMPS page, LAMMPS (Large-scale Atomic/Molecular Massively Parallel Simulator) is a classical molecular dynamics code focused on materials modeling. It has potentials for solid-state materials (metals, semiconductors), soft matter (biomolecules, polymers), and coarse-grained or mesoscopic systems.
Available Versions
lammps/20170331
lammps/20180316
lammps/20200303 (default)
lammps/20230802
lammps/20250722/gpu
Serial Job Submission
submit_lammps_serial.sh
#!/bin/bash
#SBATCH -J lammps_serial
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -t 05:00:00
#SBATCH --mem=4G
export INPUT="in.lj"
export OUTPUT="*.log *.dump"
module load lammps
job-nanny lmp -in in.lj
MPI Job Submission
submit_lammps_mpi.sh
#!/bin/bash
#SBATCH -J lammps_mpi
#SBATCH -N 2
#SBATCH --ntasks-per-node=28
#SBATCH -t 48:00:00
#SBATCH --mem-per-cpu=2G
export INPUT="in.reax.rdx"
export OUTPUT="*.log *.dump *.out"
module load lammps
job-nanny srun -n $SLURM_NTASKS lmp -in in.reax.rdx -log lammps.log
GPU Job Submission
submit_lammps_gpu.sh
#!/bin/bash
#SBATCH -J lammps_gpu
#SBATCH -p gpu
#SBATCH --gres=gpu:1
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -c 8
#SBATCH -t 48:00:00
#SBATCH --mem=32G
export INPUT="in.gpu"
export OUTPUT="*.log *.dump"
module load lammps
module load cuda/12.9
job-nanny lmp -in in.gpu -sf gpu -pk gpu 1
Example Input File
in.lj
# Lennard-Jones 3D simulation
units lj
atom_style atomic
# Box creation
lattice fcc 0.8442
region box block 0 10 0 10 0 10
create_box 1 box
create_atoms 1 box
# Masses
mass 1 1.0
# Potential
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
# Initial configuration
neighbor 0.3 bin
neigh_modify delay 10
# Minimization
fix 1 all nve
run 1000
# Production
reset_timestep 0
thermo 100
thermo_style custom step temp pe etotal press
dump 1 all atom 1000 dump.lammpstrj
run 10000
Example Input for ReaxFF
in.reax.rdx
# ReaxFF simulation of RDX
units real
atom_style charge
# Read data
read_data data.rdx
# ReaxFF potential
pair_style reaxff NULL
pair_coeff * * ffield.reax.rdx RDX
# Settings
neighbor 2.0 bin
neigh_modify every 10 delay 0 check no
# Fixes
fix 1 all nve
fix 2 all qeq/reaxff 1 0.0 10.0 1e-6 param.qeq
# Thermalization
velocity all create 300.0 4928459
fix 3 all temp/berendsen 300.0 300.0 100.0
thermo 100
thermo_style custom step temp pe etotal press vol
run 5000
unfix 3
# NVT production
fix 3 all nvt temp 300.0 300.0 100.0
dump 1 all custom 1000 dump.reax id type x y z vx vy vz
run 50000
Job Array for Temperature Scan
submit_lammps_array.sh
#!/bin/bash
#SBATCH -J lammps_array
#SBATCH --array=1-5
#SBATCH -N 1
#SBATCH -n 1
#SBATCH -t 24:00:00
#SBATCH --mem=8G
TEMPS=(300 400 500 600 700)
TEMP=${TEMPS[$SLURM_ARRAY_TASK_ID-1]}
export INPUT="template.in"
export OUTPUT="T${TEMP}/"
module load lammps
mkdir -p T${TEMP}
cd T${TEMP}
# Modify temperature in input file
sed "s/TEMPERATURE/$TEMP/g" ../template.in > in.${TEMP}
job-nanny lmp -in in.${TEMP} -log log.${TEMP}
Property Calculation
submit_lammps_props.sh
#!/bin/bash
#SBATCH -J lammps_props
#SBATCH -N 2
#SBATCH --ntasks-per-node=28
#SBATCH -t 24:00:00
#SBATCH --mem-per-cpu=2G
export INPUT="in.production"
export OUTPUT="properties/"
module load lammps
mkdir -p properties
job-nanny srun -n $SLURM_NTASKS lmp -in in.production
# Post-processing analysis
cat > post_process.py << 'EOF'
import numpy as np
import matplotlib.pyplot as plt
# Read log data
data = np.loadtxt('log.lammps', skiprows=1)
step = data[:,0]
temp = data[:,1]
pe = data[:,2]
etotal = data[:,3]
press = data[:,4]
# Plot
plt.figure()
plt.plot(step, temp)
plt.xlabel('Step')
plt.ylabel('Temperature (K)')
plt.savefig('properties/temperature.png')
plt.figure()
plt.plot(step, pe, label='Potential Energy')
plt.plot(step, etotal, label='Total Energy')
plt.xlabel('Step')
plt.ylabel('Energy')
plt.legend()
plt.savefig('properties/energy.png')
# Statistics
with open('properties/summary.txt', 'w') as f:
f.write(f"Average Temperature: {np.mean(temp):.2f} K\n")
f.write(f"Temperature Std: {np.std(temp):.2f} K\n")
f.write(f"Average Pressure: {np.mean(press):.2f} bar\n")
f.write(f"Average Energy: {np.mean(etotal):.2f}\n")
EOF
python post_process.py
References
Documentation: https://lammps.sandia.gov/doc/Manual.html
Tutorials: https://lammps.sandia.gov/tutorials.html
Mailing list: https://lammps.sandia.gov/mail.html
See also
GROMACS - Molecular dynamics for biomolecules
NAMD - Scalable molecular dynamics
Running Simulations - How to submit jobs