Extra-pair force package - how to include in build script

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

‘‘‘

You just need to put three backticks (```) before and after the copied script test and it will be displayed properly quoted without any need for escaping.

The screen output from the compile command should indicate whether the compilation was successful and included the desired source files, but I see no place in the script where you copy the custom files into the EXTRA-PAIR folder. A git clone without copying would only work, if you clone a fork of LAMMPS and then select the branch where you have added your custom files to the package folder.

If the files are copied and compiled, you need to check, if the compilation was successful.
I see no check of that kind. So it could be that the compilation failed and that thus no new executable was copied to your bin folder and you are looking at an old executable.

Rather than going through the complexity of compiling on a remote cluster, I would actually do the testing first on a local machine.

Many thanks to Axel for reading my posting and his super helpful replies!

  1. Have just re-edited the text of build script as he advised with ‘‘‘ in order to make special characters not treated as special.

  2. As Axel noted, there are no places in script with copies of custom files. This is the original compile script provided by TACC in response to my need for LAMMPS with Voronoi++ package, but not these custom pair files. As is, it does a perfect job of creating an executable which runs perfectly well when I ask for a known pair style, pair_dpd.

I did not want to cloud reader’s mind with all the modifications I made (many hours worth) and which failed. These include “cp” statements at various points in the download and compile script, as well as breaking the script into two different shell scripts, and copying pair_XXX.cpp and pair_XXX.h by hand into src directory (also src/EXTRA-PAIR directory) after running the first script and before the second.

I did not want to write a tedious list of my failures. The devil may be in the details. Something I tried may have been almost correct … say I divided the compile shell script into two at the wrong point?

Instead, I would welcome how a knowledgeable reader would begin with the working compile script and do the task of making LAMMPS recognize a new pair style pair_XXX. Many thanks!!!

You used the wrong type of quotes. These are single quotes not backticks. Just look at your original post. Has it become more readable? Is the script properly quoted?

We appreciate your trying to be helpful but the opposite is the case. Instead of clouding our minds you are now obscuring the problem.

The main problem here is twofold:

  1. You seem to be assuming that the cause of your problem is the shell script to compile. That excludes other possible points of failure like the environment module loading step, cmake configuration step, the compilation step, the copy of the executable.
  2. There are no details provided about the actual execution as recorded by the batch submission in a file containing your standard and your error output to the console. There is no evidence that each of the steps I mentioned were successful. Given the age of your source code, it is quite possible that it predates some refactoring steps in the LAMMPS source code and needs adjustments to be compiled without error. This is the by far most common cause of failure when people try to compile an updated LAMMPS with some custom source code.

Perhaps it would help if you have a(nother) look at the (sticky) post about forum guidelines and suggestions.

Hi All,

Thanful to Axel for his reply! As Axel notes, the error can be from many sources.

About the builid script: Full disclosure: I do not understand all but the most obvious steps in the download/compile script I posted. I was hoping someone else would. Like:

“Aha, I see where you are overwriting your src directory cloned at the top of the script in these later lines. Even though immediately after cloning the git repo you tried altering the code in an existing pair style file, say one named “pair_dpd.cpp/h” … your version of “cp pair_dpd.cpp” will be overwritten ….” or

”Aha, this is where in the download/compile script you can slip your new style into the source by inserting “cp pair_XXX.cpp src/EXTRA-PAIR” and “cp pair_XXX.cpp src/EXTRA-PAIR” commands .”

About errors: There is sadly nothing written into slurmXXX.err and slurmXXX.out files. The files are created but blank.

More about errors: Below are the last few lines of log.lammps telling me the code halted execution b/c it cannot find the files that, in several unsuccessful ways, I tried to appear as a pair_XXX.o file.

login4.stampede3(1038)$ tail log.lammps

variable uIrani equal 0.0

variable oneplusu equal 1.0+${uIrani}

variable oneplusu equal 1.0+0

variable oneplus2u equal 1.0+2.0*${uIrani}

variable oneplus2u equal 1.0+2.0*0

pair_style amy { {Tempr} } {Dmax} 3297

pair_style amy 0 ${Dmax} 3297

pair_style amy 0 2.8 3297

ERROR: Unrecognized pair style ‘amy’ (../force.cpp:239)

Last input line: pair_style amy { {Tempr} } {Dmax} 3297

Details on latest unsuccessful way of trying to solve the problem:
Downloaded source from github in a compile script as in original message … in other words this download was via the commands below:

Copied pair_amy.cpp and pair_amy_h into src/EXTRA-PAIR directory

Ran compile script from step after the downloading source … in other words, now skipping over the commands below

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 https://github.com/lammps/lammps.git "${SRC_DIR}"
mkdir -p "${BIN_DIR}"
```

I still cannot read your scripts and it is not clear what you run when.
For anything that you run interactively, you should be able to redirect the output.

At any rate, this is becoming worse that playing 20 questions and extremely
time consuming to resolve through forum (or email) communication.
There is no shame in focusing on research and requiring help with
technical problems, but you have to ask for the right help in the right way.

My suggestions thus is: try finding a (software engineering?) student with
experience in compiling software on Linux. That person can look over
your shoulder and correct basic mistakes and collect the information we
need to provide the proper, LAMMPS-specific advice. In principle, the issue
should be solvable simply by using information in the LAMMPS manual.
There should be a way to properly compensate the student for the effort, too.

Will do, Axel! Many thanks.