How to compile LAMMPS with polymlp on macOS (arm) with conda-forge compilers

conda create -n lammps
conda activate lammps
conda install compilers tree

Supposed directory structure:

% tree lammps lammps-polymlp-package -d -L 1 
lammps
├── bench
├── cmake
├── doc
├── examples
├── fortran
├── lib
├── potentials
├── python
├── src
├── tools
└── unittest
lammps-polymlp-package
├── lib
└── src

Go to LAMMPS source code directory (lammps). In the following of this post, shell commands are performed with respect to this directory.

Copy source code of polymlp in LAMMPS source code directory.

% cp -r ../lammps-polymlp-package/lib/polymlp lib/
% cp -r ../lammps-polymlp-package/src/POLYMLP src/

Add polymlp to the list of PACKAGE in src/Makefile

cat src/Makefile
...
PACKAGE = \
        adios \
        amoeba \
...
        poems \
        polymlp \
        ptm \
...
        ml-iap \
        phonon
...

Modify lib/polymlp/Makefile.lammps

% cat lib/polymlp/Makefile.lammps
polymlp_INC = -fopenmp -DLAMMPS_EXCEPTIONS
polymlp_PATH = -L../../lib/polymlp
polymlp_SYSINC = -I${CONDA_PREFIX}/include
polymlp_SYSLIB = -L${CONDA_PREFIX}/lib -lomp

Copy a specific Makefile for setting conda environment.

% cp src/MAKE/Makefile.serial src/MAKE/Makefile.conda

Modify src/MAKE/Makefile.conda

% cat src/MAKE/Makefile.conda
...
CC =            ${CONDA_PREFIX}/bin/clang++
CCFLAGS =       -g -O3 -std=c++11
SHFLAGS =       -fPIC
DEPFLAGS =      -M

LINK =          ${CONDA_PREFIX}/bin/clang++
LINKFLAGS =     -g -O3 -std=c++11
LIB =
SIZE =          size

ARCHIVE =       ${CONDA_PREFIX}/bin/ar
ARFLAGS =       -rc
SHLIBFLAGS =    -shared -rdynamic
...

Make LAMMPS with polymlp

% ulimit -s unlimited
% cd src
% make yes-polymlp 
% make ps
% make mpi-stubs
% make conda

Executable lmp_conda is created in src directory. Note that the compilation of polymlp_gtinv_data.cpp requires large stacksize, so before compilation, ulimit -s unlimite may be executed.

At run time,

export DYLD_LIBRARY_PATH=$CONDA_PREFIX/lib

is required. It is convenient if this environment variable is written in $CONDA_PREFIX/etc/conda/activate.d/env_vars.sh.

Precomputed polymlp data for elements are found at http://cms.mtl.kyoto-u.ac.jp/seko/mlp-repository/index.html.