Optical matrix elements

Deals with issues related to computation of optical spectra in reciprocal space: RPA, TDDFT, local field effects.

Moderators: Davide Sangalli, andrea.ferretti, myrta gruning, andrea marini, Daniele Varsano, Conor Hogan

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

Optical matrix elements

Post by amolina » Thu Feb 23, 2012 6:15 pm

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.
Alejandro Molina-Sánchez
Institute of Materials Science (ICMUV)
University of Valencia, Spain

User avatar
claudio
Posts: 448
Joined: Tue Mar 31, 2009 11:33 pm
Contact:

Re: Optical matrix elements

Post by claudio » Fri Feb 24, 2012 12:42 am

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
Claudio Attaccalite
[CNRS/ Aix-Marseille Université/ CINaM laborarory / TSN department
Campus de Luminy – Case 913
13288 MARSEILLE Cedex 09
web site: http://www.attaccalite.com

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

Re: Optical matrix elements

Post by amolina » Fri Mar 02, 2012 6:50 pm

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.
Alejandro Molina-Sánchez
Institute of Materials Science (ICMUV)
University of Valencia, Spain

User avatar
claudio
Posts: 448
Joined: Tue Mar 31, 2009 11:33 pm
Contact:

Re: Optical matrix elements

Post by claudio » Mon Mar 05, 2012 11:02 am

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
You do not have the required permissions to view the files attached to this post.
Claudio Attaccalite
[CNRS/ Aix-Marseille Université/ CINaM laborarory / TSN department
Campus de Luminy – Case 913
13288 MARSEILLE Cedex 09
web site: http://www.attaccalite.com

arlonne
Posts: 26
Joined: Thu Apr 18, 2013 4:50 pm

Re: Optical matrix elements

Post by arlonne » Fri May 10, 2013 10:28 pm

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
arlonne
Department of Physics and Astronomy
Northwestern University, IL 60208

User avatar
claudio
Posts: 448
Joined: Tue Mar 31, 2009 11:33 pm
Contact:

Re: Optical matrix elements

Post by claudio » Sat May 11, 2013 11:55 am

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
Claudio Attaccalite
[CNRS/ Aix-Marseille Université/ CINaM laborarory / TSN department
Campus de Luminy – Case 913
13288 MARSEILLE Cedex 09
web site: http://www.attaccalite.com

arlonne
Posts: 26
Joined: Thu Apr 18, 2013 4:50 pm

Re: Optical matrix elements

Post by arlonne » Sun May 12, 2013 2:29 am

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
arlonne
Department of Physics and Astronomy
Northwestern University, IL 60208

Zahra Taghipour
Posts: 23
Joined: Mon Aug 17, 2015 5:56 am

Re: Optical matrix elements

Post by Zahra Taghipour » Mon Nov 19, 2018 9:46 pm

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

User avatar
Daniele Varsano
Posts: 3773
Joined: Tue Mar 17, 2009 2:23 pm
Contact:

Re: Optical matrix elements

Post by Daniele Varsano » Mon Nov 19, 2018 10:12 pm

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
Dr. Daniele Varsano
S3-CNR Institute of Nanoscience and MaX Center, Italy
MaX - Materials design at the Exascale
http://www.nano.cnr.it
http://www.max-centre.eu/

Zahra Taghipour
Posts: 23
Joined: Mon Aug 17, 2015 5:56 am

Re: Optical matrix elements

Post by Zahra Taghipour » Tue Nov 20, 2018 1:34 am

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.

Post Reply