Tutorial 9: Running LAMMPS on Anvil Cluster
Objective: Learn to submit LAMMPS jobs to the Anvil supercomputer using SLURM batch scripts.
1. The Problem: Why Can’t I Just Run LAMMPS?¶
You might think: “I have argon.in, I loaded LAMMPS, why can’t I just type lmp -in argon.in and walk away?”
Answer: The login node is shared by everyone. If you run heavy calculations there:
❌ You’ll slow down everyone else
❌ Your job will get killed automatically
❌ Your account might get suspended
Solution: Use the job scheduler (SLURM) to run on dedicated compute nodes.
2. How the Cluster Works¶
┌─────────────────┐
│ Your Laptop │
└────────┬────────┘
│ SSH
↓
┌─────────────────┐
│ Login Node │ ← You are here (writing files)
│ (Shared) │ ← DON'T run simulations here!
└────────┬────────┘
│ sbatch script.sh
↓
┌─────────────────┐
│ SLURM Queue │ ← Your job waits its turn
└────────┬────────┘
│ Resources available
↓
┌─────────────────┐
│ Compute Node │ ← Simulation runs here
│ (Your cores) │ ← You have exclusive access
└────────┬────────┘
│ Job completes
↓
┌─────────────────┐
│ Output Files │ ← Results appear in your directory
└─────────────────┘3. Step-by-Step: Submitting Jobs from Your Folder Structure¶
In Tutorial 7, you created organized folders with 5 different simulations. Now we’ll submit them as jobs.
Overview: What We’re Submitting¶
lammps_tutorial/
├── NVT_simulations/
│ ├── T_300K/ → Job 1
│ ├── T_500K/ → Job 2
│ └── T_700K/ → Job 3
└── NPT_simulations/
├── P_1atm/ → Job 4
└── P_10atm/ → Job 5We’ll submit 5 separate jobs (one per folder). Each runs independently on different compute nodes.
4. Creating Submission Scripts¶
Strategy: One Script Per Simulation¶
Each folder needs its own submission script that:
Navigates to the correct folder
Runs the specific input file
Saves output in that folder
Step 1: Submit the First NVT Job (T=300K)¶
cd $SCRATCH/lammps_tutorial/NVT_simulations/T_300K
nano submit.shPaste this script:
#!/bin/bash
#SBATCH --job-name=NVT_300K
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --time=00:30:00
#SBATCH --output=job_%j.out
#SBATCH --error=job_%j.err
echo "========================================="
echo "Job: NVT at 300K"
echo "Started: $(date)"
echo "Directory: $(pwd)"
echo "========================================="
# Load LAMMPS
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
# Run simulation
lmp -in argon_300K.in
echo "========================================="
echo "Completed: $(date)"
echo "========================================="Save: Ctrl+O, Enter, Ctrl+X
Submit the job:
sbatch submit.shYou’ll see:
Submitted batch job 123456Check it’s running:
squeue -u $USERStep 2: Submit Remaining NVT Jobs¶
For T=500K:
cd ../T_500K
nano submit.shSame script, but change:
#SBATCH --job-name=NVT_500K
echo "Job: NVT at 500K"
lmp -in argon_500K.inSubmit:
sbatch submit.shFor T=700K:
cd ../T_700K
nano submit.shChange:
#SBATCH --job-name=NVT_700K
echo "Job: NVT at 700K"
lmp -in argon_700K.inSubmit:
sbatch submit.shStep 3: Submit NPT Jobs¶
For P=1atm:
cd ../../NPT_simulations/P_1atm
nano submit.sh#!/bin/bash
#SBATCH --job-name=NPT_1atm
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --time=01:00:00
#SBATCH --output=job_%j.out
#SBATCH --error=job_%j.err
echo "========================================="
echo "Job: NPT at 1 atm"
echo "Started: $(date)"
echo "========================================="
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
lmp -in argon_npt_1atm.in
echo "========================================="
echo "Completed: $(date)"
echo "========================================="Submit:
sbatch submit.shFor P=10atm:
cd ../P_10atm
nano submit.shChange:
#SBATCH --job-name=NPT_10atm
echo "Job: NPT at 10 atm"
lmp -in argon_npt_10atm.inSubmit:
sbatch submit.sh5. Monitoring All Your Jobs¶
Check all 5 jobs:
squeue -u $USERYou should see:
JOBID PARTITION NAME USER ST TIME NODES
123456 shared NVT_300K username R 0:02 1
123457 shared NVT_500K username R 0:01 1
123458 shared NVT_700K username PD 0:00 1
123459 shared NPT_1atm username R 0:01 1
123460 shared NPT_10atm username PD 0:00 1Status meanings:
R= RunningPD= Pending (waiting for resources)
Watch live updates:
watch -n 5 squeue -u $USERPress Ctrl+C to stop.
6. Collecting Results¶
After all jobs complete (5-15 minutes), check each folder for output.
Step 1: Quick Check All Folders¶
cd $SCRATCH/lammps_tutorial
# Check NVT results
ls NVT_simulations/T_300K/
ls NVT_simulations/T_500K/
ls NVT_simulations/T_700K/
# Check NPT results
ls NPT_simulations/P_1atm/
ls NPT_simulations/P_10atm/Each folder should now contain:
submit.sh
argon_*.in
job_*.out
job_*.err
thermo_*.out ← Temperature/energy data
argon_*.lammpstrj ← Trajectory
final_*.data ← Final state
log.lammpsStep 2: Verify Successful Completion¶
Check job outputs:
cd NVT_simulations/T_300K
tail -5 job_*.outLook for:
=========================================
Completed: [timestamp]
=========================================Check for errors:
cat job_*.errShould be empty. If not, read the error message!
Step 3: Quick Look at Results¶
Temperature data for 300K:
head -20 thermo_300K.outYou should see temperatures fluctuating around 2.50 (target).
Compare all three NVT temperatures:
cd $SCRATCH/lammps_tutorial/NVT_simulations
# Extract average temperatures (after equilibration)
tail -100 T_300K/thermo_300K.out | awk '{sum+=$2; count++} END {print "T_300K avg:", sum/count}'
tail -100 T_500K/thermo_500K.out | awk '{sum+=$2; count++} END {print "T_500K avg:", sum/count}'
tail -100 T_700K/thermo_700K.out | awk '{sum+=$2; count++} END {print "T_700K avg:", sum/count}'7. Advanced: Using a Loop to Submit Multiple Jobs¶
Pro tip: Instead of submitting each job manually, use a bash loop.
Create All NVT Submission Scripts at Once¶
cd $SCRATCH/lammps_tutorial/NVT_simulations
# Loop through temperature folders
for temp_dir in T_300K T_500K T_700K; do
cd $temp_dir
# Extract temperature from folder name (e.g., T_300K → 300K)
temp_label=${temp_dir#T_}
# Create submission script
cat > submit.sh << EOF
#!/bin/bash
#SBATCH --job-name=NVT_${temp_label}
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --time=00:30:00
#SBATCH --output=job_%j.out
#SBATCH --error=job_%j.err
echo "Job: NVT at ${temp_label}"
echo "Started: \$(date)"
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
lmp -in argon_${temp_label}.in
echo "Completed: \$(date)"
EOF
# Submit the job
sbatch submit.sh
# Go back to parent directory
cd ..
doneThis creates and submits all 3 NVT jobs with one command!
8. What If a Job Failed?¶
Diagnosing Failures¶
Symptom 1: Job completes in < 5 seconds
Check error file:
cat job_*.errCommon error: “Cannot open input script”
Fix: Check filename matches exactly
ls -lh argon_*.in
Make sure the filename in submit.sh matchesCommon error: “lmp: command not found”
Fix: Module loading failed
Add these lines to your submit.sh:
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310Symptom 2: Job runs but no thermo output
Check LAMMPS log:
tail -50 log.lammpsLook for ERROR messages.
Symptom 3: Job killed before completion
tail job_*.outLook for:
slurmstepd: error: *** JOB CANCELLED AT [time] DUE TO TIME LIMIT ***Fix: Increase time in #SBATCH --time=01:00:00
Resubmitting Failed Jobs¶
# Fix the problem (edit submit.sh or input file)
nano submit.sh
# Resubmit
sbatch submit.shOld job output files won’t be overwritten (they have unique job IDs).
9. Useful SLURM Commands¶
| Command | Purpose |
|---|---|
squeue -u $USER | Check your jobs |
squeue -u $USER --start | Estimated start times |
scancel 123456 | Cancel specific job |
scancel -u $USER | Cancel ALL your jobs |
scontrol show job 123456 | Detailed job info |
sacct -j 123456 | Job history (after completion) |
10. Summary Checklist¶
After this tutorial, you should have:
5 folders each with a
submit.shscriptSuccessfully submitted 5 jobs (3 NVT + 2 NPT)
All jobs completed without errors
thermo_*.outfiles in each folderUnderstand how to check job status with
squeueKnow how to diagnose job failures
File structure check:
cd $SCRATCH/lammps_tutorial
find . -name "thermo_*.out" | wc -lShould output: 5 (one per simulation)
Next Tutorial: Analyzing these results with Python (Tutorial 9)
11. Quick Reference¶
Submit job from any folder:
sbatch submit.shCheck all your running jobs:
squeue -u $USERCancel a stuck job:
scancel JOB_IDCheck if job finished successfully:
tail -5 job_*.out
# Should see "Completed: [timestamp]"View real-time progress:
tail -f thermo_*.out
# Press Ctrl+C to stop12. Class Examples¶
Complete working examples available:
ls /anvil/projects/x-chm250117/class_examples/If you need to start fresh:
cd $SCRATCH
rm -rf lammps_tutorial
cp -r /anvil/projects/x-chm250117/class_examples/lammps_tutorial ./13. Further Reading¶
Anvil User Guide — Complete SLURM documentation
Anvil LAMMPS — LAMMPS on Anvil
SLURM Commands — Quick reference PDF
Let’s submit the Argon simulation from Tutorial 7.
Step 1: Make Sure You Have Your Input File¶
cd $SCRATCH/lammps_tutorial
ls -lh argon.inYou should see your argon.in file. If not, go back to Tutorial 7!
Step 2: Create a Submission Script¶
A submission script is a text file that tells SLURM:
What resources you need (cores, time, memory)
What commands to run
Create the script:
nano submit_argon.shStep 3: Copy This Script¶
Paste the following into nano (carefully!):
#!/bin/bash
#SBATCH --job-name=my_first_job
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --time=00:30:00
#SBATCH --output=job_%j.out
#SBATCH --error=job_%j.err
# Print job info
echo "========================================="
echo "Job started: $(date)"
echo "Running on node: $(hostname)"
echo "Job ID: $SLURM_JOB_ID"
echo "========================================="
# Load LAMMPS
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
# Run the simulation
lmp -in argon.in
echo "========================================="
echo "Job finished: $(date)"
echo "========================================="Save and exit: Ctrl+O, Enter, Ctrl+X
Step 4: Understand What You Just Wrote¶
The lines starting with #SBATCH are directives (instructions to SLURM):
| Line | Meaning |
|---|---|
--job-name=my_first_job | Name shown in queue |
--account=chm250117 | Class allocation ID |
--partition=shared | Which queue (shared = small jobs) |
--nodes=1 | Use 1 compute node |
--ntasks-per-node=4 | Use 4 CPU cores |
--time=00:30:00 | Max 30 minutes (HH:MM:SS) |
--output=job_%j.out | Save output ( |
| --error=job_%j.err | Save errors separately |
Step 5: Submit Your Job¶
sbatch submit_argon.shYou’ll see:
Submitted batch job 123456That number is your Job ID! Write it down.
Step 6: Check If It’s Running¶
squeue -u $USEROutput:
JOBID PARTITION NAME USER ST TIME NODES
123456 shared my_first_job username R 0:02 1Status codes:
PD= Pending (waiting in queue)R= Running ← Your job is active!CG= Completing(No output) = Job finished
Refresh every few seconds:
watch -n 5 squeue -u $USERPress Ctrl+C to stop watching.
Step 7: Wait for Completion¶
Your job will take ~5-10 minutes. When squeue shows nothing, it’s done!
Step 8: Check the Results¶
ls -lhYou should see:
argon.in
submit_argon.sh
job_123456.out ← Job log
job_123456.err ← Errors (should be empty)
thermo.out ← Temperature/energy data
argon.lammpstrj ← Trajectory
final_state.data ← Final configurationLook at the job output:
cat job_123456.outYou should see your echo messages plus LAMMPS output.
Check for errors:
cat job_123456.errIf this file is empty, everything worked!
4. What If It Didn’t Work?¶
Problem 1: “Submitted batch job” but nothing happens¶
Check: Is your job stuck in the queue?
squeue -u $USERIf status is PD (pending) for >5 minutes, the cluster might be busy. Be patient.
Problem 2: Job finishes immediately (< 1 second)¶
Check the error file:
cat job_*.errCommon errors:
“lmp: command not found”
FIX: Check your module load commands. Make sure you have:
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310“Cannot open input script argon.in”
FIX: LAMMPS can't find your input file.
Check: ls -lh argon.in
Make sure argon.in is in the same directory as submit_argon.sh“Invalid command” or “Unknown command”
FIX: Typo in your LAMMPS input file.
Open argon.in and check for spelling mistakes.Problem 3: Job runs but no output files¶
Check: Did the job actually finish?
tail -20 job_*.outLook for “Job completed” at the end. If you don’t see it, the job was killed (probably hit time limit).
5. Useful SLURM Commands¶
| Command | What It Does | Example |
|---|---|---|
sbatch script.sh | Submit a job | sbatch submit_argon.sh |
squeue -u $USER | Check your jobs | See what’s running |
scancel 123456 | Cancel job 123456 | scancel 123456 |
scancel -u $USER | Cancel ALL your jobs | Use with caution! |
scontrol show job 123456 | Detailed job info | Why is it pending? |
6. Running Longer Jobs¶
For production runs (hours to days), modify the script:
nano submit_production.sh#!/bin/bash
#SBATCH --job-name=argon_production
#SBATCH --account=chm250117
#SBATCH --partition=standard ← Use 'standard' for longer jobs
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=8 ← More cores for speed
#SBATCH --time=24:00:00 ← 24 hours
#SBATCH --output=prod_%j.out
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
# Run from SCRATCH for fast I/O
cd $SCRATCH/lammps_tutorial
# Run with MPI for parallel execution
mpirun -np $SLURM_NTASKS lmp -in argon.in
echo "Production run complete"7. Exercise: Run at Different Temperature¶
Challenge: Submit TWO jobs running Argon at 300 K and 700 K simultaneously.
Hint
You need:
Two input files:
argon_300K.inandargon_700K.inTwo submission scripts:
submit_300K.shandsubmit_700K.sh
Make sure the output filenames are different in each!
Solution
# Create 300K version
cp argon.in argon_300K.in
nano argon_300K.in
# Change: velocity all create 2.50 ... and fix nvt temp 2.50 2.50 ...
# Change: log thermo_300K.out
# Create 700K version
cp argon.in argon_700K.in
nano argon_700K.in
# Change: velocity all create 5.84 ... and fix nvt temp 5.84 5.84 ...
# Change: log thermo_700K.out
# Create submission scripts
cp submit_argon.sh submit_300K.sh
nano submit_300K.sh
# Change: lmp -in argon_300K.in
cp submit_argon.sh submit_700K.sh
nano submit_700K.sh
# Change: lmp -in argon_700K.in
# Submit both!
sbatch submit_300K.sh
sbatch submit_700K.sh
# Check both are running
squeue -u $USER8. Class Examples¶
Pre-made scripts are available:
ls /anvil/projects/x-chm250117/class_examples/Copy a complete example:
cp /anvil/projects/x-chm250117/class_examples/submit_argon.sh ./
cp /anvil/projects/x-chm250117/class_examples/argon_nvt.in ./9. Summary Checklist¶
After this lab, you should have:
Created a SLURM submission script
Successfully submitted a job with
sbatchMonitored job status with
squeueRetrieved output files (
thermo.out, etc.)Understand what each
#SBATCHdirective does
Next Tutorial: Analyzing LAMMPS output with Python (Tutorial 9)
10. Quick Reference Card¶
Essential commands:
# Submit job
sbatch script.sh
# Check status
squeue -u $USER
# Cancel job
scancel JOB_ID
# View output (while running)
tail -f job_*.out
# Check errors
cat job_*.errJob script template:
#!/bin/bash
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --time=00:30:00
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
lmp -in input.in11. Further Reading¶
Anvil User Guide — Running jobs
Anvil LAMMPS Documentation — LAMMPS on Anvil
SLURM Quick Start — Official SLURM guide
Submitted batch job 123456The number 123456 is your Job ID — you’ll use this to check status.
5.4 Monitor the Job¶
Check queue status:
squeue -u $USEROutput:
JOBID PARTITION NAME USER ST TIME NODES NODELIST
123456 shared argon_tut alele R 0:05 1 a001Status codes:
PD= Pending (waiting in queue)R= RunningCG= Completing (cleaning up)No output = Job finished
Cancel a job:
scancel 1234565.5 Check the Results¶
Once the job completes (disappears from squeue), check for output files:
ls -lhYou should see:
argon.in
submit_argon.sh
argon_123456.out # Standard output
argon_123456.err # Error messages
thermo.out # LAMMPS thermodynamic data
argon.lammpstrj # Trajectory file
final_state.data # Final configurationView the job log:
less argon_123456.outCheck for errors:
cat argon_123456.err6. Parallel Execution with MPI¶
LAMMPS can use multiple CPU cores via MPI (Message Passing Interface) to run faster.
6.1 How Many Cores to Use?¶
Rule of thumb: Use 1 core per ~1000-2000 atoms for optimal performance.
For our 2000-atom system:
Good: 1-4 cores
Acceptable: 8 cores
Wasteful: 32+ cores (communication overhead dominates)
6.2 Modified Submission Script for MPI¶
#!/bin/bash
#SBATCH --job-name=argon_parallel
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=16 # Request 16 cores
#SBATCH --time=00:30:00
#SBATCH --output=argon_mpi_%j.out
#SBATCH --error=argon_mpi_%j.err
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
echo "Using $SLURM_NTASKS MPI tasks"
# Run LAMMPS with MPI
mpirun -np $SLURM_NTASKS lmp -in argon.in
echo "Simulation completed"Key change: mpirun -np $SLURM_NTASKS lmp -in argon.in
This launches LAMMPS across multiple cores. LAMMPS automatically divides the simulation box spatially (domain decomposition).
7. Example Submission Scripts¶
7.1 Production Run (Long Simulation)¶
#!/bin/bash
#SBATCH --job-name=argon_production
#SBATCH --account=chm250117
#SBATCH --partition=standard
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=8
#SBATCH --time=24:00:00 # 24 hours
#SBATCH --output=prod_%j.out
#SBATCH --error=prod_%j.err
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
# Important: Run from SCRATCH (fast I/O)
cd $SCRATCH/lammps_production
cp $SLURM_SUBMIT_DIR/argon.in .
# Run simulation
mpirun -np $SLURM_NTASKS lmp -in argon.in
# Copy results back to submission directory
cp thermo.out final_state.data $SLURM_SUBMIT_DIR/
echo "Production run completed at $(date)"7.2 Test Run (Quick Debugging)¶
#!/bin/bash
#SBATCH --job-name=quick_test
#SBATCH --account=chm250117
#SBATCH --partition=debug # High priority, short time
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --time=00:10:00 # 10 minutes max
#SBATCH --output=test_%j.out
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
# Modify input to run only 1000 steps
sed 's/run.*/run 1000/' argon.in > test.in
lmp -in test.in
echo "Test completed"8. Checking Allocation Usage¶
To see how many core-hours you’ve used:
mybalanceOutput:
Account: YOUR_ALLOCATION
Service Units Used: 1234
Service Units Available: 100000Service Units (SUs) = core-hours. Running on 8 cores for 2 hours = 16 SUs.
9. Common SLURM Commands¶
| Command | Purpose | Example |
|---|---|---|
sbatch script.sh | Submit a job | sbatch run.sh |
squeue -u $USER | Check your jobs | squeue -u alele |
scancel JOB_ID | Cancel a job | scancel 123456 |
scancel -u $USER | Cancel all your jobs | scancel -u alele |
sinfo | Check cluster status | sinfo -p shared |
scontrol show job JOB_ID | Detailed job info | scontrol show job 123456 |
sacct -j JOB_ID | Job accounting info | sacct -j 123456 |
mybalance | Check allocation usage | mybalance |
10. Troubleshooting Common Errors¶
10.1 “Job Failed to Start”¶
Error in .err file:
slurmstepd: error: execve(): lmp: No such file or directoryFix: LAMMPS module not loaded. Add module load lammps to script.
10.2 “Permission Denied”¶
Error:
sbatch: error: Batch script contains DOS line breaksFix: File was edited on Windows. Convert to Unix format:
dos2unix submit_argon.sh10.3 “Exceeded Time Limit”¶
Error in .out file:
slurmstepd: error: *** JOB 123456 ON a001 CANCELLED AT 2026-02-26T10:00:00 DUE TO TIME LIMIT ***Fix: Increase --time in submission script or reduce simulation steps.
10.4 “Out of Memory”¶
Error:
slurmstepd: error: Detected 1 oom-kill event(s)Fix:
Request more memory: add
#SBATCH --mem=16GReduce system size or trajectory dump frequency
11. Appendix: Installing Custom LAMMPS Packages¶
LAMMPS is modular — many features are optional “packages” that must be compiled in. The default Anvil LAMMPS module (version 20210310) includes most common packages, but you may need to install a custom build.
11.1 Check Installed Packages¶
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
lmp -help | grep -A 50 "Installed packages"This lists all compiled packages (e.g., MOLECULE, KSPACE, RIGID, etc.).
11.2 Class Examples Directory¶
Sample LAMMPS input files and job scripts are available in the shared class directory:
# List available examples
ls /anvil/projects/x-chm250117/class_examples/
# Copy an example to your workspace
cp /anvil/projects/x-chm250117/class_examples/argon_nvt.in $SCRATCH/
cp /anvil/projects/x-chm250117/class_examples/submit_argon.sh $SCRATCH/These examples are tested and ready to use. You can modify them for your specific needs.
11.3 When You Need a Custom Build¶
You’ll need to compile LAMMPS yourself if:
You need a package not in the default build (e.g.,
COLVARS,PLUMED)You want GPU acceleration (CUDA/Kokkos)
You need a development feature from LAMMPS GitHub
11.4 Basic Compilation Workflow¶
Step 1: Load Build Tools
module load gcc/11.2.0 openmpi/4.0.6
module load cmakeStep 2: Download LAMMPS Source
cd $SCRATCH
git clone -b stable https://github.com/lammps/lammps.git
cd lammpsStep 3: Create Build Directory
mkdir build
cd buildStep 4: Configure with CMake
cmake ../cmake \
-DCMAKE_INSTALL_PREFIX=$HOME/software/lammps \
-DPKG_MOLECULE=ON \
-DPKG_KSPACE=ON \
-DPKG_RIGID=ON \
-DPKG_COLVARS=ON \
-DBUILD_MPI=ONStep 5: Compile
make -j 8 # Use 8 cores
make install # Install to $HOME/software/lammpsStep 6: Add to PATH
Add to your ~/.bashrc:
export PATH=$HOME/software/lammps/bin:$PATHReload:
source ~/.bashrcStep 7: Test
lmp -help11.5 Common Package Options¶
| Package | Purpose | CMake Flag |
|---|---|---|
MOLECULE | Bonds, angles, molecules | -DPKG_MOLECULE=ON |
KSPACE | Long-range electrostatics (PME) | -DPKG_KSPACE=ON |
RIGID | Rigid body dynamics | -DPKG_RIGID=ON |
COLVARS | Collective variables | -DPKG_COLVARS=ON |
KOKKOS | GPU acceleration | -DPKG_KOKKOS=ON |
USER-REAXFF | Reactive force fields | -DPKG_REAXFF=ON |
11.6 Using Your Custom LAMMPS in Jobs¶
In your submission script, replace:
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310With:
module load gcc/11.2.0 openmpi/4.0.6
export PATH=$HOME/software/lammps/bin:$PATH12. Exercise: Submit a Parameter Sweep¶
Task: Run the same Argon simulation at three different temperatures (300K, 500K, 700K) in parallel.
Approach: Use a job array to submit 3 jobs at once.
Script:
#!/bin/bash
#SBATCH --job-name=argon_sweep
#SBATCH --account=chm250117
#SBATCH --partition=shared
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=4
#SBATCH --time=00:30:00
#SBATCH --output=sweep_%A_%a.out # %A = array job ID, %a = task ID
#SBATCH --array=0-2 # Run tasks 0, 1, 2
module purge
module load gcc/11.2.0 openmpi/4.0.6
module load lammps/20210310
# Define temperatures for each array index
TEMPS=(2.50 4.17 5.84) # T* values for 300K, 500K, 700K
T=${TEMPS[$SLURM_ARRAY_TASK_ID]}
echo "Running temperature $T (Task ID: $SLURM_ARRAY_TASK_ID)"
# Create custom input file for this temperature
sed "s/TEMP_PLACEHOLDER/$T/g" template.in > argon_$T.in
# Run simulation
lmp -in argon_$T.in
echo "Completed T=$T"Prepare template:
Create template.in where temperature lines use TEMP_PLACEHOLDER:
velocity all create TEMP_PLACEHOLDER 87287 dist gaussian
fix 1 all nvt temp TEMP_PLACEHOLDER TEMP_PLACEHOLDER 0.5Submit:
sbatch sweep.shThis launches 3 jobs simultaneously, each with a different temperature.
13. Summary Checklist¶
Before submitting a job, verify:
Input file is correct and tested
Working in
$SCRATCH(not$HOME)--accountmatches your allocation--timehas 20% bufferEmail address is correct
Output filenames use
%jto avoid overwritingLAMMPS module is loaded in script
Requested cores match system size (~1 core per 1000-2000 atoms)
14. Further Reading¶
Anvil User Guide: Running Jobs — Official documentation
Anvil LAMMPS Documentation — LAMMPS-specific guide for Anvil
SLURM Quick Start — Official SLURM tutorial
Job Arrays Tutorial — Advanced parallel job submission