LAMMPS Quick Start
The instructions on this page show how to run a simple LAMMPS molecular dynamics example using an E4S base container from DockerHub.
Step 1: Docker Image
Download E4S base image ecpe4s/e4s-spack-cpu.
Flip for details
This image includes Spack and MPI, making it a strong starting point for installing LAMMPS.
Step 2: Run Container
Start an interactive container session.
Flip for details
Mount your working directory so your input script and outputs persist on your host machine.
Step 3: Install and Load LAMMPS
Use Spack to install and load LAMMPS.
Flip for details
Spack resolves dependencies and prepares your environment for running the executable.
Step 4: Create Input File
Create a simple LAMMPS input script.
Flip for details
Use cat > in.lj to create the script, then run it in the next step.
Step 5: Run Example
Execute the LAMMPS simulation with mpirun.
Flip for details
The sample runs a short Lennard-Jones simulation and prints thermodynamic output.
What You Learn
Understand the end-to-end workflow.
Flip for details
Container setup, Spack install/load, script creation, and simulation execution.
Getting Started with LAMMPS Using the E4S Base Container
(Docker Desktop on macOS or Linux)
This short guide walks you through a complete LAMMPS beginner workflow.
1. Download the E4S Base Image
Pull the E4S base container:
docker pull ecpe4s/e4s-spack-cpu:latest
Optional check:
docker images ecpe4s/e4s-spack-cpu
2. Run the Container in Interactive Mode
Create a working directory:
mkdir -p ~/lammps-quickstart
cd ~/lammps-quickstart
Start an interactive shell inside the container:
docker run -it --rm \
--entrypoint bash \
-v "$PWD:/work" \
-w /work \
ecpe4s/e4s-spack-cpu:latest
You are now inside the container.
3. Install and Load LAMMPS with Spack
Inside the container, load MPI:
spack load mpich
Install LAMMPS (this can take several minutes):
spack install lammps +mpi ^mpich
Load LAMMPS:
spack load lammps +mpi ^mpich
Confirm loaded packages:
spack find --loaded
Locate the LAMMPS executable:
LAMMPS_EXE=$(command -v lmp || command -v lmp_mpi)
echo "$LAMMPS_EXE"
4. Create a Simple LAMMPS Input File
Create a file named in.lj.
You can do this with an editor, or directly in the terminal using:
cat > in.lj
Then paste the following input and press Ctrl-D to save:
units lj
atom_style atomic
boundary p p p
lattice fcc 0.8442
region box block 0 4 0 4 0 4
create_box 1 box
create_atoms 1 box
mass 1 1.0
pair_style lj/cut 2.5
pair_coeff 1 1 1.0 1.0 2.5
neighbor 0.3 bin
neigh_modify every 1 delay 0 check yes
velocity all create 1.0 87287
fix 1 all nve
timestep 0.005
thermo 10
run 100
5. Run the Example
Run the simulation on one MPI rank:
mpirun -n 1 "$LAMMPS_EXE" -in in.lj
Expected output includes thermodynamic columns such as Step, Temp, TotEng, and Press.
What You Learned
- How to use an E4S base container for a reproducible LAMMPS environment
- How to install and load LAMMPS with Spack
- How to run a simple molecular dynamics input script
Next, you can try larger systems, more timesteps, and multiple MPI ranks.