GithubHelp home page GithubHelp logo

qijingzheng / vaspbandunfolding Goto Github PK

View Code? Open in Web Editor NEW
183.0 13.0 88.0 35.59 MB

A collection of python scripts that deal with VASP outpts, e.g. WAVECAR, POTCAR etc.

Python 100.00%
all-electron python unfolding vasp-files vasp-processing

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

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'

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.

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

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

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

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

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

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

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

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.

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

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

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...

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?

`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.

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.

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

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

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.