a question for cofactor in function ip_eps2

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
ZHuang
Posts: 14
Joined: Sat Jul 08, 2023 3:32 pm

a question for cofactor in function ip_eps2

Post by ZHuang » Sat Sep 14, 2024 2:14 am

Dear developer,

I am confused about the cofactor used in the function ip_eps2 in dipolesdb.py in yambopy : https://github.com/yambo-code/yambopy/b ... polesdb.py

In line 381 the cofactor was defined as

Code: Select all

cofactor = spin_deg*8.*np.pi/(self.lattice.rlat_vol)
I am curious about why the volume used here is the Recip. lattice volume.
In the equation used to calculate the epsilon or absorption coefficient, it seems that the volume of the lattice cell (with the unit of m^3 or other cubic length) but not that of recip lattice was used.
For example, equation 10 in [PWSCF s epsilon.x users manual] https://web.mit.edu/espresso_v6.1/amd64 ... ps_man.pdf

I have this question because the values of the imaginary part of epsilon calculated by ip_eps2 in yambopy is much larger than that given by "yambo -o c", although they have the same shape.

However, if I used the Direct lattice volume in the cofactor (i.e., spin_deg*8.*np.pi/(self.lattice.lat_vol)), I got valueS much smaller than those calculated by "yambo -o c".

I found that the values of the imaginary part of epsilon calculated by a cofactor of spin_deg*8.*np.pi/(self.lattice.rlat_vol*self.lattice.lat_vol) matched well with that given by "yambo -o c" in both the sample and values. But this definition of cofactor causes more confusion.

Thank you very much for your kind help!
Zhipeng
Tongji University, Shanghai, China

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

Re: a question for cofactor in function ip_eps2

Post by palful » Mon Oct 07, 2024 3:03 pm

Dear Zhipeng,

Indeed, for the independent-particles response function, there is an intensity mismatch between the yambopy and yambo results. However, the definition of cofactor used in yambopy - the one that you pointed out - is the same one used in Yambo.

Recently, I have found a bug related to the incorrect accounting of the weight of the k-points in the yambopy k-sum, which I patched:

Code: Select all

412                 # rescale weight factors because we are in the expanded BZ
413                 wa    = weights[na,:]*self.nk_ibz/nkpoints
In this way, for 3D systems the IP spectrum from yambopy matches exactly that of yambo (at least in my testing). There is still some factor missing in the case of 2D systems though. In order to download the latest patched version, which is not yet available as a release on pip, I suggest to follow these steps: https://wiki.yambo-code.eu/wiki/index.p ... test_patch

Please, don't hesitate to let me know if this fixes it for you or not. Note also that in case of BSE exciton spectra the results from yambopy should match those of yambo.

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

ZHuang
Posts: 14
Joined: Sat Jul 08, 2023 3:32 pm

Re: a question for cofactor in function ip_eps2

Post by ZHuang » Fri Nov 08, 2024 12:42 pm

Dear Fulvio
Thank you very much for kind reply.
Best
Zhipeng

lorenzo.sponza
Posts: 15
Joined: Tue Mar 21, 2023 10:52 am

Re: a question for cofactor in function ip_eps2

Post by lorenzo.sponza » Tue May 20, 2025 4:07 pm

Dear Fulvio,
Let me append my post to this topic because I am also encountering some problem in matching yambo's IP results. I am working with release 0.4.0 of yambopy and working on GaN bulk (so a 3D material, not an isolated nanosheet). I decided to dig a bit this issue because if a scaling factor is pretty harmless when dealing with absorption or reflection, this can be a problem when calculating EELS because the roots of the real part of epsilon fall at different energies resulting in completely misplaced plasmon peaks.

I did some tests in both the 'imag' and 'full' mode. I haven't been able to trace back the very origin of the discrepancy, but it seems to me that in the current version of yambopy there is an extra factor of 2pi/Omega (mode=='imag') or 2/Omega (mode=='full'). Moreover, in the latter mode, I have the impression that a +1.0 contribution to the real part of epsilon is missing. Here below I post the dirty (very dirty) patch I added to my version of yambopy to reproduce yambo spectra.

Code: Select all

#dimensional factors
        if self.spin == 1 : spin_deg=2
        if self.spin == 2 : spin_deg=1
        #cofactor = spin_deg*8.*np.pi/(self.lattice.rlat_vol)   # to be removed
        cofactor = spin_deg*4.                                  # to be added
        if mode=='imag' or res_k: cofactor = cofactor * np.pi   # to be added added
        ... ... ...
            if mode=='full':
                        #construct complex-valued response function
                        #including resonant and antiresonant components
                        G1 = -1./(freqa-ecva+broad*I)
                        G2 = -1./(-freqa-ecva-broad*I)

                        # oscillators
                        osc = wa*dip2a

                        # +=: sum over (c,v,s) ; np.sum(axis=1): sum over k                    
                        #eps += np.sum(osc*(G1+G2),axis=1)/np.pi              # to be removed
                        eps += np.sum(osc*(G1+G2),axis=1)                     # to be added               

        eps = eps*cofactor
        if mode=='full' : eps.real += 1                                   # to be added
I should add that I recover "almost" exactly yambo's spectra, but I'm still not quite on top of them. In fact, both in the 'full' and in the 'imag' mode yambopy's Im[eps] vanishes at very low energies (omega~0), whereas yambo's does not. I haven't explored the origin of this discrepancy. Neither I have tested the res_k=True option.

I hope these observations can help you in solving also the 2D prefactor issue.

Cheers!
Dr. Lorenzo Sponza
- Unversité Paris-Saclay, ONERA, CNRS, Laboratoire d'Etude des Microstructures (LEM)
92322 Châtillon, France
- European Theoretical Spectroscopy Facility (ETSF)
B-4000 Sart Tilman, Liège, Belgium

Post Reply