On the advice of Axel K, I post my issue here so the answer is not just for me, but helps others. I will try to be maximally concise yet informative, and welcome anyone asking for more or less info. I am grateful to you for your (unpaid) time!
Broad statement of issue:
I want LAMMPS to use a user-defined force of type XXX …. not found within lammps/src at develop · lammps/lammps · GitHub … but rather defined by files that I would name pair_XXX.cpp and pair_XXX.h.
Typical error upon running of executable:
ERROR: Unrecognized pair style ‘XXX’ (../force.cpp:239)
Question succinctly stated:
How do I modify the build script (below) so the executable recognizes the new pair force?
In particular:
>Is there cmake command needed be sure that the EXTRA-PAIR package is dealt with properly?
>If .cpp/.h files just need to live in the src/EXTRA-PAIR directory, at what stage in the build script below should I either break the script in two pieces to cp the files in, or perhaps insert that logic into the script to copy them there?
Details:
System: NSF TACC Stampede3 supercomputer, with “skx” nodes (48 cores per node, 1 processing thread per core).
LAMMPS Version: 2 Sept 2026 version of LAMMPS obtained by asking for a git clone from https://github.com/lammps/lammps.git
How executable is built: Using CMake utility. Build shell script to make executable lmp_stampede is below – with huge credit to TACC consulting staff who wrote it!
Extra packages: To calculate Voronoi volumes around particles, we ask for Voro++ which is downloaded and built by LAMMPS CMake itself.
Command to run LAMMPS on SLURM job queue:
sbatch -A AccountName Make_run.sh
Here is Make_run.sh:
#!/bin/bash
#SBATCH -p skx-dev # partition (queue)
#SBATCH -n 32 # number of cores
#SBATCH --job-name=“june26_1e-6” # job name
#SBATCH -o slurm.%N.%j.out # STDOUT
#SBATCH -e slurm.%N.%j.err # STDERR
#SBATCH -t 00:10:00
#SBATCH -N 1 # number of nodes
module load intel/24.0
module load impi/21.11
export OMP_NUM_THREADS=1
ibrun lmp_stampede -in input_XXX > output_XXX
Here is shell to bring down source code from github and build executable …
Thanks to Axel for teaching me that enclosing special characters in ‘‘‘ will make them readable!
# ================================================
#
# build_lammps_2Sep2026_voronoi_cmake.sh
#
# Version: 2Sep26
# System: Stampede3, TACC
# CMake version of the original traditional-make build
#
# ================================================
# MODULES
module reset
module load intel/24.0
module load impi/21.11
module load cmake/4.1.1
# LAMMPS 2Sep2026 requires CMake >= 3.20.
# Load a CMake module here if the default cmake is older than 3.20.
# module load cmake
cmake --version
# DOWNLOAD LAMMPS
VERSION=patch_2Sep2026
ROOT_DIR=$(pwd)
SRC_DIR={ROOT_DIR}/{VERSION}
BUILD_DIR=${SRC_DIR}/build-stampede
BIN_DIR=${SRC_DIR}/bin
if [[ -e “${SRC_DIR}” ]]; then
echo "ERROR: ${SRC_DIR} already exists."
echo "Remove/rename it before running this clean-build script."
exit 1
fi
git clone -b “${VERSION}” --single-branch{SRC_DIR}
mkdir -p “${BIN_DIR}”
# COMPILERS
# Match the original Intel MPI + oneAPI Intel compiler configuration.
export I_MPI_CC=icx
export I_MPI_CXX=icpx
# CONFIGURE LAMMPS
#
# Original make configuration:
# make yes-most
# make no-ext
# make no-gpu
# make no-intel
# make yes-voronoi
#
# CMake’s most.cmake is the supported counterpart to “make yes-most”.
# Explicit package settings below preserve the original exclusions and
# make the intended configuration obvious.
#
# Voro++ is downloaded and built by LAMMPS CMake itself.
cmake -S “${SRC_DIR}/cmake" -B "${BUILD_DIR}” \
-C "${SRC_DIR}/cmake/presets/most.cmake" \\
-D CMAKE_BUILD_TYPE=RelWithDebInfo \\
-D CMAKE_C_COMPILER=mpicc \\
-D CMAKE_CXX_COMPILER=mpicxx \\
-D CMAKE_C_FLAGS_RELWITHDEBINFO="-O3 -g -xCORE-AVX512 -diag-disable=cpu-dispatch" \\
-D CMAKE_CXX_FLAGS_RELWITHDEBINFO="-O3 -g -xCORE-AVX512 -diag-disable=cpu-dispatch" \\
-D BUILD_MPI=yes \\
-D BUILD_OMP=yes \\
-D FFT=MKL \\
-D FFT_MKL_THREADS=no \\
-D PKG_GPU=no \\
-D PKG_INTEL=no \\
-D PKG_VORONOI=yes \\
-D DOWNLOAD_VORO=yes \\
-D LAMMPS_MACHINE=stampede
#-D PKG_COMPRESS=no \
# BUILD LAMMPS
cmake --build “${BUILD_DIR}” --parallel 8
# COPY EXECUTABLE TO bin/, matching the location used by the old script.
# LAMMPS_MACHINE=stampede names the executable lmp_stampede.
cp -f “${BUILD_DIR}/lmp_stampede" "${BIN_DIR}/lmp_stampede”
# SUMMARY
printf ‘\nLAMMPS build completed successfully.\n’
printf ‘Executable: %s\n’ “${BIN_DIR}/lmp_stampede”
“${BIN_DIR}/lmp_stampede” -h | head -n 30
‘‘‘