Wannier functions1,2 (WFs) are a powerful tool for evaluating various electronic properties of solids, ranging from electric polarization3,4,5 and orbital magnetization6,7,8 to topological properties9,10,11,12,13. Moreover, WFs provide a way to describe a group of energy bands in a crystal by a compact Hamiltonian, thus allowing a fast evaluation of the band structure at any point of the Brillouin zone (BZ) without an extra call to the ab initio code14. This procedure called Wannier interpolation is similar in spirit to the tight-binding method15, but with the significant advantage that it offers a systematic way of precise description of any number of bands without truncation of the hopping integrals. Moreover, not only the band energies but also the matrix elements of various observables and operators, which are expressed in terms of wavefunctions and their derivatives over momentum space are precisely interpolated, while the tight-binding approach contains an unavoidable error due to the limited basis set. Wannier interpolation is particularly useful in the search for Weyl points in the band structure11,16, and in the evaluation of momentum-space integrals of rapidly varying functions. Such integrals appear, for example, in calculations of the anomalous Hall conductivity17, orbital magnetization18, Boltzmann transport coefficients19, and optical properties20,21. By now, Wannier interpolation schemes have been developed for many other properties that demand dense BZ samplings, such as electron-phonon coupling22,23, gyrotropic effects24, and spin Hall conductivity25,26.

Due to their gauge dependence, WFs are strongly non-unique and may be constructed in multiple ways. The most popular technique is the maximal localization procedure2,27, implemented in the well-established code Wannier9028,29, whose development is now driven by a broad community30. The construction of a good set of WFs requires some careful input from the user. This includes specifying a set of trial orbitals, which serve as an initial guess for the target WFs, and, if the bands of interest do not form an isolated group, choosing the “disentanglement” energy windows14. Recently, there has been significant progress in the automated construction of WFs with minimal user intervention. Different techniques have been proposed, such as the optimized projection functions method31, the selected columns of the density matrix method32,33,34, and an automated method to choose trial orbitals and energy windows35,36. In addition, a database of Wannier Hamiltonians is currently being constructed37. These advances constitute significant steps towards employing Wannier interpolation for high-throughput automated calculations of electronic properties of solids.

Most of the Wannier interpolation schemes mentioned above have been implemented within the popular codes—Wannier90 (namely its post-processing module postw90.x) and WannierTools11. These codes, being well-established and widely adopted by the community, have quite broad functionalities. However, more complex materials and physical effects pose harder numerical challenges, and calculation with those codes can become quite heavy. In particular, for a system with a large number of WFs and a complicated Fermi surface, it may be hard to achieve convergence with respect to momentum-space grid in a reasonable time. When it comes to high-throughput calculations, performance becomes even more important.

In this article, I present a series of methodological improvements that allow to improve dramatically the performance of the Wannier interpolation method, without compromising its accuracy. The proposed methodology is implemented in the python code WannierBerri (WB), which is freely available to install and open for contributors (see “Code availability”). The present article covers only the core methodology of the code which procure its efficiency. The more broad scope of the code can be found on its web page and will be detailed in future publications. Interesting to note that WannierBerri may be equally used for Wannier interpolation and tight-binding calculations, and also offers a convenient platform for the development of more functionality. The name of the code is derived from Wannier functions and the Basque word “berri” which means “new” and enters local toponyms (e.g., Lekunberri, Ekainberri).

The high efficiency of the WB code is achieved by the combination of several methodological improvements. First, note that in a typical calculation for a 3D bulk material using postw90.x, the bottleneck is the Fourier transform, which is implemented as a standard discrete Fourier transform. Therefore, it looks appealing to use fast Fourier transforms (FFTs)38,39 which are widely used in numerical calculations40,41. However, it is problematic to do so over a very dense grid of points, which may include up to 108 points. This issue is overcome in this work by a mixed scheme employing both fast and “slow” Fourier transforms. Next, the symmetries of the system may be used to reduce the evaluation only to the irreducible points and obtain the contributions from other points by applying symmetry operations. This also helps to render the result more symmetric (tensor components that should be equal or vanish will be exactly equal, or exactly vanish), even if the symmetries are slightly broken due to numerical inaccuracies in wannierization. Then I introduce an adaptive refinement algorithm that identifies points that give the largest contribution to the integral and makes the grid denser in the vicinity of such points. This helps to have a more accurate description near special points, where the integrand is rapidly changing—for example, near Weyl nodes or nodal lines. This is similar in spirit to the adaptive refinement scheme used in17,42, but is more automatic and requires less input from the user. Finally, I introduce methods that drastically reduce the computational cost of the minimal-distance replica selection method (MDRS)30, as well as the cost of scanning over multiple Fermi levels.

The article is organized as follows. First, I describe the set of proposed improvements to the existing Wannier interpolation methodology. Next, the usage of the code is demonstrated for the “textbook” example of the anomalous Hall conductivity of bcc iron, and the performance of the WB code is benchmarked against postw90 on the basis of that example. Finally, a broader functionality implemented in the WB code is described. “Methods” describes more computational details, and the routines to obtain the matrix elements that are not implemented in the interfaces of most ab initio codes to Wannier90, but essential to calculate the properties related to spin and orbital moment of Bloch electrons.


General equations for Wannier interpolation

We start with a brief overview of the Wannier interpolation method, mainly with a goal to introduce notation necessary for further discussion. For more details, please refer to review ref. 2 and original articles cited therein. The problem of Wannier interpolation is stated in the following way. First, we evaluate the energies Enq and wavefunctions ψnq(r) ≡ eiqrunq(r) from first principles on a rather coarse grid of \({N}_{{\bf{q}}}={N}_{{\bf{q}}}^{1}\times {N}_{{\bf{q}}}^{2}\times {N}_{{\bf{q}}}^{3}\) wavevectors q within the reciprocal unit cell. Next, we want to find the energies and wavefunctions at points on a denser grid of wavevectors k. Further, we will consistently use q and k to denote the ab initio and interpolation grids, respectively.

For a group of entangled bands, one can define a set of J WFs defined as

$$\left|{\bf{R}}n\right\rangle =\frac{1}{{N}_{{\bf{q}}}}\sum _{{\bf{q}}}{e}^{-i{\bf{q}}\cdot {\bf{R}}}\mathop{\sum }\limits_{m=1}^{{{\mathcal{J}}}_{{\bf{q}}}}\left|{\psi }_{m{\bf{q}}}\right\rangle {V}_{mn}({\bf{q}}),$$

where \({{\mathcal{J}}}_{{\bf{q}}}\ge J\) and R are real-space lattice vectors. The matrices \({V}_{mn^{\prime} }({\bf{q}})\) contain all the information on the construction of WFs and may be generated by the Wannier90 code. They are constrained by \(\mathop{\sum }\nolimits_{m = 1}^{{{\mathcal{J}}}_{{\bf{q}}}}{V}_{mn}^{* }({\bf{q}}){V}_{mn^{\prime} }({\bf{q}})={\delta }_{nn^{\prime} }\) and are chosen in such a way that the WFs are localized, which yields that the Bloch wavefunctions in the Wannier gauge

$$\left|{\psi }_{n{\bf{k}}}^{{\rm{W}}}\right\rangle \equiv {e}^{i{\bf{k}}\cdot {\bf{r}}}\left|{u}_{n{\bf{k}}}^{{\rm{W}}}\right\rangle \equiv \sum _{{\bf{R}}}{e}^{i{\bf{k}}\cdot {\bf{R}}}\left|{\bf{R}}n\right\rangle$$

vary slowly with the k vector, unlike the true wavefunctions. Now let us see how WFs may be used to interpolate the band energies. First, one evaluates the matrix elements of the Hamiltonian

$$\begin{array}{lll}{H}_{mn}({\bf{R}})&\equiv &\frac{1}{{N}_{{\bf{q}}}}\mathop{\sum}\limits_{{\bf{q}}}{e}^{-i{\bf{q}}\cdot {\bf{R}}}\langle {\psi }_{m{\bf{q}}}^{{\rm{W}}}| \hat{H}| {\psi }_{n{\bf{q}}}^{{\rm{W}}}\rangle\\ &=&\frac{1}{{N}_{{\bf{q}}}}\mathop{\sum}\limits_{{\bf{q}}}{e}^{-i{\bf{q}}\cdot {\bf{R}}}\mathop{\sum}\limits_{l}{V}_{lm}^{* }({\bf{q}}){E}_{l{\bf{q}}}{V}_{ln}({\bf{q}}).\end{array}$$

Next, to obtain energies at an arbitrary point k one needs to construct the Wannier Hamiltonian

$${H}_{mn}^{{\rm{W}}}({\bf{k}})=\sum _{{\bf{R}}}{H}_{mn}({\bf{R}}){e}^{i{\bf{k}}\cdot {\bf{R}}},$$

which further may be diagonalized as

$$\sum _{mn}{U}_{ml}^{* }({\bf{k}}){H}_{mn}^{{\rm{W}}}({\bf{k}}){U}_{nl^{\prime} }({\bf{k}})={E}_{l}({\bf{k}}){\delta }_{ll^{\prime} },$$

where \({U}_{nl^{\prime} }({\bf{k}})\) are unitary matrices with columns corresponding to the eigenvectors of the Hamiltonian (4). In a similar way, for any operator \(\hat{X}\), for which the matrix elements are evaluated on the ab initio grid, one may obtain the real-space matrix elements

$${X}_{mn}({\bf{R}})\equiv \frac{1}{{N}_{{\bf{q}}}}\sum _{{\bf{q}}}{e}^{-i{\bf{q}}\cdot {\bf{R}}}{X}_{mn}^{\,\text{W}\,}({\bf{q}}),$$

where in a simple case (e.g., \(\hat{X}={\boldsymbol{\sigma }}\))

$${X}_{mn}^{\,\text{W}\,}({\bf{q}})=\sum _{ll^{\prime} }{V}_{lm}^{* }({\bf{q}})\langle {\psi }_{m{\bf{q}}}| \hat{X}| {\psi }_{n{\bf{q}}}\rangle {V}_{l^{\prime} n}({\bf{q}}),$$

or if \(\hat{X}\) involves momentum-space derivatives, (e.g., the position operator \({\hat{r}}_{\alpha }\equiv i\partial /\partial {k}_{\alpha }\)) may also involve matrix elements between neighboring q points (see refs. 17,18 for details). Then the matrix elements may be interpolated to any k point in the Wannier gauge by

$${X}_{mn}^{{\rm{W}}}({\bf{k}})=\sum _{{\bf{R}}}{X}_{mn}({\bf{R}}){e}^{i{\bf{k}}\cdot {\bf{R}}},$$

and further rotated to the Hamiltonian gauge

$${\overline{X}}_{mn}^{{\rm{H}}}({\bf{k}})={\left({U}^{\dagger }\cdot {X}^{{\rm{W}}}\cdot U\right)}_{mn}.$$

Note that Eqs. (3), (4), and (5) are particular cases of (6), (8), and (9). Equation (6) can be performed by means of FFT, and its result is periodic in R with a supercell formed by vectors \({{\bf{A}}}_{i}={{\bf{a}}}_{i}{N}_{{\bf{q}}}^{i}\), where ai (i = 1, 2, 3) are the primitive unit cell vectors. Among the equivalent R vectors, we choose those belonging to the corresponding Wigner–Seitz (WS) supercell. If an R vector belongs to the WS supercell boundary, we include all equivalent vectors on the boundary with the corresponding elements X(R) divided by the degeneracy of the R vector. Further, the MDRS method (see “Minimal-distance replica selection method (MDRS)”) may also slightly modify the set of R vectors.

As an example, the total Berry curvature of the occupied manifold is interpolated17 via

$$\begin{array}{lll}{{{\Omega }}}_{\gamma }({\bf{k}})\,=\,{\mathrm{Re}}\ \mathop{\sum }\limits_{n}^{\,\mathrm{occ}\,}{\overline{{{\Omega }}}}_{nn,\gamma }^{{\mathrm{H}}}-2{\epsilon }_{\alpha \beta \gamma }{\mathrm{Re}}\ \mathop{\sum }\limits_{n}^{\,\mathrm{occ}}\mathop{\sum }\limits_{l}^{\mathrm{unocc}\,}{D}_{nl,\alpha }{\overline{A}}_{ln,\beta }^{{\mathrm{H}}}\\ \qquad\quad\,+\,{\epsilon }_{\alpha \beta \gamma }{\mathrm{Im}}\ \mathop{\sum}\limits_{n}^{\,\mathrm{occ}}\mathop{\sum}\limits_{l}^{\mathrm{unocc}\,}{D}_{nl,\alpha }{D}_{ln,\beta },\end{array}$$

where the ingredients of the equation are obtained using Eqs. (8), (9) starting from \({D}_{nl,\alpha }\equiv \frac{{\overline{H}}_{nl,\alpha }^{{\rm{H}}}}{{E}_{l}-{E}_{n}}\), \({H}_{\alpha }^{{\rm{W}}}\equiv {\partial }_{\alpha }{H}^{{\rm{W}}}\), \({A}_{mn,\alpha }({\bf{R}})\equiv \langle {\boldsymbol{0}}m| {\hat{r}}_{\alpha }| {\bf{R}}n\rangle\), \({\overline{{{\Omega }}}}_{\gamma }^{{\rm{W}}}\equiv {\epsilon }_{\alpha \beta \gamma }{\partial }_{\alpha }{A}_{\beta }^{{\rm{W}}}\), ∂α ≡ ∂/∂kα. The anomalous Hall conductivity is evaluated as an integral

$${\sigma }_{\alpha \beta }^{{\rm{AHE}}}=-\frac{{e}^{2}}{\hslash }{\epsilon }_{\alpha \beta \gamma }\int \frac{d{\bf{k}}}{{(2\pi )}^{3}}{{{\Omega }}}_{\gamma }({\bf{k}}).$$

Note, that while the direct Fourier transform (6) is performed only once for the calculation, and is not repeated for the multiple k points upon interpolation, the inverse Fourier transform (8) is repeated for every interpolation k point. In fact, it presents the most time-consuming part of the calculation of AHE in relatively small 3D bulk systems as implemented in the Wannier90 code.

Mixed Fourier transform

In this section, we will see how the evaluation of Eq. (8) may be accelerated. It is easy to see that the computation time of a straightforward discrete Fourier transform scales with the number of R vectors and k points as tNRNk, and we are typically interested in a case NkNR (NR ≈ Nq).

When the Fourier transform is done on a regular grid of k points, it is usually appealing to use the FFT. For that one needs to place the R vectors on a regular grid of size Nk, fill the missing spots with zeros and perform the standard FFT, for which the time will scale as \(t\propto {N}_{{\bf{k}}}\mathrm{log}\,{N}_{{\bf{k}}}\). However, there are some difficulties with such FFT. Mainly, because to perform FFT on a large grid implies storing the data for all k points in memory at the same time, which becomes a severe computational limitation. Also, FFT does not allow to reduce computation to only the symmetry-irreducible k points and is more difficult to do in parallel. However, there is a way to combine the advantages of both the FFT and the usual discrete Fourier transform, leading to the concept of mixed Fourier transform.

We want to evaluate Eq. (8) for a set of k points.


where \(0\le {n}_{i}\, <\,{N}_{{\bf{k}}}^{i}\) – integers (i = 1, 2, 3), \({N}_{{\bf{k}}}^{i}\)—size of interpolation grid, bi—reciprocal lattice vectors. Now suppose we can factorize \({N}_{{\bf{k}}}^{i}={N}_{{\rm{FFT}}}^{i}{N}_{{\bf{K}}}^{i}\). This is always possible unless \({N}_{{\bf{k}}}^{i}\) is a prime number. But for really dense grids, we can adjust \({N}_{{\bf{k}}}^{i}\) a bit, to be factorizable in any way we want. Then the set of points Eq. (12) is equivalent to a set of points k = K + κ, where

$${{\boldsymbol{\kappa }}}_{{m}_{1},{m}_{2},{m}_{3}}=\frac{{m}_{1}}{{N}_{{\rm{FFT}}}^{1}}{{\bf{b}}}_{1}+\frac{{m}_{2}}{{N}_{{\rm{FFT}}}^{2}}{{\bf{b}}}_{2}+\frac{{m}_{3}}{{N}_{{\rm{FFT}}}^{3}}{{\bf{b}}}_{3},$$

where \(0\le {l}_{i}\,<\,{N}_{{\bf{K}}}^{i}\), \({N}_{{\bf{K}}}={\prod }_{i}{N}_{{\bf{K}}}^{i}\), \(0\le {m}_{i}<{N}_{{\mathrm{FFT}}}^{i}\). This separation is illustrated in Fig. 1a, which shows a 2 × 2 grid of K points, each corresponding to 4 × 4 FFT grid (dots of a certain color). Now for each K point, we can define

$${X}_{mn}({\bf{K}},{\bf{R}})\equiv {X}_{mn}({\bf{R}}){e}^{i{\bf{K}}\cdot {\bf{R}}}$$

and then Eq. (8) reads as

$${X}_{mn}^{{\rm{W}}}({\bf{k}}={\bf{K}}+{\boldsymbol{\kappa }})=\sum _{{\bf{R}}}{X}_{mn}({\bf{K}},{\bf{R}}){e}^{i{\boldsymbol{\kappa }}\cdot {\bf{R}}}$$

The principle idea of mixed Fourier transform consists in performing the Fourier transform Eq. (15) as FFT, while Eq. (14) is performed directly. To perform the FFT, we put all the R vectors on a grid \({N}_{{\rm{FFT}}}^{1}\times {N}_{{\rm{FFT}}}^{2}\times {N}_{{\rm{FFT}}}^{3}\), and a vector \({\bf{R}}=\mathop{\sum }\nolimits_{i = 1}^{3}{n}_{i}{{\bf{a}}}_{i}\) is placed on a slot with coordinates \({\widetilde{n}}_{i}={n}_{i}\ {\rm{mod}}\ {N}_{{\rm{FFT}}}^{i}\) (ni are both positive and negative integers, while \(0\le {\widetilde{n}}_{i}<{N}_{{\rm{FFT}}}^{i}\)). If the FFT grid is not big enough, contributions from different R vectors may appear on the same slot. In this case, they should be added up, and it does not affect the final results. However, for optimal performance, such a situation should be avoided at least for the majority of R vectors. Typically, it is a good choice to take the size of the FFT grid approximately equal to the ab initio grid.

Fig. 1: Illustration of the procedure of mixed Fourier transform, adaptive refinement, and use of symmetries.
figure 1

af show the procedure step by step using a 2D picture for visualization purposes, while the code actually works in 3D. The area of colored circles corresponds to the weight of the K point, gray crosses denote the points with zero weight. See the text for a detailed description. g AHC of bcc Fe, evaluated from a grid of 50 × 50 × 50 k points and 50 recursive adaptive refinement iterations.

The advantages of this approach are the following. First, the computational time scales as t1NKNR for Eq. (14) and \({t}_{2}\propto {N}_{{\bf{K}}}{N}_{{\rm{FFT}}}\mathrm{log}\,{N}_{{\rm{FFT}}}\) for Eq. (15). Because it is required that NFFT ≥ NR (to fit all R vectors in the FFT box), we have \({t}_{1}\le {t}_{2}\propto {N}_{{\bf{k}}}\mathrm{log}\,{N}_{{\rm{FFT}}}\) (in practice it occurs that t1t2), which scales better than both the Fast and “slow” Fourier transforms. Next, we can perform Eqs. (14) and (15) independently for different K points. This saves us memory and also offers a simple parallelization scheme. Also, we can further restrict evaluation only to symmetry-irreducible K points (see “Symmetries”) and also perform adaptive refinement over K points (see “Recursive adaptive refinement”).

Moreover, the evaluation time of a mixed Fourier transform only logarithmically depends on the size of the ab initio grid (recall that NFFT ~ NR ~ Nq), while for the slow Fourier transform, the dependence is linear. However, in practice, we will see (see “Computation time”) that the Fourier transform in the present implementation consumes only a small portion of computational time, and therefore the overall computational time is practically independent of the size of the ab initio grid.


When we integrate some quantity over the BZ, at every K point (after summing over κ points), we obtain the result as a rank-m tensor \({X}_{{i}_{1},\ldots ,{i}_{m}}({\bf{K}})\), for example, the berry curvature vector Ωγ or the conductivity tensor σxy. Then the BZ integral is expressed as a sum

$${\mathcal{X}}=\mathop{\sum }\limits_{{\bf{K}}}^{{\rm{all}}}X({\bf{K}}){w}_{{\bf{K}}}$$

and we initially set {K} as a regular grid (13a) and wK = 1/NK. Suppose G is the magnetic point group of the system. (Because X(K) is invariant under translations, here we are interested in the point group, rather than space group.) We define the set of symmetry-irreducible K points irr as a set of points that \(\forall {\bf{K}},{\bf{K}}^{\prime} \in {\rm{irr}}\), gG holds \(g{\bf{K}}\,\ne \,{\bf{K}}^{\prime}\), unless g = E (identity). Then we can rewrite the sum Eq. (16) as

$${\mathcal{X}}=\mathop{\sum }\limits_{{\bf{K}}}^{{\rm{all}}}{g}_{{\bf{K}}}X({g}_{{\bf{K}}}^{-1}{\bf{K}}){w}_{{\bf{K}}}$$

where we choose gK such that \({g}_{{\bf{K}}}^{-1}{\bf{K}}\in {\rm{irr}}\) (this choice maybe not unique), and obviously gK = E for K irr. Thus, only the irreducible K points need to be evaluated. Next, to make sure that the result respects the symmetries, despite possible numerical inaccuracies, we symmetrize the result as:

$$\widetilde{{\mathcal{X}}}=\frac{1}{| G| }\mathop{\sum }\limits_{f}^{G}f{\mathcal{X}}.$$

Note, that \(\widetilde{{\mathcal{X}}}={\mathcal{X}}\) if the model respects the symmetry precisely (e.g., when symmetry-adapted WFs43 are used). Combining Eqs. (17) and (18) and using \(\mathop{\sum }\nolimits_{f}^{G}f\cdot {g}_{{\bf{K}}}=\mathop{\sum }\nolimits_{f}^{G}f\), we get

$$\widetilde{{\mathcal{X}}}=\frac{1}{| G| }\mathop{\sum }\limits_{f}^{G}f\left[\mathop{\sum }\limits_{{\bf{K}}}^{{\rm{irr}}}X({\bf{K}})\left(\mathop{\sum }\limits_{{\bf{K}}^{\prime} }^{G\cdot {\bf{K}}}{w}_{{\bf{K}}^{\prime} }\right)\right],$$

where GK denotes the orbit of K under the action of group G. The latter equation reflects the implementation in the WB code. Starting from a regular grid of K points, we search for pairs of symmetry-equivalent points. Whenever such a pair is found, one of the points is excluded and it’s weight is transferred to the other point. Compare Fig. 1a, b: the red points are removed and their weight is moved to green points. Thus we end with a set of irreducible K point with weights \({\widetilde{w}}_{{\bf{K}}}=\mathop{\sum }\nolimits_{{\bf{K}}^{\prime} }^{G\cdot {\bf{K}}}{w}_{{\bf{K}}^{\prime} }\). Next, we evaluate X(K) (employing the corresponding interpolation scheme) only at symmetry-irreducible K points. Note, that although some k points corresponding to the same K point (same color in Fig. 1) are equivalent, we have to evaluate them all to be able to use the FFT. Finally, after summation, we symmetrize the result. The described procedure achieves two goals: (i) reduce the computational costs, and (ii) make the result precisely symmetric, even if the WFs are not perfectly symmetric. In the present example, we managed to obtain highly symmetric WFs (although without the employment of symmetry-adapted WFs method), and therefore the symmetrization procedure does not change the result (within relative accuracy ~10−5). However, for complex materials, such quality of WFs is not always easy to achieve.

Recursive adaptive refinement

It is well-known that in calculations of quantities involving Berry curvature (33) or orbital moment (34) of Bloch states (e.g., AHC, Berry curvature dipole (29)44 or gyrotropic magnetoelectric tensor (30)24,45), one performs integration over k-space of a function that rapidly changes with k. As a result, small areas of k-space give a major contribution to the integral. Such areas often appear in the vicinity of Weyl points, nodal lines, as well as avoided crossings. To accelerate convergence with respect to the number of k points, we utilize adaptive mesh refinement similar to refs. 17,42. The authors of refs. 17,42 assumed a pre-defined threshold, and the k points yielding Berry curvature above the threshold was refined. This is inconvenient because one needs a good intuition to guess an optimal value for this threshold because it depends both on the quantity one wants to calculate, and the material considered.

In WB, it is implemented in a way that does not require an initial guess from the user. This procedure, in combination with the symmetrization described above, is illustrated in Fig. 1 in two dimensions (2D), while the actual work in 3D is described below. After excluding symmetry-equivalent K points (Fig. 1b), the results are evaluated for every K point and stored. We assume that initially each K point has weight \({\widetilde{w}}_{{\bf{K}}}\) and corresponds to a volume defined by vectors \({{\bf{c}}}_{{\bf{K}}}^{i}={{\bf{b}}}_{i}/{N}_{{\bf{k}}}^{i}\) centered at K. Then we pick a few “most important K points”. The criteria of importance may be different—either the Maximal value for any EF, or maximal value summed over all EF, or yielding most variation over the EF (if the evaluated quantity is a function of Fermi level EF). Suppose we selected the magenta point, then those points are refined–replaced with eight points around it with coordinates

$${\bf{K}}^{\prime} ={\bf{K}}\pm \frac{{{\bf{c}}}_{{\bf{K}}}^{1}}{4}\pm \frac{{{\bf{c}}}_{{\bf{K}}}^{2}}{4}\pm \frac{{{\bf{c}}}_{{\bf{K}}}^{3}}{4},$$

where all combinations of ± signs are used. In Fig. 1c, four new blue K points in the 2D case. The weight and volume of the initial point is distributed over the new points, thus \({w}_{{\bf{K}}^{\prime} }={\widetilde{w}}_{{\bf{K}}}/8\) and \({{\bf{c}}}_{{\bf{K}}^{\prime} }^{i}={{\bf{c}}}_{{\bf{K}}}^{i}/2\). Then the symmetrization is applied again (the four blue points are connected by fourfold rotation) to exclude the equivalent points, and the weight of the equivalent points is collected on the remaining point, while the vectors \({{\bf{c}}}_{{\bf{K}}^{\prime} }^{i}\) are not changed. After the new K points are evaluated, we go to the next iteration of refinement. On each iteration, any point may be refined, including both those from the initial regular grid, and those created during previous refinement iterations. The procedure stops after the pre-defined number of iterations was performed. Figure 1g shows how undesired artificial peaks of the AHC curve are removed iteration by iteration, yielding a smooth curve (see “Example: AHC of bcc iron” for details).

Minimal-distance replica selection method (MDRS)

The MDRS method30 allows to obtain a more accurate Wannier interpolation, in particular when moderate q grids are used in the ab initio calculations. With the MDRS method, the Fourier transform (8) is modified in the following way:

$${X}_{mn}^{{\rm{W}}}({\bf{k}})=\sum _{{\bf{R}}}\frac{1}{{{\mathcal{N}}}_{mn{\bf{R}}}}{X}_{mn}({\bf{R}})\mathop{\sum }\limits_{j=1}^{{{\mathcal{N}}}_{mn{\bf{R}}}}{e}^{i{\bf{k}}\cdot \left({\bf{R}}+{{\bf{T}}}_{mn{\bf{R}}}^{(j)}\right)},$$

where \({{\bf{T}}}_{mn{\bf{R}}}^{(j)}\) are \({{\mathcal{N}}}_{mn{\bf{R}}}\) lattice vectors that minimize the distance rm − (rn + R + T) for a given set m, n, R. However, the evaluation of Eq. (21) is quite slower than Eq. (8), because every k, m, n, R an extra loop over j is needed. Therefore, calculations employing MDRS in postw90.x (which is enabled by default) takes more time. Instead, it is convenient to re-define the real-space matrix elements as

$${\widetilde{X}}_{mn}({\bf{R}})=\sum _{{\bf{R}}^{\prime} }\frac{1}{{{\mathcal{N}}}_{mn{\bf{R}}^{\prime} }}{X}_{mn}({\bf{R}}^{\prime} )\mathop{\sum }\limits_{j=1}^{{{\mathcal{N}}}_{mn{\bf{R}}^{\prime} }}{\delta }_{{\bf{R}},{\bf{R}}^{\prime} +{{\bf{T}}}_{mn{\bf{R}}^{\prime} }^{(j)}}$$

only once for the calculation, and then the transformation to k-space is performed via

$${X}_{mn}^{{\rm{W}}}({\bf{k}})=\sum _{{\bf{R}}}{e}^{i{\bf{k}}{\bf{R}}}{\widetilde{X}}_{mn}({\bf{R}}).$$

Note, that the set of R vectors in Eq. (22) is increased compared to the initial set of vectors in Eq. (6) in order to fit all nonzero elements \({\widetilde{X}}_{mn}({\bf{R}})\). Equation (23) having essentially the same form as Eq. (8) can be evaluated via mixed Fourier transform, as described in section “Mixed Fourier transform”.

Thus the MDRS method is implemented in WB via Eqs. (22)–(23), and has practically no extra computational cost, while giving notable accuracy improvement.

Scanning multiple Fermi levels

It is often needed to study anomalous Hall conductivity (AHC) not only for the pristine Fermi-level EF but considering it as a free parameter ϵ. On the one hand, it gives an estimate of the accuracy of the calculation, e.g., sharp spikes may indicate that the result is not converged. On the other hand, ϵ-dependence gives access to the question of the influence of doping and temperature, and also allows calculation of anomalous Nernst effect (27). As implemented in postw90.x, evaluation of multiple Fermi levels has a large computational cost. However, there is a way to perform the computation of AHC for multiple Fermi levels almost without extra costs. To show this, let’s rewrite Eqs. (10), (11) as \({\sigma }_{\alpha \beta }(\epsilon )=-{\epsilon }_{\alpha \beta \gamma }\frac{{e}^{2}}{\hslash }{{{\Omega }}}_{\gamma }(\epsilon )\), where Ωγ(ϵ) = ∑KwKΩγ(K, ϵ) and

$${{\Omega }}({\bf{K}},\epsilon )=\sum _{{\boldsymbol{\kappa }}}\left(\mathop{\sum }\limits_{n}^{O({\bf{k}},\epsilon )}{P}_{n}({\bf{k}})+\mathop{\sum }\limits_{l}^{U({\bf{k}},\epsilon )}\mathop{\sum }\limits_{n}^{O({\bf{k}},\epsilon )}{Q}_{ln}({\bf{k}})\right),$$

where k = K + κ, the definitions of Pn and Qln straightly follow from Eq. (10), and we omit the cartesian index γ further in this subsection. Now suppose we want to evaluate Ω(ϵi) for a series of Fermi levels ϵi. For different k-points and Fermi levels ϵ, the sets of occupied O(k, ϵ) and unoccupied states U(k, ϵ) change, and repeating these summations many times may be computationally heavy. Instead, we note that when going from one Fermi-level ϵi to another ϵi+1 only a few states at a few κ points change from unoccupied to occupied. Let’s denote the set of such κ points as δκi then, the change of the total Berry curvature is

$$\begin{array}{lll}\delta {{{\Omega }}}_{i}&\equiv &{{\Omega }}({\epsilon }_{i+1})-{{\Omega }}({\epsilon }_{i})=\\ &=&\mathop{\sum }\limits_{{\bf{k}}}^{\delta {\kappa }_{i}}\left(\mathop{\sum }\limits_{n}^{O({\bf{k}},{\epsilon }_{i+1})}{P}_{n}({\bf{k}})+\mathop{\sum }\limits_{l}^{U({\bf{k}},{\epsilon }_{i+1})}\mathop{\sum }\limits_{n}^{O({\bf{k}},{\epsilon }_{i+1})}{Q}_{ln}({\bf{k}})-\mathop{\sum }\limits_{n}^{O({\bf{k}},{\epsilon }_{i})}{P}_{n}({\bf{k}})-\mathop{\sum }\limits_{l}^{U({\bf{k}},{\epsilon }_{i})}\mathop{\sum }\limits_{n}^{O({\bf{k}},{\epsilon }_{i})}{Q}_{ln}({\bf{k}})\right)\\ &=&\mathop{\sum }\limits_{{\bf{k}}}^{\delta {\kappa }_{i}}\left(\mathop{\sum }\limits_{n}^{\delta {O}_{i}({\bf{k}})}{P}_{n}+\mathop{\sum }\limits_{l}^{U({\bf{k}},{\epsilon }_{i+1})}\mathop{\sum }\limits_{n}^{\delta {O}_{i}({\bf{k}})}{Q}_{ln}({\bf{k}})-\mathop{\sum }\limits_{l}^{\delta {O}_{i}({\bf{k}})}\mathop{\sum }\limits_{n}^{O({\bf{k}},{\epsilon }_{i})}{Q}_{ln}({\bf{k}})\right),\end{array}$$

where δOi(k) ≡ O(k, ϵi+1) − O(k, ϵi). Note that if the step ϵi+1 − ϵi is small, then δκi and δOi(k) include only a few elements, if not empty. Hence, the evaluation of Eq. (25) will be very fast. Thus, the full summation Eq. (24) is needed only for the first Fermi level.

In a similar way, this approach may be applied to other Fermi-sea properties such as orbital magnetization, which may be written as

$$\begin{array}{lll}{M}_{\gamma }({\bf{k}})&=&\mathop{\sum }\limits_{n}^{\,\text{occ}\,}{\rm{Re}}\ \left[{\overline{C}}_{nn,\gamma }^{{\rm{H}}}+{E}_{n}{\overline{{{\Omega }}}}_{nn,\gamma }^{{\rm{H}}}\right]-\\ &&-2{\epsilon }_{\alpha \beta \gamma }\mathop{\sum }\limits_{l}^{\,\text{unocc}}\mathop{\sum }\limits_{n}^{\text{occ}\,}{\rm{Re}}\ \left[{D}_{nl,\alpha }({\overline{B}}_{ln,\beta }^{{\rm{H}}}+{\overline{A}}_{ln,\beta }^{{\rm{H}}}{E}_{n})\right]\\ &&+{\epsilon }_{\alpha \beta \gamma }{\rm{Im}}\ \mathop{\sum }\limits_{l}^{\,\text{unocc}}\mathop{\sum }\limits_{n}^{\text{occ}\,}{D}_{nl,\alpha }({E}_{l}+{E}_{n}){D}_{ln,\beta }\end{array}$$

where \({C}_{mn,\gamma }({\bf{R}})\equiv {\epsilon }_{\alpha \beta \gamma }\langle {\boldsymbol{0}}m| {r}_{\alpha }\cdot \hat{H}\cdot ({r}_{\beta }-{R}_{\beta })| {\bf{R}}n\rangle\), \({B}_{mn,\beta }({\bf{R}})\equiv \langle {\boldsymbol{0}}m| \hat{H}\cdot ({r}_{\beta }-{R}_{\beta })| {\bf{R}}n\rangle\) and the other ingredients were explained under Eq. (10). Equation (26) is written following the approach of ref. 18, but the result has a different form, which can be straightforwardly processed by analogy with Eqs. (24) and (25), where the first line of Eq. (26) expresses Pn(k), while the second and third lines correspond to Qln(k). Note that evaluation of Cmn,γ(R) requires additional matrix elements evaluated on the ab initio grid, see “Evaluation of additional matrix elements” for details.

Example: AHC of bcc iron

In this section, the usage of the WannierBerri code is demonstrated on a simple example—anomalous Hall conductivity of bcc iron. After the Wannier functions are constructed with Wannier90 (see “Computational details”), the calculation is performed by the following short python script. First, we import the needed packages:

import wannierberri as WB

import numpy as np

Then, we read the information about the system and WFs:


from files Fe.chk, Fe.eig, Fe.mmn (the first is written by Wannier90, the other two by the interface of the ab initio code, e.g., pw2wannier90.x), or we can read all information from a file Fe_tb.dat, which is also written by Wannier90, or maybe composed by the user from any tight-binding model:


Next, we define the symmetries that we wish to take into account. In the ab initio calculation, we have specified the magnetization along the z axis, hence the symmetries that are preserved are inversion \({\mathcal{I}}\), fourfold rotation around the z axis C4z, and a combination of time-reversal \({\mathcal{T}}\) and twofold rotation around the x axis C2x. Here, we need only the generators of the symmetry group.



The other symmetries will be automatically obtained by taking products of these generators, for example, the mirror is \({M}_{z}={({C}_{4z})}^{2}\cdot {\mathcal{I}}\).

Next, we need to set the grids of k, K, and κ points. Most conveniently, it can be done by setting the “length” parameter (in Å):


This will guarantee the grid to be consistent with the symmetries, and the spacing of k points will be \({{\Delta }}k\approx \frac{2\pi }{{\rm{length}}}\). In this particular case, the reciprocal lattice vectors have length bi = 3.1 Å−1, hence the suggested grid size is \(\frac{{\rm{length}}\cdot | {{\bf{b}}}_{i}| }{2\pi }\approx 49\). However, the grid size is adjusted to 50 × 50 × 50 points in order to factorize it as 10 × 10 × 10κ grid and 5 × 5 × 5K grid.

Next, we want to integrate the Berry curvature to get the AHC. This is done by the WB.integrate method.

WB.integrate(system, grid,


smearEf=10, # 10K





and in addition to AHC, we evaluate the cumulative density of states (cDOS) Eq. (32). We consider Fermi level as a free parameter, scanning over a set of Fermi levels from 17 to 18 eV with a step of 1 meV, and small smearing over the Fermi level corresponding to temperature 10 K (~1 meV) is used. It is known, that in the BZ integration, some k points may give a large contribution to the integral. This is especially strong for Berry curvature, which blows up near band degeneracies and avoided crossings, that fall close to the Fermi level. This is reflected as huge spikes in the EF-resolved curves—see blue curve in Fig. 1g. To make the calculation more precise around such points, an adaptive recursive refinement algorithm is used, and we set the number of iterations to 50.

From the cDOS, we can find the precise position of the Fermi level EF = 17.618 eV—the energy at which the cumulative DOS reaches eight electrons per unit cell. This is more accurate than the result evaluated from a coarse ab initio grid. Next, it is instructive to plot the AHC after each iteration. In Fig. 1g, one can see that after 50 iterations the chaotic peaks are removed, and we can get a reasonably smooth curve, although we have started from a rather coarse grid of only 50 × 50 × 50 k points. In practice, it is still recommended to start with denser grids, when possible.

To demonstrate why the adaptive refinement is so useful for calculations of AHC, we can also visualize the Berry curvature. With the following lines

WB.tabulate(system, grid,






we produce files Fe_berry-?.frmsf, containing the energies and Berry curvature of bands 4-8 (band counting starts from zero) tabulated over the 3D Brillouin zone. The format of the files allows being directly passed to the FermiSurfer visualization tool46 which can produce a plot like Fig. 2, which clearly shows that Berry curvature is large in the regions where two bands come close to each other.

Fig. 2: Fermi surface of bcc iron.
figure 2

Color shows the Berry curvature Ωz on a logarithmic scale. Figure produced using FermiSurfer46 software.

This short example demonstrates that the calculations with WB may be run with a few lines of Python script and the broader functionality will be detailed further.

Computation time

Now let us compare the time for the calculations of anomalous Hall conductivity using postw90.x and WannierBerri. We will take the example of bcc Fe and vary different parameters while using the same computational resource (see “Methods”).

The computation consists of two phases. First, some preliminary operations are done. Those include reading the input files and performing Fourier transform from ab initio grid q to real-space vectors R : Eqs. (3), (6), and (7). This operation takes in WB (postw90.x) between 2 (3) seconds for the small q grid 4 × 4 × 4 and 2 (3) minutes for a large grid of 16 × 16 × 16. This time is mostly taken by reading the large formatted text file Fe.mmn, and it is done only once and does not scale with the density of the interpolation grid. In WB this is done in the constructor of the System_w90 class, and the object can be saved on disk using a pickle module so that this operation does not repeat for further calculations.

Next comes the interpolation part itself, for which the evaluation time scales linearly with the number of k points used. Further, the time for an interpolation grid 200 × 200 × 200 is given, which is a rather good grid to make an accurate calculation for this material.

We start with comparing time with the MDRS switched off and without the use of symmetries in WB. As can be seen in Fig. 3, for a small q grid 4 × 4 × 4 WB is just slightly faster then postw90.x. However, for dense q grids the computational time of postw90.x grows linearly with the number of q points, while in WB it stays almost the same. This happens because in postw90.x the Fourier transform is the major time-consuming routine. On the other hand, in WB, although the cost of the mixed Fourier transform is expected to grow logarithmically with the ab initio grid, we do not see it because Fourier transform amounts only to ~10% of the computational time.

Fig. 3: Computational time for AHC.
figure 3

Time for calculations with WB (triangles) and postw90.x (circles) for different ab initio grids. For postw90.x, the calculations are done with (green) and without (purple) MDRS. For WB, the calculations are done with (cyan) and without (red) use of symmetries.

Next, we switch on the MDRS method and the computational time of postw90.x grows by a factor of 5. On the other hand, the computational time of WannierBerri does not change (not shown).

Finally, let’s switch on the use of symmetries in WB. Thus the computational time decreases by a factor of 8. In the ultra-dense grid limit, one would expect the speedup to be approximately equal to the number of elements in the group—16 in the present example, due to exclusion of symmetry-equivalent K points. But this does not happen, because we use an FFT grid of 25 × 25 × 25 κ points for all ab initio grids, hence the K grid is only 8 × 8 × 8, and a considerable part of K points are at high-symmetry positions. Therefore they have less symmetric partners to be excluded from the calculation.

Thus we can see that the difference in computational time with postw90.x and WB reaches three orders of magnitude for this example. Note that the examples above were performed only for the pristine Fermi level. Now let’s see what happens upon scanning the Fermi levels (Fig. 4). In WB, the computational time remains practically unchanged when we use up to Nϵ ≈ 1000 Fermi levels, and only start to grow considerably at Nϵ ~ 104. On the other hand in postw90.x, the computational time significantly grows with Nϵ, which is especially remarkable for small q grids, where the growth becomes linear already from Nϵ ~10. For denser q grids, the fixed amount of time (independent of Nϵ) is larger, so the linear growth starts at higher Nϵ.

Fig. 4: Computational time for scanning multiple Fermi levels.
figure 4

Time for calculations with WB (dashed lines) and postw90.x (pw90, solid lines) are shown for different ab initio grids. MDRS method and symmetries are disabled here.

In this section, we did not use the adaptive refinement procedure. However, when one starts from a rather large grid of K points, the new K points coming from the refinement procedure constitute only a small portion of the initial grid, and hence do not contribute much to computation time.

We have shown that the methods suggested in this article help to significantly reduce the computation time from days to minutes. However, bcc iron is a simple example with only one atom per unit cell, and only 18 WFs are needed. More complicated systems will require more time. For example, to obtain a converged value of anomalous Nernst conductivity in PrAlGe47 using wannier19 (an early version of WB), the calculation took approximately 30 h on the same computation node. Estimates predict that the same calculation with postw90.x could take several months. Thus it is the case where the numerical advance not only saves time but also brings the calculation from the unreasonably time-consuming area, where most people would avoid working, to a reasonably feasible computation time.

The functionality implemented in WannierBerri

This appendix outlines the functionality that is currently implemented in WannierBerri. For more detailed and updated information, please refer to the online documentation.

The code may be used to evaluate the following quantities, represented as Brillouin zone integrals:

  • “ahc” : intrinsic anomalous Hall conductivity \({\sigma }_{\alpha \beta }^{{\rm{AHE}}}\)48 via Eq. (11)

  • Anomalous Nernst conductivity49 \({\alpha }_{\alpha \beta }^{{\rm{ANE}}}\) may be obtained from σαβ(ϵ)AHE evaluated over a dense grid of Fermi levels ϵ

$${\alpha }_{\alpha \beta }^{{\rm{ANE}}}=-\frac{1}{e}\int d\varepsilon \frac{\partial f}{\partial \varepsilon }{\sigma }_{\alpha \beta }^{{\rm{AHE}}}(\varepsilon )\frac{\varepsilon -\mu }{T},$$

where \(f(\varepsilon )=1/\left(1+{e}^{\frac{\varepsilon -\mu }{{k}_{{\rm{B}}}T}}\right)\);

  • Morb” : orbital magnetization

$${M}_{n}^{\gamma }({\bf{k}})=\frac{e}{2\hslash }{\rm{Im}}\ {\epsilon }_{\alpha \beta \gamma }\int [d{\bf{k}}]\mathop{\sum }\limits_{n}^{{\rm{occ}}}\left[\langle {\partial }_{a}{u}_{n{\bf{k}}}| {H}_{{\bf{k}}}+{E}_{n{\bf{k}}}-2{E}_{{\rm{F}}}| {\partial }_{b}{u}_{n{\bf{k}}}\rangle \right];$$
  • berry_dipole”: Berry curvature dipole

$${D}_{\alpha \beta }(\mu )=\int [d{\bf{k}}]\mathop{\sum }\limits_{n}^{{\rm{occ}}}{\partial }_{\alpha }{{{\Omega }}}_{n}^{\beta },$$

which describes nonlinear Hall effect44;

  • “gyrotropic_Korb” and gyrotropic_Kspin: gyrotropic magnetoelectric effect (GME)45 tensor (orbital and spin contributions):

$${K}_{\alpha \beta }(\mu )=\int [d{\bf{k}}]\mathop{\sum }\limits_{n}^{{\rm{occ}}}{\partial }_{\alpha }{m}_{n}^{\beta };$$
  • “conductivity_Ohmic”: ohmic conductivity within the Boltzmann transport theory in constant relaxation time (τ) approximation:

$${\sigma }_{\alpha \beta }^{{\rm{Ohm}}}(\mu )=\tau \int [d{\bf{k}}]\mathop{\sum }\limits_{n}^{{\rm{occ}}}{\partial }_{\alpha }{E}_{n{\bf{k}}}{\partial }_{\beta }{E}_{n{\bf{k}}}\delta ({E}_{n{\bf{k}}}-\mu )=\tau \int [d{\bf{k}}]\mathop{\sum }\limits_{n}^{{E}_{n{\bf{k}}}<\mu }{\partial }_{\alpha \beta }^{2}{E}_{n{\bf{k}}};$$
  • “dos”: density of states n(E);

  • “cumdos”: cumulative density of states

$$N(E)={\int \nolimits_{-\infty }^{E}}n(\epsilon )d\epsilon .$$

For a more complete and updated list, please refer to the documentation at [wberri-org].

Currently, the following quantities are available to tabulate:

  • “berry”: Berry curvature

$${{{\Omega }}}_{n}^{\gamma }({\bf{k}})=-{\epsilon }_{\alpha \beta \gamma }{\rm{Im}}\ \langle {\partial }_{\alpha }{u}_{n{\bf{k}}}| {\partial }_{\beta }{u}_{n{\bf{k}}}\rangle ;$$
  • “morb”: orbital moment of Bloch states

$${m}_{n}^{\gamma }({\bf{k}})=\frac{e}{2\hslash }{\epsilon }_{\alpha \beta \gamma }{\rm{Im}}\ \langle {\partial }_{\alpha }{u}_{n{\bf{k}}}| {H}_{{\bf{k}}}-{E}_{n{\bf{k}}}| {\partial }_{\beta }{u}_{n{\bf{k}}}\rangle ;$$
  • “spin”: the expectation value of the Pauli operator

$${{\bf{s}}}_{n}({\bf{k}})=\langle {u}_{n{\bf{k}}}| \hat{{\boldsymbol{\sigma }}}| {u}_{n{\bf{k}}}\rangle ;$$
  • “V”: the band gradients kEnk.


In this article, I have presented a series of methods that boost the performance of Wannier interpolation to a higher level. The methods are implemented in the Python code WannierBerri. It is important to note that the mixed Fourier transform and the optimization of MDRS method and Fermi-level iteration while giving a large computational advantage, do not affect the result within machine precision. Hence, WannierBerri can be easily benchmarked with the established postw90.x code. The code not only allows to perform high-speed and high-precision calculations of AHC and a palette of other properties but also serves as a platform for implementing more functionalities involving Wannier interpolation. Thus it has the potential to become a community code. Interestingly, the code uses the same routines to perform calculations both based on WFs and tight-binding models. Finally, in combination with recent advances in automated construction of WFs, it paves a way to high-throughput calculations of properties of solids that require Wannier interpolation.


Computational details

The input files for WannierBerri are prepared by a combination of an ab initio code and Wannier90. In this article, we used the QuantumEspresso (QE) code50, and closely followed the Tutorial#18 of Wannier90. First, we perform self-consistent calculations on a grid 16 × 16 × 16 q points, fixing the magnetization along [001] axis. We use Generalized gradient approximation (GGA)51 for exchange-correlation functional and a norm-conserving pseudopotential from the PseudoDojo library52,53, and spin–orbit coupling is taken into account. Next, we perform a non-self-consistent calculations using a Γ-centered grid of 8 × 8 × 8 q points. Further, we define the set of trial orbitals sp3d22, dxy, dxz, and dyz, which set the initial guess for 18 WFs describing the conduction band of Fe. And prepare the input files for Wannier90 by means of the pw2wannier90.x interface. Finally, the maximally localized Wannier functions are constructed by the Wannier90 code. The resulting files may be used to start calculations both by postw90.x and WannierBerri. Further, we repeat this procedure for a series of non-self-consistent q grids. The reader may refer to the documentation of Wannier90 and QE for more details.

Calculations were performed on identical 32-core virtual nodes of the ScienceCloud cluster at the University of Zürich. The nodes are based on AMD EPYC 7702 64-Core Processors with frequency 2GHz and 128 GB RAM per node, and one node was used per task. The computation time reported in Figs. 3 and 4 refers to this computational setup.

External libraries used in the code

The WannierBerri code is developed in the object-oriented Python3 language and makes use of the popular numerical libraries, which include NumPy54, SciPy55, and lazy-propery. Fast Fourier transform is implemented via libraries pyFFTW (wrapper of FFTW3 library56) and NumPy, and the user has an option to choose between them, although no notable difference in performance has been observed. The calculations are performed in parallel over K points by means of the multiprocessing module and the parameter “numproc” specifies that a Pool of 16 worker processes is used.

Evaluation of additional matrix elements

Wannier interpolation starts from certain matrix elements defined on the ab initio (q) grid. Those matrix elements should be evaluated within the ab initio code, namely within its interface to Wannier90. However, only QuantumEspresso50 has the most complete interface pw2wannier90.x. The other codes provide only the basic interface, which includes the eigenenergies Enq (.eig file) and overlaps

$${M}_{mn}^{{\bf{b}}}({\bf{q}})=\langle {u}_{m{\bf{q}}}| {u}_{n{\bf{q}}+{\bf{b}}}\rangle$$

(file .mmn), where b vector connects neighboring q points. This information allows to interpolate the band energies (and their derivatives of any order) as well as Berry connections20 and Berry curvature17. However, to evaluate the orbital magnetization via Eq. (26) or the orbital moment of Bloch states (34), one needs matrix elements of the Hamiltonian18 (.uHu file)

$${C}_{mn}^{{{\bf{b}}}_{1},{{\bf{b}}}_{2}}({\bf{q}})=\langle {u}_{m{\bf{q}}+{{\bf{b}}}_{1}}| {\hat{H}}_{{\bf{q}}}| {u}_{n{\bf{q}}+{{\bf{b}}}_{2}}\rangle .$$

The evaluation of Eq. (37) is very specific to the details of the ab initio code, and implemented only in pw2wannier90.x and only for norm-conserving pseudopotentials. To enable the study of properties related to the orbital moment with other ab initio codes, the following workaround may be employed. By inserting a complete set of Bloch states at a particular q point \({\mathbb{1}}=\mathop{\sum }\nolimits_{l}^{\infty }\left|{u}_{l{\bf{q}}}\right\rangle \left\langle {u}_{l{\bf{q}}}\right|\), we can rewrite Eq. (37) as

$${C}_{mn}^{{{\bf{b}}}_{1},{{\bf{b}}}_{2}}({\bf{q}})\approx \mathop{\sum }\limits_{l}^{{l}_{\max }}{\left({M}_{lm}^{{{\bf{b}}}_{1}}({\bf{q}})\right)}^{* }{E}_{l{\bf{q}}}{M}_{ln}^{{{\bf{b}}}_{2}}({\bf{q}}).$$

This equation is implemented within the wannierberri.mmn2uHu submodule, which allows to generate the .uHu file out of .mmn and .eig files. The equality in Eq. (38) is exact only in the limit \({l}_{\max }\to \infty\) and infinitely large basis set for the wavefunctions representation. So in practice, one has to check convergence for a particular system. As an example, we calculate the orbital magnetization of bcc Fe using the .uHu file computed with pw2wannier90.x and using the wannierberri.mmn2uHu interface with different summation limit \({l}_{\max }\) in (38). As can be seen in Fig. 5 already \({l}_{\max }=200\) (corresponding energy ~230 eV) yields a result very close to that of pw2wannier90.x. However, one should bear in mind that convergence depends on many factors, such as the choice of WFs and pseudopotentials. In particular, for tellurium, we observed24 that including only a few bands above the highest p-band is enough to obtain accurate results. However for iron, using a pseudopotential shipped with the examples of Wannier90, we failed to reach convergence even with \({l}_{\max }=600\).

Fig. 5: Orbital magntization of bcc Fe.
figure 5

Given as a function of the Fermi level EF relative to the pristine Fermi level \({E}_{{\rm{F}}}^{0}\). Curves evaluated using the .uHu file computed with pw2wannier90.x (dashed line) and using the wannierberri.mmn2uHu interface (solid lines) with different summation limit \({l}_{\max }\) in (38).

To interpolate the spin operator expectation value, the matrix \({s}_{mn}({\bf{q}})=\langle {u}_{m{\bf{q}}}| \hat{\sigma }| {u}_{n{\bf{q}}}\rangle\) is needed. To facilitate study of spin-dependent properties within VASP57 code, a submodule wannierberri.vaspspn is included, which computes Smnq based on the normalized pseudo-wavefunction read from the WAVECAR file. Note that the use of pseudo-wavefunction instead of the full PAW58 wavefunction is an approximation, which however in practice gives a rather accurate interpolation of spin.

The mmn2uHu and vaspspn modules were initially developed and used in ref. 24 as separate scripts, but were not published so far. Now they are included in the WannierBerri package with the hope of being useful to the community.