About this page
Tutorial- What this page solves
- You want to use molecular dynamics to compute the stress and strain of a copper crystal under tension, but LAMMPS is not installed yet and you do not know how to write an input file. This page uses a single-crystal copper tensile run to take you through installing LAMMPS, running the simulation once, and plotting a stress-strain curve.
- Who it is for
- Graduate students and researchers who are using LAMMPS for the first time. You can work at a command line and know basic atomic and crystal concepts, but you have not compiled LAMMPS or written an input file before.
- What you will have
- A copper tensile input file that runs, a Python script that plots the stress-strain curve from the output data, the plot itself, and a way to check the modulus against elastic constants.
- Covers
- Compile the CPU version of LAMMPS from source on Linux or WSL2, and confirm that it includes the packages you need
- Write and run a uniaxial tension input file for single-crystal copper along [100], with each block explained
- Plot a stress-strain curve from the output files and read off the initial modulus and the first yield stress
- Side paths such as the Windows installer, GPU and KOKKOS builds, potential selection, and HPC and China-specific setups (see the options sections)
- Does not cover
- Modeling other systems such as polymers or reactive force fields, which use different units and force fields
- Step-by-step fixes for each LAMMPS error, which are in the LAMMPS error guide
- The physical interpretation of tensile results, such as how dislocations and twins form
- The exact module names on each HPC platform, which change with the version
Main steps
Step 1
Why this stepLAMMPS is a molecular dynamics program, and its command is lmp. This step compiles lmp from source and installs it into your home directory, so no administrator rights are needed.
The EAM potential used in the tensile example belongs to the MANYBODY package. The basic.cmake preset turns on four packages, KSPACE, MANYBODY, MOLECULE, and RIGID, and the commands on this page use that preset.
If you are on Windows and only want to learn the in file, you can use the official installer instead. See "Installer or WSL2 for Windows users".
# Dependencies (Ubuntu 22.04/24.04 or Ubuntu on WSL2)
sudo apt update
sudo apt install -y build-essential cmake git libopenmpi-dev openmpi-bin python3-pip
cmake --version # 30Sep2026 needs >= 3.20; if older: python3 -m pip install --user cmake
# Get the source: the stable branch is the latest stable release (30Sep2026 as of 2026-10)
git clone -b stable --depth 1 https://github.com/lammps/lammps.git lammps
# To match 2025.07.22 use: git clone -b stable_22Jul2025_update6 --depth 1 ...
cd lammps && mkdir build && cd build
cmake -C ../cmake/presets/basic.cmake \
-D BUILD_MPI=yes -D BUILD_OMP=yes -D PKG_OPENMP=yes \
-D CMAKE_INSTALL_PREFIX=$HOME/.local \
../cmake
cmake --build . -j 8
cmake --install . # installs into ~/.local, no root needed
# add to ~/.bashrc
export PATH=$HOME/.local/bin:$PATH
export LAMMPS_POTENTIALS=$HOME/.local/share/lammps/potentials
# Check: the MPI library name and packages such as MANYBODY must appear
lmp -h | sed -n '/MPI v/p;/Installed packages/,/List of individual/p'Step 2
Why this stepAn in file is the input script for LAMMPS. Each line is one command, and the program runs them in order. This block first sets the units and how the atoms are arranged, and then says which potential calculates the forces between atoms.
A potential is a set of formulas and parameters that calculate the forces and energies between atoms. This example uses the copper potential published by Mishin et al. in 2001. It belongs to the EAM class (embedded atom method, common for metals), and LAMMPS ships with its file.
These commands build 20×20×20 face-centered cubic (fcc) unit cells, with 4 atoms per cell, for 32000 atoms in total. The box is periodic in all three directions, so each face connects to the opposite face and the system has no surface.
# in.cu_tensile -- uniaxial tension of single-crystal Cu along [100]
# Works with LAMMPS 22Jul2025 and 30Sep2026; requires the MANYBODY package
# ---------- 1. Initialization ----------
units metal # length Å, time ps, energy eV, pressure bar
dimension 3
boundary p p p
atom_style atomic
variable T equal 300.0 # temperature in K
variable erate equal 1.0e9*1.0e-12 # 1e9 s^-1 converted to 1/ps
# ---------- 2. Build the model ----------
lattice fcc 3.615 # matches the Cu lattice constant in the potential file
region box block 0 20 0 20 0 20 # 20x20x20 unit cells, 32000 atoms
create_box 1 box
create_atoms 1 box
# ---------- 3. Potential ----------
pair_style eam/alloy
pair_coeff * * Cu_mishin1.eam.alloy Cu # file ships in the LAMMPS potentials/ folder
neighbor 2.0 bin
neigh_modify delay 0 every 1 check yes
- 01
Set units metal
units metal sets the units for every number that follows: length in Å (angstrom), time in ps (picosecond), energy in eV, and pressure in bar. Most metal potential files use these units, so this page uses metal throughout.
- 02
Build the crystal
lattice fcc 3.615 sets the copper lattice constant to 3.615 Å, which matches the equilibrium value in the potential file. The 0 20 in region means 20 unit cells, a box about 72 Å on a side. The lattice constant must be the potential's equilibrium value, or the model starts with residual stress.
- 03
Set the potential with pair_style eam/alloy and pair_coeff
pair_style selects the form of the potential. eam/alloy matches files in the .eam.alloy format. After pair_coeff * *, write the file name and then the element names, one per atom type. Files in this format already contain atomic masses, so no mass command is needed.
- 04
Set neighbor and neigh_modify
The neighbor list records which atoms around each atom need force calculations. neighbor 2.0 bin sets the skin, the extra buffer distance, to 2.0 Å. neigh_modify delay 0 every 1 check yes makes LAMMPS check every step, starting at step 0, whether the neighbor list must be rebuilt.
Step 3
Why this stepIn a newly built crystal, the atom positions and box size may not match the potential's equilibrium, so the atoms feel large forces. Energy minimization moves the atoms along the forces and adjusts the box until the forces and pressure are small enough.
fix box/relax lets the box change size during minimization so that the pressure at 0 K is zero. vmax 0.001 limits how much the volume can change in one step, which keeps the minimization from diverging.
# ---------- 4. Energy minimization, relaxing box pressure to 0 ----------
thermo 100
thermo_style custom step pe press lx ly lz
fix relax all box/relax iso 0.0 vmax 0.001
min_style cg
minimize 1.0e-12 1.0e-12 10000 100000
unfix relax
Step 4
Why this stepThe stretch should start from a state with a set temperature and zero pressure. This step gives the atoms initial velocities for 300 K, then runs 20 ps (picoseconds, where 1 ps = 10⁻¹² s) with the npt integrator, which controls temperature and pressure together, so the lattice reaches its thermal expansion.
npt means that both temperature and pressure are controlled. Tdamp 0.1 ps is the response time for temperature control, and Pdamp 1.0 ps is the response time for pressure control. These are 100 steps and 1000 steps, which match the range the manual recommends.
The velocity command gives all atoms random velocities corresponding to 300 K. mom yes rot yes removes the net translation and rotation of the whole system, so the system does not drift as a whole.
# ---------- 5. Equilibrate at 300 K, 0 bar for 20 ps ----------
reset_timestep 0
timestep 0.001 # 1 fs
velocity all create ${T} 4928459 mom yes rot yes dist gaussian
fix eq all npt temp ${T} ${T} 0.1 iso 0.0 0.0 1.0
thermo 1000
thermo_style custom step temp pe press lx ly lz
run 20000
unfix eq
Step 5
Why this stepThis step does the stretching. The x direction is pulled at a constant rate, while y and z are held at 0 bar so they can shrink freely. That gives a uniaxial stress state. A strain rate of 1×10⁹ s⁻¹ converts to 0.001 per ps in metal units, where time is in ps.
# ---------- 6. Constant strain-rate tension along x, y and z held at 0 bar ----------
variable tmp equal lx
variable L0 equal ${tmp} # evaluated immediately: length before loading
reset_timestep 0
fix nptyz all npt temp ${T} ${T} 0.1 y 0.0 0.0 1.0 z 0.0 0.0 1.0 drag 1.0
fix pull all deform 1 x erate ${erate} units box remap x
variable strain equal (lx-v_L0)/v_L0
variable sxx equal -pxx/10000 # bar to GPa; sign flipped so tension is positive
variable syy equal -pyy/10000
variable szz equal -pzz/10000
fix out all print 100 "${strain} ${sxx} ${syy} ${szz}" file stress_strain.txt screen no title "# strain sxx_GPa syy_GPa szz_GPa"
compute peatom all pe/atom
dump traj all custom 2000 tensile.lammpstrj id type x y z c_peatom
thermo_style custom step v_strain temp v_sxx v_syy v_szz pe press
restart 50000 tensile.*.restart
run 300000 # 300 ps, engineering strain reaches 0.30
write_data final.data
- 01
Record the length before stretching with variable L0
${} is evaluated the moment this line is read, so L0 stays fixed at the length before stretching, and all later strains are measured against it. If you wrote variable L0 equal lx instead, L0 would change along with the box and the strain would stay at 0.
- 02
Control the stretch with fix deform and fix nptyz
fix deform stretches the x direction at a constant engineering strain rate. erate is given in 1/(time unit), which is 1/ps in metal units, so 1×10⁹ s⁻¹ becomes 0.001. y and z are controlled by npt at 0 bar, which lets them contract through the Poisson effect. The x direction is controlled only by deform, with no npt pressure control.
- 03
Convert pressure to stress (sxx)
pxx is the x component of the pressure tensor. It is in bar and is negative under tension. The minus sign makes tensile stress positive, and dividing by 10000 converts it to GPa (1 GPa = 10000 bar). The press keyword in thermo_style makes LAMMPS compute the pressure tensor, which pxx and the other variables depend on.
- 04
Write the output
fix print writes the strain and stress to stress_strain.txt every 100 steps. The string is enclosed in double quotes, and ${strain} is evaluated at each output. dump writes a .lammpstrj trajectory frame every 2000 steps, which OVITO and VMD can open. restart writes a continuation file every 50000 steps.
Step 6
Why this stepThe stretch output is a column of raw numbers. This step plots them as a curve and reads two values from it. The slope of the initial straight segment is Young's modulus, the ratio of stress to strain during elastic deformation. The first yield stress is the largest stress reached before the curve first drops clearly.
The script first fits a straight line to the data from 0 to 1% strain to get the modulus. The curve has thermal noise, so it applies a 20-point moving average before looking for the yield point.
A small system reloads after yielding, so the global maximum of the curve may appear later. The script therefore takes the maximum before the first clear drop, not the global maximum.
# plot_ss.py: read the fix print output, plot the stress-strain curve, fit the initial modulus and find the first yield
import numpy as np
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
d = np.loadtxt("stress_strain.txt", comments="#")
strain, sxx = d[:, 0], d[:, 1]
# 20-point moving average to suppress thermal noise (100 steps per point); valid mode avoids the false drop caused by zero padding at both ends
w = 20
sxx_s = np.convolve(sxx, np.ones(w) / w, mode="valid")
strain_s = strain[w // 2 : w // 2 + len(sxx_s)]
lin = strain <= 0.01 # fit only 0–1% strain
E = np.polyfit(strain[lin], sxx[lin], 1)[0]
# First yield: the maximum before the stress first falls 20% below its running maximum (after exceeding 1 GPa)
# Small cells reload after yielding and the global maximum can come later, so plain argmax is not enough
run_max = np.maximum.accumulate(sxx_s)
drop = np.nonzero((run_max > 1.0) & (run_max - sxx_s > 0.2 * run_max))[0]
j = drop[0] if drop.size else len(sxx_s)
i = np.argmax(sxx_s[:j])
print(f"E(0-1%) = {E:.1f} GPa")
print(f"first yield = {sxx_s[i]:.2f} GPa at strain {strain_s[i]:.3f}")
plt.plot(strain, sxx, lw=0.5, alpha=0.4, label="raw")
plt.plot(strain_s, sxx_s, lw=1.5, label=f"moving avg ({w})")
plt.xlabel("Engineering strain")
plt.ylabel("Stress σxx (GPa)")
plt.legend()
plt.tight_layout()
plt.savefig("stress_strain.png", dpi=200)
# You can also parse log.lammps directly (needs the LAMMPS Python module; the conda build includes it)
# from lammps.formats import LogFile
# run = LogFile("log.lammps").runs[-1] # keys are the thermo column names, e.g. "v_strain", "v_sxx"
Choose by your situation
Hand it to an agent
Example one-sentence instruction: "Use LAMMPS to simulate uniaxial tension of a [100] single-crystal Cu nanowire about 4 nm in diameter and 20 nm long at 300 K and 1×10⁹ s⁻¹, with the Mishin EAM potential and GPU acceleration; output the stress-strain curve, Young's modulus, yield strength and common neighbor analysis snapshots, and compare with a nanowire about 2 nm in diameter to show the size effect."
The agent carries out these steps: rents a GPU and runs the environment self-test; writes the input files for model building, relaxation and tension; runs a short test to estimate run time before submitting the production run; extracts stress-strain data with Python and fits the modulus; marks dislocations and twins with common neighbor analysis; and reviews the results adversarially to confirm the task is actually done. The deliverables are the input files, post-processing scripts, logs, plots, structure snapshots, an environment record and a report. Compute is released when the run finishes.
You still need to check these yourself: whether the potential suits the deformation mechanism you study; the definition of the stress normalization volume; whether the effects of strain rate and size on yield strength are stated in the conclusions; and whether repeats with different random seeds are needed to estimate statistical error.
Step 1
Choose a route by three questions: do you need MPI parallel runs, do you need CUDA, and do you have root access. The typical cost of a wrong choice is finding out after installation that you cannot run in parallel, or that the GPU is not used at all.
| Route | When to use it | MPI | GPU | Notes |
|---|---|---|---|---|
| Windows LAMMPS-GUI installer (GitHub release, LAMMPS-Win10-x64-GUI-30Sep2026.exe) | Learning and debugging input files, small systems | No | GPU package, OpenCL mixed precision | Includes command-line lmp; no KIM and some other packages; SmartScreen shows a warning during installation |
| Windows MS-MPI installer (rpm.lammps.org/windows, LAMMPS-64bit-30Sep2026-MSMPI.exe) | Multi-process parallel runs on Windows | MS-MPI only; install msmpisetup.exe separately | GPU package, OpenCL | Run with mpiexec -n 4 lmp -in ...; the installer sets PATH and LAMMPS_POTENTIALS; MS-MPI only since 2Aug2023 |
| WSL2 + CMake source build | Windows machine that needs CUDA or MPI | OpenMPI | GPU package or KOKKOS (CUDA) | Install no Linux display driver inside WSL; keep files on the Linux file system |
| conda-forge (conda install lammps) | Linux/macOS without compiling | openmpi/mpich/nompi variants | CUDA variants use KOKKOS, no GPU package | Version is 2025.07.22; no Windows build; includes KIM; ships no potentials/ folder and does not set LAMMPS_POTENTIALS (tested with the osx-arm64 package on this page) |
| Linux static binary (download.lammps.org/static) | Cluster login nodes, no root, just need it to run | No | None | No dependence on system libraries; no Python module |
| apt / dnf distribution packages | Quick trial | Yes | None | apt version is 20240207 on Ubuntu 24.04 and 20220106 on 22.04 |
| CMake source build (Linux, clusters) | Production runs, custom packages or GPU | Yes | GPU package or KOKKOS | Main route of this page; can install into $HOME without root |
| Docker/Apptainer (NVIDIA NGC nvcr.io/hpc/lammps) | GPU machines with the NVIDIA Container Toolkit | Built into the image | Yes, CUDA | Run lmp -h inside the container first to see whether the accelerator is the GPU package or KOKKOS |
Windows
The LAMMPS-GUI installer is suited to learning. Its editor runs the current in file directly and shows thermo plots and snapshots. It has three limits: no MPI parallelism; the GPU package is only the OpenCL version, which needs a graphics driver with an OpenCL runtime; and KOKKOS runs only in serial or with OpenMP.
There are two ways to use multiple cores on Windows. With the GUI installer, use OpenMP: lmp -sf omp -pk omp 8 -in in.file. With the MSMPI installer, use MPI: mpiexec -n 8 lmp -in in.file. The official notes say combining the two is usually slower, so pick one.
If you need CUDA, need to build your own packages, or need the same scripts as a cluster, switch to WSL2. CUDA on WSL needs the NVIDIA driver on the Windows side (R495 or later), and inside WSL you install only the cuda-toolkit-12-x metapackage. WSL2 GPU support requires a Pascal or newer GPU.
# Windows PowerShell (administrator)
wsl --install -d Ubuntu-24.04
wsl --set-default-version 2
# Inside Ubuntu: install only the CUDA Toolkit, no Linux display driver
# On the NVIDIA download page choose Linux > x86_64 > WSL-Ubuntu and install the cuda-toolkit-12-x metapackage
nvidia-smi # if not found: /usr/lib/wsl/lib/nvidia-smi
# keep the working directory on the Linux file system, not under /mnt/c
mkdir -p ~/md && cd ~/mdVersion
The new stable release of 30 September 2026 raised the toolchain requirements. On clusters with older GCC or CMake, building the new version fails at the configure step.
How to decide: run gcc --version and cmake --version first. If GCC is older than 10.4 and you need KOKKOS, use stable_22Jul2025_update6 or install a newer compiler first. If CMake is too old, python3 -m pip install --user cmake installs a recent version without root.
If your input must be compared with results from a supervisor or a published study, record the full version string printed by lmp -h. 30Sep2026 fixed platform-dependent results on ARM64 and on platforms with FMA enabled, so the two versions can differ in the last digits.
| Item | stable_22Jul2025_update6 | stable_30Sep2026 |
|---|---|---|
| Minimum CMake | 3.16 | 3.20 |
| C++ standard | C++11 by default; KOKKOS needs C++17 | C++17; KOKKOS needs C++20 |
| Bundled Kokkos | 4.6.2 (GCC ≥ 8.2, CUDA ≥ 11.0) | 5.2 (GCC ≥ 10.4, NVCC ≥ 12.2) |
| GPU package default GPU_ARCH | sm_50 | sm_75 |
| Traditional make build | Works for KOKKOS | KOKKOS is CMake-only since 11Feb2026; make only builds packages that need no extra steps in lib/ |
| dump image / dump movie | Core feature | Moved to the new GRAPHICS package, included in the basic.cmake preset |
| Removed packages | — | ATC, AWPMD, POEMS, ML-RANN, VTK; pair agni (dump vtk moved to EXTRA-DUMP) |
Optional
Enable extra packages with -D PKG_<NAME>=yes, for example -D PKG_REAXFF=yes, -D PKG_MEAM=yes, -D PKG_EXTRA-COMPUTE=yes. To enable most common packages, use -C ../cmake/presets/most.cmake.
After changing the package selection, rerun cmake in the same build directory and rebuild; existing settings are kept in CMakeCache.txt.
Step 3
Both run EAM on NVIDIA GPUs, but they split the work differently: the GPU package puts the pair computation on the GPU and leaves the rest on the CPU, while KOKKOS tries to keep the whole time step on the GPU.
For the CUDA backend, write -D GPU_API=cuda explicitly. If you leave it out, GPU_API defaults to opencl, which builds the OpenCL version. That version also runs on NVIDIA cards, but it is not the CUDA backend.
Set GPU_ARCH and Kokkos_ARCH from the GPU compute capability: V100 is sm_70 / VOLTA70; T4 and RTX 20 series are sm_75 / TURING75; A100 is sm_80 / AMPERE80; RTX 30 series and A40 are sm_86 / AMPERE86; RTX 40 series and L40S are sm_89 / ADA89 (not sm_90); H100 is sm_90 / HOPPER90; RTX 50 series is sm_120 / BLACKWELL120. CUDA 13 can no longer compile offline for Maxwell, Pascal or Volta. The 22Jul2025 default is sm_50, so with CUDA 13 you must set GPU_ARCH explicitly.
A KOKKOS executable moved to a GPU with a different major architecture version (for example from 7.x to 8.x) exits with an error; within the same major version it only adds a JIT compilation at startup. To support several GPU types, build for the oldest one or build one executable per type.
# Look up the compute capability first: 8.6 -> sm_86, 8.9 -> sm_89
nvidia-smi --query-gpu=name,compute_cap --format=csv
# Option A: GPU package (CUDA back end)
mkdir build-gpu && cd build-gpu
cmake -C ../cmake/presets/basic.cmake \
-D PKG_GPU=on -D GPU_API=cuda -D GPU_ARCH=sm_86 -D GPU_PREC=mixed \
-D BUILD_MPI=yes -D BUILD_OMP=yes -D PKG_OPENMP=yes \
-D CMAKE_INSTALL_PREFIX=$HOME/.local \
../cmake
cmake --build . -j 16
# Option B: KOKKOS (CUDA back end); the two -C presets can be combined
mkdir build-kokkos && cd build-kokkos
cmake -C ../cmake/presets/basic.cmake \
-C ../cmake/presets/kokkos-cuda.cmake \
-D Kokkos_ARCH_AMPERE86=yes \
-D BUILD_MPI=yes \
../cmake
cmake --build . -j 16| Aspect | GPU package | KOKKOS |
|---|---|---|
| What is accelerated | pair and parts of PPPM; integration and most fixes stay on the CPU | every pair, fix and compute with a /kk variant runs on the GPU; commands without a /kk variant copy data between CPU and GPU |
| MPI ranks per GPU | several ranks sharing one GPU are usually faster; the manual suggests 2–10 | 1 by default; sharing a GPU among ranks requires CUDA MPS |
| Precision | single / mixed (default) / double | double by default; single and mixed also supported since 30Sep2026 |
| Best for | many CPU cores and few GPUs; the OpenCL build on Windows | large systems on one GPU; the manual says KOKKOS is usually faster with many atoms in double precision |
| Run flags | -sf gpu -pk gpu N | -k on g N -sf kk |
| Key build options | -D PKG_GPU=on -D GPU_API=cuda -D GPU_ARCH=sm_XX | -C kokkos-cuda.cmake -D Kokkos_ARCH_<GPU>=yes |
Step 4
In a conda environment, mpirun comes from that environment itself (MPICH Hydra). After activating it, run mpirun -np 8 lmp -in in.cu_tensile directly, and do not mix in the system OpenMPI.
The conda CPU package includes neither the GPU nor the KOKKOS package, so the parallel option it supports is -sf omp -pk omp N.
-sf gpu appends the suffix to every command that has a /gpu variant, so eam/alloy becomes eam/alloy/gpu; -sf kk works the same way. You can switch between CPU and GPU from the command line without editing the input file.
KOKKOS assumes by default that MPI is GPU-aware. A single GPU with a single process is not affected. With several processes, if your MPI is not GPU-aware, add -pk kokkos gpu/aware off (see troubleshooting).
Mixed precision is the GPU package default. Before publishing, run the same simulation for a while with a double-precision build or the CPU version and compare energy and stress.
To estimate run time, first set run to 2000 steps, read timesteps/s on the Performance line at the end of the log, and extrapolate to the full step count.
# CPU only, 8 MPI ranks
mpirun -np 8 lmp -in in.cu_tensile
# CPU only, OPENMP package, 1 process with 8 threads (also works with the Windows GUI installer)
lmp -sf omp -pk omp 8 -in in.cu_tensile
# GPU package: 4 MPI ranks share 1 GPU
mpirun -np 4 lmp -sf gpu -pk gpu 1 -in in.cu_tensile
# KOKKOS: 1 MPI rank per GPU
lmp -k on g 1 -sf kk -in in.cu_tensile
# On Pascal and newer GPUs, half neighbor lists are often faster
lmp -k on g 1 -sf kk -pk kokkos newton on neigh half -in in.cu_tensile
# Multiple GPUs with an MPI that is not GPU-aware (common with distribution OpenMPI)
mpirun -np 2 lmp -k on g 2 -sf kk -pk kokkos gpu/aware off -in in.cu_tensileVariant
Nanowire tension is the most common modification of the bulk script. Three things change: the model, the barostat directions, and the volume used to normalize stress.
Keep periodic boundaries in y and z, but leave a vacuum layer much wider than the cutoff (5.5 Å for the Mishin potential) so the wire does not interact with its periodic images. In the example the box is about 72 Å wide, the wire about 40 Å in diameter, and the vacuum about 32 Å.
pxx is the virial stress of the whole box divided by the box volume. The box volume includes vacuum, so plain -pxx/10000 clearly underestimates the stress in the wire. The conversion above assumes the cross-section does not change during loading. Alternatively, sum compute stress/atom and divide by the number of atoms times the volume per atom. Whichever you use, state the definition of the normalization volume in the paper.
# Replace step 2 with these lines: [100] Cu nanowire, about 4 nm in diameter and 20 nm long
lattice fcc 3.615
region box block 0 55 -10 10 -10 10 # lattice units; integer number of cells along x
create_box 1 box
region wire cylinder x 0 0 5.5 INF INF # radius of 5.5 lattice constants, about 19.9 Å
create_atoms 1 region wire
# Step 4: relax the box along x only
fix relax all box/relax x 0.0 vmax 0.001
# Step 5: barostat along x only
fix eq all npt temp ${T} ${T} 0.1 x 0.0 0.0 1.0
# Step 6: y and z are vacuum, so no barostat there; use NVT
fix nvt1 all nvt temp ${T} ${T} 0.1
fix pull all deform 1 x erate ${erate} units box remap x
# pxx is normalized by the whole box volume (including vacuum); rescale to the wire volume
variable R equal 5.5*3.615
variable sxx equal -pxx*vol/(PI*v_R^2*lx)/10000 # GPa, ignoring Poisson contractionContinuation
Restart files store atoms, the box, units, atom_style and similar settings. What they do not store must be re-specified in the continuation script: all fixes and computes, and pair_coeff for many-body potentials that read parameters from files (EAM, Tersoff and others).
When you continue a run, fix deform needs the original box length at the start of the stretch. It uses that length only when the run command includes start and stop: start is the step where the original stretch began (0 after reset_timestep 0), and stop is the total step count. The fix ID of deform must match the original script (here, pull). If you write only run 300000 upto, deform recalculates the elongation from the box length at restart.
run N upto stops the total step count at N, so the run reaches the same end point no matter how many times it was interrupted. In the continuation script, L0 must be the length before the original stretch (see troubleshooting).
# in.cu_tensile.continue -- continue tension from the restart at step 150000
read_restart tensile.150000.restart
pair_style eam/alloy # many-body potentials are not stored in restart files; re-specify
pair_coeff * * Cu_mishin1.eam.alloy Cu
neighbor 2.0 bin
variable T equal 300.0
variable erate equal 1.0e9*1.0e-12
variable L0 equal 72.5 # set to the number after variable L0 equal in the original log
timestep 0.001
fix nptyz all npt temp ${T} ${T} 0.1 y 0.0 0.0 1.0 z 0.0 0.0 1.0 drag 1.0
fix pull all deform 1 x erate ${erate} units box remap x # same fix-ID as the original script
variable strain equal (lx-v_L0)/v_L0
variable sxx equal -pxx/10000
fix out all print 100 "${strain} ${sxx}" append stress_strain.txt screen no
thermo_style custom step v_strain temp v_sxx pe press
thermo 1000
restart 50000 tensile.*.restart
run 300000 upto start 0 stop 300000 # run to total step 300000; start/stop keep deform on the original box lengthPotentials
You do not need to download a Cu EAM potential: Cu_mishin1.eam.alloy (Mishin et al., PRB 63, 224106, 2001), Cu_u3.eam (Foiles 1986) and Cu_zhou.eam.alloy are all in the LAMMPS potentials/ folder. On the NIST Interatomic Potentials Repository (ctcms.nist.gov/potentials/system/Cu), the same Mishin potential is listed as Cu01.eam.alloy. NIST notes that the Mendelev 2013 Cu2 potential improves stacking fault energies, and that the ipr2 version of Zhou 2004 corrects spurious fluctuations in the tabulated functions. For dislocation and twinning studies, choose a potential with these notes in mind and cite the source in your methods.
A conda installation has no such folder; download the file from the GitHub tag that matches your version: curl -LO https://raw.githubusercontent.com/lammps/lammps/stable_22Jul2025_update6/potentials/Cu_mishin1.eam.alloy, and put it next to the input file, or in a fixed folder that LAMMPS_POTENTIALS points to.
OpenKIM potentials need no file download; reference the model ID in the input: kim init EAM_Dynamo_MishinMehlPapaconstantopoulos_2001_Cu__MO_346334655118_006 metal, then kim interactions Cu after the model is built. This requires the KIM package. The conda and apt builds include KIM; the Windows prebuilt packages do not.
Newer versions read the UNITS label on the first line of a potential file. If the units in your input file do not match, LAMMPS stops with an error, so you must change units or use a potential file that matches (see troubleshooting).
| System | Common potentials (pair_style) | Packages | Units | Sources |
|---|---|---|---|---|
| Metals and alloys | eam, eam/alloy, eam/fs, meam | MANYBODY, MEAM | metal | NIST IPR, OpenKIM, LAMMPS potentials/ folder |
| Covalent crystals (Si, Ge, SiC) | sw, tersoff | MANYBODY | metal | potentials/ folder, NIST IPR, OpenKIM |
| Carbon materials (graphene, CNT, hydrocarbons) | airebo, tersoff | MANYBODY | metal | potentials/CH.airebo |
| Polymers and organic molecules (fixed topology) | lj/cut/coul/long + bond, angle, dihedral terms (OPLS-AA, GAFF); lj/class2 (PCFF, COMPASS) | MOLECULE, KSPACE, CLASS2 | real | Data files generated with moltemplate, LigParGen or msi2lmp |
| Reactive systems (combustion, oxidation, bond breaking and forming) | reaxff + fix qeq/reaxff; or fix bond/react | REAXFF; REACTION | real | ReaxFF parameters in the potentials/ folder and in paper supplements |
| Near-DFT accuracy | snap, pace, mliap | ML-SNAP, ML-PACE, ML-IAP | metal | Files supplied with papers, OpenKIM |
Post-processing
OVITO opens tensile.lammpstrj directly (and also reads .gz). Add the Common neighbor analysis modifier to the pipeline to color atoms as FCC, HCP or Other. In FCC copper, a single layer of HCP atoms marks a twin boundary and two adjacent HCP layers mark an intrinsic stacking fault. VMD opens the file with vmd -lammpstrj tensile.lammpstrj; it cannot read compressed files.
Dislocation density versus strain is a common post-processing request in the Chinese community; several CSDN articles demonstrate it, and the scripts are mostly shared in QQ groups. The dxa_density.py script below uses only the public interface of the OVITO Python module (pip install ovito): DislocationAnalysisModifier outputs the total line length DislocationAnalysis.total_line_length (Å) and the cell volume DislocationAnalysis.cell_volume (ų); dividing them and multiplying by 10²⁰ gives m⁻². DislocationAnalysis.length.1/6<112> is the length of Shockley partials.
# dxa_density.py: run DXA on every frame and print dislocation density and FCC/HCP fractions
import sys
from ovito.io import import_file
from ovito.modifiers import DislocationAnalysisModifier
pipeline = import_file(sys.argv[1] if len(sys.argv) > 1 else "tensile.lammpstrj")
dxa = DislocationAnalysisModifier(input_crystal_structure=DislocationAnalysisModifier.Lattice.FCC)
pipeline.modifiers.append(dxa)
print("# step rho_total(1/m^2) rho_shockley(1/m^2) FCC_frac HCP_frac")
for frame in range(pipeline.source.num_frames):
data = pipeline.compute(frame)
a = data.attributes
vol = a["DislocationAnalysis.cell_volume"] # Å^3
rho = a["DislocationAnalysis.total_line_length"] / vol * 1e20 # Å/Å^3 -> m^-2
rho_s = a.get("DislocationAnalysis.length.1/6<112>", 0.0) / vol * 1e20
n = data.particles.count
fcc = a["DislocationAnalysis.counts.FCC"] / n
hcp = a["DislocationAnalysis.counts.HCP"] / n
print(f"{a['Timestep']:8d} {rho:.3e} {rho_s:.3e} {fcc:.3f} {hcp:.3f}")
Working from China
This section collects practices that recur on the Computational Chemistry Commune forum (keinsci), CSDN, Zhihu and university HPC documentation, checked against the current documentation or source code of LAMMPS and the related tools. Numbers marked as tested on this page come from actual queries or runs on 2026-10-10.
# ~/.condarc: route conda-forge through the Tsinghua TUNA mirror (community-only setup from the TUNA help page)
channels:
- conda-forge
- nodefaults
show_channel_urls: true
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda clean -i
# build string = accelerator + MPI: cpu, cuda129, cuda130, cuda134 combined with nompi, mpich, openmpi
conda create -n lammps -y "lammps=2025.07.22=cpu*openmpi*" # about 410 MB total for a new env
conda create -n lammps-gpu -y "lammps=2025.07.22=cuda129*openmpi*" # about 1 GB total for a new env
conda activate lammps && lmp -h | head -20
# 1) On a machine with internet access, download the third-party archive (URL as in cmake/Modules/Packages/VORONOI.cmake)
curl -LO https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
# 2) Copy it to the cluster and point <prefix>_URL at the local file; the default SHA256 is still checked, so the version must match
cd lammps/build
cmake ../cmake -C ../cmake/presets/basic.cmake -D PKG_VORONOI=yes -D DOWNLOAD_VORO=yes \
-D VORO_URL=file://$HOME/src/voro++-0.4.6.tar.gz
cmake --build . -j 8
# Many downloads: run tools/offline/init_caches.sh on the online machine (default cache ~/.cache/lammps),
# copy the cache to the same path on the cluster, source tools/offline/use_caches.sh and add the -D LAMMPS_DOWNLOADS_URL=... options it prints
# VMD Tk Console: convert a Packmol pdb to a LAMMPS data file (TopoTools)
package require topotools
mol new system.pdb
# for pdb files VMD takes the type from the atom name, so C1, C2, H1 become separate types; merge them by element first
[atomselect top {name "C.*"}] set type C
[atomselect top {name "H.*"}] set type H
pbc set {40.0 40.0 40.0} ;# writelammpsdata refuses to write without a box
topo writelammpsdata system.data full
# type IDs follow the alphabetical order of type names: C=1, H=2; the comment at the end of each Masses line is the type name
Use the Tsinghua conda mirror and pick the variant with a build string
When conda-forge downloads are slow in China, follow the Tsinghua TUNA mirror help page and point conda-forge at mirrors.tuna.tsinghua.edu.cn/anaconda/cloud in ~/.condarc. Tested on this page (micromamba query of the mirror on 2026-10-10): linux-64 has lammps 2025.07.22 in four build families, cpu, cuda129, cuda130 and cuda134, each split into nompi, mpich and openmpi. With a bare conda install lammps the solver decides which MPI to use and whether to include CUDA; a build string such as "lammps=2025.07.22=cpu*openmpi*" pins the variant. Total download for a new environment: about 410 MB for cpu+openmpi and about 1 GB for cuda129+openmpi.
On a university cluster, check the modules before building your own
University clusters usually provide LAMMPS already, and the executable name differs between modules. The SCUT platform provides a source-built lammps/2Aug2023 (executable lmp_intel_cpu_intelmpi) and a conda environment lammps20230802-cpu (executable lmp). SJTU's Siyuan-1 provides CPU modules such as lammps/20230328-intel-2021.4.0-omp and lammps/20230802-intel-2021.4.0-gpu, with the example run command mpirun lmp -pk intel 0 omp 2 -sf intel -i in.lj; drop -pk intel and -sf intel when the force field is not supported by the INTEL package. Run module avail lammps first, then lmp -h after loading to see the installed packages. These modules are mostly 2023 versions, so new keywords written from the 30Sep2026 documentation may not be recognized; when that happens, check the documentation for that version. The SJTU documentation requires builds to run on compute nodes, since parallel compilation is not allowed on login nodes.
Third-party downloads fail during the build
With VORONOI, PLUMED, ML-PACE, KIM and similar packages enabled, CMake downloads source archives from GitHub, download.lammps.org or OpenKIM. On an unstable campus network or a cluster without internet access, CMake reports Each download failed! (the exact text in a CSDN write-up of a build on an offline cluster). That author placed the archive by hand and faked CMake's step stamp files. A more direct fix is to point the cache variable <prefix>_URL at a local file, for example VORO_URL, PLUMED_URL, PACELIB_URL or KIM_URL; the prefix and default URL are on the SetDownloadSettings line in cmake/Modules/Packages/<package>.cmake. The GPU package and KOKKOS libraries ship with the LAMMPS source (DOWNLOAD_KOKKOS is off by default), so a GPU build does not need to download either of them.
Common problems when building data files with modeling tools
Packmol only keeps atoms inside the box at least tolerance apart; it ignores periodic images. In his Packmol tutorial on the keinsci forum, Sobereva uses add_box_sides 1.2 to add 1.2 Å to the box in each direction; from Packmol 20.15.0 the pbc keyword packs directly into a periodic box. VMD TopoTools' topo writelammpsdata fails with need to have non-zero box sizes when no box is set, so run pbc set first; it assigns type IDs in alphabetical order of the VMD type names, and for pdb files the type name is taken from the atom name. Data files exported through OVITO after building in Materials Studio also often have a type order that differs from the force-field file, and a keinsci thread reorders the type IDs by hand in Word and Excel. For potentials written as pair_coeff * * file element…, such as eam/alloy, tersoff and reaxff, the data file does not need to change: list the element names in the order of data-file types 1, 2, 3 and so on. The example in the LAMMPS manual: with elements ordered C H O N in the ffield file and types 1 to 4 being C, C, N, H, write pair_coeff * * ffield.reax C C N H.
Concepts and judgment
Explanation
compute stress/atom is in pressure×volume units (bar·Å³) and has the opposite sign of pressure. It is not a per-atom stress; divide by a per-atom volume before reading it as stress.
press in thermo is (pxx+pyy+pzz)/3, which is about -σxx/3 in uniaxial tension. press cannot stand in for σxx.
Explanation
Strain rates in MD tension are typically 10⁷–10¹⁰ s⁻¹, many orders of magnitude above experiment, so yield stresses come out high. Common practice: before production, run once at 10⁹ and once at 10⁸ s⁻¹ to see how much the yield stress changes, then decide whether a lower rate is worth the cost. When comparing sizes or temperatures, keep the strain rate the same and state it in the paper.
The yield stress in this example is the homogeneous nucleation stress of a defect-free periodic crystal. It is about two orders of magnitude above macroscopic experimental values, which is normal for an ideal-crystal model (measured data are in the reference section).
Reference and appendix
Reference
When switching from metal to real, multiply the erate value by a further 10⁻³: 1×10⁹ s⁻¹ is 1.0e-6 (1/fs) in real units.
| Quantity | metal | real |
|---|---|---|
| Distance | Å | Å |
| Time | ps (default timestep 0.001 = 1 fs) | fs (default timestep 1.0 = 1 fs) |
| Energy | eV | kcal/mol |
| Pressure | bar (1 GPa = 10000 bar) | atm (1 GPa = 9869.2 atm) |
| fix deform erate | 1/ps | 1/fs |
| Default neighbor skin | 2.0 Å | 2.0 Å |
Reference
In log.lammps, the thermo block of each run starts with a header line beginning with Step and ends with a line starting Loop time of. The header columns are the thermo_style keywords, and variables appear as v_strain and v_sxx. After Loop time comes a timing breakdown (shares of Pair, Neigh, Comm, Output and so on): a low Pair share with a high Comm or Output share means too many processes or too frequent output.
Reference
The numbers below come from actual runs on 2026-10-10 with LAMMPS 22Jul2025 update6, the conda-forge CPU build, on macOS arm64.
Tested on this page (LAMMPS 22Jul2025 update6, conda-forge CPU build, macOS arm64): with region changed to 0 10 0 10 0 10 (4000 atoms) and all other parameters unchanged, the full 20 ps equilibration and 300 ps tension were run. After equilibration at 300 K, lx is 36.31 Å, a lattice constant of 3.631 Å. plot_ss.py gives a 0–1% strain modulus of 67.3 GPa, which agrees with the theoretical [100] Young's modulus: the same potential at 0 K and 0.1% strain gives C11 = 169.7 GPa and C12 = 122.3 GPa (the Mishin 2001 paper reports 169.9 and 122.6 GPa), and E = (C11−C12)(C11+2C12)/(C11+C12) gives 67.2 GPa. The first yield stress is 8.80 GPa at a strain of 0.113, after which the stress drops abruptly to about 4.3 GPa; σyy and σzz stay within ±0.3 GPa, showing that the zero-pressure control in y and z works. With 864 atoms (6×6×6 cells) the results are 68.6 GPa and 8.85 GPa (strain 0.115). This yield stress is the homogeneous nucleation stress of a defect-free periodic crystal and is about two orders of magnitude above macroscopic experimental values, which is normal for an ideal-crystal model.
Single-core cost (same version and machine, 4000 atoms, 1000 steps each, 99.9% CPU use): the NPT equilibration runs at 204 steps/s (0.82 M atom-step/s); the tension stage with fix deform, fix print and dump runs at 156 steps/s, i.e. 6.4 ms per step (0.62 M atom-step/s). Extrapolated, 32000 atoms take about 51 ms per step on one core, and the 320,000 steps of equilibration plus tension take about 4.5 hours. Other jobs were running on the machine during testing, so multi-process speedups were distorted and are not reported here.
Tested on this page (same version; length shortened to 20 cells, 7540 atoms; 4 ps of equilibration at 300 K, then tension at 1×10⁹ s⁻¹ to a strain of 0.03): after equilibration lx is 71.52 Å, 1.1% shorter than the built length of 72.30 Å because surface stress contracts the wire axially, so take L0 after equilibration. The modulus fitted over 0–1% strain is 55.8 GPa with the volume conversion above and only 13.2 GPa with plain -pxx/10000; the ratio of about 4.2 equals the ratio of the box cross-section to the wire cross-section. Summing compute stress/atom and dividing by the number of atoms times the atomic volume a³/4 (corrected for the axial elongation) gives a stress within 0.5% of the conversion above. stress/atom has the opposite sign to pressure, so do not negate the sum again.
Tested on this page: running plot_ss.py on the 4000-atom case above prints E(0-1%) = 67.3 GPa and first yield = 8.80 GPa at strain 0.113. Small cells reload after the first yield; the 864-atom case reaches a higher peak of 9.9 GPa at a strain of 0.23, so the script takes the maximum before the first clear drop instead of the global maximum. The runs read by lammps.formats.LogFile correspond to minimization, equilibration and tension in that order, and the keys of runs[-1] are Step, v_strain, Temp, v_sxx, v_syy, v_szz, PotEng and Press.
Tested on this page (OVITO 3.16.1, the 151-frame tension trajectory of the 4000-atom case above, about 11 s): DXA finds no dislocations before a strain of 0.116, while the FCC fraction is 0.936 at a strain of 0.100 and drops to 0.625 at 0.116. The first dislocations appear at a strain of 0.118 with a density of 4.1×10¹⁷ m⁻², and the HCP fraction rises to 0.149. After that the density jumps between 0 and 1.4×10¹⁸ m⁻² and is 9.6×10¹⁷ m⁻² at a strain of 0.300, while the HCP fraction stays between 0.15 and 0.33. The jumps come from the small box: with an edge of about 36 Å, one dislocation line spanning the box corresponds to about 8×10¹⁶ m⁻², so nucleation and annihilation across periodic boundaries change single-frame values several-fold. To compare dislocation densities in a paper, use a larger box or average over a strain interval.
Measured on this page (an 864-atom shortened run at 1×10¹⁰ s⁻¹, continued from strain 0.10 to the planned end step): with only upto, the final strain was 0.32. With start 0 stop added, the final strain was 0.30 and the final stress was 6.80 GPa, which matches the uninterrupted run at 6.78 GPa. Using this section's script (changing only L0), continuing the 4000-atom run from step 150000 of the "first input file" section for 1000 steps gave the same strain as the original run, and the stress agreed to 7 significant figures. Continuing from step 150000 with the page parameters but without start and stop would give a final strain of 0.3225.
Troubleshooting by error text or symptom
Find your error text or symptom below. Entries are roughly ordered by how often they occur. For other errors, see the LAMMPS error guide at /learn/lammps-errors.
Unrecognized pair style 'eam/alloy' is part of the MANYBODY package which is not enabled in this LAMMPS binary
Cause: The LAMMPS build was made without the MANYBODY package.
Fix: Run cmake again with -D PKG_MANYBODY=yes, or use the basic.cmake preset, and rebuild.
cannot open eam/alloy potential file Cu_mishin1.eam.alloy: No such file or directory
Cause: The potential file is neither in the current directory nor in the directory LAMMPS_POTENTIALS points to. The conda build has no potentials directory.
Fix: Copy the file into the directory that holds the in file, or set LAMMPS_POTENTIALS to the potentials directory. With the install command on this page, that is $HOME/.local/share/lammps/potentials. The conda build needs the file downloaded from GitHub first; see "How to choose a potential and where to download it".
Potential file Cu_mishin1.eam.alloy requires metal units but real units are in use
Cause: The units in the in file do not match the units of the potential file.
Fix: Change to units metal, and rewrite timestep and erate in metal units.
ERROR: Lost atoms: original 32000 current 31998
Cause: The time step is too large, the starting structure has overlapping atoms, or the potential or units are wrong.
Fix: Check the lattice constant and timestep first. The full troubleshooting steps are in the LAMMPS error guide.
mpirun -np 4 prints every line four times, and the log shows 1 by 1 by 1 MPI processor grid
Cause: CMake did not find the MPI development package and built a serial binary, or mpirun comes from a different MPI than the one used to build. Then the N processes each run the same serial simulation independently.
Fix: lmp -h must show an MPI library name. Install libopenmpi-dev and run cmake again. On a cluster, load the same MPI module you built with.
The log shows a Dangerous builds warning (after the old tutorial's neigh_modify delay 10)
Cause: The delay 10 setting postpones the neighbor-list checks, and in this example it produces that warning.
Fix: Remove delay 10 and use neigh_modify delay 0 every 1 check yes, as on this page.
The stress-strain curve does not start at zero
Cause: The stretch was started without the 300 K equilibration step, so the start carries thermal stress; or the lattice constant is not the potential's equilibrium value.
Fix: Run energy minimization and 300 K equilibration in order, and use the lattice constant 3.615 Å.
Stress stays low during the stretch, or the curve barely rises with strain
Cause: Pressure control with npt was also applied in x, and it cancels the stretch. Many abnormal tensile curves on the MatSci forum come from this.
Fix: Use fix deform alone in x. Use npt to hold y and z at 0 bar.
σxx is high, and the stresses in y and z are not close to 0
Cause: y and z were not held at 0 bar, so the state is uniaxial strain rather than uniaxial stress, and the stress comes out high.
Fix: Hold y and z at 0 bar with npt so they can contract through the Poisson effect.
ERROR: Thermo keyword pxx in variable requires thermo to use/init press
Cause: thermo_style has no pressure keyword, but the variable pxx needs one.
Fix: Keep press in thermo_style.
After a restart, strain is recalculated from 0 and the final strain differs from the original run
Cause: L0 was set to the lx at restart, or the run command lacks start and stop.
Fix: Set L0 to the length before the original stretch, which is the number after variable L0 equal in the original script. Write the run as run 300000 upto start 0 stop 300000.
eam/alloy reads a .eam file, or eam reads a .eam.alloy file
Cause: .eam (funcfl format) and .eam.alloy (setfl format) are two different file formats, and mixing them reads the file wrongly.
Fix: Choose pair_style by file suffix: eam/alloy for .eam.alloy, eam for .eam.
cmake finishes without errors, but the GPU build is not the CUDA backend
Cause: GPU_API defaults to opencl, so -D PKG_GPU=on alone does not select CUDA.
Fix: Add -D GPU_API=cuda and -D GPU_ARCH=sm_XX, where XX is the compute capability of your card, and rebuild.
cmake fails, and earlier you ran make yes-gpu in src or built lib/gpu separately
Cause: The CMake and make build methods were mixed.
Fix: Run make no-all purge in src, or unpack the source again, and then use only -D PKG_GPU=on.
At run time, CUDA driver version is insufficient
Cause: The CUDA Toolkit is newer than the driver. The CUDA version in the top right of nvidia-smi is the highest version the driver supports, and nvcc --version shows the Toolkit used to build. The first should not be lower than the second.
Fix: Rebuild with a Toolkit version no newer than what the driver supports.
nvcc cannot be found during the build
Cause: The CUDA bin directory is not in PATH.
Fix: Run export PATH=/usr/local/cuda/bin:$PATH, then delete the build directory and run cmake again.
mpirun -np 4 lmp < in.cu_tensile does not read the input
Cause: With some MPI implementations, the < redirection does not deliver the input in parallel runs.
Fix: Use the -in option with the file name: mpirun -np 4 lmp -in in.cu_tensile.
On macOS, mpirun reports OFI poll failed (default nic=utun...)
Cause: While a VPN is on, MPICH selects the utun virtual network interface (measured on macOS for this page).
Fix: Run export FI_PROVIDER=tcp before the run.
Cannot use -kokkos on without KOKKOS installed
Cause: The conda CPU package does not include the KOKKOS package.
Fix: Use -sf omp -pk omp N for CPU parallelism. For KOKKOS, use the CUDA variant of the conda build; see "Choosing an install route".
Package gpu command without GPU package installed
Cause: The conda CPU package does not include the GPU package (measured on this page).
Fix: For GPU runs, use the CUDA variant of the conda build, which includes KOKKOS, or compile from source.
Turning off GPU-aware MPI since it is not detected; or a multi-process KOKKOS run crashes with a segmentation fault
Cause: KOKKOS assumes by default that MPI is GPU-aware, but the MPI in use, such as the OpenMPI shipped with some distributions, is not.
Fix: Add -pk kokkos gpu/aware off to the run command.
When running the Windows installer, SmartScreen shows a risk warning
Cause: The installer is self-signed, so the system warns about the risk.
Fix: Choose "Run anyway" in the prompt.
CUDA fails inside WSL, and you previously installed the cuda or cuda-drivers metapackage
Cause: These metapackages overwrite the Windows driver mapped into WSL.
Fix: Install only the cuda-toolkit-12-x metapackage.
CMake reports Each download failed!
Cause: Third-party source packages needed by some packages cannot be downloaded from GitHub, download.lammps.org, or OpenKIM. This is common on unstable campus networks or clusters without external access.
Fix: Point the cache variable <prefix>_URL at a local archive, for example -D VORO_URL=file://...; the SHA256 check still uses the default and the version must match.
# 1) On a machine with internet access, download the third-party archive (URL as in cmake/Modules/Packages/VORONOI.cmake)
curl -LO https://download.lammps.org/thirdparty/voro++-0.4.6.tar.gz
# 2) Copy it to the cluster and point <prefix>_URL at the local file; the default SHA256 is still checked, so the version must match
cd lammps/build
cmake ../cmake -C ../cmake/presets/basic.cmake -D PKG_VORONOI=yes -D DOWNLOAD_VORO=yes \
-D VORO_URL=file://$HOME/src/voro++-0.4.6.tar.gz
cmake --build . -j 8
# Many downloads: run tools/offline/init_caches.sh on the online machine (default cache ~/.cache/lammps),
# copy the cache to the same path on the cluster, source tools/offline/use_caches.sh and add the -D LAMMPS_DOWNLOADS_URL=... options it prints
VMD TopoTools topo writelammpsdata reports need to have non-zero box sizes
Cause: The box size is not set, so writelammpsdata refuses to write the file.
Fix: Run pbc set to set the box first, then write the data file.
# VMD Tk Console: convert a Packmol pdb to a LAMMPS data file (TopoTools)
package require topotools
mol new system.pdb
# for pdb files VMD takes the type from the atom name, so C1, C2, H1 become separate types; merge them by element first
[atomselect top {name "C.*"}] set type C
[atomselect top {name "H.*"}] set type H
pbc set {40.0 40.0 40.0} ;# writelammpsdata refuses to write without a box
topo writelammpsdata system.data full
# type IDs follow the alphabetical order of type names: C=1, H=2; the comment at the end of each Masses line is the type name
The old HPC module does not recognize keywords from the 30Sep2026 manual
Cause: HPC modules are often built from around 2023.
Fix: Check the keywords against the manual for that module version. The SJTU documentation requires compiling on compute nodes, not on login nodes.
References
- LAMMPS stable_30Sep2026 release notes (GitHub) — C++17, CMake 3.20, KOKKOS C++20, GRAPHICS package and removed packages
- LAMMPS manual: Build with CMake — Minimum CMake version and preset files
- LAMMPS manual: Packages with extra build options (GPU, KOKKOS) — GPU_API and GPU_ARCH defaults, Kokkos architecture IDs
- LAMMPS manual: GPU package — -sf gpu -pk gpu usage and MPI ranks per GPU
- LAMMPS manual: KOKKOS package — -k on g usage, GPU-aware MPI, C++20 and CUDA 12.2 requirements
- LAMMPS-GUI installation docs — Prebuilt packages include the OpenCL GPU package, no MPI, Windows signing prompts
- LAMMPS Windows installer notes — MS-MPI builds and OpenMP usage
- conda-forge lammps-feedstock — Package list of the conda build; CUDA builds use KOKKOS
- NVIDIA CUDA on WSL User Guide — No Linux driver inside WSL; install only the cuda-toolkit metapackage
- LAMMPS manual: pair_style eam — funcfl vs setfl formats, pair_coeff syntax, potential repositories
- LAMMPS manual: fix deform — erate units, barostatting the two lateral directions during tension, restart behavior
- LAMMPS manual: compute stress/atom — Units of pressure×volume, sign opposite to pressure
- NIST Interatomic Potentials Repository: Cu — List of Cu potentials and OpenKIM IDs
- Mishin et al., Phys. Rev. B 63, 224106 (2001) — Original paper for Cu_mishin1.eam.alloy
- MatSci forum: mpirun launches multiple runs — Diagnosing N serial copies when MPI is not linked
- MatSci forum: fix npt + fix deform — Experience thread: which directions to barostat during tension, and MD strain-rate magnitudes
- MatSci forum: Regarding uniaxial tensile test — Experience thread: do not barostat the pulled direction
- MatSci forum: GPU package compilation — Experience thread: mixing CMake with make yes-gpu fails; GPU_API defaults to OpenCL
- MatSci forum: There is an error with the GPU implemented — Experience thread: CUDA Toolkit newer than the driver breaks GPU runs
- Gravelle et al., A Set of Tutorials for the LAMMPS Simulation Package, LiveCoMS 6, 3037 (2025) — LAMMPS-GUI based tutorial collection co-written by LAMMPS developers
- Tsinghua TUNA mirror: Anaconda mirror help — custom_channels setup for conda-forge and conda clean -i
- SCUT scientific computing platform: LAMMPS — Module and conda-environment deployments, executable names and Slurm scripts
- SJTU HPC documentation: LAMMPS — Module versions per cluster, -pk intel -sf intel usage, building on compute nodes
- CSDN: building LAMMPS with the quip package on an offline cluster without root — Experience post: CMake Each download failed! on an offline cluster and placing archives by hand
- LAMMPS source: tools/offline — init_caches.sh and use_caches.sh for offline build caches
- Sobereva: using Packmol to build initial MD structures (keinsci forum) — Experience post: tolerance 2.0 and add_box_sides 1.2 to avoid bad contacts across periodic boundaries
- Packmol User's Guide — pbc keyword available from 20.15.0
- TopoTools source topolammps.tcl — writelammpsdata requires a non-zero box; type IDs follow the alphabetical order of type names
- keinsci forum: a way to change the element order in a LAMMPS data file — Experience post: type order of data files exported from Materials Studio via OVITO differs from the force field
- LAMMPS manual: pair_style reaxff — Example of mapping elements to types in pair_coeff (C C N H)
- OVITO Python reference: DislocationAnalysisModifier — Global attributes total_line_length, cell_volume, length.1/n<ijk>
- CSDN: computing dislocation line length with Python ovito — Experience post: per-frame dislocation line length with OVITO Python
- CSDN: phase fractions and dislocation density with ovito+python — Experience post: workflow for per-frame dislocation density output in OVITO