by Sebastian Tillack for exciting fluorine
Purpose: In this tutorial, you will learn how to compute and visualize Maximally Localized Wannier Functions (MLWFs) from a calculation using hybrid functionals. Furthermore, we show how to use MLWFs in order to achieve the electronic bandstructure and density of states.
Table of Contents

0. Theoretical background
1. Prerequisites
The system we will consider throughout this tutorial is diamond.
The interpolation scheme based on the Wannier functions that is presented in this tutorial is of general validity for any system. However, it is of fundamental importance for all those systems in which, due to the complexity of the structure and/or of the used methodology, the calculation of electronic properties on a fine grid in reciprocal space is very expensive or even prohibitive. In particular, this applies to the case of calculations performed using GW and/or hybrid exchangecorrelation functionals. Indeed, for this latter case the Wannier interpolation is the only way of plotting the electronic bandstructure implemented in exciting. As an example, the application to hybrid functionals is presented in this tutorial.
We assume that you have successfully completed the tutorial on Hybridfunctional calculations and that the PBE, PBE0, and HSE folders already exist as quoted in that tutorial. All the calculations which are described in the present (Wannier) tutorial can be performed in the corresponding directories already considered in Hybridfunctional calculations.
In the next we assume that the calculation performed in Hybridfunctional calculations are stored (according to the general notation used in all tutorials) in the starting folder /home/tutorials/diamondhybrids. This should be adapted if you used a different notation.
Then, to start the tutorial move to the reference directory
$ cd /home/tutorials/diamondhybrids
First, we will focus on the PBE0 exchangecorrelation functional. The same approach can be used for HSE, but it will not be treated explicitly in this tutorial.
2. Calculation of Wannier functions, electronic bandstructure, and DOS for PBE0
First, move to the PBE0 directory
$ cd PBE0
Then, modify the input file input.xml present in the current directory. The changed file looks like this
<input> <title>Diamond PBE0 Wannier</title> <structure speciespath="$EXCITINGROOT/species" > <crystal scale="6.7425"> <basevect> 0.0 0.5 0.5 </basevect> <basevect> 0.5 0.0 0.5 </basevect> <basevect> 0.5 0.5 0.0 </basevect> </crystal> <species speciesfile="C.xml"> <atom coord="0.00 0.00 0.00" /> <atom coord="0.25 0.25 0.25" /> </species> </structure> <groundstate do="skip" ngridk="4 4 4" rgkmax="5.0" nempty="20" xctype="HYB_PBE0"> <Hybrid excoeff="0.25" /> </groundstate> <properties> <! CALCULATION OF THE WANNIER FUNCTIONS > <wannier input="hybrid"> <group method="opfmax" fst="1" lst="4"/> <group method="disFull" outerwindow="0.0 2.5" innerwindow="0.0 1.5" nwf="13"/> </wannier> </properties> </input>
So what have we changed?
 First, note that we have set the attribute do="skip" in the groundstate element in order not to redo the relatively expensive groundstate calculation.
 Second, we have added the element properties which in turn contains the subelement wannier which will be discussed in details in the next subsection.
Before continuing, do not forget to update the speciespath.
$ SETUPexcitingroot.sh
i) Calculation of the Wannier functions
The calculation of the Wannier functions is the crucial part in the Wannier interpolation scheme. The construction of the Wannier functions can be very time demanding in complex systems.
In exciting this task is performed inside the element properties by the block defined by the new element wannier. Here, is an XML snippet of this block:
<! CALCULATION OF THE WANNIER FUNCTIONS > <wannier input="hybrid"> <group method="opfmax" fst="1" lst="4"/> <group method="disFull" outerwindow="0.0 2.5" innerwindow="0.0 1.5" nwf="13"/> </wannier>
So let's run the calculation with the command
$ time exciting_smp
Once the calculation is finished, the newly created file WANNIER_INFO.OUT informs us about the run and the result. Information about the obtained Wannier functions is printed at the end of the file. To look at the result in our example type the following command.
$ tail n 33 WANNIER_INFO.OUT
********************************************************************************
* Wannier functions *
********************************************************************************
# localization center (lattice) Omega Omega_I Omega_D Omega_OD
================================================================================
1 0.1250 0.6250 0.1250 2.3388 2.0613 0.0000 0.2775
2 0.1250 0.1250 0.3750 2.3388 2.0613 0.0000 0.2775
3 0.1250 0.1250 0.1250 2.3388 2.0613 0.0000 0.2775
4 0.6250 0.1250 0.1250 2.3388 2.0613 0.0000 0.2775

total: 9.3553 8.2452 0.0000 1.1101

5 0.1215 0.1226 0.1291 2.9409 2.3371 0.0011 0.6026
6 0.5337 0.4661 0.0337 3.9136 3.3109 0.0166 0.5862
7 0.4540 0.1749 0.1808 3.9183 3.1991 0.0230 0.6963
8 0.6242 0.1233 0.1267 2.6997 2.1743 0.0010 0.5244
9 0.1233 0.6242 0.1257 2.6994 2.1742 0.0010 0.5242
10 0.0267 0.4794 0.0201 4.2170 3.5023 0.0256 0.6892
11 0.1226 0.1215 0.6268 2.9415 2.3376 0.0011 0.6027
12 0.2669 0.2672 0.2672 4.1676 3.3500 0.0568 0.7608
13 0.2734 0.2838 0.2761 4.1168 3.5224 0.0229 0.5716
14 0.4791 0.0269 0.5259 4.2186 3.5035 0.0256 0.6895
15 0.1749 0.4533 0.4591 3.9198 3.2002 0.0231 0.6965
16 0.2837 0.2734 0.2867 4.1167 3.5223 0.0228 0.5716
17 0.0342 0.0344 0.4658 4.1328 3.4335 0.0378 0.6615

total: 48.0028 39.5675 0.2583 8.1770
================================================================================
total: 57.3581 47.8127 0.2583 9.2871
average: 3.3740 2.8125 0.0152 0.5463
We see the Wannier functions corresponding to the two groups that we have specified. The first four Wannier functions correspond to the first group and the valence bands. The remaining 13 Wannier functions correspond to the second group. The second to fourth column display where in the crystal the corresponding Wannier functions are localized. The last four columns give us information about the individual spreads of the Wannier functions.
Note that the order of the resulting Wannier functions might vary. Further, due to the high symmetry in the diamond crystal, the localization centers might be different for your run. The minimization of the spread functional is a high dimensional optimization problem and the spread might have multiple equivalent minima and the algorithm might not necessarily converge to the same minimum. The resulting MLWFs are not unique. The sum of the spreads of each Wannier function (within each group), however, should be the same for each equivalent solution.
ii) Visualization of Wannier functions
Now we would like to take a closer look on how the actual functions we have computed in the previous step look like. From the result printed above we already see that the four Wannier functions corresponding to the four valence bands are perfectly centered in the middle of the four tetrahedral bonds of a carbon atom. In order to visualize that we have to make a few changes to the input file.
 Modify the line containing the element wannier as follows:
<wannier input="hybrid" do="fromfile">
 Add the following XML snippet inside the element properties
<! VISUALIZATION OF THE WANNIER FUNCTIONS > <wannierplot fst="1" lst="4" cell="1 1 1"> <plot3d> <box grid="60 60 60"> <origin coord="0.0 0.0 0.0"/> <point coord="1.0 0.0 0.0"/> <point coord="0.0 1.0 0.0"/> <point coord="0.0 0.0 1.0"/> </box> </plot3d> </wannierplot>
By adding do="fromfile" to the wannier element we tell exciting to read the already computed Wannier functions from the file WANNIER_TRANSFORM.OUT. Within the new element wannierplot we have do define a range of Wannier functions we want to visualize labeled by the first column in the above output. Here, we are going the visualize the four Wannier functions corresponding to the valence bands. With cell="1 1 1" we define in which unit cell we want the functions to be localized. This corresponds to the realspace lattice vector R labeling the Wannier function w_{n,R}(r). The realspace grid on which the functions are evaluated is specified by grid="60 60 60". The three point elements define a box (given by cartesian vectors) in which the functions are computed. The box is always centered around the origin which is given relative to the localization center of the corresponding Wannier function, i.e., setting the origin to zero already selects the region in real space where the Wannier function is localized.
Again we start the calculation with the command
$ time exciting_smp
After the calculation is finished (and assuming you have set up xcrysden for exciting) you can visualize the result in xcrysden by executing the script
$ PLOTwannierfunction.sh
ii) Electronic bandstructure using the Wannier interpolation scheme
Now that we have successfully constructed a set of maximally localized Wannier functions we can make use of it to calculate an accurate band structure. In order to perform the calculation using Wannier interpolation, do the following changes in the input file.
 Check if the line containing the element wannier is written as follows:
<wannier input="hybrid" do="fromfile">
 Inside the element properties, substitute the XML snippet appearing under "VISUALIZATION OF THE WANNIER FUNCTIONS" with the following one:
<! CALCULATION OF THE ELECTRONIC BANDSTRUCTURE > <bandstructure wannier="true"> <plot1d> <path steps="200"> <point coord="1.0 0.0 0.0" label="Gamma"/> <point coord="0.625 0.375 0.0" label="K"/> <point coord="0.5 0.5 0.0" label="X"/> <point coord="0.0 0.0 0.0" label="Gamma"/> <point coord="0.5 0.0 0.0" label="L"/> </path> </plot1d> </bandstructure>
Notice that in comparison with the standard case, the element bandstructure must have the explicit attribute wannier = "true".
Run the calculation with
$ time exciting_smp
For looking explicitly at the electronic bandstructure calculated using the PBE0 functional and the Wannier (WA) interpolation scheme, you can execute the script PLOTbandstructure.py (for a detailed description of the script arguments see The python script "PLOTbandstructure.py") as follows:
$ PLOTbandstructure.py a WA e 30 30
The generated plot PLOT.png shows the PBE0 band structure obtained using the Wannier interpolation scheme.
ii) Density of states using the Wannier interpolation scheme
After the calculation of the electronic bandstructure, we show how to obtain the density of states (DOS) with and without the use of the Wannier interpolation scheme. In order to perform the calculation using Wannier interpolation, do the following changes in the input file.
 Check if the line containing the element wannier is written as follows:
<wannier input="hybrid" do="fromfile">
 Inside the element properties, substitute the XML snippet appearing under "CALCULATION OF THE ELECTRONIC BANDSTRUCTURE" with the following one:
<! CALCULATION OF THE DENSITY OF STATES > <dos wannier="true" ngridkint="40 40 40" winddos="1 1" nwdos="1000" inttype="tetra"/>
The calculation of the DOS involves an integration over the Brillouin zone. In practice, this is approximated by a summation over a finite grid of reciprocal space points sampling the Brillouin zone.
In the snippet above, the attribute winddos="1 1" defines the energy window for which the DOS is calculated and nwdos="1000" gives the number of energy subdivisions within this window. With inttype="tetra" we specify the integration method (tetrahedron integration in this case).
Notice that in order to use the Wannier interpolation scheme, the element dos must contain the explicit attribute wannier = "true". Thus, the initial mesh specified by ngridk = "4 4 4" inside groundstate is "expanded" by Wannier interpolation to the mesh specified by ngridkint = "40 40 40".
Run the calculation as usual with
$ time exciting_smp
For looking explicitly at the DOS calculated using the PBE0 functional and the Wannier (WA) interpolation scheme, you can execute the script PLOTdos.py (for a detailed description of the script arguments see The python script "PLOTdos.py") as follows:
$ PLOTdos.py a WA t "ngridk = '4 4 4' + WA('40 40 40')"
The generated plot PLOT.png will look like the following
For the sake of comparison, we show in the next the calculation of the DOS using the PBE0 functional and the original mesh (KS) specified by ngridk = "4 4 4" without Wannier interpolation. To this purpose, modify the attributes of the element dos as follows:
<! CALCULATION OF THE DENSITY OF STATES > <dos winddos="1 1" nwdos="1000" inttype="tetra"/>
Run the calculation with
$ time exciting_smp
Now, we can compare the DOS calculated using the original mesh ("4 4 4") and the previus one obtained by Wannier (WA) interpolation of the original mesh to a "40 40 40" grid in reciprocal space. In order to visualize the results, execute
$ PLOTdos.py a WA KS ll "ngridk = '4 4 4' + WA('40 40 40')" "ngridk = '4 4 4'" rp
The resulting PLOT.png file should look like the following.
Literature
 S. Tillack, A. Gulans, and C. Draxl, Phys. Rev. B 101, 235102 (2020)
 Some further reading:
 N. Marzari and D. Vanderbilt, Phys. Rev. B 56, 12847 (1997)
 I. Souza, N. Marzari, and D. Vanderbilt, Phys. Rev. B 65, 035109 (2001)
 J. I. Mustafa, S. Coh, M. L. Cohen, and S. G. Louie, Phys. Rev. B 92, 165134 (2015)