Bethe-Salpeter solver: Lanczos-Haydock: Difference between revisions

From The Yambo Project
Jump to navigation Jump to search
m (Fixed references)
 
(5 intermediate revisions by one other user not shown)
Line 8: Line 8:


You can avoid the full matrix [[Bethe-Salpeter solver: diagonalization|diagonalization]] (which rapidly become expensive as it scales as N<sup>3</sup>) by using the Lanczos-Haydock solver. While for small matrices the full diagonalization and the Lanczos-Haydock solver have similar computational cost, for matrices of the size 10000 by 10000 and larger, the Lanczos-Haydock solver is remarkably faster. The drawback is that excitonic functions cannot be calculated.
You can avoid the full matrix [[Bethe-Salpeter solver: diagonalization|diagonalization]] (which rapidly become expensive as it scales as N<sup>3</sup>) by using the Lanczos-Haydock solver. While for small matrices the full diagonalization and the Lanczos-Haydock solver have similar computational cost, for matrices of the size 10000 by 10000 and larger, the Lanczos-Haydock solver is remarkably faster. The drawback is that excitonic functions cannot be calculated.
Within the Lanczos-Haydock approach the macroscopic dielectric function is rewritten as a continued fraction<ref>L. X. Benedict and E. L. Shirley, Phys. Rev. B '''59''', 5441 (1999)</ref>
Within the Lanczos-Haydock approach the macroscopic dielectric function is rewritten as a continued fraction<ref name="Benedict1999"/>.


[[file:BSE1-Eq5.png|none|x100px]]
[[file:BSE1-Eq5.png|none|x100px]]


where ''a'' 's and ''b'' 's result from the [https://en.wikipedia.org/wiki/Lanczos_algorithm#Lanczos_method| Lanczos iterative algorithm].  
where ''a'' 's and ''b'' 's result from the [https://en.wikipedia.org/wiki/Lanczos_algorithm#Lanczos_method| Lanczos iterative algorithm]. In Yambo the approach is coded both for the Hermitian case (BSE neglecting coupling) and for the pseud-hermitian case (BSE with coupling)<ref name="Gruning2011"/>.


==Prerequisites==
==Prerequisites==
Line 53: Line 53:
This outputs the following log:
This outputs the following log:
  ...
  ...
  <01s> [06] BSE solver(s)
  <---> [03] BSE solver(s) @q1
  <01s> [06.01] Haydock solver
  <---> [03.01] Haydock Solver for abs @q1, scheme hermitian
  <01s> [Haydock] Iteration 1
  <---> [Haydock] Iteration 1
  <03s> [Haydock] Iteration 30 Accuracy : 0.01723| -0.02000
  <---> [Haydock] Iteration 30 Accuracy  0.010712|-0.020000
  ...
  ...
The Lanczos-Haydock iterative procedure converged to the desired accuracy in 21 iterations.
The Lanczos-Haydock iterative procedure converged to the desired accuracy in 30 iterations.


This runs only produces human readable files. That means that if you changes the input parameters (such as the broadening or the energy range) the Lanczos-Haydock procedure has to be repeated.  
This runs only produces human readable files. That means that if you changes the input parameters (such as the broadening or the energy range) the Lanczos-Haydock procedure has to be repeated.  
Among the human readable files, o-3D_BSE-low.eps_q1_haydock_bse contains the real and imaginary part of the macroscopic dielectric function:
Among the human readable files, o-3D_BSE-low.eps_q1_haydock_bse contains the real and imaginary part of the macroscopic dielectric function:
  $ less o-3D_BSE-low.eps_q1_haydock_bse
  $ less o-3D_BSE-low.eps_q1_haydock_bse
  ...
  ...
  #
  #
  # E/ev[1]   EPS-Im[2] EPS-Re[3] EPSo-Im[4] EPSo-Re[5] EPS`-Im[6] EPS`-Re[7]
  #   E/ev[1]           EPS-Im[2]         EPS-Re[3]         EPSo-Im[4]         EPSo-Re[5]         EPS`-Im[6]         EPS`-Re[7]
  #
  #
    2.00000    0.16089    5.81293    0.04945    4.12727    0.16089    5.81293
    2.00000000        0.596701317E-1      3.11588907        0.300982650E-1      2.50442362        0.596701317E-1      3.11588907 
    2.03015    0.16711    5.86203    0.05076    4.14234    0.16711    5.86203
    2.03015089        0.607327521E-1      3.13400769        0.304788072E-1      2.51354647        0.607327521E-1      3.13400769 
  ...
  ...
This file has a slightly different data structure with respect to the diagonalization solver:
This file has a slightly different data structure with respect to the diagonalization solver:
Line 76: Line 77:
  $gnuplot
  $gnuplot
  ...
  ...
   plot 'o-3D_BSE.eps_q1_diago_bse' u 1:2 w l t 'Diagonalization', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:2 w l t 'Haydock (last its)', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:6 w l t 'Haydock (last-1 its)'
   plot 'o-3D_BSE.eps_q1_diago_bse' u 1:2 w l t 'Diagonalization', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:2 w l t 'Haydock (30 its)', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:6 w l t 'Haydock (29 its)'
[[file:03_bse_haydock.png|none|600px]]
[[file:03_bse_haydock.png|none|600px]]
Except for the peak at higher energy, the results on this scale are identical to those obtained via the diagonalization solver. By comparing the results for the Lanczos-Haydock solver at 30 and 29 iterations, it is clear that the difference with the diagonalization results can be eliminated by lowering the threshold for the iterative process.
Except for the peak at higher energy, the results on this scale are identical to those obtained via the diagonalization solver. By comparing the results for the Lanczos-Haydock solver at 30 and 29 iterations, it is clear that the difference with the diagonalization results can be eliminated by lowering the threshold for the iterative process.
Line 89: Line 90:
outputs the following log  
outputs the following log  
  ...
  ...
  <01s> [06] BSE solver(s)
  <---> [03] BSE solver(s) @q1
  <01s> [06.01] Haydock solver
  <---> [03.01] Haydock Solver for abs @q1, scheme hermitian
  <01s> [Haydock] Iteration 1
  <---> [Haydock] Iteration 1
  <06s> [Haydock] Iteration 48 Accuracy 0.0098| 0.02000
  <---> [Haydock] Iteration 43 Accuracy 0.002787| 0.020000
  ...
  ...
Now 45 iterations, rather than 21, were needed to reach the desired accuracy.
Now 43 iterations, rather than 30, were needed to reach the desired accuracy.
By plotting these results:
By plotting these results:
  $ gnuplot
  $ gnuplot
Line 110: Line 111:
* Previous module: [[Bethe-Salpeter kernel]]
* Previous module: [[Bethe-Salpeter kernel]]
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: diagonalization | diagonalization]]  
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: diagonalization | diagonalization]]  
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: SLEPC|SLEPC]]
* Back to [[Calculating optical spectra including excitonic effects: a step-by-step guide]] tutorial
* Back to [[Calculating optical spectra including excitonic effects: a step-by-step guide]] tutorial
* [[Tutorials|Back to tutorials menu]]
* [[Tutorials|Back to tutorials menu]]
Line 115: Line 117:


==References==
==References==
<references>
<ref name="Benedict1999">L. X. Benedict, and E. L. Shirley, Phys. Rev. B '''59''', 5441 (1999)</ref>
<ref name="Gruning2011">M. Gruning, A. Marini, and X. Gonze, [https://doi.org/10.1016/j.commatsci.2011.02.021 Comp. Mat. Science '''50''' 2148-2156 (2011)]</ref>
</references>

Latest revision as of 09:09, 12 September 2023

In this module you learn how to obtain the optical absorption spectrum of bulk BN within the Bethe-Salpeter equation (BSE)framework for a previously calculated Bethe-Salpeter (BS) kernel. You will learn how to by-pass the diagonalization of the full two-particle Hamiltonian by using the subspace-iterative Lanczos-Haydock solver.


Background

The macroscopic dielectric function (from which the absorption and EEL spectra can be computed) is obtained from the eigenvalues Eλ (excitonic energies) and eigenvectors Aλcvk (exciton composition in terms of electron-hole pairs) of the two-particle Hamiltonian:

BSE1-Eq4.png

You can avoid the full matrix diagonalization (which rapidly become expensive as it scales as N3) by using the Lanczos-Haydock solver. While for small matrices the full diagonalization and the Lanczos-Haydock solver have similar computational cost, for matrices of the size 10000 by 10000 and larger, the Lanczos-Haydock solver is remarkably faster. The drawback is that excitonic functions cannot be calculated. Within the Lanczos-Haydock approach the macroscopic dielectric function is rewritten as a continued fraction[1].

BSE1-Eq5.png

where a 's and b 's result from the Lanczos iterative algorithm. In Yambo the approach is coded both for the Hermitian case (BSE neglecting coupling) and for the pseud-hermitian case (BSE with coupling)[2].

Prerequisites

Cheatsheet on Haydock

You will need:

  • The SAVE databases for 3D hBN
  • The 3D_BSE directory containing the databases from the Static screening and Bethe-Salpeter kernel modules
  • The yambo executable
  • gnuplot for plotting spectra

Choice of input parameters

To use the Lanczos-Haydock solver invoke yambo with "-y h" option in the command line:

$ yambo -F 03_3D_BSE_haydock_solver.in -y h -V qp -J 3D_BSE

The input is open in the editor. The input variable to be changed are

% BEnRange
  2.00000 | 8.00000 | eV    
%
BEnSteps= 200      
% BDmRange
  0.10000 |  0.10000 | eV    
%
% BLongDir
 1.000000 | 1.000000 | 0.000000 | 
%
% KfnQP_E 
 1.440000 | 1.000000 | 1.000000 |
%

as for the diagonalization solver and the additional parameter

BSHayTrs= -0.02000          

defines the threshold accuracy for the Lanczos-Haydock iterative process: the calculation stops when the difference between two consecutive calculated spectra is smaller than the absolute value of the threshold. The minus sign indicates that the average difference over the specified energy range is considered (i.e. that means that cancellations of error may occur) as opposed to the maximum absolute difference over the specified energy range (plus sign). For the moment we leave this variable unchanged. This parameter ultimately determines the terms are included in the continued fraction here above. Later we explore how this variable influences the final result.

Bethe-Salpeter solver runlevel

Invoke yambo to run the calculation:

$ yambo -F 03_3D_BSE_haydock_solver.in -J "3D_BSE-low,3D_BSE"  

This outputs the following log:

...
<---> [03] BSE solver(s) @q1
<---> [03.01] Haydock Solver for abs @q1, scheme hermitian
<---> [Haydock] Iteration 1
<---> [Haydock] Iteration 30 Accuracy  0.010712|-0.020000
...

The Lanczos-Haydock iterative procedure converged to the desired accuracy in 30 iterations.

This runs only produces human readable files. That means that if you changes the input parameters (such as the broadening or the energy range) the Lanczos-Haydock procedure has to be repeated. Among the human readable files, o-3D_BSE-low.eps_q1_haydock_bse contains the real and imaginary part of the macroscopic dielectric function:

$ less o-3D_BSE-low.eps_q1_haydock_bse
...
#
#    E/ev[1]            EPS-Im[2]          EPS-Re[3]          EPSo-Im[4]         EPSo-Re[5]         EPS`-Im[6]         EPS`-Re[7]
#
    2.00000000        0.596701317E-1      3.11588907        0.300982650E-1      2.50442362        0.596701317E-1      3.11588907   
    2.03015089        0.607327521E-1      3.13400769        0.304788072E-1      2.51354647        0.607327521E-1      3.13400769   
...

This file has a slightly different data structure with respect to the diagonalization solver:

Energy in eV | Imaginary part BSE | Real part BSE |Imaginary part IPA | Real part IPA |Imaginary part BSE (it-1) | Real part BSE (it-1)|

We can plot the second and sixth columns and compare with the result from diagonalization:

$gnuplot
...
 plot 'o-3D_BSE.eps_q1_diago_bse' u 1:2 w l t 'Diagonalization', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:2 w l t 'Haydock (30 its)', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:6 w l t 'Haydock (29 its)'
03 bse haydock.png

Except for the peak at higher energy, the results on this scale are identical to those obtained via the diagonalization solver. By comparing the results for the Lanczos-Haydock solver at 30 and 29 iterations, it is clear that the difference with the diagonalization results can be eliminated by lowering the threshold for the iterative process.

Convergence of the iterative procedure

Repeat now the calculation by changing the input variable:

BSHayTrs= 0.02000          

which enforces a stricter condition on the convergence of the iterative process (see above)

Running yambo:

$ yambo -F 03_3D_BSE_haydock_solver.in -J "3D_BSE-high,3D_BSE"  

outputs the following log

...
<---> [03] BSE solver(s) @q1
<---> [03.01] Haydock Solver for abs @q1, scheme hermitian
<---> [Haydock] Iteration 1
<---> [Haydock] Iteration 43 Accuracy  0.002787| 0.020000
...

Now 43 iterations, rather than 30, were needed to reach the desired accuracy. By plotting these results:

$ gnuplot
plot 'o-3D_BSE.eps_q1_diago_bse' u 1:2 w l ls 1 t 'Diagonalization', 'o-3D_BSE-high.eps_q1_haydock_bse' u 1:2 w l ls 2 t 'Haydock (high)', 'o-3D_BSE-low.eps_q1_haydock_bse' u 1:2 w l ls 3 t 'Haydock (low)'
03 bse haydock high.png

Which shows that the Lanczos-Haydock solver with the stricter convergence criterion and the diagonalization solver are identical on this scale.

Summary

From this tutorial you've learned:

  • How to compute the optical spectrum by using the Lanczos-Haydock solver within the Bethe-Salpeter equation framework
  • How to improve the calculated optical spectrum by using a stricter convergence criterion for the iterative Lanczos-Haydock solver

Links

References

  1. L. X. Benedict, and E. L. Shirley, Phys. Rev. B 59, 5441 (1999)
  2. M. Gruning, A. Marini, and X. Gonze, Comp. Mat. Science 50 2148-2156 (2011)