A modified fene/expand bond compilation

I wanted to add a modified version of the fene_expand bond where the bond and the WCA are shifted by different constants:

E = -\frac{K R_0^2}{2} \ln \left[ 1 - \left( \frac{r - \Delta_1}{R_0} \right)^2 \right] + U_{LJ} \left( \frac{\sigma}{r - \Delta_2} \right)

I took the fene_expand code and created a modified fene_expand2. Results are on my github.

I am compiling (on a cluster) with

#!/bin/bash

BUILD_NAME=dev_my
cd lammps
mkdir build_${BUILD_NAME}
cd build_${BUILD_NAME}

module purge
module load intel/19.1.1.217
module load intel-mpi/intel/2019.7

cmake3 -D CMAKE_INSTALL_PREFIX=$HOME/.local \
-D LAMMPS_MACHINE=della_${BUILD_NAME} \
-D ENABLE_TESTING=no \
-D BUILD_MPI=no \
-D BUILD_OMP=yes \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_COMPILER=icpc \
-D CMAKE_CXX_FLAGS_RELEASE="-Ofast -xHost -qopenmp -restrict -DNDEBUG" \
-D PKG_MOLECULE=yes \
-D PKG_RIGID=yes \
-D PKG_KSPACE=yes -D FFT=MKL -D FFT_SINGLE=yes \
-D PKG_INTEL=yes \
-D PKG_EXTRA-PAIR=yes \
-D INTEL_ARCH=cpu -D INTEL_LRT_MODE=threads ../cmake

make -j 10
make install

and I am getting

In file included from /home/polyachenkoya/software/lammps/build_dev_my/styles/style_bond.h(4),
                 from /home/polyachenkoya/software/lammps/src/force.cpp(101):
/home/yp1065/software/lammps/src/MOLECULE/bond_fene_expand2.h(16): error: identifier "BondFENEExpand2" is undefined
  BondStyle(fene/expand2, BondFENEExpand2);

I tried to find if there are any extra places where fene_expand is mentioned by running

grep -nHIrF -- bond_fene_expand

and

grep -nHIrF -- BondFENEExpand

in my root lammps directory and the src parts (I did not implement docs and other stuff) of both outputs look identical for bond_fene_expand / bond_fene_expand2 and BondFENEExpand / BondFENEExpand2.

So I am having trouble finding how my code for bond/fene/expand2 is different from the existing bond/fene/expand so that one compiles but not the other.

There is a bug in your bond_fene_expand2.h file. You have:

#ifndef LMP_BOND_FENE_EXPAND_H
#define LMP_BOND_FENE_EXPAND_H

But the same define is also set by bond_fene_expand.h and thus if the new include file is read, the definition of the new class is skipped because of this define to protect from multiple inclusion.

Try changing it to:

#ifndef LMP_BOND_FENE_EXPAND2_H
#define LMP_BOND_FENE_EXPAND2_H

The same applies to the OPENMP version.

Yes, it helped, thank you!

There were a few other bugs after this but it’s all working now.