CompPhysVienna / n2p2

n2p2 - A Neural Network Potential Package
https://compphysvienna.github.io/n2p2/
GNU General Public License v3.0
214 stars 81 forks source link

LAMMPS NNP interface on macOS #173

Open TomaSusi opened 1 year ago

TomaSusi commented 1 year ago

After fudging around with the makefile (the one I've used is appended at the end of the post; for some reason I could not get Intel to work even though I run an Intel macOS), I've been able to successfully compile the n2p2 in a Conda environment to use with the pynnp calculator using the following install commands:

export CFLAGS=-isysroot/opt/MacOSX10.10.sdk/
export LDFLAGS=-L/opt/MacOSX10.10.sdk/usr/lib

cd src
make -j 8 all COMP=gnu
cd pynnp
make all COMP=gnu
pip install -e .

However, it seems this "all" does not cover the LAMMPS NNP interface. I tried to install it with the easy route, but I get a weird error:

(ase-n2p2) tomasusi@imacpro:~/git/n2p2/src$ make lammps-nnp
cd libnnp && /Applications/Xcode.app/Contents/Developer/usr/bin/make COMP=gnu MODE=static
cp Atom.h CompactFunction.h CoreFunction.h CutoffFunction.h Element.h ElementMap.h Log.h Mode.h NeuralNetwork.h Prediction.h Settings.h SetupAnalysis.h Stopwatch.h Structure.h SymFnc.h SymFncBaseComp.h SymFncBaseCompAng.h SymFncBaseCompAngWeighted.h SymFncBaseCutoff.h SymFncBaseExpAng.h SymFncCompAngn.h SymFncCompAngnWeighted.h SymFncCompAngw.h SymFncCompAngwWeighted.h SymFncCompRad.h SymFncCompRadWeighted.h SymFncExpAngn.h SymFncExpAngnWeighted.h SymFncExpAngw.h SymFncExpRad.h SymFncExpRadWeighted.h SymFncStatistics.h SymGrp.h SymGrpBaseComp.h SymGrpBaseCompAng.h SymGrpBaseCompAngWeighted.h SymGrpBaseCutoff.h SymGrpBaseExpAng.h SymGrpCompAngn.h SymGrpCompAngnWeighted.h SymGrpCompAngw.h SymGrpCompAngwWeighted.h SymGrpCompRad.h SymGrpCompRadWeighted.h SymGrpExpAngn.h SymGrpExpAngnWeighted.h SymGrpExpAngw.h SymGrpExpRad.h SymGrpExpRadWeighted.h Vec3D.h mpi-extra.h utility.h version.h ../../include
cd libnnpif && /Applications/Xcode.app/Contents/Developer/usr/bin/make COMP=gnu MODE=static INTERFACES=""
The following interfaces were selected: 
cp  ../../include
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-aclpsvXx] source_file ... target_directory
make[1]: *** [headers] Error 64
make: *** [libnnpif] Error 2

It seems that the copy command is only getting one argument, perhaps because the interfaces keyword is empty..? Any idea what this could be about?


Here's my makefile.gnu:

#!/bin/make -f

###############################################################################
# EXTERNAL LIBRARY PATHS
###############################################################################
# Enter here paths to GSL or EIGEN if they are not in your standard include
# path. DO NOT completely remove the entry, leave at least "./".
PROJECT_GSL=${HOME}/miniconda3/envs/ase-n2p2/include/gsl/
PROJECT_EIGEN=${HOME}/miniconda3/envs/ase-n2p2/include/eigen3/

###############################################################################
# COMPILERS AND FLAGS
###############################################################################
PROJECT_CC=clang++
PROJECT_MPICC=mpicc
# OpenMP parallelization is disabled by default, add flag "-fopenmp" to enable.
PROJECT_CFLAGS=-lstdc++ -O3 -march=native -std=c++11 -isysroot/opt/MacOSX10.10.sdk/ -target x86_64-apple-darwin
PROJECT_CFLAGS_MPI=-Wno-long-long
PROJECT_LDFLAGS=-L/opt/MacOSX10.10.sdk/usr/lib
PROJECT_DEBUG=-g -pedantic-errors -Wall -Wextra
PROJECT_TEST=--coverage -fno-default-inline -fno-inline -fno-inline-small-functions -fno-elide-constructors
PROJECT_AR=ar
PROJECT_ARFLAGS=-rcsv
PROJECT_CFLAGS_BLAS=
PROJECT_LDFLAGS_BLAS=-lblas -lgsl -lgslcblas
TomaSusi commented 1 year ago

Ah, just writing this made me realize that I can install with

make -j 8 all COMP=gnu INTERFACES=LAMMPS

which appears to work; however, I'm a bit confused where the resulting binary lmp_mpi should be located, as it is not in n2p2/bin.