Eastsheng's Wiki

VASP安装与编译

2022-09-18 18:11:28

[toc]

VASP5.4.4安装

一、安装 Intel® oneAPI Base Toolkit 和 Intel® oneAPI HPC来替代

  • 在安装之前需要安装一系列依赖包:

    1
    2
    sudo apt-get install libgtk-3-0 libxss1 libnss3 libgtk2.0 libpango-1.0-0 libasound2 
    sudo apt-get install xorg openbox
  • intel® oneAPI Base Toolkit 安装:

    1
    2
    wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18673/l_BaseKit_p_2022.2.0.262_offline.sh
    sudo sh ./l_BaseKit_p_2022.2.0.262_offline.sh
  • Intel® oneAPI HPC 安装

    1
    2
    wget https://registrationcenter-download.intel.com/akdlm/irc_nas/18679/l_HPCKit_p_2022.2.0.191_offline.sh
    sudo sh ./l_HPCKit_p_2022.2.0.191_offline.sh
  • 添加环境变量并查看是否安装好:

    最好把source /opt/intel/oneapi/setvars.sh intel64写进~/.bashrc中

    1
    2
    3
    4
    5
    source /opt/intel/oneapi/setvars.sh intel64
    icc -v
    ifort -v
    mpiicc -v
    mpiifort -v

二、编译

1
2
3
4
5
6
7
8
tar -zxvf vasp.5.4.4.tar.gz
cd vasp.5.4.4
cp -r /opt/intel/oneapi/mkl/2022.1.0/interfaces/fftw3xf . # cp MKL中的fftw库到vasp文件夹中
cd fftw3xf/
make libintel64
cd ..
cp arch/makefile.include.linux_intel makefile.include # 修改makefile.include,在OFLAG后添加-xAVX,如:OFLAG = -xAVX -O2
make all

VASP6.3.2安装:Intel

一、安装 Intel® oneAPI Base Toolkit 和 Intel® oneAPI HPC来替代

  • 在安装之前需要安装一系列依赖包:
1
2
sudo apt-get install libgtk-3-0 libxss1 libnss3 libgtk2.0 libpango-1.0-0 libasound2 
sudo apt-get install xorg openbox
1
2
wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/e6ff8e9c-ee28-47fb-abd7-5c524c983e1c/l_BaseKit_p_2024.2.1.100_offline.sh
sudo sh l_BaseKit_p_2024.2.1.100_offline.sh
1
2
wget https://registrationcenter-download.intel.com/akdlm/IRC_NAS/d461a695-6481-426f-a22f-b5644cd1fa8b/l_HPCKit_p_2024.2.1.79_offline.sh
sudo sh l_HPCKit_p_2024.2.1.79_offline.sh
  • 添加环境变量并查看是否安装好:

    最好把source /opt/intel/oneapi/setvars.sh intel64写进~/.bashrc中

1
2
3
4
5
6
source /opt/intel/oneapi/setvars.sh intel64
icx -v
icpx -v
ifort -v
mpiicc -v
mpiifort -v

二、编译

1
2
3
4
5
6
7
8
9
10
11
12
13
14
unzip vasp.6.3.2.zip
cd vasp.6.3.2
cp -r /opt/intel/oneapi/mkl/2024.2/share/mkl/interfaces/fftw3xf . # cp MKL中的fftw库到vasp文件夹中
cd fftw3xf/
make libintel64
cd ..
cp arch/makefile.include.intel makefile.include
vim makefile.include
# 修改makefile.include,如下
# CC_LIB = icx
# CXX_PARS = icpx
# 若cpu为AMD,还需修改
# VASP_TARGET_CPU ?= -axCORE-AVX512
make all

安装成功

make[2]: Leaving directory ‘/home/xxx/softwares/vasp/vasp.6.3.2/build/ncl’
make[1]: Leaving directory ‘/home/xxx/softwares/vasp/vasp.6.3.2/build/ncl’

三、环境变量

1
2
3
4
5
6
cd bin
ls
# vasp_gam vasp_ncl vasp_std
sudo vim ~/.bashrc
# export PATH=/home/xxx/softwares/vasp/vasp.6.3.2/bin:$PATH

VASP6.3.2安装(建议):在Intel/AMD CPU 上 使用 Intel One API编译VASP

https://zhuanlan.zhihu.com/p/690838844

  • 建议安装较低版本的One API,具体见上VASP5.4.4安装
1
2
sudo sh ./l_BaseKit_p_2022.2.0.262_offline.sh
sudo sh ./l_HPCKit_p_2022.2.0.191_offline.sh
  • VASP 6.2.0及以上的版本,需要预先安装HDF5来实现VASP计算结果输出为h5文件,便于利用官方python包py4vasp进行数据读取与后处理。
  • 安装HDF5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 编译zlib
wget https://www.zlib.net/zlib-1.3.1.tar.gz
tar -zxvf zlib-1.3.1.tar.gz
cd zlib-1.3.1/
./configure --prefix=/home/xxx/softwares/vasp/zlib-1.3.1/_build
make
make check
make install
# 编译Szip
wget https://docs.hdfgroup.org/archive/support/ftp/lib-external/szip/2.1.1/src/szip-2.1.1.tar.gz
tar -zxvf szip-2.1.1.tar.gz
cd szip-2.1.1/
./configure --prefix=/home/xxx/softwares/vasp/szip-2.1.1/_build
make
make check
make install
# 编译HDF5
wget https://support.hdfgroup.org/releases/hdf5/v1_14/v1_14_6/downloads/hdf5-1.14.6.tar.gz
tar -zxvf hdf5-1.14.6.tar.gz
./configure CC=mpiicc FC=mpiifort CXX=mpiicpc --enable-fortran --enable-cxx --prefix=/home/xxx/softwares/vasp/hdf5-1.14.6/_build --with-zlib=/home/xxx/softwares/vasp/zlib-1.3.1/_build --with-szlib=/home/xxx/softwares/vasp/szip-2.1.1/_build
make
make check
make install
export LD_LIBRARY_PATH="/home/xxx/softwares/vasp/hdf5-1.14.6/_build/lib:${LD_LIBRARY_PATH}"

  • 编译VASP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
unzip vasp.6.3.2.zip
cd vasp.6.3.2
cp -r /opt/intel/oneapi/mkl/2022.0.2/interfaces/fftw3xf .
cd fftw3xf/
make libintel64
cd ..
cp arch/makefile.include.intel makefile.include
vim makefile.include
# 在OBJECTS末尾添加编译得到的libfftw3xf_intel.a的目录
# OBJECTS = fftmpiw.o fftmpi_map.o fft3dlib.o fftw3d.o /home/xxx/softwares/vasp/vasp.6.3.2/fftw3xf/libfftw3xf_intel.a

# Intel CPU 需要修改以下Flag,注意修改-mkl为-qmkl
# OFLAG = -O2 -xHOST
# VASP_TARGET_CPU = -xHOST
# FCL += -qmkl=sequential -xHOST
# MKLROOT = ~/intel/oneapi/mkl/2022.0.2
# INCS =-I$(MKLROOT)/include/fftw -I/opt/intel/oneapi/mpi/2021.5.1/include
# AMD CPU 则需要修改以下Flag,注意修改-mkl为-qmkl
OFLAG = -O2 -march=core-avx2
VASP_TARGET_CPU = -march=core-avx2
FCL += -qmkl=sequential -xCORE-AVX2
MKLROOT = /opt/intel/oneapi/mkl/2022.0.2
INCS =-I$(MKLROOT)/include/fftw -I/opt/intel/oneapi/mpi/2021.5.1/include

# 添加HDF5的设置
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT = /home/xxx/softwares/vasp/hdf5-1.14.6/_build # 根据自身安装目录调整
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include
# 加载环境后编译
source /opt/intel/oneapi/setvars.sh intel64
export LD_LIBRARY_PATH="/home/xxx/softwares/vasp/hdf5-1.14.6/_build/lib:${LD_LIBRARY_PATH}"
make all

make[2]: Leaving directory ‘/home/chends/softwares/vasp/vasp.6.3.2/build/ncl’
make[1]: Leaving directory ‘/home/chends/softwares/vasp/vasp.6.3.2/build/ncl’

安装成功

VASP6.3.2安装:快速安装(不区分CPU类型)

如果上述安装不成功,可以试试下面这个,但是由于没用mkl库,算起来很慢

http://bbs.keinsci.com/thread-33640-1-1.html

  • 安装必要库:

    1
    2
    3
    sudo apt update
    sudo apt upgrade
    sudo apt install build-essential gfortran libopenblas-dev libopenmpi-dev libscalapack-openmpi-dev libfftw3-dev libhdf5-openmpi-dev libfftw3-mpi-dev cmake pkg-config
  • 解压:

    1
    2
    3
    4
    unzip vasp.6.3.2.zip
    cd vasp.6.3.2

    cp arch/makefile.include.gnu_omp makefile.include
  • 修改 makefile.include:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    # BLAS and LAPACK (mandatory)
    #OPENBLAS_ROOT ?= /path/to/your/openblas/installation
    BLASPACK = -lopenblas

    # scaLAPACK (mandatory)
    #SCALAPACK_ROOT ?= /path/to/your/scalapack/installation
    SCALAPACK = -lscalapack-openmpi

    # FFTW (mandatory)
    #FFTW_ROOT ?= /path/to/your/fftw/installation
    LLIBS += -lfftw3 -lfftw3_omp
    INCS += -I/usr/include

    # HDF5-support (optional but strongly recommended)
    CPP_OPTIONS+= -DVASP_HDF5
    #HDF5_ROOT ?= /path/to/your/hdf5/installation
    LLIBS += -L/usr/lib/x86_64-linux-gnu/hdf5/openmpi/ -lhdf5_fortran
    INCS += -I/usr/include/hdf5/openmpi/
  • 编译:

    1
    make DEPS=1 -j

官网H2O例子

  • H2O VASP官网例子
    • POSCAR
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    H2O _2
    0.52918 ! scaling parameter
    15 0 0
    0 15 0
    0 0 15
    1 2
    select
    cart
    0.00 0.00 0.00 F F F
    1.10 -1.43 0.00 T T F
    1.10 1.43 0.00 T T F
  • INCAR
1
2
3
4
5
6
7
PREC = Normal    ! standard precision 
ENMAX = 400 ! cutoff should be set manually
ISMEAR = 0 ; SIGMA = 0.1
IBRION = 1 ! use DIIS algorithm to converge
NFREE = 2 ! 2 independent degrees of freedom
NSW = 10 ! 10 ionic steps
EDIFFG = -0.02 ! forces smaller 0.02 A/eV
  • KPOINTS
1
2
3
4
5
Gamma-point only
0
Monkhorst Pack
1 1 1
0 0 0
  • POTCAR
  • 官网自带的有,也可以从赝势库中自己手动生成:
1
cat ~/softwares/VASP/PAW_PBE/O/POTCAR ~/softwares/VASP/PAW_PBE/H/POTCAR >POTCAR
  • 运行命令:mpirun -np 8 vasp_std

参考与可视化以及后处理程序资源: