CPMD的编译安装
发布时间:2021-05-11
CPMD的编译安装
1.1 CPMD
简介
CPMD(Car-Parrinello Molecular Dynamics)是由IBM公司和马克斯-普朗克研究中心共同开发的一款用于对分子、原子和材料等研究的大型从头算模拟软件。对于非赢利的学术机构是可以免费提供源代码的,而对于商业组织则需要向官网申请许可。CPMD可以用来计算孤立体系和周期性边界(晶体等)体系的物理、化学性质;可以对体系做几何优化并寻找化学反应过渡态;还可以计算体系的激发态性质。因此,CPMD是一款功能强大的从头算科学模拟软件,广泛使用在材料物理、化学、大分子生物学的研究上。
CPMD Official website: http://cpmd.org/
CPMD Online Manual: http://cpmd.org/wordpress/index.php/documentation
CPMD Tutorial: http://cpmd.org/wordpress/index.php/tutorial
官网:https://www.cpmd.org/wordpress/
1.2 编译前的准备工作
1.2.1
源码包下载
非营利组织可以通过官网https://www.cpmd.org/wordpress/index.php/download/apply-for-a-license/
申请下载,申请后官网提示
Thank you for your submission, your request will be processed within approximately 2 working weeks.
官网在接受许可协议后会发送下载说明。
本次通过申请后根据提示下载了cpmd-v4.3.tar.gz
版本,还下载了测试包
cpmd-test.tar.gz
,标准的
CPMD pseudo
库
pseudo_std.tar.gz
,Goedecker
赝势库
Goedecker.tar.gz
。
tar zvxf cpmd-v4.3.tar.gz
编译并行版本需要MPI
、
FFTW
、
BLAS
和
LAPACK
。其中,
BLAS
、
LAPACK
也可以用
MKL
替代。本次编译是Intel
编译器+IntelMPI+FFTW3+MKL
方式。
1.2.2
Intel编译器、IntelMPI和MKL编译安装
首先,需要编译好Intel
编译器、IntelMPI
和
MKL
,编译方式参考第章。
编译完成后在环境变量中添加以下语句:
source /public/home/jinnzh/intel/bin/compilervars.sh intel64
export PATH=/public/home/jinnzh/intel/bin:$PATH
export LD_LIBRARY_PATH=/public/home/jinnzh/intel/lib/intel64:$LD_LIBRARY_PATH
export INCLUDE=/public/home/jinnzh/intel/include:$INCLUDE
###### impi ####
export PATH=/public/home/jinnzh/intel/impi/2019.5.281/intel64/bin:$PATH
export LD_LIBRARY_PATH=/public/home/jinnzh/intel/impi/2019.5.281/intel64/lib:$LD_LIBRARY_PATH
export INCLUDE=/public/home/jinnzh/intel/impi/2019.5.281/intel64/include:$INCLUDE
###### intel MKL ######
export PATH=/public/home/jinnzh/intel/mkl/bin:$PATH
export LD_LIBRARY_PATH=/public/home/jinnzh/intel/mkl/lib/intel64:$LD_LIBRARY_TATH
export INCLUDE=/public/home/jinnzh/intel/mkl/include:$INCLUDE
1.2.3
用icc编译FFTW3
从http://www.fftw.org/
下载
fftw-3.3.8.tar.gz
。
tar -zvxf fftw-3.3.8.tar.gz
编译双精度版本
首先查看configure
文件中的参数:
./configure --help
默认FFTW
编译生成
double
类型,加入参数“
--enable-single
”或“
--enable-float
”编译单精度
(float)
,加入参数“
--enable-long-double
”支持长双进度类型。
./configure --prefix=/public/home/jinnzh/fftw3/intelmpiicc-double --enable-threads --enable-mpi CC=icc MPICC=mpiicc F77=mpiifort --enable-openmp --enable-avx2 --enable-shared
make
make install
编译完成,在/public/home/jinnzh/fftw3/intelmpiicc-double
目录下生成相关文件。
配置环境变量
vi .bashrc
添加以下语句:
export PATH=/public/home/jinnzh/fftw3/intelmpiicc-double/bin:$PATH
export C_INCLUDE_PATH=/public/home/jinnzh/fftw3/intelmpiicc-double/include:$C_INCLUDE_PATH
export LD_LIBRARY_PATH=/public/home/jinnzh/fftw3/intelmpiicc-double/lib:$LD_LIBRARY_PATH
保存退出,
然后source .bashrc,配置完毕。
1.3 编译安装
1.3.1
生成Makefile并修改相应配置
cd CPMD/
输入./configure.sh --help
可以查看那些platform
可用,选取合适的
platform
,适合本次编译的
LINUX-X86_64-INTEL-IMPI-FFTW
,然后输入:
./configure.sh LINUX-X86_64-INTEL-IMPI-FFTW
生成了Makefile
文件。
vi Makefile
将以下部分内容做修改:
FFLAGS = -O2 -I$(MKLROOT)/include/fftw -axMIC-AVX512 -free -I${SRCDIR} -I${OBJDIR}
LFLAGS = -static-intel -mkl=sequential -axMIC-AVX512 -lfftw3_mpi
CFLAGS = -O2 -I${SRCDIR}
NVCCFLAGS = -I${SRCDIR}
CPP = /usr/bin/cpp -P -traditional
CPPFLAGS = -D__Linux -D__HAS_FFT_FFTW3 -D__PARALLEL -DLINUX_IFC -D__HASNT_OMP_45 \
-D__HASNT_F03_EXECUTE_COMMAND_LINE -D__HASNT_F08_ISO_FORTRAN_ENV -I${SRCDIR} -D'SVN_REV="4610"'
NOOPT_FLAG = -O1
CC = mpiicc
FC = mpiifort -cpp
LD = mpiifort -cpp
NVCC =
AR = /usr/bin/ar ruv
RANLIB = /usr/bin/ranlib
修改为:
FFLAGS = -O2 -I$(MKLROOT)/include/fftw -axMIC-AVX512 -free -I${SRCDIR} -I${OBJDIR}
LFLAGS = -static-intel -mkl=sequential -axMIC-AVX512 -L/public/home/jinnzh/fftw3/intelmpiicc-double/lib -lfftw3_mpi
CFLAGS = -O2 -I${SRCDIR}
NVCCFLAGS = -I${SRCDIR}
CPP = /usr/bin/cpp -P -traditional
CPPFLAGS = -D__Linux -D__HAS_FFT_FFTW3 -D__PARALLEL -DLINUX_IFC -D__HASNT_OMP_45 \
-D__HASNT_F03_EXECUTE_COMMAND_LINE -D__HASNT_F08_ISO_FORTRAN_ENV -I${SRCDIR} -D'SVN_REV="4610"'
NOOPT_FLAG = -O1
CC = mpiicc
FC = mpiifort -cpp
LD = mpiifort -cpp
NVCC =
AR = /usr/bin/ar ruv
RANLIB = /usr/bin/ranlib
主要是添加了fftw3
的路径。
1.3.2
执行make
make
编译完成,在/public/home/jinnzh/sourcecode/cpmd/CPMD
目录下生成
bin
和
lib
文件夹。
bin
文件夹中有一个可执行程序
cpmd.x
,
lib
文件夹中有一个
libcpmd.a
的库文件。
1.4 添加环境变量
vi .bashrc
添加以下语句:
export PATH=/public/home/jinnzh/sourcecode/cpmd/CPMD/bin:$PATH
保存退出。然后,source .bashrc,配置完毕。
1.5 测试
首先,解压缩下载的测试包cpmd-test.tar.gz
。
tar zvxf cpmd-test.tar.gz
然后进入CPMD-test/
文件夹。
cd CPMD-test/
cd std/c120/
mpirun -np 18 cpmd.x inp-1 > test1.log
计算结束,将测试包自带的结果文件out-1
和本次计算结果文件
test1.log
做对比,结果显示,两者计算结果一致。
out-1
中的内容如下:
ELECTRONIC GRADIENT:
MAX. COMPONENT = 8.57421E-06 NORM = 1.39121E-07
NUCLEAR GRADIENT:
MAX. COMPONENT = 2.37003E-02 NORM = 3.03030E-03
TOTAL INTEGRATED ELECTRONIC DENSITY
IN G-SPACE = 480.000000
IN R-SPACE = 480.000000
(K+E1+L+N+X) TOTAL ENERGY = -673.74663075 A.U.
(K) KINETIC ENERGY = 480.59566392 A.U.
(E1=A-S+R) ELECTROSTATIC ENERGY = -609.61285996 A.U.
(S) ESELF = 638.30762328 A.U.
(R) ESR = 23.08431617 A.U.
(L) LOCAL PSEUDOPOTENTIAL ENERGY = -416.44286455 A.U.
(N) N-L PSEUDOPOTENTIAL ENERGY = 75.54394528 A.U.
(X) EXCHANGE-CORRELATION ENERGY = -203.83051543 A.U.
GRADIENT CORRECTION ENERGY = -7.89476700 A.U.
MAX. COMPONENT = 8.57421E-06 NORM = 1.39121E-07
NUCLEAR GRADIENT:
MAX. COMPONENT = 2.37003E-02 NORM = 3.03030E-03
TOTAL INTEGRATED ELECTRONIC DENSITY
IN G-SPACE = 480.000000
IN R-SPACE = 480.000000
(K+E1+L+N+X) TOTAL ENERGY = -673.74663075 A.U.
(K) KINETIC ENERGY = 480.59566392 A.U.
(E1=A-S+R) ELECTROSTATIC ENERGY = -609.61285996 A.U.
(S) ESELF = 638.30762328 A.U.
(R) ESR = 23.08431617 A.U.
(L) LOCAL PSEUDOPOTENTIAL ENERGY = -416.44286455 A.U.
(N) N-L PSEUDOPOTENTIAL ENERGY = 75.54394528 A.U.
(X) EXCHANGE-CORRELATION ENERGY = -203.83051543 A.U.
GRADIENT CORRECTION ENERGY = -7.89476700 A.U.
test1.log
中的内容如下:
ELECTRONIC GRADIENT:
MAX. COMPONENT = 8.92653E-06 NORM = 1.22485E-07
TOTAL INTEGRATED ELECTRONIC DENSITY
IN G-SPACE = 480.0000000000
IN R-SPACE = 480.0000000000
(K+E1+L+N+X) TOTAL ENERGY = -673.74666237 A.U.
(K) KINETIC ENERGY = 480.59617332 A.U.
(E1=A-S+R) ELECTROSTATIC ENERGY = -609.61286750 A.U.
(S) ESELF = 638.30764864 A.U.
(R) ESR = 23.08431059 A.U.
(L) LOCAL PSEUDOPOTENTIAL ENERGY = -416.44235159 A.U.
(N) N-L PSEUDOPOTENTIAL ENERGY = 75.54293943 A.U.
(X) EXCHANGE-CORRELATION ENERGY = -203.83055603 A.U.
GRADIENT CORRECTION ENERGY = -7.89478099 A.U.
MAX. COMPONENT = 8.92653E-06 NORM = 1.22485E-07
TOTAL INTEGRATED ELECTRONIC DENSITY
IN G-SPACE = 480.0000000000
IN R-SPACE = 480.0000000000
(K+E1+L+N+X) TOTAL ENERGY = -673.74666237 A.U.
(K) KINETIC ENERGY = 480.59617332 A.U.
(E1=A-S+R) ELECTROSTATIC ENERGY = -609.61286750 A.U.
(S) ESELF = 638.30764864 A.U.
(R) ESR = 23.08431059 A.U.
(L) LOCAL PSEUDOPOTENTIAL ENERGY = -416.44235159 A.U.
(N) N-L PSEUDOPOTENTIAL ENERGY = 75.54293943 A.U.
(X) EXCHANGE-CORRELATION ENERGY = -203.83055603 A.U.
GRADIENT CORRECTION ENERGY = -7.89478099 A.U.
表明计算正常结束,编译安装完成。