Page 1 of 1

BSE speed

Posted: Wed Jun 14, 2023 11:02 am
by Franz Fischer
Hi,

I have a question regarding the BSE implementation.
As an example I performed a BSE calculation for 2D-MoS2 on a 30x30x1 k-grid including 2 valence and 2 conduction bands with a wavefunction cutoff of 80 Ry (~20000 G-vectors) and a screening cutoff of 10 Ry (~700 G-vectors). The transition space of the BSE Kernel (resonant) is kpts_BZ * nbnd_valence * nbnd_conduction = 900 * 2 * 2 = 3600. Since the BSE matrix is hermitian there should be 6481800 individual Coulomb matrix elements (this can probably be reduced by using symmetries).

Writing out the Coulomb matrix elements in a plane-wave basis (see attached figure) there will be 4 summations, over G and G' (for the screening) and two over the wavefunction G-vectors. So for each Coulomb matrix element you would have ~ 700 * 700 * 20000 * 20000 ~ 2E14 summands.

Considering how many Coulomb matrix elements there are and the number of summands I am wondering how this calculation finished in 3 minutes on ~60 cores.

Perhaps my derivation is wrong or are you using some smart tricks to speed-up the calculation?

Best,
Franz

Re: BSE speed

Posted: Wed Jun 14, 2023 11:24 am
by Daniele Varsano
Dear Franz,

indeed, symmetries are used, anyway as you say the dimension of the matrix to be calculated is kpts_BZ * nbnd_valence * nbnd_conduction.
Regarding the kernel, the terms <ck|e^(i(q+g)r|c'k'> are calculated as FFT of the product of the wavefunctions, so finally the kernel reduce to a matrix multiplication Y=AX plus a dot product.

Best,

Daniele

Re: BSE speed

Posted: Wed Jun 14, 2023 12:23 pm
by Franz Fischer
Dear Daniele,

I have a (possibly really stupid) follow-up question: How do you compute the product of the wavefunctions?

Best,
Franz

Re: BSE speed

Posted: Mon Jun 19, 2023 8:24 am
by Davide Sangalli
Dear Franz,
since it is a product in real-space and a convolution in G-space, the operation is performed in real-space and later a Fast Fourier Transform (FFT) of the product is performed. This is also to be taken into account when considering the scaling.
This is the subroutine which computes the product of two wave-functions:
https://github.com/yambo-code/yambo/blo ... ter_Bamp.F

The sum over G, G' is performed up to 10 Ry in your case (700 G vectors), and also the product of the wave-functions up to 700 G vectors is used.

The real-space multiplication is done up to the size of the real space grid which is defined using both the values of 20 Ry and 70 Ry. See this line:

Code: Select all

call WF_load(WF,NG,O_ng_shift,bands_to_load,(/1,Xk%nibz/),space='R',title=trim(section_title))
inside https://github.com/yambo-code/yambo/blo ... rc/bse/K.F where the input cutoff (10 Ry) is used together with other values. Inside WF_load (if I remember well) this is combined with "wf_ng" (the cutoff on the WFs).
The conversion of these cut-off into a real-space grid is done according to some "magic rules". See details here:
https://github.com/yambo-code/yambo/blo ... ft_setup.F
See the "magic table" in the subroutine "fft_best_size"
The value is reported in the log and in the report, you should see something like fft size 15 x 15 x 8 (just random numbers here) or similar.

Finally, as already pointed out, not all wave-functions products are computed. There are some complex tables which limit the total number by taking advantage of symmetries. If you wish to dig into this see here:
https://github.com/yambo-code/yambo/blo ... llisions.F

Re: BSE speed

Posted: Thu Jun 22, 2023 9:44 am
by Franz Fischer
Dear Davide,

thank you for your thorough answer, but there are still some things that I don't understand.

Can you elaborate on:
and also the product of the wave-functions up to 700 G vectors is used.
With this product you mean the real-space product of the WFs, i.e. the convolution in G-space. What is then meant by the next sentence?
The real-space multiplication is done up to the size of the real space grid which is defined using both the values of 20 Ry and 70 Ry.
Here you again mention a real-space multiplication using different grid sizes. Moreover, where are the values 20 Ry and 70 Ry coming from?

Concerning the symmetries mentioned here:
Finally, as already pointed out, not all wave-functions products are computed. There are some complex tables which limit the total number by taking advantage of symmetries.
I saw in the file that you linked that you are checking that the product of your symmetries that bring k_BZ and k'_BZ to the IBZ lies in the star of k'_BZ. I don't really understand what you mean by that. Or in other words, how do you compute the quantity PHASE in https://github.com/yambo-code/yambo/blo ... llisions.F?

Best,
Franz