Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Band Unfolding for Quantum-Espresso code #134

Open
DFTmagnetism opened this issue Oct 23, 2023 · 6 comments
Open

Band Unfolding for Quantum-Espresso code #134

DFTmagnetism opened this issue Oct 23, 2023 · 6 comments

Comments

@DFTmagnetism
Copy link

Dear Sir/Madam,

I would like to inquire about the usage of the PyProcar tool for unfolding band structures in conjunction with the Quantum Espresso code.

Additionally, I am interested in knowing whether it is possible to generate plots of orbital band projections after obtaining the unfolded band structure.

Best regards,
Amir

@lllangWV
Copy link
Member

Hello Amir,

at the current moment, it is not working for qe. I just did an example of MgB2 in a supercell, the bands are what I expected (This is in comparison to VASP) but the unfolding is not. I am going to try to get in contact with on of the QE developers to see if we can find a solution for this. I'll keep you updated on the status of this.

And yes you can generate plots of orbital band projections after obtaining the unfolded band structure. There was a small bug in the code, I am going to update it today.

pyprocar.unfold(
code='vasp',
mode='parametric',
unfold_mode='both',
dirname= data_dir,
orbitals=[1,2,3],
elimit=[-15,5],
supercell_matrix=np.diag([2, 2, 2]))

image

Logan Lang

@DFTmagnetism
Copy link
Author

Hello,

Thank you very much for your response!
But there is an error:

Cell In[7], line 2
1 import numpy as np
----> 2 pyprocar.unfold(
3 code='vasp',
4 mode='parametric',
5 unfold_mode='both',
6 dirname=data_dir,
7 orbitals=[1,2,3],
8 elimit=[-15,5],
9 supercell_matrix=np.diag([2, 2, 2]))

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/scripts/scriptUnfold.py:117, in unfold(procar, poscar, outcar, vaspxml, abinit_output, dirname, transformation_matrix, kpoints, elkin, code, mode, unfold_mode, spins, atoms, orbitals, items, projection_mask, unfold_mask, fermi, interpolation_factor, interpolation_type, vmax, vmin, kticks, knames, kdirect, elimit, ax, show, savefig, old, savetab, **kwargs)
113 ebs_plot = EBSPlot(ebs, kpath, ax, spins)
116 if mode is not None:
--> 117 if not procar.has_phase :
118 raise ValueError("The provided electronic band structure file does not include phases")
119 ebs_plot.ebs.unfold(
120 transformation_matrix=transformation_matrix, structure=structure)

AttributeError: 'str' object has no attribute 'has_phase'

Could you please tell me how can I solve this error?

Thanks,
Amir

@ahromero
Copy link
Collaborator

ahromero commented Nov 6, 2023 via email

@DFTmagnetism
Copy link
Author

Yes. When I add LORBIT=12, I have:

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/scripts/scriptUnfold.py:110, in unfold(procar, poscar, outcar, vaspxml, abinit_output, dirname, transformation_matrix, kpoints, elkin, code, mode, unfold_mode, spins, atoms, orbitals, items, projection_mask, unfold_mask, fermi, interpolation_factor, interpolation_type, vmax, vmin, kticks, knames, kdirect, elimit, ax, show, savefig, old, savetab, **kwargs)
80 settings.ebs.modify(settings.unfold.config)
82 # if code == "vasp":
83 # if outcar is not None:
84 # outcar = io.vasp.Outcar(outcar)
(...)
108 # interpolation_factor=interpolation_factor,
109 # )
--> 110 parser = io.Parser(code = code, dir = dirname)
111 ebs = parser.ebs
113 ebs_plot = EBSPlot(ebs, kpath, ax, spins)

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/io/parser.py:27, in Parser.init(self, code, dir)
24 self.code = code
25 self.dir = dir
---> 27 self.parse()

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/io/parser.py:49, in Parser.parse(self)
46 self.parse_siesta()
48 elif self.code == "vasp":
---> 49 self.parse_vasp()
51 elif self.code == "elk":
52 self.parse_elk()

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/io/parser.py:239, in Parser.parse_vasp(self)
234 except:
235 self.kpath=None
--> 239 procar = vasp.Procar(
240 filename=procar,
241 structure=poscar.structure,
242 reciprocal_lattice=poscar.structure.reciprocal_lattice,
243 kpath=self.kpath,
244 n_kx=outcar.n_kx,
245 n_ky=outcar.n_ky,
246 n_kz=outcar.n_kz,
247 efermi=outcar.efermi,
248 interpolation_factor=1
249 )
251 try:
252 vasprun = vasp.VaspXML(filename = vasprun)

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/io/vasp.py:613, in Procar.init(self, filename, structure, reciprocal_lattice, kpath, n_kx, n_ky, n_kz, efermi, interpolation_factor)
610 self.orbitalName_short = ["s", "p", "d", "f", "tot"]
611 self.labels = self.orbitalName_old[:-1]
--> 613 self._read()
614 if self.has_phase:
615 self.carray = self.spd_phase[:, :, :, :-1, 1:-1]

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/io/vasp.py:756, in Procar._read(self)
754 self._read_orbitals()
755 if self.has_phase:
--> 756 self._read_phases()
757 rf.close()
758 return

File ~/anaconda3/lib/python3.11/site-packages/pyprocar/io/vasp.py:1108, in Procar._read_phases(self)
1106 up, down = np.vsplit(self.spd_phase, 2)
1107 # ispin = 1 for a while, we will made the distinction
-> 1108 up = up.reshape(
1109 self.kpointsCount,
1110 int(self.bandsCount / 2),
1111 1,
1112 self.ionsCount+1,
1113 self.orbitalCount * 2,
1114 )
1115 down = down.reshape(
1116 self.kpointsCount,
1117 int(self.bandsCount / 2),
(...)
1120 self.orbitalCount * 2,
1121 )
1122 # concatenating bandwise. Density and magntization, their
1123 # meaning is obvious, and do uses 2 times more memory than
1124 # required, but I WANT to keep it as close as possible to the
1125 # non-collinear or non-polarized case

ValueError: cannot reshape array of size 4723200 into shape (30,96,1,41,20)

@DFTmagnetism
Copy link
Author

DFTmagnetism commented Nov 10, 2023

Dear Logan Lang,

Could you please tell me, could you solve the problem?

Best,
Amir

@lllangWV
Copy link
Member

Hello Amir,

For the unfolding in QE, we are still trying to diagnose the issue. It has to do with how QE uses different a different basis than in vasp.

As for the above issue with vasp, the issue is coming from line 1110 ( int(self.bandsCount / 2)) and 1117 ( int(self.bandsCount / 2)). There should be no division by 2. I have changed this in the main branch GitHub. I have not updated pypi with this change, I want to finish other work before updating pypi.

Logan Lang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants