Installation
This guide walks you through compiling LAMMPS 3 Mar 2020 with the
custom bond/create/random
fix needed for the generate_InitCond
polymer-network examples. Two build environments are supported:
Harvard FASRC-style cluster (CMake, GCC ≥ 14, Open MPI modules)
macOS (Conda environment, CMake, Open MPI)
Note
The bond/create/random
fix is not part of vanilla 3 Mar 2020.
We patch it in manually from the
pdebuyl/lammps *fbc_random* branch.
Prerequisites (Harvard cluster)
Start an interactive job:
salloc -p test --mem 4G -t 0-3:00
Load build tools:
module avail # confirm available module names module load cmake/3.31.6-fasrc01 module load gcc/14.2.0-fasrc01 module load openmpi/5.0.5-fasrc01
Download and unpack LAMMPS 3 Mar 2020:
wget https://download.lammps.org/tars/lammps-3Mar2020.tar.gz tar -xf lammps-3Mar2020.tar.gz cd lammps-3Mar2020
Add the patched fix (create the directory if absent):
mkdir -p src/MC cp /path/to/fix_bond_create_random.cpp src/MC/ cp /path/to/fix_bond_create_random.h src/MC/
Configure & build (Harvard cluster)
Create a build directory:
mkdir build && cd build
Configure with CMake (MPI build):
cmake ../cmake -DBUILD_MPI=on
Enable required packages (old package names):
cmake -DPKG_MC=on \ -DPKG_MOLECULE=on \ -DPKG_USER-MISC=on \ -DPKG_USER-COLVARS=on .
Compile:
cmake --build . -j$(nproc)
The resulting executable will be in:
build/lmp
Sanity check
Verify that the new fix is available:
./lmp -h | grep bond/create/random
Expected output:
bond/create/random Create bonds (random partner selection) [MC]
Prerequisites (macOS)
Install Conda and create a new environment:
# Assumes Miniconda or Anaconda is already installed conda create -n lammps_env conda activate lammps_env
Install compilers and tools via Conda:
conda install -c conda-forge cxx-compiler conda install -c conda-forge cmake=3.31.6 conda install -c conda-forge openmpi
Configure & build (macOS)
Download and unpack LAMMPS 3 Mar 2020 (same as step 3 above):
curl -O https://download.lammps.org/tars/lammps-3Mar2020.tar.gz tar -xf lammps-3Mar2020.tar.gz cd lammps-3Mar2020
Add the patched fix (same as step 4 above).
Create a build directory:
mkdir build && cd build
Configure with CMake (specify C++14 standard):
cmake ../cmake -DCMAKE_CXX_STANDARD=14
Enable required packages:
cmake -DPKG_MC=on \ -DPKG_MOLECULE=on \ -DPKG_USER-MISC=on \ -DPKG_USER-COLVARS=on .
Compile (same as in step 8 above):
cmake --build . -j$(sysctl -n hw.ncpu)
The executable will be in:
build/lmp
Optional: Python wrapper
If you plan to control LAMMPS from Jupyter or NumPy, install the Cython wrapper:
pip install --user lammps-cython
Troubleshooting
“Package MC is not enabled” Re-run CMake with
-DPKG_MC=on
and rebuild.“New bond exceeded bonds per atom …” Increase your
maxbond
setting in thebond/create/random
command or raiseextra/special/per/atom
in theread_data
section.