WannierTools 是一款专注于拓扑材料研究的开源软件,适用于计算材料的电子结构和拓扑性质。

以强拓扑绝缘体 Bi2Se3 为例,在研究它的性质时,通常需要使用 VASP 进行 DFT 计算,之后就需要使用 wannier90 进行紧束缚的计算,最后就需要使用 WannierTools 对其拓扑性质进行分析,比如拓扑数、表面态和表面自旋。

所以需要知道 WannierTools 这个工具的安装是必要的步骤。

这里默认是在 LInux 系统下进行操作,没办法我目前是 Ubuntu 系统,其他的平台和系统我目前还不了解。

环境安装

WannierTools 的很多计算需要特定的加速才比较优秀,环境安装是比较重要的一步,这里引用官方文档,在 Installation of WannierTools (Linux or Mac)中,需要准备好的库有:

“Installation”

You need to install the following (mandatory) packages:

  • Fortran compiler (Gfortran or ifort)

  • MPICH version higher than 2.1.5

  • Lapack and Blas library, (Intel MKL recommended)

  • Arpack-ng

当然,随着时间的推移(现在是2024年),其中的需要安装的库或者依赖都会变化。

Fortran compiler

你需要知道你现在是否安装了 Fortran compiler

检查

检查Gfortran或ifort:- 在终端中运行以下命令:

1
gfortran --version

或者

1
ifort -v

如果系统返回版本信息,则表示已安装相应的Fortran编译器。如果没有返回信息,您需要安装Gfortran或Intel Fortran编译器。

安装

Ubuntu/Debian 系统

在终端输入

1
2
3
sudo apt update
sudo apt install gfortran
gfortran --version

如需要安装特定的版本(例如gfortran-10)

1
2
3
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gfortran-10

MPICH

检查

在终端中运行以下命令:

1
2
mpiexec --version
mpichversion

如果系统返回版本信息,则表示已安装

安装

Ubuntu/Debian 系统

准备环境

1
2
sudo apt update
sudo apt install build-essential

访问 MPICH 的官方网站,下载最新版本的源代码包,如果可以使用 wget 安装,就输入

1
wget http://www.mpich.org/static/downloads/4.3.0/mpich-4.3.0.tar.gz

注意,你需要知道现在最新的版本是哪个,或者你需要哪个版本,4.3.0只是目前写博客时的最新版本。

之后进行解压:

1
2
tar -xzvf mpich-4.3.0.tar.gz
cd mpich-4.3.0

配置安装目录,编译和安装:

1
2
./configure --prefix=/usr/local/mpich-4.3.0\
make && sudo make install

一段时间后,需要你耐心等待,之后就需要设置环境变量

1
2
echo 'export PATH=/usr/local/mpich-4.3.0/bin:$PATH' >> ~/.bashrc
source ~/.bashrc

注意,如果你的路径不一样,你就需要修改 /usr/local/ 为你的安装路径。

最后,你也可以运行一些示例程序来测试MPICH是否正常工作。进入示例目录并运行测试程序:

1
2
cd examples
mpiexec -n 4 ./cpi  # 假设cpi是一个示例程序

Intel MKL

这里介绍安装 Intel MKL 是因为他功能更加全面,如果安装过 VASP,过程中就会安装 Intel 的编译环境,对 MKL 应该也不陌生。这个安装就跳过,如果之后没有再添加就说明我比较懒。

Arpack

这个库适用于求解大规模特征值,在计算矩阵时很有用。

WannierTools 安装

终于到了本体的安装,这一部分安装对于前面来说就比较容易了。

先看官方安装包里面的文档:

“Installation”

WannierTools is written in Fortran90. Eventually, Fortran compiler is required to install it. At present, we only support the installation on Mac or Linux or other Unix like systems.

  1. Download the package a. You can download the latest develop branch by using “git clone” git clone https://github.com/quanshengwu/wannier_tools.git b. You could also download the release version on page https://github.com/quanshengwu/wannier_tools/releases

  2. After the download, uncompress it if necessary. The source file is included in the src/ folder. The executable binary will be copied to bin/ folder after compilation. There are several examples in the examples/ folder. The symmetrization module is in the wannhr_symm/ folder which is an independent python package.

  3. Go into the folder src/ for the compilation. We prepared several Makefiles for different usage. Please copy the one that you need into Makefile like

cp Makefile.intel-mpi Makefile

  1. Modify Makefile a. Choose the lapack and Blas library by setting LIBS. b. if you want to use mpi, please add -DMPI as an option of compiler F90.

  2. Make it by typing

make

  1. After the compilation, binary wt.x will be generated and copied to ../bin/ folder.

  2. About the usage, please visit website www.wanniertools.com

对,几乎很详细地教会你怎么安装,就怕你哪一步不懂。

按照官方教程来,几乎不会出错,唯一需要注意的是2024年有一个编译器的弃用。Intel Fortran Compiler Classic(ifort)已被弃用,并将在2024年底停止支持。Intel建议用户尽早迁移到基于LLVM的新编译器(ifx),以获得持续的支持和新功能。这意味着在未来的版本中,ifort将不再可用。

所以你就需要在 Makefile 里面将 ifort 改为 ifx 以避免之后的出错。

估计这在之后 WannierTools 会自动更新这个修复,到那时候那就当我没讲了。