LAMMPS setup with MPI
LAMMPS (Large-scale Atomic/Molecular Massively Parallel Simulator) is a classical molecular dynamics (MD) simulator designed for modeling atomic, polymeric, and coarse-grained systems. It is open-source and highly parallelized, making it suitable for running on high-performance computing clusters. Its versatility allows researchers to simulate a wide range of materials and phenomena, from simple liquids to complex biological molecules, under various physical conditions.
This guide shows how to build and run LAMMPS on Arch Linux using OpenMPI. It includes checking prerequisites, building from source, verifying MPI support, and running a sample simulation.
1. Install Required Tools
LAMMPS requires openmpi and cmake. First, verify if they are installed:
which openmpi
which mpicxx
which cmakeIf any are missing, install via pacman:
sudo pacman -S openmpi cmake git2. Clone LAMMPS Repository
Get the latest LAMMPS source code:
git clone https://github.com/lammps/lammps.git
cd lammps3. Build LAMMPS with MPI Support
Create a build directory and configure with CMake:
mkdir build && cd build
cmake ../cmake -D BUILD_MPI=YES
make -j$(nproc)This builds LAMMPS using all available CPU cores. And you will get a lmp named executable file which will be used in all LAMMPS calculations.
4. Verify MPI Support
Check if the built LAMMPS binary has MPI enabled:
cd ~/lammps/build/
./lmp -h | grep MPIIf MPI is listed, your LAMMPS build is ready for parallel execution.
5. Run a Sample Simulation
Test LAMMPS on a simple Lennard-Jones system using 2 MPI processes:
mpirun -np 2 ./lmp -in ../examples/UNITS/in.ar.ljThis command will start the simulation and output the trajectory, which can later be visualized using OVITO.