[Bug?] Transition indexing in get_transitions()

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
lorenzo.sponza
Posts: 8
Joined: Tue Mar 21, 2023 10:52 am

[Bug?] Transition indexing in get_transitions()

Post by lorenzo.sponza » Tue Jun 20, 2023 5:05 pm

Hello everybody,
I'm trying using Yambopy to build up an analysis tool and I'm not sure about the transition indexing in the method get_transitions().
More specifically, at line 163 of electronsdb.py instructions are:

Code: Select all

for k,v,c in product(range(nkpoints),range(nvalence),range(nconduction)):
  vc = v*nvalence+c
  transitions[k,vc] = eigenvalues[k,c+nvalence]-eigenvalues[k,v]
If I got the idea right, vc is the index of the transition at point k and it should run from 0 to nvalence*nconduction-1. If that is the case, the code seems to have a bug here. Take for instance

Code: Select all

>>> nkpoints=1 ; nvalence=2 ; nconduction=4
>>> for k,v,c in product(range(nkpoints),range(nvalence),range(nconduction)): print(k, v, c, v*nvalence+c ) 
... 
0 0 0 0
0 0 1 1
0 0 2 2
0 0 3 3
0 1 0 2
0 1 1 3
0 1 2 4
0 1 3 5
then transitions 2 and 3 are overwritten and the indexing stops at 5 instead of 7 as it should. I think that the right instruction should be

Code: Select all

vc = v*nconduction+c

If I'm wrong, then I haven't understood what the indexing is meant to do and I apologise for the post.
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

rreho
Posts: 13
Joined: Mon Apr 26, 2021 3:39 pm

Re: [Bug?] Transition indexing in get_transitions()

Post by rreho » Tue Jun 20, 2023 5:48 pm

Dear Lorenzo,
I had a look at the code and I agree that this seems like a bug. Do you think this is affecting also other routines? From a first look at it, it seems like this should not affect other classes in Yambopy.

Cheers.

User avatar
amolina
Posts: 135
Joined: Fri Jul 15, 2011 11:23 am
Location: Valencia, Spain
Contact:

Re: [Bug?] Transition indexing in get_transitions()

Post by amolina » Tue Jun 20, 2023 8:38 pm

Dear Lorenzo,
I agree with you. It is a bug and the right expression is what you suggest. Are you using yambopy or yambopy-devel? I will commit the bug fix.
Thanks!
Alejandro
Alejandro Molina-Sánchez
Institute of Materials Science (ICMUV)
University of Valencia, Spain

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

Re: [Bug?] Transition indexing in get_transitions()

Post by lorenzo.sponza » Wed Jun 21, 2023 7:08 am

Hello!
I'm using yambopy (version 2.0 I think, but I'm not sure where I can read the version).
I haven't checked if this bug affects other routines. I don't know if the method get_transitions() is used by other objects.

Happy to contribute. 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