Format of the BSE kernel file

Various technical topics such as parallelism and efficiency, netCDF problems, the Yambo code structure itself, are posted here.

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

Post Reply
yunhailiseu
Posts: 21
Joined: Fri Nov 29, 2013 1:30 pm

Format of the BSE kernel file

Post by yunhailiseu » Mon Oct 20, 2014 2:35 pm

Dear Yambo team,

I need to know the value of specific element of the BSE kernel. How is this matrix orginazied, and in which file is it stored?

I plan to write a fortran program to read its elements, and for simplicity I disabled the use of netcdf library. But before that I have to know its structure.

I tried exploring the source code, only to get lost in the complex derived data types and subroutine calls.

Best,
Yunhai
Yunhai Li
Department of Physics, Southeast University
Nanjing, Jiangsu, PRC

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

Re: Format of the BSE kernel file

Post by Daniele Varsano » Mon Oct 20, 2014 3:03 pm

Dear Yunhai,
the BSE matrix is sotred in ./SAVE/(n)db.BS_Q1
if the file is huge, it is automatically fragmented in multiple files.
If you use netcdf libraries, you can inspect it by using the ncdump command, otherwise it is a binary files.
If you want to have a look inside the code:
/bse/K.F

Code: Select all

539          BS_mat(icv1,icv2)=H_res_x*real(spin_occ)*Co-H_res_c
Here is when the BSE matrix is filled. icv1 and icv2 are generalized indexes of the electron-hole pairs.
The matrix is divided in blocks according with the k-point sampling. Try to follow the flux starting from this line:

Code: Select all

356  call PP_redux_wait
357  do ik2=1,BS_columns
358    !
and note:
H_res_x is the exchange part of the kernel
H_re_c is the direct term
ik2bz is the k-points in the Bz
iv1 valence bands
ic1 conduction bands
is1 symmetry operation
... the same for the index 2.

Hope it helps,

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/

yunhailiseu
Posts: 21
Joined: Fri Nov 29, 2013 1:30 pm

Re: Format of the BSE kernel file

Post by yunhailiseu » Sat Oct 25, 2014 3:22 pm

Daniele Varsano wrote:Dear Yunhai,
the BSE matrix is sotred in ./SAVE/(n)db.BS_Q1
if the file is huge, it is automatically fragmented in multiple files.
If you use netcdf libraries, you can inspect it by using the ncdump command, otherwise it is a binary files.
If you want to have a look inside the code:
/bse/K.F

Code: Select all

539          BS_mat(icv1,icv2)=H_res_x*real(spin_occ)*Co-H_res_c
Here is when the BSE matrix is filled. icv1 and icv2 are generalized indexes of the electron-hole pairs.
The matrix is divided in blocks according with the k-point sampling. Try to follow the flux starting from this line:

Code: Select all

356  call PP_redux_wait
357  do ik2=1,BS_columns
358    !
and note:
H_res_x is the exchange part of the kernel
H_re_c is the direct term
ik2bz is the k-points in the Bz
iv1 valence bands
ic1 conduction bands
is1 symmetry operation
... the same for the index 2.

Hope it helps,

Daniele
Daniele,

Sorry for the late reply.

It seems that the elements of BSE kernel is evaluted via a four-fold loop.

Code: Select all

do ik2=1,BS_columns
        ................
        do ik1=ik2,1,-1
                .................
                do icv1=1,BS_blk_dim(ik1)
                        ...............................
                        do icv2=1,BS_blk_dim(ik2)
                                  ...............................
                                  BS_mat(icv1,icv2)=H_res_x*real(spin_occ)*Co-H_res_c
                                  ...............................
                         end do
                         ........................
                  end do
                  ............................
          end do
          ................................
end do                     
I am considering writing the matirx "BS_mat" to user-specified files directly, which does not require the knowleged of the BSE kernel file. But what kind of variables are its elements? Complex number of single precision?

Code: Select all

do ik2=1,BS_columns
    do ik1=ik2,1,-1
It seems that in this loop only the "up-triangle elements" of pseudo-matirx (ik2,ik1) are considered.

Code: Select all

                do icv1=1,BS_blk_dim(ik1)
                        ...............................
                        do icv2=1,BS_blk_dim(ik2)
Also, BS_mat may not always be a square matirx, as BS_blk_dim(ik1) may not be equal to BS_blk_dim(ik2).

Does it mean that Yambo uses the Hermitian nature of BSE kernel to reduce the computional effort?

Best,
Yunhai
Yunhai Li
Department of Physics, Southeast University
Nanjing, Jiangsu, PRC

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

Re: Format of the BSE kernel file

Post by Daniele Varsano » Sat Oct 25, 2014 3:40 pm

Dear Yunhai,
Complex number of single precision?
Yes.
Does it mean that Yambo uses the Hermitian nature of BSE kernel to reduce the computional effort?
Yes, for the resonant part of the BSE matrix. While if the coupling is included the coupling part of the matrix it is stored in a different vector named BS_cpl_mat.

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/

yunhailiseu
Posts: 21
Joined: Fri Nov 29, 2013 1:30 pm

Re: Format of the BSE kernel file

Post by yunhailiseu » Mon Oct 27, 2014 9:55 am

Daniele Varsano wrote:Dear Yunhai,
Complex number of single precision?
Yes.
Does it mean that Yambo uses the Hermitian nature of BSE kernel to reduce the computional effort?
Yes, for the resonant part of the BSE matrix. While if the coupling is included the coupling part of the matrix it is stored in a different vector named BS_cpl_mat.

Best,
Daniele
Dear Daniele.

One more quesiton: how are the k-points and cv pairs ordered?
I may guess that the k-points are ordered as they appear in the section of "[03] Transferred momenta grid' in the report file, but not sure.

Best,
Yunhai
Yunhai Li
Department of Physics, Southeast University
Nanjing, Jiangsu, PRC

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

Re: Format of the BSE kernel file

Post by Daniele Varsano » Mon Oct 27, 2014 10:19 am

Dear Yunhai,
yes, the k-points should as in the report. Careful: the transferred momenta grid are the q-points (k-k').
About the cv ordering, I suggest you to take a simple example and print out the index of the bands and k-points. They are ordered according a table:
in ./src/bse/K.F

Code: Select all

ik1bz=BS_eh_table(iBSE1,1)
       iv1=BS_eh_table(iBSE1,2)
       ic1=BS_eh_table(iBSE1,3)
...
The table are defined in ./src/bse/K_eh_setup.F

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/

yunhailiseu
Posts: 21
Joined: Fri Nov 29, 2013 1:30 pm

Re: Format of the BSE kernel file

Post by yunhailiseu » Mon Oct 27, 2014 3:22 pm

Daniele Varsano wrote:Dear Yunhai,
yes, the k-points should as in the report. Careful: the transferred momenta grid are the q-points (k-k').
About the cv ordering, I suggest you to take a simple example and print out the index of the bands and k-points. They are ordered according a table:
in ./src/bse/K.F

Code: Select all

ik1bz=BS_eh_table(iBSE1,1)
       iv1=BS_eh_table(iBSE1,2)
       ic1=BS_eh_table(iBSE1,3)
...
The table are defined in ./src/bse/K_eh_setup.F

Best,
Daniele
Dear Daniele,

Thank you! I am very clear now.

Best,
Yunhai
Yunhai Li
Department of Physics, Southeast University
Nanjing, Jiangsu, PRC

Post Reply