Exciton weight in by plot-excitondb.py

Post here any question you encounter when running the scripts of the yambo-py suite. Post here problem strictly to the python interface as problem coming from the yambo runs should go in the appropriate subforum.

Moderators: palful, amolina, mbonacci

Post Reply
aromani
Posts: 1
Joined: Mon May 26, 2025 11:06 pm

Exciton weight in by plot-excitondb.py

Post by aromani » Fri Jul 25, 2025 3:32 pm

Hello,
I'm following the tutorial to plot the exciton weight by plot-excitondb.py. I'm doing it on my system (NiI2 spin polarized) and I have an error that says:

"
File "/users/3059354/program/yambopy/yambopy/dbs/excitondb.py", line 962, in get_exciton_bs
size *= 1.0/np.max(exc_weights)
"

I checked get_exciton_bs and I saw that there is an "if" for non spin-polarised case and an empty "elif" that is commented and that does not give an alternative script for spin-polarised cases.


"
def get_exciton_bs(self,energies_db,path,excitons,size=1,f=None,debug=False):
"""
Get a YambopyBandstructure object with the exciton band-structure

Arguments:
ax -> axis extance of matplotlib to add the plot to
lattice -> Lattice database
energies_db -> Energies database, can be either ElectronsDB or QPDB
path -> Path in the brillouin zone
"""
from qepy.lattice import Path
if not isinstance(path,Path):
raise ValueError('Path argument must be a instance of Path. Got %s instead'%type(path))

if self.spin_pol=='no':
bands_kpoints, exc_energies, exc_weights, path_car = self.exciton_bs(energies_db, path, excitons, debug)
exc_energies = exc_energies[:,self.start_band:self.mband]
exc_weights = exc_weights[:,self.start_band:self.mband]
#elif spin_pol=='pol':

if f: exc_weights = f(exc_weights)
size *= 1.0/np.max(exc_weights)
ybs = YambopyBandStructure(exc_energies, bands_kpoints, weights=exc_weights, kpath=path_car, size=size)
return ybs
"

Is there a way to bypass this error for spin-polarised system?
Thank you very much.

(Anna Romani, Queen's University Belfast, UK)

User avatar
palful
Posts: 101
Joined: Tue Jan 26, 2016 11:23 am
Location: Modena and Milan

Re: Exciton weight in by plot-excitondb.py

Post by palful » Mon Jul 28, 2025 11:50 am

Ciao Anna,

I am afraid that support for plotting the exciton weights in spin-polarised systems is only partially developed.

If you check excitondb.py, you will see that there is a function `get_exciton_bs_spin_pol`, which in turn calls the function `exciton_bs_spin_pol`. However, `get_exciton_bs_spin_pol` is never actually called (it should be called under the commented `if` that you pointed out).

I suspect that `exciton_bs_spin_pol` is not tested or even not working. You may consider trying patch it in order to make it work! It would be nice to have the capability to plot the exciton weights over spin-polarized bands, both summing over all spins but also selecting specific transitions (such as spin-flip or not).

In the meantime, I have opened an issue on this problem here: https://github.com/yambo-code/yambopy/issues/71

Best,
Fulvio
Dr. Fulvio Paleari
S3-CNR Institute of Nanoscience and MaX Center
Modena, Italy

Post Reply