romerogroup / pyprocar

A Python library for electronic structure pre/post-processing
GNU General Public License v3.0
165 stars 72 forks source link

QEParser error #141

Closed MaxonDomkrat closed 3 months ago

MaxonDomkrat commented 3 months ago

Hi, I'm faced a problem while trying to use dosplot function:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 pyprocar.dosplot(
      2                 code='qe',
      3                 mode='plain',
      4                 dirname=data_dir)

File ~/.local/lib/python3.10/site-packages/pyprocar/scripts/scriptDosplot.py:266, in dosplot(code, dirname, mode, orientation, spins, atoms, orbitals, items, fermi, elimit, dos_limit, savefig, projection_mask, ax, show, print_plot_opts, **kwargs)
    262 elif orientation[0].lower() == 'v':
    263     orientation = 'vertical'
--> 266 parser = io.Parser(code = code, dir = dirname)
    267 dos = parser.dos
    268 structure = parser.structure

File ~/.local/lib/python3.10/site-packages/pyprocar/io/parser.py:26, in Parser.__init__(self, code, dir)
     23 self.code = code
     24 self.dir = dir
---> 26 self.parse()

File ~/.local/lib/python3.10/site-packages/pyprocar/io/parser.py:42, in Parser.parse(self)
     39     self.parse_bxsf()
     41 elif self.code == "qe":
---> 42     self.parse_qe()
     44 elif self.code == "siesta":
     45     self.parse_siesta()

File ~/.local/lib/python3.10/site-packages/pyprocar/io/parser.py:173, in Parser.parse_qe(self)
    164 def parse_qe(self):
    165     """parses qe files
    166 
    167     Returns
   (...)
    170         None
    171     """
--> 173     parser = qe.QEParser(
    174                         dirname = self.dir,
    175                         scf_in_filename = "scf.in", 
    176                         bands_in_filename = "bands.in", 
    177                         pdos_in_filename = "pdos.in", 
    178                         kpdos_in_filename = "kpdos.in", 
    179                         atomic_proj_xml = "atomic_proj.xml"
    180                         )
    182     self.ebs = parser.ebs
    183     self.kpath = parser.kpath

File ~/.local/lib/python3.10/site-packages/pyprocar/io/qe.py:86, in QEParser.__init__(self, dirname, scf_in_filename, bands_in_filename, pdos_in_filename, kpdos_in_filename, atomic_proj_xml)
     77     self.getKpointLabels()
     79 # if xml_root.findall(".//input/control_variables/calculation")[0].text == "nscf":
     80 #     self.is_dos_fermi_calc = True
     81 # if self.kpath is not None:
     82 # self.bands -= self.efermi
     83 self.ebs = ElectronicBandStructure(
     84                         kpoints=self.kpoints,
     85                         bands=self.bands,
---> 86                         projected=self._spd2projected(self.spd),
     87                         efermi=self.efermi,
     88                         kpath=self.kpath,
     89                         projected_phase=self._spd2projected(self.spd_phase),
     90                         labels=self.orbital_names[:-1],
     91                         reciprocal_lattice=self.reciprocal_lattice,
     92                     )
     94 return None

AttributeError: 'QEParser' object has no attribute 'spd'

I compared my input files with the files provided in the examples, but did not find any anomalies that could cause this error. I will be very grateful for any help.

lllangWV commented 3 months ago

Hey,

so this is being caused because the code can not locate the atomic_proj.xml file.

Usually, it is located in {CALC_ROOT_DIR}/{OUT_DIR}/{prefix}.save/atomic_proj.xml.

Sometimes I like to copy this file into {CALC_ROOT_DIR}.

Does this file exist for you? If so where is it?

Logan Lang

MaxonDomkrat commented 3 months ago

Thanks for the quick response. My atomic_proj.xml file located in the same directory as all of the other files. calc_root_dir

lllangWV commented 3 months ago

Okay, everything looks correct.

Is it possible for you to send me the files? I have to go into the code to see what is wrong.

I would prefer if you sent all the files, but if that is not possible you can just send me the inputs.

MaxonDomkrat commented 3 months ago

Here is an archive with all the files listed in this directory: https://drive.google.com/file/d/1VO1B1G-4QPWnX4-yKRbevUsQRyrcxxc0/view?usp=sharing

lllangWV commented 3 months ago

Hey,

I found the issue. It comes from the parsing of the outdir from scf.in. In our code we use regex to parse this varaible, I will have to adapt this to cover your case.

In the mean time, a fix is the following. In scf.in, change outdir = './out/' -> outdir = './out'

Also, if you want to do dosplot, you have to make sure that your non-self-consistent calculation is over a kmesh and not a kpath as for the band structure. Additionally, in kpdos.in you have to set kresolveddos=.false.

MaxonDomkrat commented 3 months ago

Changing outdir = './out/' -> outdir = './out' indeed solved this problem.

Thank you very much for your help!