QijingZheng / VaspBandUnfolding

A collection of python scripts that deal with VASP outpts, e.g. WAVECAR, POTCAR etc.
198 stars 89 forks source link
all-electron python unfolding vasp-files vasp-processing

Introduction

VaspBandUnfolding consists of a collection of python scripts that deal with VASP output files.

Installation

Examples

Reading VASP WAVECAR

VASP POTCAR

The paw.py contains method to parse the PAW POTCAR (pawpotcar class) can calculate relating quantities in the PAW within augment sphere. For example,

from paw import pawpotcar

pp = pawpotcar(potfile='POTCAR')

# Q_{ij} = < \phi_i^{AE} | \phi_j^{AE} > -
#          < \phi_i^{PS} | \phi_j^{PS} >
Qij = pp.get_Qij()
# nabla_{ij} = < \phi_i^{AE} | nabla_r | \phi_j^{AE} > -
#              < \phi_i^{PS} | nabla_r | \phi_j^{PS} >
Nij = pp.get_nablaij()

A helping script utilizing the paw.py in the bin directory can be used to visulize the projector function and partial waves.

# `Ti` POTCAR for exampleTCAR for example
potplot -p POTCAR   

Ti POTCAR

As the name suggests, paw.py also contains the methods (nonlq and nonlr class) to calculate the inner products of the projector function and the pseudo-wavefunction. The related formula can be found in my post.

PAW All-Electron Wavefunction in VASP

Band unfolding

Using the pseudo-wavefunction from supercell calculation, it is possible to perform electronic band structure unfolding to obtain the effective band structure. For more information, please refer to the following article and the GPAW website.

V. Popescu and A. Zunger Extracting E versus k effective band structure from supercell calculations on alloys and impurities Phys. Rev. B 85, 085201 (2012)

Theoretical background with an example can be found in my post:

Band Unfolding Tutorial

Here, we use MoS2 as an example to illustrate the procedures of band unfolding. Below is the band structure of MoS2 using a primitive cell. The calculation was performed with VASP and the input files can be found in the examples/unfold/primitive

band_primitive_cell

  1. Create the supercell from the primitive cell, in my case, the supercell is of the size 3x3x1, which means that the transformation matrix between supercell and primitive cell is
    # The tranformation matrix between supercell and primitive cell.
    M = [[3.0, 0.0, 0.0],
         [0.0, 3.0, 0.0],
         [0.0, 0.0, 1.0]]
  2. In the second step, generate band path in the primitive Brillouin Zone (PBZ) and find the correspondig K points of the supercell BZ (SBZ) onto which they fold.

    from unfold import make_kpath, removeDuplicateKpoints, find_K_from_k
    
    # high-symmetry point of a Hexagonal BZ in fractional coordinate
    kpts = [[0.0, 0.5, 0.0],            # M
            [0.0, 0.0, 0.0],            # G
            [1./3, 1./3, 0.0],          # K
            [0.0, 0.5, 0.0]]            # M
    # create band path from the high-symmetry points, 30 points inbetween each pair
    # of high-symmetry points
    kpath = make_kpath(kpts, nseg=30)
    K_in_sup = []
    for kk in kpath:
        kg, g = find_K_from_k(kk, M)
        K_in_sup.append(kg)
    # remove the duplicate K-points
    reducedK, kid = removeDuplicateKpoints(K_in_sup, return_map=True)
    
    # save to VASP KPOINTS
    save2VaspKPOINTS(reducedK)
  3. Do one non-SCF calculation of the supercell using the folded K-points and obtain the corresponding pseudo-wavefunction. The input files are in examples/unfold/sup_3x3x1/. The effective band structure (EBS) and then be obtained by processing the WAVECAR file.

    from unfold import unfold
    
    # basis vector of the primitive cell
    cell = [[ 3.1850, 0.0000000000000000,  0.0],
           [-1.5925, 2.7582909110534373,  0.0],
           [ 0.0000, 0.0000000000000000, 35.0]]
    
    WaveSuper = unfold(M=M, wavecar='WAVECAR')
    
    from unfold import EBS_scatter
    sw = WaveSuper.spectral_weight(kpath)
    # show the effective band structure with scatter
    EBS_scatter(kpath, cell, sw, nseg=30, eref=-4.01,
           ylim=(-3, 4), 
           factor=5)
    
    from unfold import EBS_cmaps
    e0, sf = WaveSuper.spectral_function(nedos=4000)
    # or show the effective band structure with colormap
    EBS_cmaps(kpath, cell, e0, sf, nseg=30, eref=-4.01,
           show=False,
           ylim=(-3, 4))

    The EBS from a 3x3x1 supercell calculation are shown below:

    real part | imaginary part

    Another example of EBS from a 3x3x1 supercell calculation, where we introduce a S vacancy in the structure.

    real part | imaginary part

    Yet another band unfolding example from a tetragonal 3x3x1 supercell calculation, where the transformation matrix is

    M = [[3.0, 0.0, 0.0],
         [3.0, 6.0, 0.0],
         [0.0, 0.0, 1.0]]

    real part | imaginary part

    Compared to the band structure of the primitive cell, there are some empty states at the top of figure. This is due to a too small value of NBANDS in supercell non-scf calculation, and thus those states are not included.

Band unfolding wth atomic contributions

After band unfolding, we can also superimpose the atomic contribution of each KS states on the spectral weight. Below is the resulting unfolded band structure of Ce-doped bilayer-MoS2. Refer to ./examples/unfold/Ce@BL-MoS2_3x3x1/plt_unf.py for the entire code.

imaginary part

Band re-ordering

Band re-ordering is possible by maximizing the overlap between nerghbouring k-points. The overlap is defined as the inner product of the periodic part of the Bloch wavefunctions.

                    `< u(n, k) | u(m, k-1) >`

Note, however, the WAVECAR only contains the pseudo-wavefunction, and thus the pseudo u(n,k) are used in this function. Moreover, since the number of planewaves for each k-points are different, the inner product is performed in real space.

The overlap maximalization procedure is as follows:

  1. Pick out those bands with large overlap (> olap_cut).
  2. Assign those un-picked bands by maximizing the overlap.

An example band structure re-ordering is performed in MoS2. The result is shown in the following image, where the left/right panel shows the un-ordered/re-ordered band structure.

band_reorder |