Error installing the Python Module together with the USER-NNP package

Hello,
I can independently compile LAMMPS with the NNP-package following the classical way:
cd src
make libnnpif
export LD_LIBRARY_PATH=/lib:${LD_LIBRARY_PATH}
cd /
ln -s lib/nnp
cp -r src/interface/LAMMPS/src/USER-NNP /src
cd /src
make yes-user-nnp
make serial

I can also compile the python module with the default packages by following:

mkdir build
cd build
*cmake -C …/cmake/presets/basic.cmake -D BUILD_SHARED_LIBS=on *

  •  -D LAMMPS_EXCEPTIONS=on -D PKG_PYTHON=on ../cmake*
    

cmake --build .
cmake --install .

I also realized that I can add packages by adding to the cmake command the following (in this case USER-PHONON package):

-C …/cmake/presets/basic.cmake -D BUILD_SHARED_LIBS=on -D LAMMPS_EXCEPTIONS=on -D PKG_PYTHON=on -DPKG_PHONON=yes …/cmake

However, the problem comes when I add the -DPKG_NNP=yes command, at the end of the day it tells me that this package is not recognized. Is there an way to solve this problem, i.e. to combine the python module together with NNP-package?

Thank you in advance for your help.
Jon

There is no USER-NNP package in the LAMMPS distribution and by copying the code from the repository into the LAMMPS tree and using the cmake compilation strategy, you will not get a consistent build.

That package has been integrated into LAMMPS under the name “ML-HDNNP” and thus no copying is needed. Instead, when configuring with CMake the libnnpif library will be downloaded and built automatically when you simply add “-DPKG_ML-HDNNP=on”.
Please see the documentation: 6.2. Package details — LAMMPS documentation

Thank you Axel for your reply, I have been reading more deeply about the nnp and ML-HDNNP packages, I understand now. I have been trying to compile lammps the way you tell me. However, I get the an error which I am not able to overcome during the compilation process. If I compile it without the package, there is no error:

cmake -C …/cmake/presets/basic.cmake -D BUILD_SHARED_LIBS=on -D LAMMPS_EXCEPTIONS=on -D PKG_PYTHON=on …/cmake

However, when I include the package:

cmake -C …/cmake/presets/basic.cmake -D BUILD_SHARED_LIBS=on -D LAMMPS_EXCEPTIONS=on -D PKG_PYTHON=on -D PKG_ML-HDNNP=on …/cmake

After downloading the package, it gives me this error:

[ 1%] No update step for ‘n2p2_build’
[ 1%] Performing patch step for ‘n2p2_build’
[ 1%] No configure step for ‘n2p2_build’
[ 2%] Performing build step for ‘n2p2_build’
CMake Error at /Users/jonzubeltzusese/Desktop/software/lammps-23Jun2022/build/n2p2_build-prefix/src/n2p2_build-stamp/n2p2_build-build-RelWithDebInfo.cmake:49 (message):

  • Command failed: 2*

  • ‘/usr/bin/make’ ‘-f’ ‘makefile’ ‘libnnpif’ ‘INTERFACES=LAMMPS’ ‘COMP=llvm’ ‘PROJECT_OPTIONS=-I/usr/local/Cellar/open-mpi/4.1.4/include’ ‘PROJECT_DEBUG=’ ‘PROJECT_CC=/Library/Developer/CommandLineTools/usr/bin/c++’ ‘PROJECT_MPICC=/Library/Developer/CommandLineTools/usr/bin/c++’ ‘PROJECT_CFLAGS=-fPIC -O2 -g -DNDEBUG -std=c++11’ ‘PROJECT_AR=/Library/Developer/CommandLineTools/usr/bin/ar’ ‘APP_CORE=nnp-convert’ ‘APP_TRAIN=nnp-train’ ‘APP=nnp-convert’*

  • See also*

  • /Users/jonzubeltzusese/Desktop/software/lammps-23Jun2022/build/n2p2_build-prefix/src/n2p2_build-stamp/n2p2_build-build-.log

When I check this file, this is what it comes:

more /Users/jonzubeltzusese/Desktop/software/lammps-23Jun2022/build/n2p2_build-prefix/src/n2p2_build-stamp/n2p2_build-build-.log*
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
In file included from Atom.cpp:17:
In file included from ./Atom.h:20:
In file included from ./Vec3D.h:21:
In file included from /Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/cmath:308:
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/math.h:300:15: fatal error: ‘math.h’ file not found
#include_next <math.h>

  •          ^~~~~~~~*
    

1 error generated.

It can not find the <math.h> library, I have been googling this error and although trying many things, i can not fix it. I must admit that I am not an expert on this. Do you have any idea about the origin and solution to this problem?
Thank you in advance

This is a failure of the nnp library that seems to expect that it is compile within a git checkout.
You have to report that to the developers of that library. The LAMMPS developers cannot do much about it. This doesn’t happen if LAMMPS is downloaded as a git checkout, e.g. with:

git clone --depth 100 --branch stable https://github.com/lammps/lammps.git lammps-git

If I download lammps as a git checkout the git errors are solved, however, the one about “math.h” persists and I can not compile it:

[email protected] build % more /Users/jonzubeltzusese/Desktop/software/lammps-git/build/n2p2_build-prefix/src/n2p2_build-stamp/n2p2_build-build-*.log
In file included from Atom.cpp:17:
In file included from ./Atom.h:20:
In file included from ./Vec3D.h:21:
In file included from /Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/cmath:308:
/Library/Developer/CommandLineTools/usr/bin/…/include/c++/v1/math.h:300:15: fatal error: ‘math.h’ file not found
#include_next <math.h>
^~~~~~~~
1 error generated.
make[4]: *** [Atom.o] Error 1
make[3]: *** [libnnp] Error 2

That you have to thank the Apple engineers for. I didn’t notice any mention that you are trying to compile under MacOS (this is why I keep reminding people to always report LAMMPS version and platform)
You should be able to work around this specific issue by adding -C ../cmake/presets/clang.cmake to your CMake command line so CMake will pick up the correctly working compiler binary instead of the (broken) symlink under a generic name.

It think it is mentioned in the LAMMPS manual, but since there are so many details with respect to compiling (since LAMMPS has so many options and supports many platforms and features), it is easy to overlook.

My god, it works now. During the last hour I also tried to compile it in another older mac (sorry for not specifying the platform, my bad) macOS high sierra 10.13 and there the -C …/cmake/presets/basic.cmake works! So I guess is a problem with the newest versions of macOS.
Thank you very much Axel, if sometime I see you in person I will invite you for a beer.

1 Like

Please note the clang.cmake preset is in addition to the basic.cmake preset.
These can be used in series. One changes compiler names and settings, the other selects packages.

Make sure your wallet is stuffed, I have an eclectic taste, and I live in a city where you can practice :beer: (E.g. I live only 2 1/2 blocks away from the famous “Monk’s Cafe and Beer Emporium”)