JuDFTteam / masci-tools

Post-processing toolkit for electronic structure calculations
https://masci-tools.readthedocs.io
MIT License
17 stars 10 forks source link

ORBcomp bug? #75

Open MRedies opened 3 years ago

MRedies commented 3 years ago

I have a orbcomp DOS with keys like ORB:12,ind:3_up and I try to plot it like:

with HDF5Reader("banddos.hdf") as h5reader:
    data, attributes = h5reader.read(recipe=FleurORBCOMP)

for indx_list in [[1], [2,3,4], [5,6,7,8,9], [10,11,12,13,14,15,16]]:
    f, ax = plt.subplots(1,1,figsize=(8,6))
    for indx in indx_list:
        print(indx)
        plot_fleur_dos(data, attributes, multiply_by_equiv_atoms=True, linewidth=2, axis=ax,
           show=False, title="PBE0", legend_options={'fontsize':14}, weights=f"ORB:13,ind:{indx}_up",
           limits={'x':[1.7,1.9], 'y':[-0.5,0]}, legend=False, spin_arrows=False)

and this triggers the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_35667/1664073625.py in <module>
      3     for indx in indx_list:
      4         print(f"ORB:13,ind:{indx}_up")
----> 5         plot_fleur_dos(data, attributes, multiply_by_equiv_atoms=True, linewidth=2, axis=ax,
      6            show=False, title="PBE0", legend_options={'fontsize':14}, weights=f"ORB:13,ind:{indx}_up",
      7            limits={'x':[1.7,1.9], 'y':[-0.5,0]}, legend=False, spin_arrows=False)

~/masci-tools/masci_tools/vis/fleur.py in plot_fleur_dos(dosdata, attributes, spinpol, multiply_by_equiv_atoms, plot_keys, show_total, show_interstitial, show_sym, show_atoms, show_lresolved, key_mask, backend, **kwargs)
    358 
    359     spinpol = attributes['spins'] == 2 and spinpol and any('_down' in key for key in dosdata.keys())
--> 360     legend_labels, keys = _generate_dos_labels(dosdata, attributes, spinpol)
    361 
    362     if key_mask is None:

~/masci-tools/masci_tools/vis/fleur.py in _generate_dos_labels(dosdata, attributes, spinpol)
    482         types_elements.append(attributes['atoms_elements'][ind])
    483 
--> 484     for key in sorted(dosdata.keys(), key=_dos_order):
    485         if key == 'energy_grid':
    486             continue

~/masci-tools/masci_tools/vis/fleur.py in _dos_order(key)
    448         return (spin, general.index(key))
    449     elif ':' in key:
--> 450         before, after = key.split(':')
    451 
    452         tail = after.lstrip('0123456789')

ValueError: too many values to unpack (expected 2)

I guess the second : is causing a headace. @janssenhenning I will send you a link to my banddos.hdf via mattermost. I don't want to put it on github.

janssenhenning commented 3 years ago

@MRedies Yes you are right. This should be a simple fix

janssenhenning commented 3 years ago

@MRedies I fixed some things and at least the plot_fleur_dos call does not crash anymore. However I would recommend setting show_atoms=None and selecting all the components you want to plot manually with the plot_keys argument. The automatic selection is still broken since the orbital decomposition is done for all atoms instead of all atom types

P.S.: You can also try out the now blazing fast bandstructure plots (in comparison :D)