ERROR: Unrecognized pair style

Hi I have downloaded LAMMPS and the first couple of examples seem to work ok, but when I go to perform more specialized examples, specifically granular and meam there are compilation issues.

The errors seem to be related to the force


LAMMPS (2 Aug 2023 - Update 3)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
  using 1 OpenMP thread(s) per MPI task
...
...
...
ERROR: Unrecognized pair style 'meam' is part of the MEAM package which is not enabled in this LAMMPS binary. (src/force.cpp:271)
Last command: pair_style	meam

ERROR: Unrecognized pair style 'granular' is part of the GRANULAR package which is not enabled in this LAMMPS binary. (src/force.cpp:271)
Last command: pair_style      granular

I went to the src directory and performed: make force

error message:

make force
g++     force.cpp   -o force
In file included from force.h:17,
                 from force.cpp:14:
pointers.h:27:10: fatal error: mpi.h: No such file or directory
   27 | #include <mpi.h>        // IWYU pragma: export
      |          ^~~~~~~
compilation terminated.
make: *** [<builtin>: force] Error 1

I got an error with mpi

I verified that MPI was already installed on the system

I used the following environmental variables to ensure the correct MPI wrappers are used


export CC=mpicc
export CXX=mpicxx
export FC=mpif90
make clean-all
make mpi

issues persisted.

Other steps I took:

I copied the lammps executable from the downladed binaries and put it in the folder with the examples. I still encountered the same issues.

I did git clone


git clone -b release https://github.com/lammps/lammps.git mylammps
Cloning into 'mylammps'...
remote: Enumerating objects: 387222, done.
remote: Counting objects: 100% (2138/2138), done.
remote: Compressing objects: 100% (1065/1065), done.
remote: Total 387222 (delta 1250), reused 1873 (delta 1068), pack-reused 385084
Receiving objects: 100% (387222/387222), 708.80 MiB | 3.69 MiB/s, done.
Resolving deltas: 100% (324276/324276), done.
Updating files: 100% (13140/13140), done.

in this case I think the make force proceeded somewhat more, but it still got an error, and still had issues with unrecognized paeir style


make force
mpicxx     force.cpp   -o force
/usr/bin/ld: /tmp/ccPKQCd5.o: warning: relocation against `_ZTIN9LAMMPS_NS11AngleHybridE' in read-only section `.text'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: /tmp/ccPKQCd5.o: in function `LAMMPS_NS::Force::Force(LAMMPS_NS::LAMMPS*)':
force.cpp:(.text+0x229): undefined reference to `LAMMPS_NS::utils::strdup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
...
...
...
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
make: *** [<builtin>: force] Error 1

Also meam and granular seem to be up to date:

make GRANULAR
make: 'GRANULAR' is up to date.
make MEAM
make: 'MEAM' is up to date.

Any help appreciated

Thanks

No, they are not. As the error message tells you, your LAMMPS executable has only a subset of the features enabled and is missing the MEAM and GRANULAR packages. The reference to the force.cpp file is merely because LAMMPS creates instances of pair styles in the Force class.

Why???

Also this makes no sense.

This makes no sense as well.

LAMMPS comes with detailed compilation instructions in the LAMMPS manual. Outside of the git clone step, nothing you did is mentioned anywhere in the documentation, so I am wondering where you got these instructions. Clearly not from a reliable source.

Build instructions are in this section of the manual: 3. Build LAMMPS — LAMMPS documentation
I strongly suggest that you use the CMake based build instructions.

After a fresh clone of the LAMMPS sources, you can get a fairly complete LAMMPS executable with:

cmake -S cmake -B build -C cmake/presets/most.cmake
cmake --build build

You can speed up compilation with adding --parallel 8 assuming that you have 8 CPU cores on your machine.

After that you should have a fairly complete LAMMPS executable in build/lmp.
If MPI and OpenMP are properly installed and available, those will be used automatically, also support for PNG and JPEG images, compressed output files and so on.
Additional packages can be added and features selected by running CMake again with the proper arguments and then recompiling as above.

Thank you for the input.

I went though the cmake instructions.

after it was installed I found that the packages were not enabled so I did make yes-all


~/mylammps/src$ make ps
Installed YES: package ADIOS
..
Installed YES: package GRANULAR
..
..

Then I copied the granular example to a new folder and tried to build it and got the same error


~/mylammps/test/granular$ lmp -in in.pour.drum
LAMMPS (2 Aug 2023 - Update 3)
OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98)
  using 1 OpenMP thread(s) per MPI task
Created orthogonal box = (0 0 0) to (30 30 50)
  1 by 1 by 1 MPI processor grid
Changing box ...
ERROR: Unrecognized pair style 'granular' is part of the GRANULAR package which is not enabled in this LAMMPS binary. (src/force.cpp:271)
Last command: pair_style      granular

I thought maybe it is because I have to build lammp again after making the changes as per these instructions:

Recompile After Changes:
Whenever you edit LAMMPS source files, enable or disable packages, or change build options, recompile with:

cmake --build .

but when I tried to do it I got this error

cmake --build .
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- Appending /opt/intel/oneapi/compiler/2024.1/lib to CMAKE_LIBRARY_PATH: /opt/intel/oneapi/compiler/2024.1/lib
-- Running check for auto-generated files from make-based build system
CMake Error at Modules/StyleHeaderUtils.cmake:176 (message):
  

  ########################################################################

  Found package(s) installed by the make-based build system

  

  Please run

  make -C /home/mylammps/src no-all purge

  to uninstall

  ########################################################################
Call Stack (most recent call first):
  CMakeLists.txt:617 (DetectBuildSystemConflict)


-- Configuring incomplete, errors occurred!
See also "/home/mylammps/build/CMakeFiles/CMakeOutput.log".
gmake: *** [Makefile:11891: cmake_check_build_system] Error 1

so then I run the command as prompted

make -C /home/mylammps/src no-all purge

when I tried to build again it was much faster than the initial build

~/mylammps/build$ cmake --build . -- -j 8
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- GLOB mismatch!
-- Appending /opt/intel/oneapi/compiler/2024.1/lib to CMAKE_LIBRARY_PATH: /opt/intel/oneapi/compiler/2024.1/lib
-- Running check for auto-generated files from make-based build system
-- Generating style headers...
-- Generating package headers...
-- Generating lmpinstalledpkgs.h...
-- Could NOT find ClangFormat (missing: ClangFormat_EXECUTABLE) (Required is at least version "8.0")
-- The following tools and libraries have been found and configured:
 * Git
 * MPI
 * OpenMP
 * JPEG
 * PNG
 * ZLIB

-- <<< Build configuration >>>
   LAMMPS Version:   20230802 stable_2Aug2023_update3
   Operating System: Linux Ubuntu" 22.04
   CMake Version:    3.25.1
   Build type:       RelWithDebInfo
   Install path:     /home/.local
   Generator:        Unix Makefiles using /usr/bin/gmake
-- Enabled packages: <None>
-- <<< Compilers and Flags: >>>
-- C++ Compiler:     /usr/bin/c++
      Type:          GNU
      Version:       11.4.0
      C++ Flags:     -O2 -g -DNDEBUG
      Defines:       LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=4;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP;LAMMPS_FFMPEG
-- <<< Linker flags: >>>
-- Executable name:  lmp
-- Static library flags:    
-- <<< MPI flags >>>
-- MPI_defines:      MPICH_SKIP_MPICXX;OMPI_SKIP_MPICXX;_MPICC_H
-- MPI includes:     /usr/lib/x86_64-linux-gnu/openmpi/include;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi
-- MPI libraries:    /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so;/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so;
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mylammps/build
[  0%] Built target bond.h
[  0%] Built target angle.h
[  0%] Built target comm.h
[  0%] Built target command.h
[  0%] Built target atom.h
[  0%] Built target citeme.h
-- Git Directory: /home/mylammps/.git
[  1%] Built target variable.h
[  2%] Built target fmt_core.h
[  2%] Built target fmt_format.h
[  2%] Built target dihedral.h
[  2%] Built target error.h
[  2%] Built target domain.h
[  3%] Built target compute.h
-- Generating lmpgitversion.h...
[  4%] Built target exceptions.h
[  4%] Built target fix.h
[  4%] Built target force.h
[  5%] Built target improper.h
[  5%] Built target gitversion
[  5%] Built target group.h
[  5%] Built target input.h
[  5%] Built target kspace.h
[  5%] Built target info.h
[  5%] Built target lammps.h
[  5%] Built target lattice.h
[  6%] Built target library.h
[  6%] Generating includes/lammps/lmppython.h
[  6%] Built target lmptype.h
[  6%] Built target modify.h
[  7%] Built target memory.h
[  7%] Built target neighbor.h
[  7%] Built target neigh_list.h
[  8%] Built target lmppython.h
[  8%] Built target pair.h
[  8%] Built target output.h
[  8%] Built target platform.h
[  8%] Built target pointers.h
[  8%] Built target region.h
[  9%] Built target timer.h
[  9%] Built target utils.h
[  9%] Built target universe.h
[  9%] Built target update.h
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/finish.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/comm.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/imbalance_neigh.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/error.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/info.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/input.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/library.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/lammps.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/lmppython.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/neighbor.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/read_restart.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/replicate.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/special.cpp.o
[  9%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/variable.cpp.o
[ 10%] Building CXX object CMakeFiles/lammps.dir/home/mylammps/src/write_restart.cpp.o
/home/mylammps/src/variable.cpp: In member function ‘int LAMMPS_NS::Variable::next(int, char**)’:
/home/mylammps/src/variable.cpp:786:14: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  786 |         fread(buf,1,64,fp);
      |         ~~~~~^~~~~~~~~~~~~
[ 10%] Linking CXX static library liblammps.a
[100%] Built target lammps
[100%] Building CXX object CMakeFiles/lmp.dir/home/mylammps/src/main.cpp.o
[100%] Linking CXX executable lmp
[100%] Built target lmp

and I still got the same error for pairs…

I was thinking maybe there were some old bits of lammp left, but I did perform make no-all purge as per the instructions. Not sure if it is something else I might have missed…

You must not mix the traditional make based LAMMPS build procedure with using CMake. No packages may be installed or a build been previously attempted in the LAMMPS source directory by using make <machine>. CMake will detect if this is the case and generate an error. To remove conflicting files from the src you can use the command make no-all purge which will uninstall all packages and delete all auto-generated files.

Thanks

Which ones exactly?

Did you follow the commands that I suggested in my previous post?
Apparently not. What is the purpose of asking for help if you a) don’t follow the advice given by people or b) follow the instructions given in the manual?

make yes-all is a very bad idea and the documentation about building with CMake clearly tells you that you must not mix CMake instructions/commands with GNU make instructions/commands. The CMake build uses a different mechanism to include packages which is not compatible with conventional make build.

But you didn’t make any changes to any of the LAMMPS sources though, so this statement clearly doesn’t apply to you here.

and deservedly so, since you did go against the warning from the manual.

This clearly states that you didn’t enable any packages during the CMake configuration step.

Here are my suggested instructions again. If you run this cmake configuration command you should

after the first CMake command, you should get as part of the CMake configuration summary this:

   Generator:        Unix Makefiles using /usr/bin/gmake
-- Enabled packages: AMOEBA;ASPHERE;BOCS;BODY;BPM;BROWNIAN;CG-DNA;CG-SPICA;CLASS2;COLLOID;COLVARS;COMPRESS;CORESHELL;DIELECTRIC;DIFFRACTION;DIPOLE;DPD-BASIC;DPD-MESO;DPD-REACT;DPD-SMOOTH;DRUDE;EFF;ELECTRODE;EXTRA-COMPUTE;EXTRA-DUMP;EXTRA-FIX;EXTRA-MOLECULE;EXTRA-PAIR;FEP;GRANULAR;INTERLAYER;KSPACE;LEPTON;MACHDYN;MANYBODY;MC;MEAM;MESONT;MISC;ML-IAP;ML-POD;ML-SNAP;MOFFF;MOLECULE;OPENMP;OPT;ORIENT;PERI;PHONON;PLUGIN;POEMS;QEQ;REACTION;REAXFF;REPLICA;RIGID;SHOCK;SPH;SPIN;SRD;TALLY;UEF;VORONOI;YAFF

Where both GRANULAR and MEAM are included in the list of packages.

You completely missed how packages are installed in the CMake process. Either you add them with -DPKG_GRANULAR=yes and -DPKG_MEAM=yes or you use a preset -C cmake/presets/most.cmake or a combination of both, e.g. with:

cmake -S cmake -B build -C cmake/presets/basic.cmake -DPKG_GRANULAR=yes -DPKG_MEAM=yes

If you had followed my suggestion from my previous post, you would have had a LAMMPS executable with a whole lot of packages installed, including the two that you desire to use.

You can always check the executable to see which packages are included. Here for the “most” preset:

$ ./build/lmp -h
Large-scale Atomic/Molecular Massively Parallel Simulator - 17 Apr 2024 - Development
Git info (develop / patch_17Apr2024-164-ge53cc86622)

Usage example: ./build/lmp -var t 300 -echo screen -in in.alloy
[...]

Installed packages:

AMOEBA ASPHERE BOCS BODY BPM BROWNIAN CG-DNA CG-SPICA CLASS2 COLLOID COLVARS 
COMPRESS CORESHELL DIELECTRIC DIFFRACTION DIPOLE DPD-BASIC DPD-MESO DPD-REACT 
DPD-SMOOTH DRUDE EFF ELECTRODE EXTRA-COMPUTE EXTRA-DUMP EXTRA-FIX 
EXTRA-MOLECULE EXTRA-PAIR FEP GRANULAR INTERLAYER KSPACE LEPTON MACHDYN 
MANYBODY MC MEAM MESONT MISC ML-IAP ML-POD ML-SNAP MOFFF MOLECULE OPENMP OPT 
ORIENT PERI PHONON PLUGIN POEMS QEQ REACTION REAXFF REPLICA RIGID SHOCK SPH 
SPIN SRD TALLY UEF VORONOI YAFF 

[...]

Bottom line, you have to be more careful when reading and following the documentation and more diligent in not doing anything that you just make up and that is not mentioned in the documentation.

Thank you for your continued help.

I appreciate your advise, at the time I felt more comfortable to try to follow the instructions as presented in the lammps website you recommended.

https://docs.lammps.org/Build_cmake.html

I thought things were going well, though I did have issues with linking LAMMPS as a library

cc1: fatal error: caller.c: No such file or directory
compilation terminated.

but figured it was more important to try to get the examples properly working at this stage. I felt this error was not something that would affect that so I proceeded. I will come back to see if issues persist after establishing successful installation in a different post.

Then I followed the instructions on ‘3.6.3. Make shortcuts for installing many packages’, which on second inspection it only applies for traditional build not cmake.


How I proceeded this time:

I deleted the previous folder

I downloaded the from git again following these instructions:

https://docs.lammps.org/Install_git.html

I did:

git clone -b release https://github.com/lammps/lammps.git mylammps
git checkout stable
git pull

inside the lammps directory, as recommended I performed the following instructions:

Note: I chose to have all packages, as I thought it could be useful for me.


cmake -S cmake -B build -C cmake/presets/all_on.cmake
loading initial cache file cmake/presets/all_on.cmake
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.34.1") 
-- Appending /opt/intel/oneapi/compiler/2024.1/lib to CMAKE_LIBRARY_PATH: /opt/intel/oneapi/compiler/2024.1/lib
-- Running check for auto-generated files from make-based build system
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at CMakeLists.txt:340 (find_package):
  By not providing "FindADIOS2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "ADIOS2", but
  CMake did not find one.


  Could not find a package configuration file provided by "ADIOS2" with any
  of the following names:

    ADIOS2Config.cmake
    adios2-config.cmake

  Add the installation prefix of "ADIOS2" to CMAKE_PREFIX_PATH or set
  "ADIOS2_DIR" to a directory containing one of the above files.  If "ADIOS2"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!
See also "/home/mylammps/build/CMakeFiles/CMakeOutput.log".

I did not see the output you mentioned, after I also tried with:
...most.cmake
to see if I would get a different output, but I got the same error.

Just in case the command worked and the error mentioned would not have an effect in the functions I was interested in, I tried the following:

~/mylammps$ cmake --build build --parallel 8
gmake: Makefile: No such file or directory
gmake: *** No rule to make target 'Makefile'.  Stop.

~/mylammps/build$ cmake --build build --parallel 8
Error: /home/mylammps/build/build is not a directory

~/mylammps/build$ cmake --build . --parallel 8
gmake: Makefile: No such file or directory
gmake: *** No rule to make target 'Makefile'.  Stop.

Any further help appreciated.

Thanks

And yet again, you are making up your own rules instead of following the given advice and thus you are messing up badly. I don’t like to interact with people that cannot follow advice given, thus this is my last response.

With the all_on.cmake preset you are enabling packages that need extra build steps before you can use those packages. It is practically impossible to compile LAMMPS with all packages enabled at the same time.

Because you didn’t delete the build folder before running the CMake configuration again.

You cannot compile when the CMake configuration fails.

I have nothing to add to my previous suggestions. When done correctly and without any misguided alteration, my suggestions work well (the most.cmake preset is carefully chosen to not include any packages that require additional steps). All errors and failures you are encountering are because you didn’t pay attention to the documentation (of LAMMPS and CMake) or the suggestions being given.
There is no helping for that.

Thank you for your time.

I was not aware that it is impossible to compile all packages enabled at the same time as you mentioned. I did not see any related warning in the manual, or elsewhere. It appears that my actions have frustrated you, it was never my intention. I understand that it makes it more difficult to provide assistance. I will keep it in mind in the future.

It works as expected.

I did have issues initially where I got the same error. My assumption is that even though I deleted all previous lammps, I think that maybe it was still referencing them. Hence I copied the executable from the build and put it in the folder with my tests and modified the command to reference that one. Mentioning it in case it is useful for someone encountering similar issues.

../lmp -in in.pour.drum

Thanks

It is theoretically possible, but you are including packages that require extra work and prerequisite software to be installed and configured in specific ways and doing all of that can become extremely complex and tedious. It is expected (and common sense!) that people read all relevant documentation including this part: 3.7. Packages with extra build options — LAMMPS documentation