Page 1 of 1

Plot exciton weights on GW bands

Posted: Sat Oct 21, 2023 5:22 pm
by Jagjit Kaur
Hi,

I want to plot the exciton weights on GW bands using the yambopy script given in tutorial (https://www.yambo-code.eu/wiki/index.ph ... _databases). Here, the SAVE database is of kohn-sham energies. But, I wanted to plot GW bands. Therefore I called

Code: Select all

yqp = YamboQPDB.from_db(filename='ndb.QP',folder=save_path)
, And

Code: Select all

exc_bands = yexc.get_exciton_bs(yqp,path,states,size=1.0)
But the lattice parameters are been read by ns.db1 of kohn-sham energies.

Code: Select all

ylat = YamboLatticeDB.from_db_file(filename=save_path+'/ns.db1')
and

Code: Select all

yexc = YamboExcitonDB.from_db_file(ylat,filename=bse_path+'/ndb.BS_diago_Q1')
Now, these are for non-interpolated bandstructure. Though now the bands are of GW, there is an extra straight line showing up and the full brillouin zone is not mapped (see attachment). For interpolated bandstructure I am getting an error 'YamboQPDB' object has no attribute 'expand_kpts'.

Kindly help me with the bugs.

Regards,
Jagjit

Re: Plot exciton weights on GW bands

Posted: Mon Oct 23, 2023 7:55 am
by amolina
Dear Jagjit,
can you give us more information regarding the type of brillouin zone and the yambopy version that you are using?
Best,
Alejandro.

Re: Plot exciton weights on GW bands

Posted: Mon Oct 23, 2023 8:56 am
by Jagjit Kaur
Hi Alejandro,

I am using yambopy version 0.2.0 and 3D Hexagonal brillouin zone

Code: Select all

path = Path([ [[  0.0,  0.0,  0.0],'$\Gamma$'],
                  [[  0.5,  0.0,  0.0],'M'],
                  [[1./3.,1./3.,  0.0],'K'],
                  [[  0.0,  0.0,  0.0],'$\Gamma$'],
                  [[  0.0,  0.0,  0.5],'A'],
                  [[  0.5,  0.0,  0.5],'L'],
                  [[1./3.,1./3.,  0.5],'H'],
                  [[  0.0,  0.0,  0.5],'A']], [int(npoints*2),int(npoints),int(sqrt(5)*npoints), int(npoints*2),int(npoints),int(sqrt(5)*npoints), int(npoints*2)] )
This is the exc_kspace_plot.py

Code: Select all

"""
Tutorial for YamboExcitonDB.

Plotting exciton wavefunction components in the BZ

EDIT the path below to point to the yambo SAVE folder.
"""
#save_path='BSE_saves/YAMBO_saves'
#bse_path ='BSE_saves/BSE_databases'
save_path='SAVE'
bse_path ='/c13scratch/jagjit/Cs3Bi2X9/yambo/Cs3Bi2I9/BSE_spectra/03_diag/3D_QP_BSE'
from yambopy import *
from qepy import *
import numpy as np
import matplotlib.pyplot as plt

if __name__ == "__main__":

    Kspace_Plot = False
    Bands_Plot  = False
    Bands_Plot_Interpolate = True

    
    # Customly chosen Q-point
    iQ=0 # 0-> Gamma point, i.e., optical absorption limit
    # States to be merged together (because they are degenerate)
    #
    # You may try the following states:
    # 
    # [1,2], [3,4], [5], [6,7]
    #
    states = [1,2]

    #                    #
    # Start Yambopy part #
    #                    #

    # Create "lattice" object by reading the ns.db1 database inside the yambo SAVE
    ylat = YamboLatticeDB.from_db_file(filename=save_path+'/ns.db1')
    yqp = YamboQPDB.from_db(filename=save_path+'/ndb.QP')
     
    # Read exciton data at Q=iQ
    #yexc = YamboExcitonDB.from_db_file(ylat,filename=bse_path+'/ndb.BS_diago_Q1')
    yexc = YamboExcitonDB.from_db_file(ylat,filename=bse_path+'/ndb.BS_diago_Q1')
    # Plot of exciton weights in k-space
    if Kspace_Plot:
        fig = plt.figure(figsize=(6,6))
        ax  = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])
        yexc.plot_exciton_2D_ax(ax,states,mode='hexagon',limfactor=0.8,scale= 320)
        plt.show()
        k_space = 'k_space.pdf'
        plt.savefig(k_space)

    # Plot on top of the band structure
    
    ## [1.] Define path in crystal coordinates using class Path

    npoints = 50
   # path = Path([ [[  0.0,  0.0,  0.0],'$\Gamma$'],
   #               [[  0.5,  0.0,  0.0],'M'],
   #               [[1./3.,1./3.,  0.0],'K'],
   #               [[  0.0,  0.0,  0.0],'$\Gamma$']], 
   #               [int(npoints*2),int(npoints),int(sqrt(5)*npoints)] )
    path = Path([ [[  0.0,  0.0,  0.0],'$\Gamma$'],
                  [[  0.5,  0.0,  0.0],'M'],
                  [[1./3.,1./3.,  0.0],'K'],
                  [[  0.0,  0.0,  0.0],'$\Gamma$'],
                  [[  0.0,  0.0,  0.5],'A'],
                  [[  0.5,  0.0,  0.5],'L'],
                  [[1./3.,1./3.,  0.5],'H'],
                  [[  0.0,  0.0,  0.5],'A']], [int(npoints*2),int(npoints),int(sqrt(5)*npoints), int(npoints*2),int(npoints),int(sqrt(5)*npoints), int(npoints*2)] )

    ## [2.] Read electron energies
    #yel = YamboSaveDB.from_db_file(folder=save_path+'/SAVE')
    yqp = YamboQPDB.from_db(filename='ndb.QP',folder=save_path)

    ## [3.A] Plot without interpolating the values
    if Bands_Plot:
        fig = plt.figure(figsize=(4,6))
        ax  = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])

        #exc_on_bands = yexc.get_exciton_bs(yqp,path,states,size=1.0)
        exc_bands = yexc.get_exciton_bs(yqp,path,states,size=1.0)
        #exc_on_bands.plot_ax(ax,color_bands='grey',c_weights='red')
        exc_bands.plot_ax(ax,color_bands='grey',c_weights='red')

        ax.set_ylim(-1.,7.)
        plt.show()
        bs_nint = 'bs_nint.pdf'
        plt.savefig(bs_nint)

    ## [3.B] Interpolate the values
    if Bands_Plot_Interpolate:
        #yel.eigenvalues += -3.5+yel.get_fermi() # double back-shift correcting interpolate error
        fig = plt.figure(figsize=(4,6))
        ax  = fig.add_axes( [ 0.15, 0.15, 0.80, 0.80 ])

        # In case of problems with the interpolation, try to increase lpratio
        #exc_on_bands = yexc.interpolate(yqp,path,states,lpratio=10,f=None,size=0.5,verbose=True)
        #exc_on_bands.plot_ax(ax,c_bands='black',c_weights='red',alpha_weights=0.5)
        exc_bands = yexc.interpolate(yqp,path,states,f=None,size=0.5,verbose=True)
        exc_bands.plot_ax(ax,c_bands='black',c_weights='red',alpha_weights=0.5)
        ax.set_ylim(-8,8)
     
        plt.show()
        band = 'band_int.pdf'
        plt.savefig(band, bbox_inches='tight')
    
    #                  #
    # End Yambopy part #
    #                  #
Regards,
Jagjit

Re: Plot exciton weights on GW bands

Posted: Mon Oct 23, 2023 3:37 pm
by amolina
Hi Jagjit,
Be aware that if your k-grid might not include some high-symmetry points. Can you tell us which k-point are you using? It includes K?
Cheers,
Alejandro.

Re: Plot exciton weights on GW bands

Posted: Mon Oct 23, 2023 4:48 pm
by Jagjit Kaur
Hi Alejandro,

I have attached the interpolated DFT bandstructure with the exciton weights . As you can see all the k-points are included and the script which is given in the tutorial is running fine. But for the QP bandstructure with the exciton weights there seem to be problem as I am getting the following error:

Code: Select all

k1,k2,k3 = energies.expand_kpts()
AttributeError: 'YamboQPDB' object has no attribute 'expand_kpts'.     
It seems that expand_kpts is not an attribute of YamboQPDB.

I am also attaching the KS and GW bandstrcutures without the exciton weigths plotted. Even for that the k-path doesnot seem to be the issue.

Regards,
Jagjit

Re: Plot exciton weights on GW bands

Posted: Thu Oct 26, 2023 6:29 am
by Jagjit Kaur
Hi Alejandro,

The issue with the kpath is resolved but I am unable to solve the error for interpolated QP bandstructure with exciton.

Code: Select all

k1,k2,k3 = energies.expand_kpts()
AttributeError: 'YamboQPDB' object has no attribute 'expand_kpts'.
The above error is showing in the excitondb.py file.

Regards,
Jagjit

Re: Plot exciton weights on GW bands

Posted: Wed Nov 22, 2023 8:19 am
by amolina
Dear Jagjit,

We have spotted the bug. We are working on solving it. In the meantime, we are also working on a massive change yambopy uses to plot the band structures. We will inform of the new version as soon as possible.

Cheers,
Alejandro.

Re: Plot exciton weights on GW bands

Posted: Fri Feb 02, 2024 3:12 pm
by Jagjit Kaur
Hi Amolina,

I see that new version of yambopy is online now. But when I am trying to plot anything it shows the following error

Code: Select all

 from yambopy.quasiparticles.QP_rotate import *
ModuleNotFoundError: No module named 'yambopy.quasiparticles'
Is the new version still in development mode?

Regards,
Jagjit

Re: Plot exciton weights on GW bands

Posted: Sat Feb 03, 2024 11:53 am
by palful
Dear Jagjit,

In my case, when I import the same module in python with

Code: Select all

from yambopy.quasiparticles.QP_rotate import *
I do not find any problems and the module is imported correctly. Are you sure you are having the latest version and that it is installed properly? Also, I think that this module is not automatically imported by the plotting functions, although it can be manually used to expand the quasiparticle energies from the irreducible BZ to the full one.

NB: the big patch in kpath-finding and band structure plotting that Alejandro mentioned is still under development and will be added in the next update.

Re: Plot exciton weights on GW bands

Posted: Tue Feb 06, 2024 10:42 am
by Jagjit Kaur
Dear Fulvio,

Thank you for the reply. I re installed my yambopy package and now it works fine.

Regards,
Jagjit