#LAMMPS安装 (嵌入NEP势函数)
1.准备安装文件
mkdir lammps #新建lammps文件夹
cd lammps/ #进入lammps/
wget http://www.fftw.org/fftw-3.3.8.tar.gz #下载fftw-3.3.8.tar.gz
wget http://www.mpich.org/static/downloads/3.4.3/mpich-3.4.3.tar.gz #下载mpich-3.4.3.tar.gz
wget https://lammps.sandia.gov/tars/lammps-stable.tar.gz #下载lammps-stable.tar.gz
2.解压安装文件
tar -xvf fftw-3.3.8.tar.gz #解压后为fftw-3.3.8
tar -xvf mpich-3.4.3.tar.gz #解压后为mpich-3.4.3
tar -xvf lammps-stable.tar.gz #解压后为lammps-2022
3.安装fftw
lammps/ 文件夹下
mkdir fftw3 #新建fftw3文件夹
pwd#显示fftw3的位置
cd fftw-3.3.8/ #进入fftw-3.3.8/
./configure --prefix=/share/home/.../lammps/fftw3/ --enable-shared=yes #(fftw3的位置 )
make
make install
4.安装mpich
lammps/ 文件夹下mkdir mpich3
pwd#显示mpich3的位置
cd mpich-3.4.3/
./configure --prefix=/home/.../lammps/mpich3/ #(mpich3的位置)
#如果配置过程中出现:
#configure:error: no ch4 netmod selected
#则按照提醒,在配置命令中加上--with-device=ch4:ofi
#如果出现:No Fortran compiler found,则可按照提醒,在配置命令中加上--disable-fortran
make
make install
5.内嵌NEP势函数接口
去git 下载 https://github.com/brucefan1983/NEP_CPU.git
在/lammps目录下解压
unzip NEP_CPU-main.zip
cd NEP_CPU-main/
cp src/* interface/lammps/USER-NEP/
此时USER-NEP文件夹下应该有
Install.sh nep.cpp nep.h pair_NEP.cpp pair_NEP.h
cd interface/lammps/
cp -rf USER-NEP/ /home/public/hg/lammps/lammps-23Jun2022/src/ #将USER-NEP文件夹拷贝到lammps-23Jun2022的src文件目录下
cd /home/public/hg/lammps/lammps-23Jun2022/src/
make yes-USER-NEP
这一步的目的是将NEP势函数的接口加入到LAMMPS中,如果不用NEP势函数可以忽略这一步
6.安装lammps
lammps/ 文件夹下
cd lammps-23Jun2022/src/MAKE/
vi Makefile.mpi #修改mpi和fftw链接路径
# mpi = MPI with its default compiler
SHELL = /bin/sh
# ---------------------------------------------------------------------
# compiler/linker settings
# specify flags and libraries needed for your compiler
CC = g++ #需修改
CCFLAGS = -g -O3
SHFLAGS = -fPIC
DEPFLAGS = -M
LINK = g++ #需修改
LINKFLAGS = -g -O3
LIB =
SIZE = size
ARCHIVE = ar
ARFLAGS = -rc
SHLIBFLAGS = -shared
# ---------------------------------------------------------------------
# LAMMPS-specific settings, all OPTIONAL
# specify settings for LAMMPS features you will use
# if you change any -D setting, do full re-compile after "make clean"
# LAMMPS ifdef settings
# see possible settings in Section 2.2 (step 4) of manual
LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64
# MPI library
# see discussion in Section 2.2 (step 5) of manual
# MPI wrapper compiler/linker can provide this info
# can point to dummy MPI library in src/STUBS as in Makefile.serial
# use -D MPICH and OMPI settings in INC to avoid C++ lib conflicts
# INC = path for mpi.h, MPI compiler settings
# PATH = path for MPI library
# LIB = name of MPI library
MPI_INC = -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -I/home/lammps/mpich3/include #需安自定修改路径
MPI_PATH = -L/home/lammps/mpich3/lib #需安自定修改路径
MPI_LIB = -lmpich -lmpl -lpthread #需要修改
# FFT library
# see discussion in Section 2.2 (step 6) of manual
# can be left blank to use provided KISS FFT library
# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings
# PATH = path for FFT library
# LIB = name of FFT library
FFT_INC = -DFFT_FFTW3 -I/home/lammps/fftw3/include #需安自定修改路径
FFT_PATH = -L/home/lammps/fftw3/lib #需安自定修改路径
FFT_LIB = -lfftw3 #需要修改
# JPEG and/or PNG library
# see discussion in Section 2.2 (step 7) of manual
# only needed if -DLAMMPS_JPEG or -DLAMMPS_PNG listed with LMP_INC
# INC = path(s) for jpeglib.h and/or png.h
# PATH = path(s) for JPEG library and/or PNG library
# LIB = name(s) of JPEG library and/or PNG library
JPG_INC =
JPG_PATH =
JPG_LIB =
# ---------------------------------------------------------------------
# build rules and dependencies
# do not edit this section
include Makefile.package.settings
include Makefile.package
EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC)
EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH)
EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB)
EXTRA_CPP_DEPENDS = $(PKG_CPP_DEPENDS)
EXTRA_LINK_DEPENDS = $(PKG_LINK_DEPENDS)
# Path to src files
vpath %.cpp ..
vpath %.h ..
# Link target
$(EXE): $(OBJ) $(EXTRA_LINK_DEPENDS)
$(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
$(SIZE) $(EXE)
# Library targets
lib: $(OBJ) $(EXTRA_LINK_DEPENDS)
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
shlib: $(OBJ) $(EXTRA_LINK_DEPENDS)
$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
$(OBJ) $(EXTRA_LIB) $(LIB)
# Compilation rules
%.o:%.cpp
$(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $<
# Individual dependencies
depend : fastdep.exe $(SRC)
@./fastdep.exe $(EXTRA_INC) -- $^ > .depend || exit 1
fastdep.exe: ../DEPEND/fastdep.c
cc -O -o $@ $<
sinclude .depend
cd .. #返回上层src文件夹
make mpi
src下出现lmp_mpi安装成功
ln -s ./lmp_mpi /usr/bin/lmp_mpi #为lmp_mpi创建软连接
至此安装结束
7.测试
cd lammps-23Jun2022/examples/shear
mpirun -np 4 lmp_mpi -in in.shear #调用4核心运行
测试NEP
修改lammps的in文件中势函数选择NEP
pair_style nep YOUR_NEP_MODEL_FILE.txt # YOUR_NEP_MODEL_FILE.txt is your NEP model file (with path)
pair_coeff * * # This format is fixed
参考链接:
https://www.jianshu.com/p/aabc4c340ac7
https://github.com/brucefan1983/NEP_CPU