Page 1 of 5

Optical matrix elements

Posted: Thu Feb 23, 2012 6:15 pm
by amolina
Hi everybody,

I would like to know if we can get the optical matrix elements, <j|ep|i>, calculated (internally, I guess) by Yambo to obtain the dielectric function, where |j> is the unoccuppied state, |i> the occuppied state, and e the polarization of the electric field.

Thanks,

Alejandro.

Re: Optical matrix elements

Posted: Fri Feb 24, 2012 12:42 am
by claudio
Dear Alejandro

the optical matrix elements <i | p | j> and < i | r | j > are calculated in the subroutine

src/pol_function/Dipole_transverse.F

check the comments in the subroutine.

Notice that yambo does not recalculate the dipoles matrix elements every time,
if you want to force it to recalculate them remove the dipole database

SAVE/ndb.dipoles or SAVE/db.dipoles

best regards
Claudio

PS :arrow: inside the code everything is in atomic units, also the dipoles

Re: Optical matrix elements

Posted: Fri Mar 02, 2012 6:50 pm
by amolina
Dear Claudio,

I have read the subroutine. It prints the dipole matrix elements or I need to modify the code to write them?

Regards,

Alejandro.

Re: Optical matrix elements

Posted: Mon Mar 05, 2012 11:02 am
by claudio
Dear Alejandro

the subroutine just calculated the dipoles, in order to read them
you can add a line like this in the subroutine

write(100,'(3i4,6f16.8)') iv,ic,ik,rho(1:3)

and write them on a text file,
or you can use the python script in attachment (you need to compile yambo with netcdf)

Cla

Re: Optical matrix elements

Posted: Fri May 10, 2013 10:28 pm
by arlonne
Dear Claudio,
claudio wrote:Dear Alejandro

the subroutine just calculated the dipoles, in order to read them
you can add a line like this in the subroutine

write(100,'(3i4,6f16.8)') iv,ic,ik,rho(1:3)
I have tested your suggestion. It can work under serial calculation, but it failed under parallel calculations. it seems every cpu open and write this file. It is not easy to use the "of_close_open" and "msg" subroutine to handle a file. How can I write out this file use only one cpu in parallel model?

Thanks,
Longhua

Re: Optical matrix elements

Posted: Sat May 11, 2013 11:55 am
by claudio
Dear Longhua

when you run yambo in parallel each processor calculate only a part of the dipoles,
then at the end of the subroutine you will find an instruction

call PP_redux_wait(DIP_iR(:,:,:,ik,i_spin))

can redistribute all the dipole among the different preocessors.

After this instruction you can make one processor writes all of them doing:

load the preocessor number

Code: Select all

 use parallel_m,              ONLY : myid
make the preocessor number 0 writes all the dipoles

Code: Select all

if (myid==0) then
  do i_spin=1,n_spin
  do ik=1,Xk%nibz
     do ic=ic_min,X%ib(2)
        do iv=X%ib(1),iv_max
            write(100,'(3i4,6f16.8)') iv,ic,ik,DIP_iR(:,iv,ic,ik,i_spin)
       enddo
     enddo
  enddo
  enddo
endif
anyway I advise you to use the python script and read the dipole database at the end of the run:

http://www.yambo-code.org/doc/scripts.php

regards
Claudio

Re: Optical matrix elements

Posted: Sun May 12, 2013 2:29 am
by arlonne
Dear Claudio,

Thanks for your reply. I, actually, tried this method before. it didn't work. This is what I am confusing.
May be I should use the python script.

Best,
Longhua

Re: Optical matrix elements

Posted: Mon Nov 19, 2018 9:46 pm
by Zahra Taghipour
Hello Claudio,

I have a question regarding the extraction of the oscillators matrix elements.
I tried to use the script provided in "http://www.yambo-code.org/doc/scripts.p ... dipoles.py" to read the dipole elements, however, it asks for "ndb.dipoles" which I do not have among my outputs.
Currently, I am using Yambo 4.1.3 version. Are "ndb.dip_iR_and_P" files the same as "ndb.dipoles" file. Could you please help me find out how to save the oscillators matrix elements as txt file.

Zahra Taghipour
Researcher
The Ohio State University

Re: Optical matrix elements

Posted: Mon Nov 19, 2018 10:12 pm
by Daniele Varsano
Dear Zahar,
I strongly advise you to switch to a more recent release of Yambo, you are using a quite old version and many things chanced since then, and also many bugs have been fixed.
a) "ndb.dip_iR_and_P, yes they contains the dipoles.
b) probably you can use the yambo-py interface for reading the databases, but I'm not familiar with that, you may ask in the yambopy subforum.,
otherwise, you can just print the matrix elements when they are calculated (note that if they have been calculated once they are not recalculated).
You can use the piece of the code indicated in the post above by Claudio.
They are calculated in the subroutine Dipole_transverse, that is found in ./src/pol_function/DIPOLE_transverse.F and you can
add the writing lines in ./src/pol_function/DIPOLE_driver.F after the call:

Code: Select all

   call DIPOLES_ppredux_and_symmetrize()
Best,
Daniele

Re: Optical matrix elements

Posted: Tue Nov 20, 2018 1:34 am
by Zahra Taghipour
Dear Daniele,

Thank you for your recommendation. Unfortunately, this version was the only version I could install and run without the problem.
I still do not understand why the code does not output "ndb.dipoles"!

I added the following lines in ./src/pol_function/DIPOLE_driver.F after the call

open(unit=1,file="dipoles_out")
write(100,'(3i4,6f16.8)') iv,ic,ik,rho(1:3)
close(1)

But, the code does not write the matrix elements. I wonder what am I missing?
I should mention I tried the above code without line #1 and #3, as well, with no difference.

In the meanwhile, I will look into Yambopy to see if they have this included in their code to extract the dipole matrix.

Thanks, and Regards
Zahra T.