Coder Social home page Coder Social logo

vaspbandunfolding's Introduction

Introduction

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

  • vaspwfc.py can be used to read the plane-wave coefficients in the WAVECAR file and then generate real-space representation of the pseudo-wavefunction by Fourier transform. Other wavefunction related quantites, e.g. transition dipole moment (pseudo-wavefunction part), inverse participation ratio and electron localization function et al. can also be conveniently obtained.

    Moreover, a command line tool named wfcplot in the bin directory can be used to output real-space pseudo-wavefunctions.

  • paw.py can be used to parse the PAW POTCAR file. A command line tool named potplot in the bin directory can be used to visualize the projector function and partial waves contained in the POTCAR.

  • aewfc.py can be used to generate all-electron (AE) wavefunction.

  • unfold.py can be used to perform band unfolding from supercell calculations.

Installation

  • Requirements

    • Numpy
    • Scipy
    • Matplotlib
    • ASE
    • pySBT for spherical Bessel transform
  • Manual Installation

    git clone https://github.com/QijingZheng/VaspBandUnfolding
    # set the 
    cd VaspBandUnfolding
    python setup.py install --prefix=/the/path/of/your/dir/
    export PYTHONPATH=/the/path/of/your/dir:${PYTHONPATH}
  • Using Pip

    pip install git+https://github.com/QijingZheng/VaspBandUnfolding

Examples

Reading VASP WAVECAR

  • Pseudo-wavefunction.

    As is well known, VASP WAVECAR is a binary file and contains the plane-wave coefficients for the pseudo-wavefunctions. The pseudo-wavefunction in real space can be obtained by 3D Fourier transform on the plane-wave coefficients and represented on a 3D uniform grid which can be subsequently visualized with software such as VESTA.

    • For a normal WAVECAR, i.e. not gamma-only or non-collinear WAVECAR, one can write a small python script and convert the desired Kohn-Sham states to real space.

      #/usr/bin/env python
      from vaspwfc import vaspwfc
      
      pswfc = vaspwfc('./examples/wfc_r/WAVECAR')
      # KS orbital in real space, double the size of the FT grid
      phi = pswfc.get_ps_wfc(ikpt=2, iband=27, ngrid=pswfc._ngrid * 2)
      # Save the orbital into files. Since the wavefunction consist of complex
      # numbers, the real and imaginary part are saved separately.
      pswfc.save2vesta(phi, poscar='./examples/wfc_r/POSCAR')
      • In the above script, pswfc._ngrid is the default 3D grid size and phi is a numpy 3D array of size 2*pswfc._ngrid, with the first dimensiton being x and the last "z".
      • The spin, k-point and band index for the KS state are designated by the argumnt ispin, ikpt and iband, respectively, all of which start from 1.
      • Generally, the pseudo-wavefunction is complex, pswfc.save2vesta will export both the real and imaginary part of the wavefunction, with the file name "wfc_r.vasp" and "wfc_i.vasp", respectively.

      Below are the real (left) and imaginary (right) part of the selected KS orbital:

      real part imaginary part

    • For gamma-only WAVECAR, one must pass the argument lgamma=True when reading WAVECAR in the vaspwfc method. Moreover, as VASP only stores half of the full plane-wave coefficients for gamma-only WAVECAR and VASP changes the idea about which half to save from version 5.2 to 5.4. An addition argument must be passed.

      #/usr/bin/env python
      from vaspwfc import vaspwfc
      
      # For VASP <= 5.2.x, check
      # which FFT VASP uses by the following command:
      #
      #     $ grep 'use.* FFT for wave' OUTCAR
      #
      # Then
      #
      #     # for parallel FFT, VASP <= 5.2.x
      #     pswfc = vaspwfc('WAVECAR', lgamma=True, gamma_half='z')
      #
      #     # for serial FFT, VASP <= 5.2.x
      #     pswfc = vaspwfc('WAVECAR', lgamma=True, gamma_half='x')
      #
      # For VASP >= 5.4, WAVECAR is written with x-direction half grid regardless of
      # parallel or serial FFT.
      #
      #     # "gamma_half" default to "x" for VASP >= 5.4
      #     pswfc = vaspwfc('WAVECAR', lgamma=True, gamma_half='x')
      
      pswfc = vaspwfc('WAVECAR', lgamma=True, gamma_half='x')
    • For non-collinear WAVECAR, however, one must pass the argument lsorbit=True when reading WAVECAR. Note that in the non-collinear case, the wavefunction now is a two-component spinor.

      #/usr/bin/env python
      from vaspwfc import vaspwfc
      
      # for WAVECAR from a noncollinear run, the wavefunction at each k-piont/band is
      # a two component spinor. Turn on the lsorbit flag when reading WAVECAr.
      pswfc = vaspwfc('examples/wfc_r/wavecar_mose2-wse2', lsorbit=True)
      phi_spinor = pswfc.get_ps_wfc(1, 1, 36, ngrid=pswfc._ngrid*2)
      for ii in range(2):
          phi = phi_spinor[ii]
          prefix = 'spinor_{:02d}'.format(ii)
          pswfc.save2vesta(phi, prefix=prefix,
                  poscar='examples/wfc_r/poscar_mose2-wse2')
    • If only real-space representation of the pseudo-wavefunction is needed, a helping script wfcplot in the bin directory comes to rescue.

      $ wfcplot -w WAVECAR -p POSCAR -s spin_index -k kpoint_index -n band_index             # for normal WAVECAR
      $ wfcplot -w WAVECAR -p POSCAR -s spin_index -k kpoint_index -n band_index  -lgamma    # for gamma-only WAVECAR
      $ wfcplot -w WAVECAR -p POSCAR -s spin_index -k kpoint_index -n band_index  -lsorbit   # for noncollinear WAVECAR

      Please refer to wfcplot -h for more information of the usage.

  • All-electron wavefunction in real space

    Refer to this post for detail formulation.

    PAW All-Electron Wavefunction in VASP

    #/usr/bin/env python
    
    from vaspwfc import vaspwfc
    from aewfc import vasp_ae_wfc
    
    # the pseudo-wavefunction
    ps_wfc = vaspwfc('WAVECAR', lgamma=True)
    # the all-electron wavefunction
    # here 25x Encut, or 5x grid size is used
    ae_wfc = vasp_ae_wfc(ps_wfc, aecut=-25)
    
    phi_ae = ae_wfc.get_ae_wfc(iband=8)

    The comparison of All-electron and pseudo wavefunction of CO2 HOMO can be found in examples/aewfc/co2.

    CO2 HOMO CO2 HOMO

  • Dipole transition matrix

    Refer to this post for detail formulation.

    Light-Matter Interaction and Dipole Transition Matrix

    Under the electric-dipole approximation (EDA), The dipole transition matrix elements in the length gauge is given by:

          <psi_nk | e r | psi_mk>
    

    where | psi_nk > is the pseudo-wavefunction. In periodic systems, the position operator "r" is not well-defined. Therefore, we first evaluate the momentum operator matrix in the velocity gauge, i.e.

          <psi_nk | p | psi_mk>
    

    And then use simple "p-r" relation to apprimate the dipole transition matrix element

                                      -i⋅h
        <psi_nk | r | psi_mk> =  -------------- ⋅ <psi_nk | p | psi_mk>
                                   m⋅(En - Em)
    

    Apparently, the above equaiton is not valid for the case Em == En. In this case, we just set the dipole matrix element to be 0.

    NOTE that, the simple "p-r" relation only applies to molecular or finite system, and there might be problem in directly using it for periodic system. Please refer to this paper for more details.

    Relation between the interband dipole and momentum matrix elements in semiconductors

    The momentum operator matrix in the velocity gauge

            <psi_nk | p | psi_mk> = hbar <u_nk | k - i nabla | u_mk>
    

    In PAW, the matrix element can be divided into plane-wave parts and one-center parts, i.e.

        <u_nk | k - i nabla | u_mk> = <tilde_u_nk | k - i nabla | tilde_u_mk>
                                     - \sum_ij <tilde_u_nk | p_i><p_j | tilde_u_mk>
                                       \times i [
                                         <phi_i | nabla | phi_j>
                                         -
                                         <tilde_phi_i | nabla | tilde_phi_j>
                                       ]
    

    where | u_nk > and | tilde_u_nk > are cell-periodic part of the AE/PS wavefunctions, | p_j > is the PAW projector function and | phi_j > and | tilde_phi_j > are PAW AE/PS partial waves.

    The nabla operator matrix elements between the pseudo-wavefuncitons

        <tilde_u_nk | k - i nabla | tilde_u_mk>
    
       = \sum_G C_nk(G).conj() * C_mk(G) * [k + G]
    

    where C_nk(G) is the plane-wave coefficients for | u_nk >.

    import numpy as np
    
    from vaspwfc import vaspwfc
    from aewfc import vasp_ae_wfc
    
    # the pseudo-wavefunction
    ps_wfc = vaspwfc('WAVECAR', lgamma=True)
    # the all-electron wavefunction
    ae_wfc = vasp_ae_wfc(ps_wfc)
    
    # (ispin, ikpt, iband) for initial and final states
    ps_dp_mat = ps_wfc.get_dipole_mat((1,1,1), (1, 1, 9))
    ae_dp_mat = ae_wfc.get_dipole_mat((1,1,1), (1, 1, 9))
  • Inverse Participation Ratio

    IPR is a measure of the localization of Kohn-Sham states. For a particular KS state \phi_j, it is defined as

                    \sum_n |\phi_j(n)|^4 
    IPR(\phi_j) = -------------------------
                  |\sum_n |\phi_j(n)|^2||^2

    where n iters over the number of grid points.

  • Electron Localization Function (Still need to be tested!)

    In quantum chemistry, the electron localization function (ELF) is a measure of the likelihood of finding an electron in the neighborhood space of a reference electron located at a given point and with the same spin. Physically, this measures the extent of spatial localization of the reference electron and provides a method for the mapping of electron pair probability in multielectronic systems. (from wiki)

    NOTE that if you are using VESTA to view the resulting ELF file, please rename the output file as "ELFCAR", otherwise there will be some error in the isosurface plot! When VESTA read in CHG*/PARCHG/*.vasp to visualize isosurfaces and sections, data values are divided by volume in the unit of bohr^3. The unit of charge densities input by VESTA is, therefore, bohr^−3. For LOCPOT/ELFCAR files, volume data are kept intact.

    #/usr/bin/env python
    import numpy as np
    from vaspwfc import vaspwfc, save2vesta
    
    kptw = [1, 6, 6, 6, 6, 6, 6, 12, 12, 12, 6, 6, 12, 12, 6, 6]
    
    pswfc = vaspwfc('./WAVECAR')
    # chi = wfc.elf(kptw=kptw, ngrid=wfc._ngrid * 2)
    chi = pswfc.elf(kptw=kptw, ngrid=[20, 20, 150])
    save2vesta(chi[0], lreal=True, poscar='POSCAR', prefix='elf')

    Remember to rename the output file "elf_r.vasp" as "ELFCAR"!

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 |

vaspbandunfolding's People

Contributors

bluehope avatar boyoungzheng avatar ionizing avatar qijingzheng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vaspbandunfolding's Issues

No module named 'pysbt'

Hello.
When I run aewfc.py, I got the ModuleNotFoundError: No module named 'pysbt'.

  • traceback---->
    File "/root/vasp_6.1.0/gitClone/VaspBandUnfolding/All-electron-wavefunction-in-real-space.py", line 2, in
    from aewfc import vasp_ae_wfc
    File "/root/vasp_6.1.0/gitClone/VaspBandUnfolding/aewfc.py", line 5, in
    from pysbt import pysbt
    ModuleNotFoundError: No module named 'pysbt'

How can I handle this error?
thanks...

How to cite this repository

Dear Professor Zheng,

Thanks for this excellent work!
Could you please add a citation option to this repository so I can cite your work in my publications?

Best,
Yifeng

Confusion about transformation matrix

Dear Qi,
Your code is quite helpful, yet I have a question about transfomation matrix in the unfold class. You have written B = np.dot(np.linalg.inv(M).T, b) , but I found b=np.dot(M,B) i.e. B = np.dot(np.linalg.inv(M), b) in Phys. Rev. B 85, 085201 (2012), which lead differences of K sampling in supercell brillioun zone between two cases. Could you tell me why you choose transformation matrix M.T?

Thank you sincerely,
Xu

How can I obtain the inverse participation ratio (IPR) value from the WAVECAR of vasp?

Dear Prof. Zheng,

I want to use this code to get the IPR from the WAVECAR. What python script can I use?

I read the vaspwfc.py. I use the following script to obtain the ipr.npy file.

#!/usr/bin/env python
 
import numpy as np
from vaspwfc import vaspwfc

xx = vaspwfc('./WAVECAR')
ipr = xx.inverse_participation_ratio()
a=np.load('ipr.npy')
a.shape      !a is a (1, 1, 672, 3) 4-D array.

What is the meaning of the 4-D array, particularly the last dimension? (nspin, NKPTS, NBANDS, ???)

I want to plot the "energy(x) vs IPR(y)" curlve. How can I deal with the data in ipr.npy?

Thanks!

dtype=int is not enough? (readWFHeader in vaspwfc)

Method readWFHeader in vaspwfc.py uses this code (currently lines 157-160):

        self._recl, self._nspin, self._rtag = np.array(
            np.fromfile(self._wfc, dtype=np.float, count=3),
            dtype=int
        )

It seems that for large WAVECARs dtype=int is not enough. I was getting overflow errors (don't remember all the details, I can try to reproduce the behaviour if needed).
Changing from dtype=int to dtype=np.int64 fixed the issue.

Read wavefunction from WAVRCAR for some specific purposes.

Suppose I would like to achieve the following purposes based on the wavefunction analysis from WAVRCAR:

  1. Calculate the topological number based on the exact form of wavefunction, aka, an n*1 array under plane wave basis.
  2. Compute the traces of matrix presentations and determines the corresponding irreducible representations for all energy bands and all the k-points in the three-dimensional Brillouin zone.

I would like to know whether the method implemented in this package meets the above requirements.

See below for the related discussions:
https://www.vasp.at/forum/viewtopic.php?t=18177

See the related implementation below, which is based on this package:
https://github.com/SMTG-UCL/easyunfold/blob/main/easyunfold/wavecar.py

Regards,
Zhao

Problem in testing the unfold example

Dear QijingZheng,
I tried to run the example folder named as "unfold". With in this folder primitive calculations went fine. In sup_3x3x1 folder i have observed that the given POTCAR is incorrect. It is having other atoms also as shown below.
VRHFIN =Mo: 4p5s4d
VRHFIN =S : s2p4
VRHFIN =Se: s2p4
VRHFIN =W : 6s5d
I have created the supoer cell with 3x3x1 with the primitive POSCAR which is given in primitive folder.

i can able to get the converted KPOINTS file which is exactly same as in your example folder of sup_3x3x1.

After completion of the non-scf calculation i tried to run the below code for band sructure but ending with following error.

Processing k-point -0.4667 -0.4667 0.0000
Traceback (most recent call last):
File "band.py", line 39, in
sw = WaveSuper.spectral_weight(kpath)
File "/usr/local/lib/python2.7/dist-packages/unfold.py", line 454, in spectral_weight
for ik in range(NKPTS)])
File "/usr/local/lib/python2.7/dist-packages/unfold.py", line 344, in spectral_weight_k
ikpt = self.find_K_index(K0)
File "/usr/local/lib/python2.7/dist-packages/unfold.py", line 322, in find_K_index
'Cannot find the corresponding K-points in WAVECAR!'
ValueError: Cannot find the corresponding K-points in WAVECAR!

I did find any WAVECAR file in your sup_3x3x1 example folder to check the band part.

Please correct me where i went wrong.

Thanking you

Deal with situation: no space between signed numbers in PROCAR

Dear Dr. Zheng,

I want to report an issue about procar.py, and along with a solution for it.

I noticed that when PROCAR is generated, there will be no space between signed numbers sometimes. Since the infomation is extracted by relative column numbers from the end, the procar.py will raise exception in these situations:

ValueError: could not convert string to float: ':'

For example, when PROCAR says

 k-point   19 :    0.50000000-0.00000000 0.00000000     weight = 0.00231481

the line in line 150 in procar.py will return

[':','0.50000000-0.00000000',‘0.00000000’]

instead of

['0.50000000','-0.00000000',‘0.00000000’]

and therefore, procar.py will exec float(':') and thus will raise that ValueError.

To fix this issue, I suggest to fill this space before parsing PROCAR data. In detail, add these

for row in range(0,len(inp)):
           inp[row] = re.sub(r'(?P<num1>[0-9]+)(?P<num2>[\+\-][0-9]+)','\g<num1> \g<num2>',inp[row])

at line 142 in procar.py. And the issue will be no more.

Best Regards,
Sun Sibai
IOPCAS L02

Installation

Hello Qijing,

I tried to install your code but i didnt make it.
What I want to do, is to plot the wavefunctions in real space.
Could you please make me the instructions more clear?
Thank you sincerely!

Sotirios Fragkos

`save2vesta` did not multiply the cell volume

The save2vesta function borrows the CHGCAR format to visualize the wave function. Values in CHGCAR are multiplied with the cell volume V but save2vesta doesn't follow this rule, and may result in extremely low charge density value in the output file.

def save2vesta(phi=None, poscar='POSCAR', prefix='wfc',
lgam=False, lreal=False, ncol=10):
'''
Save the real space pseudo-wavefunction as vesta format.
'''
nx, ny, nz = phi.shape
try:
pos = open(poscar, 'r')
head = ''
for line in pos:
if line.strip():
head += line
else:
break
head += '\n%5d%5d%5d\n' % (nx, ny, nz)
except:
raise IOError('Failed to open %s' % poscar)
# Faster IO
nrow = phi.size // ncol
nrem = phi.size % ncol
fmt = "%16.8E"
psi = phi.copy()
psi = psi.flatten(order='F')
psi_h = psi[:nrow * ncol].reshape((nrow, ncol))
psi_r = psi[nrow * ncol:]
with open(prefix + '_r.vasp', 'w') as out:
out.write(head)
out.write(
'\n'.join([''.join([fmt % xx for xx in row])
for row in psi_h.real])
)
out.write("\n" + ''.join([fmt % xx for xx in psi_r.real]))
if not (lgam or lreal):
with open(prefix + '_i.vasp', 'w') as out:
out.write(head)
out.write(
'\n'.join([''.join([fmt % xx for xx in row])
for row in psi_h.imag])
)
out.write("\n" + ''.join([fmt % xx for xx in psi_r.imag]))

I think an operation psi *= pos.cell.volume can solve this issue.

Raw data

Dear Prof. Qijing Zheng,
I'm having problems extracting the unfolded band energies in data form. After printing the spectral function after unfolding I'm still getting the folded bands. Could you please either direct me to the correct variables or add a function that also outputs the band structure in data form.
Thank you very much.

band unfolding with spinor

Hi.

Is it possible to unfold the band structure with spinor wavefunction like including spin-orbit coupling in VASP ? I tried this with your code but i got the error "Number of planewaves not consistent"

Thanks,
Anh

Assumption of lattice vectors

I was trying to parse WAVECAR myself and was trying to read both your program and Feenstra's program (http://www.andrew.cmu.edu/user/feenstra/wavetrans/source/WaveTrans.f90). It seems the following code assumes the lattice vectors are orthogonal:

CUTOF = np.ceil(
sqrt(self._encut / RYTOEV) / (TPI / (Anorm / AUTOA))
)

If the reciprocal lattice vectors are b1=[-0.99, 0.01, 0.0], b2=[0.99, 0.01, 0.0], b3=[0, 0, 1.0] and the wave vector corresponding to the energy cutoff is G=10, the norm of n*b1+n*b2 is smaller than G as long as n<500. But the above code would estimate n<=100.

Confusion about the installation

I want to use and learn VaspBandUnfolding code for band unfolding. In this sense, i downloaded your code and keep it in one of the directories. But i don't know how to install the code. As i am fresh Master student having a very little knowledge of python and Linux system installation and usage. Can you plz guide me step by step to install this code and then reproduce the examples as given by you. I would be very highly thankful to you.
confusion

Unfolding not working fo Si 4x4x4

Hi, how are you? I am trying to do the unfolding part for a Silicon 4x4x4 supercell and it is not working. I tried before for Ga2O3 2x2x2 supercell and it worked fine, but now I am getting the following error:
"AssertionError: No. of planewaves not consistent! 31219 31263 91125"
Do you know what might be wrong? I think it could be one of the flags in VASP. I've been trying to decrease the number of plane waves (smaller ENCUT) but it hasn't worked yet.
Thanks in advance,
Igor Evangelista

Wave function in real space can't reproduce charge density from CHGCAR

Hi Qijing,

Thanks for sharing the code with us. My team is recently working on extracting wave functions in real space using your code vaspwfc. And we check the 2-atom GaAs in rho cell. Since the |real part|^2+|imginary part|^2 of the wave function is the charge density, we compared the charge density calculated by the wave function and PARCHG generated by VASP itself for GaAs conduction band minimum. Here's the result we get.

image
charge density calculated by |real part|^2+|imginary part|^2

image
charge density by PARCHG at Gamma point pf conduction band minimum.

Do you know why there's a difference? Also, I can provide sample files if you would like.

Thank you very much again!

Qian

elf_test error

Hello Qijing,

I've tried your elf method using the files you suggested to use (WAVECAR and ex.py) in "exemples - elf_test".
However, when running the program, I get the following error : "No. of planewaves not consistent! 1165 1166 3375". If I understand this correctly, it means that the calculated number of planewaves is not the same as the number of planewaves contained in the WAVECAR file.

Have you an idea where this error could come from ? I'm a beginner with the Vasp calculations so I have certainly misunderstood or misused something.

Thank you sincerely,

giorn

usage for hybrid/metagga bandstructure unfolding

How to use for hybrid/metagga band structure unfolding?
(KPOINTS: weighted IBZKPT points + zero-weighted band path k-points)

is it enough to just set the weight of the generated k-points made by this script to zero?

image

how should we do about the post-processing step with such KPOINTS?

Warning and error about dtype

python elf.py

        ###################################################################
        If you are using VESTA to view the resulting ELF, please rename the
        output file as ELFCAR, otherwise there will be some error in the
        isosurface plot!

        When CHG*/PARCHG/*.vasp are read in to visualize isosurfaces and
        sections, data values are divided by volume in the unit of bohr^3.
        The unit of charge densities input by VESTA is, therefore, bohr^−3.

        For LOCPOT/ELFCAR files, volume data are kept intact.

        You can turn off this warning by setting "warn=False" in the "elf"
        method.
        ###################################################################

/opt/intelpython2/lib/python2.7/site-packages/scipy/fftpack/basic.py:160: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result.
z[index] = x
Traceback (most recent call last):
File "elf.py", line 10, in
chi = wfc.elf(kptw=kptw, ngrid=[56, 56, 320])
File "/opt/VaspBandUnfolding/vaspwfc.py", line 748, in elf
tau += -phi_r * lap_phi_r.conj() * weight
TypeError: Cannot cast ufunc add output from dtype('complex128') to dtype('float64') with casting rule 'same_kind'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.