Branch: master
Find file History


This example shows how to use pw2wannier90.x in conjunction with 
Wannier90 ( to obtain maximally-localised
Wannier functions (MLWFs) for the valence bands of diamond. 
Wannier90 may be run in two modes, 'library' and 'standalone',
and both of these are demonstrated.

The Wannier90 code and library (available for download from under the GNU General Public License) are required. 
For operation in library mode, the pw2wannier90 post-processing code must 
be linked at compile time to the Wannier90 library. Instructions for 
compilation of Wannier90 can be found in the documentation that comes with 
the distribution. 

The calculation proceeds as follows (for the meaning of the cited input
variables see the bottom of this file)

1) make a self-consistent calculation for diamond (,
   output=diamond.scf.out). The number of computed bands is internally
   computed as half the number of electrons in the unit cell
   (4 in this case).

2) call open_grid to use symmetry to obtain the full grid of k-points
   from the reduced one. The same outdir is used, but the prefix is changed
   adding "_open" at the end. Note that you cannot chaneg the number of bands
   with this procedure. The code also print on output a list of the k-points
   in the opened grid, copy this list to the input file of wannier90, in the
   appropriate place

-- From here on, the calculation continues exactly like in the wannier90 example


   (3a) run Wannier90 (, to 
        generate a list of the required overlap elements between states at 
        different k-points. This information is written to a file called

   (3b) run pw2wannier90 (, to compute the overlap between Bloch 
        states, the projections for the starting guess and the eigenvalue 
        of each Bloch eigenstate (written to the, and files, respectively).

   (3c) run Wannier90 (, to 
        obtain the MLWF centres and spreads.


!! pw2wannier90.x has to be compiled with the -D__WANLIB and
!! libwannier.a has to be linked

   (4a) run pw2wannier90 in library mode to obtain the MLWF centres 
        and spreads (,, 
        output=diamond.lib.wout, diamond.pw2wan.lib.out). 


  (i) The WAN_DIR variable in the run_example script must be set to the 
      directory of the wannier90 executable. 

 (ii) Multiple CPUs: distribution of k-points (the -npool command line option)
      is not yet supported, only G-vectors.

 (iii) To run in library mode, pw2wannier90 must be linked to the wannier
       library. To do so, compile the Wannier90 library, libwannier.a, 
       following the instructions in the Wannier90 documentation (for the 
       impatient, type 'make lib' in the Wannier90 root directory). Then make 
       the following changes to the espresso make.sys file, and recompile 

         + Add -D__WANLIB to the DFLAGS variable
           DFLAGS = -D__WANLIB ...

         + Add a new variable WANLIB to specify location of Wannier library
           WANLIB = -L/path/of/wannier/library -lwannier

         + Add $(WANLIB) to the LIBS variable
           LIBS   = $(WANLIB) $(LAPACK_LIBS) $(BLAS_LIBS) ...

Input variables for pw2wannier90:

outdir         : location of temporary output files
prefix         : pwscf filename prefix
seedname       : wannier90 input/output filename prefix
wan_mode       : 'standalone' or 'library' [1]
write_mmn      : (logical) compute M_mn matrix [1]
write_amn      : (logical) compute A_mn matrix [1]
write_unk      : (logical) write wavefunctions to file [1]
wvfn_formatted : (logical) formatted or unformatted output for wavefunctions
reduce_unk     : (logical) output wavefunctions on a coarse grid to save memory
spin_component : 'none', 'up' or 'down'

Please report problems and suggestions to Stefano de Gironcoli
(, Arash Mostofi ( and 
Jonathan Yates (

[1] For more details see Wannier90 documentation at