编译版本为vasp6.4.0版本

编译前准备

附加包编译

这些包为vasp提供了一些附加功能,可选择其中内容编译, 不需要其中功能可直接跳到下一节vasp编译

VTST补丁

过渡态计算插件

VTST具体安装流程参考官网

此处下载补丁源码VTST Code

将VTST源码从vtstcode-197/vtstcode6.4/复制到vasp源码的src目录下

并将main.F

1
2
CALL CHAIN_FORCE(T_INFO%NIONS,DYN%POSION,TOTEN,TIFOR, &
LATT_CUR%A,LATT_CUR%B,IO%IU6)

替换为

1
2
CALL CHAIN_FORCE(T_INFO%NIONS,DYN%POSION,TOTEN,TIFOR, &
TSIF,LATT_CUR%A,LATT_CUR%B,IO%IU6)

1
IF (LCHAIN) CALL chain_init( T_INFO, IO)

替换为

1
CALL chain_init( T_INFO, IO)

接下来修改vasp源码目录src.objects文件,在其chain.o前加以下内容

1
2
3
4
bfgs.o dynmat.o instanton.o lbfgs.o sd.o cg.o dimer.o bbm.o \
fire.o lanczos.o neb.o qm.o \
pyamff_fortran/*.o ml_pyamff.o \
opt.o \

之后修改src目录下makefile

1
LIB= lib parser pyamff_fortran

如果编译多线程版本需要修改如下

1
dependencies: sources libs

OPT_AXIS补丁

结构优化固定基矢,二维材料必备

OPT_AXISgithub管网下载源码

fixing_stress_tensor路径下将stress_relax_finner.patch复制到vasp路径下并执行

1
patch -p0 < stress_relax_finner.patch

打补丁

VASPsol补丁

VASPsolgithub官网下载源码并将其中src目录下的solvation.F复制到vasp.6.4.0/src源码中

这个issues中下载vasp6.3版本的补丁并使用命令

1
patch -p0 < VASPsol_VASP630.patch

加载补丁

支持wannier90、dftd4、BEEF、HDF5、libxc的vasp编译

编译这些库比较简单,这里就不一一列举,大多只要在与vasp相同的环境下使用

1
2
3
./configure --prefix=<install path>
make all
make install

即可,这些库包括wannier90libdftd4libBEEFlibHEF5liblibxc ,它们的功能可去官网自行了解。编译好上述软件后只需在vasp源码根目录下的arch目录中复制makefile.include.intel到根目录中并命名makefile.include然后配置其路径即可,如果对openmp有了解可选择makefile.include.intel_omp作为makefile.include

将下面内容中选择你需要的部分复制进makefile.include末尾并修改对应的路径即可

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
# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include

# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90-3.1.0
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier

# For the dft-d4 interface (optional)
CPP_OPTIONS += -DDFTD4
LLIBS += $(shell pkg-config --libs dftd4)
INCS += $(shell pkg-config --cflags dftd4)

# For the beef vdw interface (optional)
CPP_OPTIONS += -Dlibbeef
LLIBS += -L/path/to/your/libbeef/lib/lib -lbeef

# For the libxc interface (optional)
CPP_OPTIONS += -DUSELIBXC
LIBXC_ROOT ?= /path/to/your/libxc/installation
LLIBS += -L$(LIBXC_ROOT)/lib -lxcf03 -lxc
INCS += -I$(LIBXC_ROOT)/include

vasp编译

修改makefile.includemkl路径并将FCL后的qmkl改为mkl,最终修改结果如下

1
2
FCL        += -mkl=sequential
MKLROOT ?= /path/to/your/intel/mkl/dir

修改编译器参数如下

1
VASP_TARGET_CPU ?= -xHOST -heap-arrays 64

如果报错不支持SSE指令集则在最后一行加如下内容打开SSE支持

1
2
3
CXXFLAGS += -xSSE4.2
CFLAGS += -xSSE4.2
FFLAGS += -xSSE4.2

最后使用make DEPS=1 -jN all命令编译三个版本的vasp,其中N为使用核数

完整的makefile.include文件如下

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxIFC\" \
-DMPI -DMPI_BLOCK=8000 -Duse_collective \
-DscaLAPACK \
-DCACHE_SIZE=4000 \
-Davoidalloc \
-Dvasp6 \
-Duse_bse_te \
-Dtbdyn \
-Dfock_dblbuf

CPP = fpp -f_com=no -free -w0 $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)

FC = mpiifort
FCL = mpiifort

FREE = -free -names lowercase

FFLAGS = -assume byterecl -w

OFLAG = -O2
OFLAG_IN = $(OFLAG)
DEBUG = -O0

OBJECTS = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o

# For what used to be vasp.5.lib
CPP_LIB = $(CPP)
FC_LIB = $(FC)
CC_LIB = icc
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB = $(FREE)

OBJECTS_LIB = linpack_double.o

# For the parser library
CXX_PARS = icpc
LLIBS = -lstdc++

##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##

# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -xHOST -heap-arrays 64
FFLAGS += $(VASP_TARGET_CPU)

# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL += -mkl=sequential
MKLROOT ?= /path/to/your/intel/mkl/dir
LLIBS += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS =-I$(MKLROOT)/include/fftw

# HDF5-support (optional but strongly recommended)
CPP_OPTIONS+= -DVASP_HDF5
HDF5_ROOT ?= /path/to/your/hdf5
LLIBS += -L$(HDF5_ROOT)/lib -lhdf5_fortran
INCS += -I$(HDF5_ROOT)/include

# For the VASP-2-Wannier90 interface (optional)
CPP_OPTIONS += -DVASP2WANNIER90
WANNIER90_ROOT ?= /path/to/your/wannier90-3.1.0
LLIBS += -L$(WANNIER90_ROOT)/lib -lwannier


# For the dft-d4 interface (optional)
CPP_OPTIONS += -DDFTD4
LLIBS += $(shell pkg-config --libs dftd4)
INCS += $(shell pkg-config --cflags dftd4)

# For the beef vdw interface (optional)
CPP_OPTIONS += -Dlibbeef
LLIBS += -L/path/to/your/libbeef/lib/lib -lbeef


# For the libxc interface (optional)
CPP_OPTIONS += -DUSELIBXC
LIBXC_ROOT ?= /path/to/your/libxc/installation
LLIBS += -L$(LIBXC_ROOT)/lib -lxcf03 -lxc
INCS += -I$(LIBXC_ROOT)/include

# For the VASPsol interface (optional)
CPP_OPTIONS += -Dsol_compat

CXXFLAGS += -xSSE4.2
CFLAGS += -xSSE4.2
FFLAGS += -xSSE4.2