Page 1 of 1

Py4vasp Plots

Posted: Mon Mar 11, 2024 6:38 pm
by alexander_duong
Hello,

Is there a way using py4vasp to change the y-axis (energy) limits when plotting the band structure and exporting it to a file? I know that I can zoom in to the range I want to look at, but is there a way so that it only outputs a plot within that range?

Thanks!

Re: Py4vasp Plots

Posted: Mon Mar 18, 2024 9:10 am
by andreas.singraber
Hello!

Sorry for the late reply!
To change the y-axis limits you can try the following:

Code: Select all

fig = calc.band.to_plotly()
This will take the band structure data and convert it into a plotly figure given the name fig. Then you can use plotly commands to modify the looks of the graph, e.g., in your case

Code: Select all

fig.update_layout(yaxis_range=[-4,4])
If you save the image with

Code: Select all

fig.write_image("bands.png")
the y-axis should be within the given limits also in the file output.

If you prefer to extract the band structure data directly and create your own graph then use the to_dict() method:

Code: Select all

data = calc.band.to_dict()
print(data.keys())
print(data["bands"])
returns:

Code: Select all

dict_keys(['kpoint_distances', 'kpoint_labels', 'fermi_energy', 'bands', 'occupations', 'projections'])
[[-12.37398323  -0.13705124  -0.13698808  -0.13698805   2.71211925
    2.71230009   2.7123001    3.59369258   8.12772068   8.12772071
    8.3210912   11.76821744  11.76826679  11.76826679  15.79650954
   24.22109415]
 [-12.16506281  -1.73013217  -0.42311383  -0.42301317   2.66585147
    3.1402435    3.14033932   4.92773258   7.62707016   7.62710245
    9.11779172  11.16938987  12.97571267  12.97575359  17.09479657
   22.02225903]
...
Hope this works for you!

All the best,
Andreas Singraber

Re: Py4vasp Plots

Posted: Fri Mar 22, 2024 3:48 pm
by alexander_duong
Thank you for your help!

Re: Py4vasp Plots

Posted: Tue Mar 26, 2024 3:45 am
by hongyang_ma
Hi Andreas,

I'm curious about how to project the x2-y2 orbital using py4vasp. Could you please let me know the name used in py4vasp for the x2-y2 orbital?

Regards,
Hongyang

Re: Py4vasp Plots

Posted: Tue Mar 26, 2024 10:28 pm
by andreas.singraber
Hello Hongyang,

as far as I know the labels should be identical to the short ones found in the PROCAR file. There is only one exception: the hyphen in x2-y2 would conflict with the selection syntax in py4vasp and hence is renamed dx2y2. Here is the full list:

Code: Select all

s
py, pz, px
dxy, dyz, dz2, dxz, dx2y2,
fy3x2, fxyz, fyz2, fz3, fxz2, fzx2, fx3 
Unfortunately, I cannot find this small change anywhere in the documentation... sorry for this inconvenience, I will suggest this to my colleagues.

All the best,
Andreas Singraber

Re: Py4vasp Plots

Posted: Wed Mar 27, 2024 4:56 am
by hongyang_ma
Dear Andreas,

Exactly! I've noticed that all the orbital labels work except for dx2-y2. It would be helpful to have an update in the document. Thank you very much!

Regards,
Hongyang

Re: Py4vasp Plots

Posted: Wed Mar 27, 2024 8:34 am
by andreas.singraber
Hello!

Just another useful remark: you can get the list of all projections available in your data via

Code: Select all

calc.projector.selections()
which will return a dictionary where you can find dx2y2 in the orbital entry.

Best,
Andreas Singraber

Re: Py4vasp Plots

Posted: Wed Mar 27, 2024 10:56 pm
by hongyang_ma
Thanks, Andreas!

Regards,
Hongyang