<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yambo-code.eu/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pedro</id>
	<title>The Yambo Project - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yambo-code.eu/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pedro"/>
	<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Special:Contributions/Pedro"/>
	<updated>2026-05-17T14:33:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Optical_properties_at_finite_temperature&amp;diff=5749</id>
		<title>Optical properties at finite temperature</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Optical_properties_at_finite_temperature&amp;diff=5749"/>
		<updated>2022-04-07T10:55:02Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:High low.png|thumb | 200px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we will show you how to calculate optical properties including thermal effects due to the electron-phonon coupling.&amp;lt;br&amp;gt;&lt;br /&gt;
This tutorial assumes that you have completed all the steps from the previous tutorial on [[Electron Phonon Coupling]].&amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial is dived into different steps first we will calculate absorption at independent particle approximation, &amp;lt;br&amp;gt;then we will include excitonic effects,&lt;br /&gt;
and finally, we will show how to analyze the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notice that there are two ways to include finite temperature effects in the BSE&#039;&#039;&#039;:&lt;br /&gt;
* The first is to use a full Bethe-Salpeter equation with all the coupling terms in such a way to treat complex quasi-particles that cannot be handled in standard (Hermitian) BSE, this is explained in section [[https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature#Bethe-Salpeter_at_finite_temperature_.28diagonalization_solver.29 Bethe-Salpeter at finite temperature (diagonalization solver)]]. This approach has the advantage that one can obtain excitonic eigenvalues and eigenfunctions at finite temperature and not only the optical spectrum.&lt;br /&gt;
 &lt;br /&gt;
* The second method is use of a standard Hermitinan (resonant) BSE plus the inversion solver &amp;lt;ref name=&#039;dbgrid&#039;&amp;gt;D. Kammerlander et al. [https://arxiv.org/abs/1209.1509 Phys. Rev. B &#039;&#039;&#039;86&#039;&#039;&#039;, 125203] &amp;lt;/ref&amp;gt;. In this case, a Lo two-particle Green&#039;s function that contains the complex quasi-particles is used in the solver to get a finite temperature spectrum. This approach has the advantage that can be used with the double-grid but it does not give access to eigenvalues and eigenfunctions of the BSE. This approach is described in the section: [[https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature#Bethe-Salpeter_at_finite_temperature_.28inversion_solver.29 Bethe-Salpeter at finite temperature (inversion solver)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Absorption at finite temperature ==&lt;br /&gt;
&lt;br /&gt;
Now you repeat the previous calculation but including all k-points, the last 3 valence and the first 3 conduction bands:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|8|2|7|&lt;br /&gt;
 %&lt;br /&gt;
 ....&lt;br /&gt;
and save the results of the 0K and 300K temperature in two separate folder with the -J option. &lt;br /&gt;
Now you can use the correction to the energy levels and the induced width to calculate the optical absorption at finite temperature. Generate the input with the command  &amp;lt;code&amp;gt;yambo_ph -o c -V qp -F yambo.in_300K&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 chi                              # [R][CHI] Dyson equation for Chi.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 Chimod= &amp;quot;IP&amp;quot;                     # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % QpntsRXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 |   &amp;lt;/span&amp;gt;                          # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXd&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 2 |  7 |  &amp;lt;/span&amp;gt;                         # [Xd] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % EnRngeXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.000000 | 5.000000 | &amp;lt;/span&amp;gt;        eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % DmRngeXd&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.0100000 | 0.0100000 | &amp;lt;/span&amp;gt;        eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ETStpsXd=  1500  &amp;lt;/span&amp;gt;                  # [Xd] Total Energy steps&lt;br /&gt;
 % LongDrXd&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;XfnQPdb= &amp;quot;E W &amp;lt; T300/ndb.QP&amp;quot; &amp;lt;/span&amp;gt;     # [EXTQP Xd] Database action&lt;br /&gt;
&lt;br /&gt;
set the path of the &#039;&#039;ndb.QP&#039;&#039; you want to read and perform the calculations. Notice that from the QP database we read two quantities the correction to the energy levels  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;E&amp;lt;/span&amp;gt; and the width  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;W&amp;lt;/span&amp;gt;. In this calculation we also included a small smearing 0.01eV to mimic the electronic smearing. Run your calculations with the command: &amp;lt;code&amp;gt;yambo_ph -F yambo.in_300K -J T300&amp;lt;/code&amp;gt; and do the same for the 0K case.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;You can plot the results with gnuplot using the command: &amp;lt;code&amp;gt; plot &#039;o-T300.eps_q1_ip&#039; w l t &#039;300 K&#039;, &#039;o-T0.eps_q1_ip&#039; w l t &#039;0 K&#039;&amp;lt;/code&amp;gt;.&amp;lt;br&amp;gt; Hereafter the result without and with electron-phonon coupling at two different temperatures:&lt;br /&gt;
[[File:Si absorption finite t.png|800px|center |Absorption of bulk silicon at finite temperature]]&lt;br /&gt;
&lt;br /&gt;
The temperature effect is clearly visible in the figure.&lt;br /&gt;
&lt;br /&gt;
== Bethe-Salpeter at finite temperature (diagonalization solver) ==&lt;br /&gt;
&lt;br /&gt;
In this section we will calculate the Bethe-Salpeter at finite temperature using the full-BSE.&lt;br /&gt;
&lt;br /&gt;
You can generate the input using the command &amp;lt;code&amp;gt;yambo_ph -X s -o b -k sex -y d -V qp -F yambo.in_BSE&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 em1s                             # [R][Xs] Statically Screened Interaction&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_Threads=0                      # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BSEmod= &amp;quot;coupling&amp;quot;      &amp;lt;/span&amp;gt;         # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  9257            RL    # [BSK] Exchange components&lt;br /&gt;
 BSENGBlk=-1                RL    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 #WehCpl                        # [BSK] eh interaction included also in coupling&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot;  &amp;lt;/span&amp;gt;     # [EXTQP BSK BSS] Database action&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.500000 | 1.000000 | 1.000000 |  &amp;lt;/span&amp;gt;      # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 BSEprop= &amp;quot;abs&amp;quot;                   # [BSS] Can be any among abs/jdos/kerr/magn/dich/photolum/esrt&lt;br /&gt;
 BSEdips= &amp;quot;none&amp;quot;                  # [BSS] Can be &amp;quot;trace/none&amp;quot; or &amp;quot;xy/xz/yz&amp;quot; to define off-diagonal rotation plane&lt;br /&gt;
 % BSEQptR&lt;br /&gt;
  1 | 1 |                             # [BSK] Transferred momenta range&lt;br /&gt;
 %&lt;br /&gt;
 % BSEBands&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 2 |  7 |&amp;lt;/span&amp;gt;                           # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.000000 | 5.000000 |&amp;lt;/span&amp;gt;         eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.010000 | 0.010000 | &amp;lt;/span&amp;gt;        eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BEnSteps= 1500    &amp;lt;/span&amp;gt;               # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 #WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
   1 | 12 |                           # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NGsBlkXs= 113                RL &amp;lt;/span&amp;gt;   # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this input file we asked Yambo to include finite temperature quasi-particle in the BSE with the line &amp;lt;code&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot; &amp;lt;/code&amp;gt;, notice that we also introduce an additional rigid shift of 0.5 eV to mimic the GW correction with the line &amp;lt;code&amp;gt; 0.500000 | 1.000000 | 1.000000 |  \# [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&amp;lt;/code&amp;gt;. You can now run the calculation with the command &amp;lt;code&amp;gt; yambo_ph -F yambo.in_BSE -J T0&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In principle you can calculate the GW correction following the [https://www.yambo-code.org/wiki/index.php?title=How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN this tutorial] and then merge the corresponding ndb.QP database with the one of the electron-phonon coupling using the command &amp;lt;code&amp;gt; ypp -qpdb m&amp;lt;/code&amp;gt;.&lt;br /&gt;
Notice that we changed the BSE type to &amp;quot;coupling&amp;quot; because you need the full Bethe-Salpeter to deal with complex quasi-particles.&amp;lt;br&amp;gt;&lt;br /&gt;
Now we do the same calculation at T = 300 K. Copy the previous input file &amp;lt;code&amp;gt; cp yambo.in_BSE yambo.in_BSE_300&amp;lt;/code&amp;gt;. Then modify where the code reads the QP database :&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T300/ndb.QP&amp;quot;  &amp;lt;/span&amp;gt;     # [EXTQP BSK BSS] Database action&lt;br /&gt;
[[File:Si bse optics.png|800px|center |Bethe-Salpeter at finite temperature for bulk silicom]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Approximations:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In this calculation we have made different approximations:&amp;lt;br&amp;gt;&lt;br /&gt;
1) we did not include the renormalization of excitons due to the change of the screening potential W with temperature. Including electron-phonon coupling&lt;br /&gt;
in the dielectric constant by changing the line &amp;lt;code&amp;gt; XfnQPdb= &amp;quot;none&amp;quot; &amp;lt;/code&amp;gt; is unfortunately not enough, for a discussion see ref. &amp;lt;ref&amp;gt;L. Adamska and P. Umari, [https://journals.aps.org/prb/abstract/10.1103/PhysRevB.103.075201 Phys. Rev. B &#039;&#039;&#039;103&#039;&#039;&#039;, 075201 (2021)] &amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2) The electron-phonon coupling should enter in the BSE through the exciton-phonon matrix elements and not from the single-particle self-energy, as we have done in this tutorial. The approximation used in this tutorial is valid for not too strong bound excitons, and in general it generated a finite life-time also for the lowest exciton in direct materials that is not correct. For a discussion see refs.&amp;lt;ref&amp;gt;G. Antonius, S. G. Louie [https://arxiv.org/abs/1705.04245 Phys. Rev. B &#039;&#039;&#039;105&#039;&#039;&#039;, 085111 (2022)]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&#039;claudio&#039;&amp;gt; see Supp. Mat. of [https://journals.aps.org/prb/abstract/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&#039;fulvio&#039;&amp;gt;F. Paleari, [https://orbilu.uni.lu/handle/10993/41058 Phd Thesis (2019)]&amp;lt;/ref&amp;gt; and &amp;lt;ref&amp;gt;H. Chen, D. Sangalli, and M. Bernardi [https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.125.107401 Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 107401 (2020)]&amp;lt;/ref&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
3) we did not include scattering between exciton and phonons, therefore our results do not contain phonon-assisted absorption peaks, you can include these terms by finite difference displacements see refs. &amp;lt;ref name=&#039;fulvio&#039;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Result analysis ==&lt;br /&gt;
Results of BSE at finite temperature can be analized in the same way of standard BSE. You can plot exciton binging energy as a function of the temperature, exciton wave-function and so, see [https://www.yambo-code.org/wiki/index.php?title=How_to_analyse_excitons Exciton Plot tutorial].&lt;br /&gt;
For example if you sort exciton with the command &amp;lt;code&amp;gt; ypp_ph -e s&amp;lt;/code&amp;gt; for the case T=0K, in addition to the exciton energy now you will find its line-width in the files .&lt;br /&gt;
&amp;lt;code&amp;gt;o.exc_qpt1_E_sorted&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;o.exc_qpt1_I_sorted&amp;lt;/code&amp;gt;.&lt;br /&gt;
 #&lt;br /&gt;
 #    Maximum Residual Value = .77136E+05&lt;br /&gt;
 #   &lt;br /&gt;
 #    E [ev]             Strength           Index              W [meV]&lt;br /&gt;
 #&lt;br /&gt;
 ...............&lt;br /&gt;
     2.82974172        0.388171151E-1      335.000000         11.9707289&lt;br /&gt;
     2.82976580        0.110338017         334.000000         11.9676380&lt;br /&gt;
     2.82979798        0.992550552         333.000000         11.9646358&lt;br /&gt;
     2.83366466        0.177820283E-2      336.000000         6.12744808&lt;br /&gt;
     2.83368802        0.183327938E-3      338.000000         6.12689734&lt;br /&gt;
     2.83369708        0.679280609E-3      337.000000         6.12836981&lt;br /&gt;
     2.87943292        0.146849517E-3      332.000000         2.51892495&lt;br /&gt;
     2.87945318        0.295515812E-3      331.000000         2.51745558&lt;br /&gt;
     2.89804840        0.539837289E-3      330.000000         1.42265606&lt;br /&gt;
     2.93557525        0.532299697         329.000000         12.5491867&lt;br /&gt;
     2.93559408        0.214365616         391.000000         12.5504198&lt;br /&gt;
     2.93561029        0.175688639         390.000000         12.5498590&lt;br /&gt;
     2.97320676        0.158064649E-3      388.000000         9.35168839&lt;br /&gt;
     2.97321057        0.300355150E-4      408.000000         9.35530090&lt;br /&gt;
     2.97321224        0.931323011E-4      389.000000         9.35327435&lt;br /&gt;
     2.97682190        0.551215744E-4      405.000000         8.87609196&lt;br /&gt;
&lt;br /&gt;
Notice that in the files you will find many exciton with negative energy due the full-BSE nature, finally consider line-width numbers with care due to the approximation described above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Excitonic Eliashberg Functions ==&lt;br /&gt;
If you run the BSE and save the excitonic wave-functions (uncomment the flag &amp;lt;code&amp;gt;WRbsWF&amp;lt;/code&amp;gt; in the BSE input file), tt is possible to plot the excitonic Eliashberg Functions with the command &amp;lt;code&amp;gt; ypp_ph -e e&amp;lt;/code&amp;gt;.&lt;br /&gt;
For an interpretation of these functions see the discussion in reference &amp;lt;ref&amp;gt;Andrea Marini&lt;br /&gt;
 [https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.101.106405 Phys. Rev. Lett. &#039;&#039;&#039;101&#039;&#039;&#039;, 106405 (2008)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Bethe-Salpeter at finite temperature (inversion solver) ==&lt;br /&gt;
&lt;br /&gt;
It is possible to take into account complex quasi-particles in the BSE solution by means of the inversion procedure.&lt;br /&gt;
The idea is to construct an Lo (Eq. 5 of Ref.&amp;lt;ref name=&#039;dbgrid&#039;&amp;gt;&amp;lt;/ref&amp;gt;) that includes the electron-phonon corrections including the imaginary part.&lt;br /&gt;
In order to generate the input you can type: &amp;lt;code&amp;gt;yambo_ph -X s -o b -k sex -y i -V qp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 em1s                             # [R][Xs] Statically Screened Interaction&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_Threads=0                      # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;i&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  9257            RL    # [BSK] Exchange components&lt;br /&gt;
 BSENGBlk=-1                RL    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 #WehCpl                        # [BSK] eh interaction included also in coupling&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot;&amp;lt;/span&amp;gt;       # [EXTQP BSK BSS] Database action&lt;br /&gt;
 KfnQP_INTERP_NN= 1               # [EXTQP BSK BSS] Interpolation neighbours (NN mode)&lt;br /&gt;
 KfnQP_INTERP_shells= 20.00000    # [EXTQP BSK BSS] Interpolation shells (BOLTZ mode)&lt;br /&gt;
 KfnQP_DbGd_INTERP_mode= &amp;quot;NN&amp;quot;     # [EXTQP BSK BSS] Interpolation DbGd mode&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.500000 | 1.000000 | 1.000000 |  &amp;lt;/span&amp;gt;      # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 BSEprop= &amp;quot;abs&amp;quot;                   # [BSS] abs/kerr/magn/dichr trace&lt;br /&gt;
 % BSEQptR&lt;br /&gt;
  1 | 1 |                             # [BSK] Transferred momenta range&lt;br /&gt;
 %&lt;br /&gt;
 % BSEBands&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   2 |  7 |  &amp;lt;/span&amp;gt;                         # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.00000 | 5.00000 | &amp;lt;/span&amp;gt;        eV    # [BSS] Energy range &lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.010000 | 0.010000 |  &amp;lt;/span&amp;gt;       eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BEnSteps= 1500  &amp;lt;/span&amp;gt;                  # [BSS] Energy steps&lt;br /&gt;
 % BLongDir &lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 #WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
 XfnQPdb= &amp;quot;none&amp;quot;                  # [EXTQP Xd] Database action&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
   1 | 12 |                           # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 113              RL    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
&lt;br /&gt;
then if you run the job you will get the spectrum at finite temperature. Notice that with the inversion solver you can choose if you want the BSE with or without the coupling by changing the &amp;lt;code&amp;gt;BSEmod&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
This approach can be combined with double-grid as explained here: [http://www.attaccalite.com/speed-up-dielectric-constant-calculations-using-the-double-grid-method-with-yambo/ Speed up dielectric constant calculations using the double-grid method with Yambo ]. Yambo automatically will interpolate quasi-particle corrections on the fine grid. &amp;lt;br&amp;gt; Notice that BSE inversion can become unfeasible for large BSE matrices.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Nota bene:&amp;lt;/span&amp;gt; if you use the inversion solver you just get the optical spectra, but you do not have access to the excitonic eigenvalues and eigenvectors and by consequence you cannot plot the excitonic wave-function or print the  excitonic Eliashberg functions.&lt;br /&gt;
&lt;br /&gt;
== Phonon-assisted density of states ==&lt;br /&gt;
Even if exciton-phonon scattering is not included in the BSE at finite temperature, it is possible to plot the phonon-assisted density of states (DOS) for light emission, defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula exc ph.png | 600px | center | Phonon-assisted JDOS ]]&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;E&amp;lt;sub&amp;gt;q&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;l&amp;lt;/sup&amp;gt;&#039;&#039;&#039; is the energy of the &#039;&#039;&#039;l&#039;&#039;&#039;-exciton at &#039;&#039;&#039;q&#039;&#039;&#039;-momentum,  &#039;&#039;&#039;ω&amp;lt;sub&amp;gt;q&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;λ&amp;lt;/sup&amp;gt;&#039;&#039;&#039; is the phonon energy, &#039;&#039;&#039;n&amp;lt;sub&amp;gt;B&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is the Bose function,  exciton are weighted with a Boltzamn factor and &#039;&#039;&#039;E&amp;lt;sub&amp;gt;min&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is the lowest exciton energy in the all BZ.&lt;br /&gt;
In order to calculate these DOS you need to solve BSE for all the q-points for the lowest excitons, you can use SLEPC library to speed up calculations, then you need a converged phonon calculations.&lt;br /&gt;
Then you interpolate phonon on a dense phonon grid using &amp;lt;code&amp;gt;matdyn.x&amp;lt;/code&amp;gt; utility in QE, and Yambo will interpolate exicton on the same grid.&lt;br /&gt;
Here we present an example for hBN that is an indirect semiconductor.&lt;br /&gt;
Running &amp;lt;code&amp;gt; ypp_ph -e p&amp;lt;/code&amp;gt; you will get:&lt;br /&gt;
 &lt;br /&gt;
 BoseTemp= 50 K    # Bosonic Temperature&lt;br /&gt;
 excitons                         # [R] Excitonic properties&lt;br /&gt;
 ph_ass_dos                       # [R] Phonon-assisted DOS&lt;br /&gt;
 States= &amp;quot;1 - 4&amp;quot;                  # Index of the BS state(s)&lt;br /&gt;
 PHfreqF= &amp;quot;./bn.freq_54&amp;quot;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 % DOSERange&lt;br /&gt;
  5.000000 | 5.500000 |         eV    # Energy range&lt;br /&gt;
 %&lt;br /&gt;
 DOSESteps= 1000                  # Energy steps&lt;br /&gt;
 DOS_broad= 0.004        eV    # Broadening of the DOS &lt;br /&gt;
&lt;br /&gt;
where &amp;quot;bn.freq_54&amp;quot; is the file produced by matdyn.x with the input:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;bn.fc&#039;,&lt;br /&gt;
     flfrq=&#039;bn.freq_54&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;bn.dos&#039;,&lt;br /&gt;
     ndos=2&lt;br /&gt;
     nk1=54, nk2=54, nk3=18&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
and the BSE was calculated on a 18x18x6 grid. The final spectra will be:&lt;br /&gt;
&lt;br /&gt;
[[File:Test dos pl bulk.png| 700px | center| Phonon-assisted JDOS]]&lt;br /&gt;
&lt;br /&gt;
where the DOS has been shifted to match the experimental peaks. Notice that the peak intensities are complitely off, because of the lack of the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5741</id>
		<title>Electron Phonon Coupling</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5741"/>
		<updated>2022-04-07T10:32:27Z</updated>

		<summary type="html">&lt;p&gt;Pedro: /* Double-grid method for the electron-phonon coupling (only in Yambo 5.x) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Electron phonon.png|thumb|200px| Electron-phonon coupling]]&lt;br /&gt;
Here we show step-by-step how to use [https://www.quantum-espresso.org/ Quantum Espresso] to calculate phonons and electron-phonon matrix-elements on a regular q-grid. &lt;br /&gt;
The final aim is to allow Yambo to read them and calculate the temperature-dependent correction to the electronic states.&lt;br /&gt;
This tutorial&amp;lt;ref&amp;gt; This tutorial is based on [http://www.attaccalite.com/elena/news/ Elena Cannuccia blog]&amp;lt;/ref&amp;gt; is quite articulated, take your time to do it patiently.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Sections 1 is presented for this school only as a template on how to generate the electron-phonon matrix elements using QuantumEspresso. As some of the steps there take quite a long time to finish, students can skip this section and move directly to section 2, &amp;quot;Quasi-particle band structure&amp;quot; where they will compute the corrections to the energy levels coming from the electron-phonon interaction. The necessary databases are provided in the link below.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon matrix elements ==&lt;br /&gt;
If you just want to see how Yambo works and leave the database generation for later, or use YamboPy to generate them, &amp;lt;br&amp;gt;&lt;br /&gt;
you can skip this section and download ready-made databases here:   [https://www.yambo-code.org/educational/tutorials/files/Si_elph_dbs.tgz Si_elph_dbs.tgz]&lt;br /&gt;
&lt;br /&gt;
Otherwise, in the cloud you need to load the quantum-espresso module:&lt;br /&gt;
 spack load quantum-espresso&lt;br /&gt;
&lt;br /&gt;
In this first section we will explain how to generate electron-phonon matrix elements in Quantum-Espresso, and how to import them in Yambo.&lt;br /&gt;
Calculations will be divided in different folders:&lt;br /&gt;
 &lt;br /&gt;
* &#039;&#039;&#039;pseudo&#039;&#039;&#039; the pseudo potential folder &lt;br /&gt;
* &#039;&#039;&#039;scf&#039;&#039;&#039; for the self-consistent calculation&lt;br /&gt;
* &#039;&#039;&#039;nscf&#039;&#039;&#039; for the non-self-consistent calculation with a larger number of bands&lt;br /&gt;
* &#039;&#039;&#039;phonon&#039;&#039;&#039; for the phonon calculations&lt;br /&gt;
* &#039;&#039;&#039;dvscf&#039;&#039;&#039; for the calculation of the electron-phonon matrix elements&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how to calculate electron-phonon induced corrections to the bands and optical properties for bulk silicon.&lt;br /&gt;
All input file are availabe in the following tgz file: [https://www.yambo-code.org/educational/tutorials/files/si.epc.tgz si.epc.tgz]&lt;br /&gt;
===SCF===&lt;br /&gt;
In &#039;&#039;&#039;scf&#039;&#039;&#039; we run a standard scf calculation using pw.x choosing a large k-grid in such a way to converge density. Do not forget to set  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;force_symmorphic=.true.&#039;&#039;&amp;lt;/span&amp;gt;, because not symmorphic symmetries are not supported yet in Yambo. Notice that:&lt;br /&gt;
&lt;br /&gt;
a) If you are working with 2D systems, not our case, we have to add the flag  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;assume_isolated=&amp;quot;2D&amp;quot;&#039;&#039;&amp;lt;/span&amp;gt; in such a way correct 2D phonons. &lt;br /&gt;
&lt;br /&gt;
b) If the cell is an &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;FCC&amp;lt;/span&amp;gt;, set manually the cell parameters by using the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;ibrav=0&#039;&#039;&amp;lt;/span&amp;gt; in your scf input file. This allows to generate correctly the uniform q grid over which phonons and electron-phonon databases are calculated, for example for Silicon you can use:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
  ......&lt;br /&gt;
  ibrav=  0,&lt;br /&gt;
  celldm(1) =5.09150&lt;br /&gt;
  .....&lt;br /&gt;
 /&lt;br /&gt;
 .....&lt;br /&gt;
 CELL_PARAMETERS alat&lt;br /&gt;
 0.0  1.0  1.0&lt;br /&gt;
 1.0  0.0  1.0&lt;br /&gt;
 1.0  1.0  0.0&lt;br /&gt;
&lt;br /&gt;
===NSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, and then copy the ${PREFIX}.save folder from &#039;&#039;&#039;scf&#039;&#039;&#039; to &#039;&#039;&#039;nscf&#039;&#039;&#039;, in the present example just do  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
In the nscf input you have to choose the number of k-points and bands you will use for the electron-phonon coupling and Yambo calculations, in our case we will use a 4x4x4 grid and 12 bands.&lt;br /&gt;
&lt;br /&gt;
===Q-points list ===&lt;br /&gt;
1. Read the q-points list. In the &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, enter in the ${PREFIX}.save then run &#039;&#039;p2y&#039;&#039; to read the wave-functions.&lt;br /&gt;
&lt;br /&gt;
2. Generate the setup file with the command &#039;&#039;yambo_ph -i -V all&#039;&#039; and uncomment the flag &#039;&#039;&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;BSEscatt&amp;lt;/span&amp;gt;&#039;&#039; then run the setup.&lt;br /&gt;
&lt;br /&gt;
3. Generate the input file to read the electron-phonon matrix elements with the command &#039;&#039;ypp_ph -k q&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 bzgrids                          # [R] BZ Grid generator&lt;br /&gt;
 Q_grid                           # [R] Q-grid analysis&lt;br /&gt;
 OutputAlat= 0.000000             # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 #NoWeights                     #  Do not print points weight&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                     # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;cooOut= &amp;quot;alat&amp;quot;&amp;lt;/span&amp;gt;                    # Points coordinates (out) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ListPts                      &amp;lt;/span&amp;gt; #  List the internal q/k points also in the parser format&lt;br /&gt;
 #ExpandPts                     #  Expand the internal q/k points in the BZ&lt;br /&gt;
 #ForceUserPts                  #  Do not check the correcteness of the user points&lt;br /&gt;
 %Qpts                            # Q points list&lt;br /&gt;
  0.000000| 0.000000| 0.000000| &lt;br /&gt;
 %&lt;br /&gt;
and uncomment the flag &#039;&#039;&#039;ListPts&#039;&#039;&#039; and q-point coordinates units in &#039;&#039;&#039;alat&#039;&#039;&#039;, the units used by QuantumEspresso. For particular cells, like the FCC, there could be an inconsistency between Yambo and QE definition of alat, in this case you can specify &#039;&#039;&#039;OutputAlat&#039;&#039;&#039; equal to the &#039;&#039;&#039;celldm(1)&#039;&#039;&#039; of QE. Then if you run ypp_ph it will generate the list of q-points for the phonon calculations:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 &amp;lt;---&amp;gt; Q-points (IBZ) PW-formatted&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.125000000  0.125000000 -0.125000000 1&lt;br /&gt;
      -0.250000000 -0.250000000  0.250000000 1&lt;br /&gt;
       0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.375000000  0.125000000 -0.125000000 1&lt;br /&gt;
       0.000000000 -0.250000000  0.250000000 1&lt;br /&gt;
      -0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.500000000  0.250000000  0.000000000 1&lt;br /&gt;
 &amp;lt;---&amp;gt; [08] Timing Overview&lt;br /&gt;
 ......&lt;br /&gt;
&lt;br /&gt;
===Phonons===&lt;br /&gt;
Plug into &#039;&#039;&#039;phonon&#039;&#039;&#039; directory.  You have to copy the self-consistent calculation in this folder&lt;br /&gt;
with the command &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./ &#039;&#039;&amp;lt;/span&amp;gt;. Then you can prepare an input file for phonons using the q-points list you generated in the previous step multiplied by -1, &lt;br /&gt;
the final input will be:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
            verbosity = &#039;high&#039;&lt;br /&gt;
               tr2_ph = 1e-12&lt;br /&gt;
               prefix = &#039;si&#039;&lt;br /&gt;
             fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
               fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
      electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
                epsil = .false.&lt;br /&gt;
                trans = .true.&lt;br /&gt;
                ldisp = .false.&lt;br /&gt;
                qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
===DVSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;dvscf&#039;&#039;&#039; folder. From the nscf folder copy density and wave-functions (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../nscf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;), from the phonon folder copy the dynamical matrices and the dvscf files (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../phonon/_ph0 ../phonon/*.dyn* ./&#039;&#039;&amp;lt;/span&amp;gt;).  Then  modify the phonon input to generate electron-phonon matrix elements for Yambo, by changing &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;epsil = .false.&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;trans = .false.&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;electron_phonon = yambo&amp;lt;/span&amp;gt;. You do not need to specify the k-point grid because it is read from the nscf wave-functions. In this way we will not recalculate phonons, but only the electron-phonon matrix elements for the number of bands present in the nscf input file, in our case 8 bands:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;&lt;br /&gt;
     electron_phonon = &#039;yambo&#039;,&lt;br /&gt;
               epsil = .false.&lt;br /&gt;
               trans = .false.&lt;br /&gt;
               ldisp = .false.&lt;br /&gt;
               qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
this run will generate a new folder &#039;&#039;elph_dir&#039;&#039; with all electron-phonon matrix elements in a format compatible with Yambo.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;IMPORTANT&amp;lt;/span&amp;gt;: do not parallelize on k-points in the &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculation, it is not supported yet!!&lt;br /&gt;
&lt;br /&gt;
===Import in Yambo===&lt;br /&gt;
Now you have to read the electron-phonon matrix elements. Go in the &#039;&#039;dvscf/si.save&#039;&#039; folder, and use ypp_ph to import electron-phonon coupling, by doing &#039;&#039;ypp_ph -g g&#039;&#039; and the PW el-ph folder:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;DBsPATH= &amp;quot;../elph_dir/&amp;quot; &amp;lt;/span&amp;gt;                    # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 #GkkpExpand                    # Expand the gkkp in the whole BZ&lt;br /&gt;
 #UseQindxB                     # Use qindx_B to expand gkkp (for testing purposes)&lt;br /&gt;
&lt;br /&gt;
run ypp_ph, and if everything went well you will get in output&lt;br /&gt;
&lt;br /&gt;
 ..... &lt;br /&gt;
 &amp;lt;---&amp;gt; [06] == Electron-Phonon Databases ==&lt;br /&gt;
 &amp;lt;---&amp;gt; Inspecting databases ...PWscf (dressed)...found 8 Q-points&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: phonon frequencies and eigenvectors |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: K+Q-grid check |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [07] == Q-points list in the DBS (iku units) ==&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Code generator        :PWscf&lt;br /&gt;
 &amp;lt;---&amp;gt; :: DB Kind               :dressed&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Expanded              :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(read)        :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(written)     :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: K-points              : 20&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Bands                 : 12&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Branches              :  6&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Uniform sampling      :yes&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Symmetry expanded     :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Debye Energy          : 63.09927 [meV]&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Notice that Yambo recognized that you are using a regular q-grid: &#039;&#039;Uniform sampling      :yes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Quasi-particle band structure ==&lt;br /&gt;
The first quantity we will calculate is the correction to the band structure induced by the electron-phonon coupling. In order to generate the corresponding input do &amp;lt;code&amp;gt;yambo_ph -g n -p fan -c ep -V gen&amp;lt;/code&amp;gt;. In the input we require the correction only at gamma point:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  1 | 12 |                           # [ELPH] G[W] bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
If you run &amp;lt;code&amp;gt;yambo_ph -J T0&amp;lt;/code&amp;gt; you will get correction at zero kelvin to the band structure. &lt;br /&gt;
You can change the temperature to 300 K by doing:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BoseTemp= 300.0            Kn &amp;lt;/span&amp;gt;   # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 12 |                           # [ELPH] G[W] bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
run again &amp;lt;code&amp;gt;yambo_ph -J T300&amp;lt;/code&amp;gt; and compare the two output files o-T0.qp and o-T300.qp, to find how much the gap change with the temperature.&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that in this calculation we set a small damping factor for the Green function of about 0.01 eV, this value should be of the order of the phonon life-time.&amp;lt;br&amp;gt;&lt;br /&gt;
If you repeat the calculation for different temperature you can obtain the trend of the gap vs temperature. The figure below report the Silicon gap at Gamma Point at different temperature obtained in this tutorial. You can recreate the file with the data needed for this plot with the following command line instruction:&lt;br /&gt;
&lt;br /&gt;
 for i in 0 50 100 150 200 250 300; do echo -n &amp;quot;$i  &amp;quot;; echo &amp;quot;$(grep &amp;quot;^ *1 *5&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;) - $(grep &amp;quot;^ *1 *4&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;)&amp;quot; | bc; done &amp;gt; gap_vs_T.dat&lt;br /&gt;
&lt;br /&gt;
and then in &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; type&lt;br /&gt;
 plot &#039;gap_vs_T.dat&#039; u 1:2 w lp &lt;br /&gt;
&lt;br /&gt;
[[File:Si_gap_finite_t.png|600px|center]]&lt;br /&gt;
If you uncomment the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt; the code saves information about the Eliashberg functions that can be plotted using the &#039;&#039;ypp_ph&#039;&#039;, see below.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally if you add &#039;&#039;-V qp&#039;&#039; in the input generation a new flag appears &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;OnMassShell&amp;lt;/span&amp;gt;, if you un-comment this flag calculation will be performed in the &amp;quot;on mass shell&amp;quot; approximation, namely the static limit the Quasi-Particle approximation, for a discussion see reference &amp;lt;ref&amp;gt;H. Kawai et al. [https://arxiv.org/abs/1310.2038 Phys. Rev. B &#039;&#039;&#039;89&#039;&#039;&#039;, 085202 (2014)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the last column in the quasi-particle file &amp;quot;o.QP&amp;quot; contains the &#039;&#039;&#039;quasi-particle width&#039;&#039;&#039;, that is related to their life-time. You can plot the band structure including this width to get quasi-particle spectra&lt;br /&gt;
similar to the one measured in ARPES experiments, see Fig. 2 in ref. &amp;lt;ref&amp;gt; G. Antonius, S. Poncé, E. Lantagne-Hurtubise, G. Auclair, X. Gonze, and M. Côté&lt;br /&gt;
 [https://arxiv.org/abs/1505.07738 Phys. Rev. B 92, 085137 (2015)] &amp;lt;/ref&amp;gt;.&lt;br /&gt;
This parameter will be used in the next tutorial on [https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature optical properties at finite temperature].&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; Yambo average the electron-phonon correction on the degenerate states, please &amp;lt;b&amp;gt;include all degenerate states in your calculations&amp;lt;/b&amp;gt;. For example in the silicon case you need correction from the 2nd band to the 8th band.&lt;br /&gt;
&lt;br /&gt;
== Convergence ==&lt;br /&gt;
&lt;br /&gt;
The results of this tutorial are not converged. This is due to the poor parameters used in this tutorial to make the calculations fast. In order to have converged results, first of all you have to be sure to have converged phonons, in order to do that increase  plane-wave cutoff,  number of k-points and if necessary reduce &#039;&#039;tr2_ph&#039;&#039;.&lt;br /&gt;
Then change the parameters for the Yambo calculations, increasing the number of &#039;&#039;&#039;k&#039;&#039;&#039; and &#039;&#039;&#039;q&#039;&#039;&#039; points and the number of bands. If you want to increase only the number of bands, just repeat the &#039;&#039;&#039;nscf&#039;&#039;&#039; and &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculations without recalculate  &#039;&#039;&#039;phonons&#039;&#039;&#039;. In the following section we will describe a smart way to accelerate convergence.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene: &amp;lt;/span&amp;gt; At present Yambo neither implements the Fröhlich term at q=0&amp;lt;ref&amp;gt;Carla Verdi and Feliciano Giustino&lt;br /&gt;
[https://arxiv.org/abs/1510.06373 Phys. Rev. Lett. &#039;&#039;&#039;115&#039;&#039;&#039;, 176401 (2015)] &amp;lt;/ref&amp;gt; nor the quadrupolar correction,&amp;lt;ref&amp;gt;G. Brunin et al.  [https://arxiv.org/abs/2002.00628  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 136601 (2020)]&amp;lt;/ref&amp;gt; therefore convergence in polar material can be very slow with the number of q-points.&lt;br /&gt;
&lt;br /&gt;
== Double-grid method for the electron-phonon coupling (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simplifying at most the matrix elements of the electron-phonon self-energy have the structure:&lt;br /&gt;
&lt;br /&gt;
[[File:Self elph.png|center|Yambo tutorial image | 270px ]]&lt;br /&gt;
&lt;br /&gt;
where we omitted the electronic band and the phonon branches indexes. In order to speed up calculation one can average the denominators on an additional fine grid around each &#039;&#039;&#039;q&#039;&#039;&#039; points as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula dbgrid.png|center|Yambo tutorial image| 500px]]&lt;br /&gt;
&lt;br /&gt;
In order to exploit the double-grid tool we need the phonon energies calculated on a fine grid. If you just want to test the functionality of Yambo you can download here some files with the phononic frequencies already calculated on different silicon grids: [https://www.yambo-code.org/educational/tutorials/files/si_freqs_files.tgz si_freqs_files.tgz] &amp;lt;br&amp;gt;&lt;br /&gt;
Otherwise you generate them by following the instructions below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Concerning the school, we suggest to use the precomputed frequencies provided above.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For a general tutorial on phonon calculation with Quantum Espresso you can have a look at [https://www.quantum-espresso.org/wp-content/uploads/phonons_tutorial_shanghai1.pdf Hands on phonons].&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from a well converged phonon calculation &#039;&#039;matdyn.x&#039;&#039; can interpolate phonon dispersion on a given q-sampling (for example a regular 14x14x14 grid, as shown in the input file below) and give the desired phonon energies. &lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;si.fc&#039;,&lt;br /&gt;
     flfrq=&#039;si.freq&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;si.dos&#039;,&lt;br /&gt;
     deltaE=1.d0,&lt;br /&gt;
     nk1=14, nk2=14, nk3=14&lt;br /&gt;
 /&lt;br /&gt;
Alternatively you can generate a random q-sampling using Yambo (&#039;&#039;ypp -k r&#039;&#039;) and insert the corresponding q points list into a matdyn file. &lt;br /&gt;
&lt;br /&gt;
Once you generated the phonon energies you can read them with the command &amp;lt;code&amp;gt;ypp_ph -g d&amp;lt;/code&amp;gt; (in this example we read the 12x12x12 double grid):&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_dg                          # [R] GKKP double grid&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PHfreqF= &amp;quot;si.freq_12&amp;quot;&amp;lt;/span&amp;gt;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 FineGd_mode= &amp;quot;mixed&amp;quot;             # Fine Grid mode. Symmetry expanded, unexpanded or mixed.&lt;br /&gt;
 #SkipBorderPts                 # Skip points in the Fine Grid that are on the surface of coarse gride smal BZ`s&lt;br /&gt;
 EkplusQmode= &amp;quot;interp&amp;quot;            # E(k+q) energies calculation mode (interp | dftp )&lt;br /&gt;
 #TestPHDGrid                   # Test double-grid: set all values of the fine grid equal to the couse ones&lt;br /&gt;
&lt;br /&gt;
then run &amp;lt;code&amp;gt;ypp_ph&amp;lt;/code&amp;gt; an it will generate a new file &#039;&#039;SAVE/ndb.PH_Double_Grid&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
In the calculation the new phonon energies will be expanded &lt;br /&gt;
using the symmetries of the systems, while the electronic energies at &#039;&#039;&#039;k+q&#039;&#039;&#039; will be interpolated using a smooth Fourier interpolation&amp;lt;ref&amp;gt;Warren E. Pickett, Henry Krakauer, and Philip B. Allen, &lt;br /&gt;
Phys. Rev. B &#039;&#039;&#039;38&#039;&#039;&#039;, 2721(1988)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
Now we go back to our &#039;&#039;yambo.in&#039;&#039; input file and repeat the calculations. The double grid will be automatically accounted for. &lt;br /&gt;
We reset the temperature to &amp;lt;code&amp;gt;BoseTemp= 0.0 Kn # Bosonic Temperature&amp;lt;/code&amp;gt; and run the calculation in a new directory:&lt;br /&gt;
 yambo_ph -J T0_12&lt;br /&gt;
&lt;br /&gt;
We can repeat the process for all the other double grids provided (12x12x12, 24x24x24, 36x36x36, 48x48x48) and check the band convergence to determine which double grid we will use.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;In fact, the best strategy to converge electron-phonon coupling calculations is to &#039;&#039;first&#039;&#039; converge the double-grid for a fixed coarse main grid, and &#039;&#039;second&#039;&#039;, once the final double-grid has been found, converge the main grid itself.  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;This is a process that takes time since it requires repeating the electron-phonon matrix element calculations each time the main grid is changed, therefore you are not supposed to do it for this tutorial.&amp;lt;/span&amp;gt;&#039;&#039;&#039; Hereafter we provide an example of Silicon band gap correction convergence versus the number of &#039;&#039;&#039;q&#039;&#039;&#039;-points in the main grid, using a double-grid with 4096 random &#039;&#039;&#039;q&#039;&#039;&#039;-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Gap conv.png|center|Yambo tutorial image | 750px]]&lt;br /&gt;
&lt;br /&gt;
The double-grid implementation is described in this paper&amp;lt;ref&amp;gt;Double-grid for the electron-phonon problem, (to be published) E. Cannuccia, C. Attaccalite and V. Olevano (2022)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon coupling using different &#039;&#039;&#039;q&#039;&#039;&#039; and &#039;&#039;&#039;k&#039;&#039;&#039; grids (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
NOT WORKING!!!!!&lt;br /&gt;
&lt;br /&gt;
The procedure to create electron-phonon matrix elements and import them in Yambo is quite complicated.&lt;br /&gt;
For this reason in Yambo 5.x we decided to simplify this kind of calculations.&lt;br /&gt;
Now you can generate the &#039;&#039;&#039;q&#039;&#039;&#039; grid independently from the &#039;&#039;&#039;k&#039;&#039;&#039; grid. &lt;br /&gt;
You follow the previous steps to generate EPC matrix elements but in the phonon/dvscf input file&lt;br /&gt;
you specify the standard QE q-grid:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12h&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
     electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
               epsil = .true.&lt;br /&gt;
               trans = .true.&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;              ldisp = .true.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;         nq1=6, nq2=6, nq3=2&amp;lt;/span&amp;gt;&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
then when you read the electron-phonon matrix elements you need to add the flag&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 DBsPATH= &amp;quot;../elph_dir/&amp;quot;          # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpExpand &amp;lt;/span&amp;gt;                   # Expand the gkkp in the whole BZ&lt;br /&gt;
&lt;br /&gt;
In this way you can converge &#039;&#039;&#039;q&#039;&#039;&#039; grid independently for the &#039;&#039;&#039;k&#039;&#039;&#039; one. This is important because in general a larger set of q-points&lt;br /&gt;
is required to have converged results compared to the k-one. Add the flag &amp;quot;-V ph&amp;quot;  in the input generation for the electron-phonon self-energy and set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpDB= &amp;quot;gkkp_expanded&amp;quot; &amp;lt;/span&amp;gt;                  # [ELPH] GKKP database (gkkp | gkkp_expanded | genFroh )&lt;br /&gt;
&lt;br /&gt;
Notice that the double-grid works also with k/q different grids.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and post-processing ==&lt;br /&gt;
&#039;&#039;&#039;Automatic generation of electron-phonon matrix elements&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Getting electron-phonon matrix elements from QuantumEspresso to Yambo is a complicated process, &amp;lt;br&amp;gt;&lt;br /&gt;
we advice you to create a script to automatize the procedure, here an example of a bash script for the silicon case: [https://www.yambo-code.org/educational/tutorials/files/SILICON_CONV.tgz SILICON-SCRIPT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are a list of utilities to analyze electron-phonon coupling results:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phonon density of states&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot phonon density of states with the command: &#039;&#039;ypp_ph -p d&#039;&#039;. In order to get a nice plot set in the input&lt;br /&gt;
&lt;br /&gt;
 phonons                          # [R] Phononic properties&lt;br /&gt;
 dos                              # [R] DOS&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PhBroad= 0.0005000          eV&amp;lt;/span&amp;gt;    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PhStps=1000 &amp;lt;/span&amp;gt;                     # Energy steps&lt;br /&gt;
&lt;br /&gt;
The we can analyse the phonon DOS of our previous &amp;lt;code&amp;gt;T0&amp;lt;/code&amp;gt; calculation by doing:&lt;br /&gt;
 ypp_ph -J T0&lt;br /&gt;
We get the output file &#039;&#039;o-T0.ph_dos&#039;&#039; which we can plot.&lt;br /&gt;
Notice that this is an easy quantity to check for the convergence in q-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Ph_dos.png|600px|center| Phonon Density of States]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Eliashberg Functions&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot Eliashberg functions&amp;lt;ref&amp;gt;F. Marsiglio, J.P. Carbotte [https://arxiv.org/abs/cond-mat/0106143 Electron - Phonon Superconductivity]&amp;lt;/ref&amp;gt; for both electrons and excitons. In order to plot Eliashberg functions you must have calculated Quasi-Particle correction with the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt;, see above.&lt;br /&gt;
The command  &#039;&#039;ypp_ph -s e&#039;&#039; generate the input for the electronic Eliashberg functions:&lt;br /&gt;
&lt;br /&gt;
 electrons                        # [R] Electronic properties&lt;br /&gt;
 eliashberg                       # [R] Eliashberg&lt;br /&gt;
 PhBroad= 0.0010000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps= 200                      # Energy steps&lt;br /&gt;
 %QPkrange                        #  generalized Kpoint/Band indices&lt;br /&gt;
  1|1|4|5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
in this example we plot Eliashberg functions for the top valence and bottom conduction band at Gamma point:&lt;br /&gt;
&lt;br /&gt;
[[File:Eliashberg functions.png|600px|center| Eliashberg functions]]&lt;br /&gt;
&lt;br /&gt;
For a discussion on how to interprete Eliashberg functions  and use them to understand the different phonon contribution you can have a look to ref.&amp;lt;ref&amp;gt;E. Cannuccia and A. Gali&lt;br /&gt;
[https://arxiv.org/abs/1907.06089 Phys. Rev. Materials 4, 014601 (2020)] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Atomic displacement amplitudes&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Running &#039;&#039;ypp_ph -p a&#039;&#039; will plot the atomic displacement for each atom in the cell each direction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Other variables in the input files &#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In the input files of the present tutorial there are other variable not used in this tutorial.&lt;br /&gt;
In particular &#039;&#039;GkkpExpand&#039;&#039; is used for other calculations not present in the GPL, while  &#039;&#039;GkkpConvert&#039;&#039; is used to checking purpose the IO for different versions&lt;br /&gt;
of the databases.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5733</id>
		<title>Electron Phonon Coupling</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5733"/>
		<updated>2022-04-07T10:05:50Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Electron phonon.png|thumb|200px| Electron-phonon coupling]]&lt;br /&gt;
Here we show step-by-step how to use [https://www.quantum-espresso.org/ Quantum Espresso] to calculate phonons and electron-phonon matrix-elements on a regular q-grid. &lt;br /&gt;
The final aim is to allow Yambo to read them and calculate the temperature-dependent correction to the electronic states.&lt;br /&gt;
This tutorial&amp;lt;ref&amp;gt; This tutorial is based on [http://www.attaccalite.com/elena/news/ Elena Cannuccia blog]&amp;lt;/ref&amp;gt; is quite articulated, take your time to do it patiently.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Sections 1 is presented for this school only as a template on how to generate the electron-phonon matrix elements using QuantumEspresso. As some of the steps there take quite a long time to finish, students can skip this section and move directly to section 2, &amp;quot;Quasi-particle band structure&amp;quot; where they will compute the corrections to the energy levels coming from the electron-phonon interaction. The necessary databases are provided in the link below.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon matrix elements ==&lt;br /&gt;
If you just want to see how Yambo works and leave the database generation for later, or use YamboPy to generate them, &amp;lt;br&amp;gt;&lt;br /&gt;
you can skip this section and download ready-made databases here:   [https://www.yambo-code.org/educational/tutorials/files/Si_elph_dbs.tgz Si_elph_dbs.tgz]&lt;br /&gt;
&lt;br /&gt;
Otherwise, in the cloud you need to load the quantum-espresso module:&lt;br /&gt;
 spack load quantum-espresso&lt;br /&gt;
&lt;br /&gt;
In this first section we will explain how to generate electron-phonon matrix elements in Quantum-Espresso, and how to import them in Yambo.&lt;br /&gt;
Calculations will be divided in different folders:&lt;br /&gt;
 &lt;br /&gt;
* &#039;&#039;&#039;pseudo&#039;&#039;&#039; the pseudo potential folder &lt;br /&gt;
* &#039;&#039;&#039;scf&#039;&#039;&#039; for the self-consistent calculation&lt;br /&gt;
* &#039;&#039;&#039;nscf&#039;&#039;&#039; for the non-self-consistent calculation with a larger number of bands&lt;br /&gt;
* &#039;&#039;&#039;phonon&#039;&#039;&#039; for the phonon calculations&lt;br /&gt;
* &#039;&#039;&#039;dvscf&#039;&#039;&#039; for the calculation of the electron-phonon matrix elements&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how to calculate electron-phonon induced corrections to the bands and optical properties for bulk silicon.&lt;br /&gt;
All input file are availabe in the following tgz file: [https://www.yambo-code.org/educational/tutorials/files/si.epc.tgz si.epc.tgz]&lt;br /&gt;
===SCF===&lt;br /&gt;
In &#039;&#039;&#039;scf&#039;&#039;&#039; we run a standard scf calculation using pw.x choosing a large k-grid in such a way to converge density. Do not forget to set  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;force_symmorphic=.true.&#039;&#039;&amp;lt;/span&amp;gt;, because not symmorphic symmetries are not supported yet in Yambo. Notice that:&lt;br /&gt;
&lt;br /&gt;
a) If you are working with 2D systems, not our case, we have to add the flag  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;assume_isolated=&amp;quot;2D&amp;quot;&#039;&#039;&amp;lt;/span&amp;gt; in such a way correct 2D phonons. &lt;br /&gt;
&lt;br /&gt;
b) If the cell is an &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;FCC&amp;lt;/span&amp;gt;, set manually the cell parameters by using the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;ibrav=0&#039;&#039;&amp;lt;/span&amp;gt; in your scf input file. This allows to generate correctly the uniform q grid over which phonons and electron-phonon databases are calculated, for example for Silicon you can use:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
  ......&lt;br /&gt;
  ibrav=  0,&lt;br /&gt;
  celldm(1) =5.09150&lt;br /&gt;
  .....&lt;br /&gt;
 /&lt;br /&gt;
 .....&lt;br /&gt;
 CELL_PARAMETERS alat&lt;br /&gt;
 0.0  1.0  1.0&lt;br /&gt;
 1.0  0.0  1.0&lt;br /&gt;
 1.0  1.0  0.0&lt;br /&gt;
&lt;br /&gt;
===NSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, and then copy the ${PREFIX}.save folder from &#039;&#039;&#039;scf&#039;&#039;&#039; to &#039;&#039;&#039;nscf&#039;&#039;&#039;, in the present example just do  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
In the nscf input you have to choose the number of k-points and bands you will use for the electron-phonon coupling and Yambo calculations, in our case we will use a 4x4x4 grid and 12 bands.&lt;br /&gt;
&lt;br /&gt;
===Q-points list ===&lt;br /&gt;
1. Read the q-points list. In the &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, enter in the ${PREFIX}.save then run &#039;&#039;p2y&#039;&#039; to read the wave-functions.&lt;br /&gt;
&lt;br /&gt;
2. Generate the setup file with the command &#039;&#039;yambo_ph -i -V all&#039;&#039; and uncomment the flag &#039;&#039;&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;BSEscatt&amp;lt;/span&amp;gt;&#039;&#039; then run the setup.&lt;br /&gt;
&lt;br /&gt;
3. Generate the input file to read the electron-phonon matrix elements with the command &#039;&#039;ypp_ph -k q&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 bzgrids                          # [R] BZ Grid generator&lt;br /&gt;
 Q_grid                           # [R] Q-grid analysis&lt;br /&gt;
 OutputAlat= 0.000000             # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 #NoWeights                     #  Do not print points weight&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                     # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;cooOut= &amp;quot;alat&amp;quot;&amp;lt;/span&amp;gt;                    # Points coordinates (out) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ListPts                      &amp;lt;/span&amp;gt; #  List the internal q/k points also in the parser format&lt;br /&gt;
 #ExpandPts                     #  Expand the internal q/k points in the BZ&lt;br /&gt;
 #ForceUserPts                  #  Do not check the correcteness of the user points&lt;br /&gt;
 %Qpts                            # Q points list&lt;br /&gt;
  0.000000| 0.000000| 0.000000| &lt;br /&gt;
 %&lt;br /&gt;
and uncomment the flag &#039;&#039;&#039;ListPts&#039;&#039;&#039; and q-point coordinates units in &#039;&#039;&#039;alat&#039;&#039;&#039;, the units used by QuantumEspresso. For particular cells, like the FCC, there could be an inconsistency between Yambo and QE definition of alat, in this case you can specify &#039;&#039;&#039;OutputAlat&#039;&#039;&#039; equal to the &#039;&#039;&#039;celldm(1)&#039;&#039;&#039; of QE. Then if you run ypp_ph it will generate the list of q-points for the phonon calculations:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 &amp;lt;---&amp;gt; Q-points (IBZ) PW-formatted&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.125000000  0.125000000 -0.125000000 1&lt;br /&gt;
      -0.250000000 -0.250000000  0.250000000 1&lt;br /&gt;
       0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.375000000  0.125000000 -0.125000000 1&lt;br /&gt;
       0.000000000 -0.250000000  0.250000000 1&lt;br /&gt;
      -0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.500000000  0.250000000  0.000000000 1&lt;br /&gt;
 &amp;lt;---&amp;gt; [08] Timing Overview&lt;br /&gt;
 ......&lt;br /&gt;
&lt;br /&gt;
===Phonons===&lt;br /&gt;
Plug into &#039;&#039;&#039;phonon&#039;&#039;&#039; directory.  You have to copy the self-consistent calculation in this folder&lt;br /&gt;
with the command &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./ &#039;&#039;&amp;lt;/span&amp;gt;. Then you can prepare an input file for phonons using the q-points list you generated in the previous step multiplied by -1, &lt;br /&gt;
the final input will be:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
            verbosity = &#039;high&#039;&lt;br /&gt;
               tr2_ph = 1e-12&lt;br /&gt;
               prefix = &#039;si&#039;&lt;br /&gt;
             fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
               fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
      electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
                epsil = .false.&lt;br /&gt;
                trans = .true.&lt;br /&gt;
                ldisp = .false.&lt;br /&gt;
                qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
===DVSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;dvscf&#039;&#039;&#039; folder. From the nscf folder copy density and wave-functions (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../nscf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;), from the phonon folder copy the dynamical matrices and the dvscf files (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../phonon/_ph0 ../phonon/*.dyn* ./&#039;&#039;&amp;lt;/span&amp;gt;).  Then  modify the phonon input to generate electron-phonon matrix elements for Yambo, by changing &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;epsil = .false.&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;trans = .false.&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;electron_phonon = yambo&amp;lt;/span&amp;gt;. You do not need to specify the k-point grid because it is read from the nscf wave-functions. In this way we will not recalculate phonons, but only the electron-phonon matrix elements for the number of bands present in the nscf input file, in our case 8 bands:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;&lt;br /&gt;
     electron_phonon = &#039;yambo&#039;,&lt;br /&gt;
               epsil = .false.&lt;br /&gt;
               trans = .false.&lt;br /&gt;
               ldisp = .false.&lt;br /&gt;
               qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
this run will generate a new folder &#039;&#039;elph_dir&#039;&#039; with all electron-phonon matrix elements in a format compatible with Yambo.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;IMPORTANT&amp;lt;/span&amp;gt;: do not parallelize on k-points in the &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculation, it is not supported yet!!&lt;br /&gt;
&lt;br /&gt;
===Import in Yambo===&lt;br /&gt;
Now you have to read the electron-phonon matrix elements. Go in the &#039;&#039;dvscf/si.save&#039;&#039; folder, and use ypp_ph to import electron-phonon coupling, by doing &#039;&#039;ypp_ph -g g&#039;&#039; and the PW el-ph folder:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;DBsPATH= &amp;quot;../elph_dir/&amp;quot; &amp;lt;/span&amp;gt;                    # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 #GkkpExpand                    # Expand the gkkp in the whole BZ&lt;br /&gt;
 #UseQindxB                     # Use qindx_B to expand gkkp (for testing purposes)&lt;br /&gt;
&lt;br /&gt;
run ypp_ph, and if everything went well you will get in output&lt;br /&gt;
&lt;br /&gt;
 ..... &lt;br /&gt;
 &amp;lt;---&amp;gt; [06] == Electron-Phonon Databases ==&lt;br /&gt;
 &amp;lt;---&amp;gt; Inspecting databases ...PWscf (dressed)...found 8 Q-points&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: phonon frequencies and eigenvectors |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: K+Q-grid check |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [07] == Q-points list in the DBS (iku units) ==&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Code generator        :PWscf&lt;br /&gt;
 &amp;lt;---&amp;gt; :: DB Kind               :dressed&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Expanded              :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(read)        :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(written)     :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: K-points              : 20&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Bands                 : 12&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Branches              :  6&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Uniform sampling      :yes&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Symmetry expanded     :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Debye Energy          : 63.09927 [meV]&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Notice that Yambo recognized that you are using a regular q-grid: &#039;&#039;Uniform sampling      :yes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Quasi-particle band structure ==&lt;br /&gt;
The first quantity we will calculate is the correction to the band structure induced by the electron-phonon coupling. In order to generate the corresponding input do &amp;lt;code&amp;gt;yambo_ph -g n -p fan -c ep -V gen&amp;lt;/code&amp;gt;. In the input we require the correction only at gamma point:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  1 | 12 |                           # [ELPH] G[W] bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
If you run &amp;lt;code&amp;gt;yambo_ph -J T0&amp;lt;/code&amp;gt; you will get correction at zero kelvin to the band structure. &lt;br /&gt;
You can change the temperature to 300 K by doing:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BoseTemp= 300.0            Kn &amp;lt;/span&amp;gt;   # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 12 |                           # [ELPH] G[W] bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
run again &amp;lt;code&amp;gt;yambo_ph -J T300&amp;lt;/code&amp;gt; and compare the two output files o-T0.qp and o-T300.qp, to find how much the gap change with the temperature.&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that in this calculation we set a small damping factor for the Green function of about 0.01 eV, this value should be of the order of the phonon life-time.&amp;lt;br&amp;gt;&lt;br /&gt;
If you repeat the calculation for different temperature you can obtain the trend of the gap vs temperature. The figure below report the Silicon gap at Gamma Point at different temperature obtained in this tutorial. You can recreate the file with the data needed for this plot with the following command line instruction:&lt;br /&gt;
&lt;br /&gt;
 for i in 0 50 100 150 200 250 300; do echo -n &amp;quot;$i  &amp;quot;; echo &amp;quot;$(grep &amp;quot;^ *1 *5&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;) - $(grep &amp;quot;^ *1 *4&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;)&amp;quot; | bc; done &amp;gt; gap_vs_T.dat&lt;br /&gt;
&lt;br /&gt;
and then in &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; type&lt;br /&gt;
 plot &#039;gap_vs_T.dat&#039; u 1:2 w lp &lt;br /&gt;
&lt;br /&gt;
[[File:Si_gap_finite_t.png|600px|center]]&lt;br /&gt;
If you uncomment the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt; the code saves information about the Eliashberg functions that can be plotted using the &#039;&#039;ypp_ph&#039;&#039;, see below.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally if you add &#039;&#039;-V qp&#039;&#039; in the input generation a new flag appears &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;OnMassShell&amp;lt;/span&amp;gt;, if you un-comment this flag calculation will be performed in the &amp;quot;on mass shell&amp;quot; approximation, namely the static limit the Quasi-Particle approximation, for a discussion see reference &amp;lt;ref&amp;gt;H. Kawai et al. [https://arxiv.org/abs/1310.2038 Phys. Rev. B &#039;&#039;&#039;89&#039;&#039;&#039;, 085202 (2014)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the last column in the quasi-particle file &amp;quot;o.QP&amp;quot; contains the &#039;&#039;&#039;quasi-particle width&#039;&#039;&#039;, that is related to their life-time. You can plot the band structure including this width to get quasi-particle spectra&lt;br /&gt;
similar to the one measured in ARPES experiments, see Fig. 2 in ref. &amp;lt;ref&amp;gt; G. Antonius, S. Poncé, E. Lantagne-Hurtubise, G. Auclair, X. Gonze, and M. Côté&lt;br /&gt;
 [https://arxiv.org/abs/1505.07738 Phys. Rev. B 92, 085137 (2015)] &amp;lt;/ref&amp;gt;.&lt;br /&gt;
This parameter will be used in the next tutorial on [https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature optical properties at finite temperature].&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; Yambo average the electron-phonon correction on the degenerate states, please &amp;lt;b&amp;gt;include all degenerate states in your calculations&amp;lt;/b&amp;gt;. For example in the silicon case you need correction from the 2nd band to the 8th band.&lt;br /&gt;
&lt;br /&gt;
== Convergence ==&lt;br /&gt;
&lt;br /&gt;
The results of this tutorial are not converged. This is due to the poor parameters used in this tutorial to make the calculations fast. In order to have converged results, first of all you have to be sure to have converged phonons, in order to do that increase  plane-wave cutoff,  number of k-points and if necessary reduce &#039;&#039;tr2_ph&#039;&#039;.&lt;br /&gt;
Then change the parameters for the Yambo calculations, increasing the number of &#039;&#039;&#039;k&#039;&#039;&#039; and &#039;&#039;&#039;q&#039;&#039;&#039; points and the number of bands. If you want to increase only the number of bands, just repeat the &#039;&#039;&#039;nscf&#039;&#039;&#039; and &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculations without recalculate  &#039;&#039;&#039;phonons&#039;&#039;&#039;. In the following section we will describe a smart way to accelerate convergence.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene: &amp;lt;/span&amp;gt; At present Yambo neither implements the Fröhlich term at q=0&amp;lt;ref&amp;gt;Carla Verdi and Feliciano Giustino&lt;br /&gt;
[https://arxiv.org/abs/1510.06373 Phys. Rev. Lett. &#039;&#039;&#039;115&#039;&#039;&#039;, 176401 (2015)] &amp;lt;/ref&amp;gt; nor the quadrupolar correction,&amp;lt;ref&amp;gt;G. Brunin et al.  [https://arxiv.org/abs/2002.00628  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 136601 (2020)]&amp;lt;/ref&amp;gt; therefore convergence in polar material can be very slow with the number of q-points.&lt;br /&gt;
&lt;br /&gt;
== Double-grid method for the electron-phonon coupling (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simplifying at most the matrix elements of the electron-phonon self-energy have the structure:&lt;br /&gt;
&lt;br /&gt;
[[File:Self elph.png|center|Yambo tutorial image | 270px ]]&lt;br /&gt;
&lt;br /&gt;
where we omitted the electronic band and the phonon branches indexes. In order to speed up calculation one can average the denominators on an additional fine grid around each &#039;&#039;&#039;q&#039;&#039;&#039; points as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula dbgrid.png|center|Yambo tutorial image| 500px]]&lt;br /&gt;
&lt;br /&gt;
In order to exploit the double-grid tool we need the phonon energies calculated on a fine grid. If you just want to test the functionality of Yambo you can download here some files with the phononic frequencies already calculated on different silicon grids: [https://www.yambo-code.org/educational/tutorials/files/si_freqs_files.tgz si_freqs_files.tgz] &amp;lt;br&amp;gt;&lt;br /&gt;
Otherwise you generate them by following the instructions below.&lt;br /&gt;
For a general tutorial on phonon calculation with Quantum Espresso you can have a look at [https://www.quantum-espresso.org/wp-content/uploads/phonons_tutorial_shanghai1.pdf Hands on phonons].&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from a well converged phonon calculation &#039;&#039;matdyn.x&#039;&#039; can interpolate phonon dispersion on a given q-sampling (for example a regular 14x14x14 grid, as shown in the input file below) and give the desired phonon energies. &lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;si.fc&#039;,&lt;br /&gt;
     flfrq=&#039;si.freq&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;si.dos&#039;,&lt;br /&gt;
     deltaE=1.d0,&lt;br /&gt;
     nk1=14, nk2=14, nk3=14&lt;br /&gt;
 /&lt;br /&gt;
Alternatively you can generate a random q-sampling using Yambo (&#039;&#039;ypp -k r&#039;&#039;) and insert the corresponding q points list into a matdyn file. &lt;br /&gt;
&lt;br /&gt;
Once you generated the phonon energies you can read them with the command &#039;&#039;ypp_ph -g d&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_dg                          # [R] GKKP double grid&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PHfreqF= &amp;quot;si.freq&amp;quot;&amp;lt;/span&amp;gt;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 FineGd_mode= &amp;quot;mixed&amp;quot;             # Fine Grid mode. Symmetry expanded, unexpanded or mixed.&lt;br /&gt;
 #SkipBorderPts                 # Skip points in the Fine Grid that are on the surface of coarse gride smal BZ`s&lt;br /&gt;
 EkplusQmode= &amp;quot;interp&amp;quot;            # E(k+q) energies calculation mode (interp | dftp )&lt;br /&gt;
 #TestPHDGrid                   # Test double-grid: set all values of the fine grid equal to the couse ones&lt;br /&gt;
&lt;br /&gt;
then run &#039;&#039;ypp_ph&#039;&#039; an it will generate a new file &#039;&#039;SAVE/ndb.PH_Double_Grid&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
In the calculation the new phonon energies will be expanded &lt;br /&gt;
using the symmetries of the systems, while the electronic energies at &#039;&#039;&#039;k+q&#039;&#039;&#039; will be interpolated using a smooth Fourier interpolation&amp;lt;ref&amp;gt;Warren E. Pickett, Henry Krakauer, and Philip B. Allen, &lt;br /&gt;
Phys. Rev. B &#039;&#039;&#039;38&#039;&#039;&#039;, 2721(1988)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
In order to perform calculation with the double grid remove the &#039;&#039;SAVE/ndb.QP&#039;&#039; file and repeat the calculation. &amp;lt;br&amp;gt;&lt;br /&gt;
The best strategy to converge electron-phonon coupling calculations is to converge the double-grid for a fixed course grid and the increase the second one. Hereafter an example of Silicon band gap correction convergence versus the number of &#039;&#039;&#039;q&#039;&#039;&#039;-points in the course grid, using a double-grid with 4096 random &#039;&#039;&#039;q&#039;&#039;&#039;-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Gap conv.png|center|Yambo tutorial image | 750px]]&lt;br /&gt;
&lt;br /&gt;
The double-grid implementation is described in this paper&amp;lt;ref&amp;gt;Double-grid for the electron-phonon problem, (to be published) E. Cannuccia, C. Attaccalite and V. Olevano (2022)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon coupling using different &#039;&#039;&#039;q&#039;&#039;&#039; and &#039;&#039;&#039;k&#039;&#039;&#039; grids (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
NOT WORKING!!!!!&lt;br /&gt;
&lt;br /&gt;
The procedure to create electron-phonon matrix elements and import them in Yambo is quite complicated.&lt;br /&gt;
For this reason in Yambo 5.x we decided to simplify this kind of calculations.&lt;br /&gt;
Now you can generate the &#039;&#039;&#039;q&#039;&#039;&#039; grid independently from the &#039;&#039;&#039;k&#039;&#039;&#039; grid. &lt;br /&gt;
You follow the previous steps to generate EPC matrix elements but in the phonon/dvscf input file&lt;br /&gt;
you specify the standard QE q-grid:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12h&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
     electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
               epsil = .true.&lt;br /&gt;
               trans = .true.&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;              ldisp = .true.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;         nq1=6, nq2=6, nq3=2&amp;lt;/span&amp;gt;&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
then when you read the electron-phonon matrix elements you need to add the flag&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 DBsPATH= &amp;quot;../elph_dir/&amp;quot;          # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpExpand &amp;lt;/span&amp;gt;                   # Expand the gkkp in the whole BZ&lt;br /&gt;
&lt;br /&gt;
In this way you can converge &#039;&#039;&#039;q&#039;&#039;&#039; grid independently for the &#039;&#039;&#039;k&#039;&#039;&#039; one. This is important because in general a larger set of q-points&lt;br /&gt;
is required to have converged results compared to the k-one. Add the flag &amp;quot;-V ph&amp;quot;  in the input generation for the electron-phonon self-energy and set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpDB= &amp;quot;gkkp_expanded&amp;quot; &amp;lt;/span&amp;gt;                  # [ELPH] GKKP database (gkkp | gkkp_expanded | genFroh )&lt;br /&gt;
&lt;br /&gt;
Notice that the double-grid works also with k/q different grids.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and post-processing ==&lt;br /&gt;
&#039;&#039;&#039;Automatic generation of electron-phonon matrix elements&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Getting electron-phonon matrix elements from QuantumEspresso to Yambo is a complicated process, &amp;lt;br&amp;gt;&lt;br /&gt;
we advice you to create a script to automatize the procedure, here an example of a bash script for the silicon case: [https://www.yambo-code.org/educational/tutorials/files/SILICON_CONV.tgz SILICON-SCRIPT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are a list of utilities to analyze electron-phonon coupling results:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phonon density of states&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot phonon density of states with the command: &#039;&#039;ypp_ph -p d&#039;&#039;. In order to get a nice plot set in the input&lt;br /&gt;
&lt;br /&gt;
 phonons                          # [R] Phononic properties&lt;br /&gt;
 dos                              # [R] DOS&lt;br /&gt;
 PhBroad= 0.0005000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps=1000                      # Energy steps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
notice that this is an easy quantity to check for the convergence in q-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Ph_dos.png|600px|center| Phonon Density of States]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Eliashberg Functions&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot Eliashberg functions&amp;lt;ref&amp;gt;F. Marsiglio, J.P. Carbotte [https://arxiv.org/abs/cond-mat/0106143 Electron - Phonon Superconductivity]&amp;lt;/ref&amp;gt; for both electrons and excitons. In order to plot Eliashberg functions you must have calculated Quasi-Particle correction with the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt;, see above.&lt;br /&gt;
The command  &#039;&#039;ypp_ph -s e&#039;&#039; generate the input for the electronic Eliashberg functions:&lt;br /&gt;
&lt;br /&gt;
 electrons                        # [R] Electronic properties&lt;br /&gt;
 eliashberg                       # [R] Eliashberg&lt;br /&gt;
 PhBroad= 0.0010000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps= 200                      # Energy steps&lt;br /&gt;
 %QPkrange                        #  generalized Kpoint/Band indices&lt;br /&gt;
  1|1|4|5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
in this example we plot Eliashberg functions for the top valence and bottom conduction band at Gamma point:&lt;br /&gt;
&lt;br /&gt;
[[File:Eliashberg functions.png|600px|center| Eliashberg functions]]&lt;br /&gt;
&lt;br /&gt;
For a discussion on how to interprete Eliashberg functions  and use them to understand the different phonon contribution you can have a look to ref.&amp;lt;ref&amp;gt;E. Cannuccia and A. Gali&lt;br /&gt;
[https://arxiv.org/abs/1907.06089 Phys. Rev. Materials 4, 014601 (2020)] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Atomic displacement amplitudes&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Running &#039;&#039;ypp_ph -p a&#039;&#039; will plot the atomic displacement for each atom in the cell each direction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Other variables in the input files &#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In the input files of the present tutorial there are other variable not used in this tutorial.&lt;br /&gt;
In particular &#039;&#039;GkkpExpand&#039;&#039; is used for other calculations not present in the GPL, while  &#039;&#039;GkkpConvert&#039;&#039; is used to checking purpose the IO for different versions&lt;br /&gt;
of the databases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5730</id>
		<title>Electron Phonon Coupling</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5730"/>
		<updated>2022-04-07T09:59:02Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Electron phonon.png|thumb|200px| Electron-phonon coupling]]&lt;br /&gt;
Here we show step-by-step how to use [https://www.quantum-espresso.org/ Quantum Espresso] to calculate phonons and electron-phonon matrix-elements on a regular q-grid. &lt;br /&gt;
The final aim is to allow Yambo to read them and calculate the temperature-dependent correction to the electronic states.&lt;br /&gt;
This tutorial&amp;lt;ref&amp;gt; This tutorial is based on [http://www.attaccalite.com/elena/news/ Elena Cannuccia blog]&amp;lt;/ref&amp;gt; is quite articulated, take your time to do it patiently.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Sections 1 is presented for this school only as a template of how to generate the electron-phonon matrix elements using QuantumEspresso. As some of the steps there take quite a long time to finish, students can skip this section and move directly to section 2, &amp;quot;Quasi-particle band structure&amp;quot; where they will compute the corrections to the energy levels coming from the electron-phonon interaction. The necessary databases are provided in the link below.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon matrix elements ==&lt;br /&gt;
If you just want to see how Yambo works and leave the database generation for later, or use YamboPy to generate them, &amp;lt;br&amp;gt;&lt;br /&gt;
you can skip this section and download ready-made databases here:   [https://www.yambo-code.org/educational/tutorials/files/Si_elph_dbs.tgz Si_elph_dbs.tgz]&lt;br /&gt;
&lt;br /&gt;
Otherwise, in the cloud you need to load the quantum-espresso module:&lt;br /&gt;
 spack load quantum-espresso&lt;br /&gt;
&lt;br /&gt;
In this first section we will explain how to generate electron-phonon matrix elements in Quantum-Espresso, and how to import them in Yambo.&lt;br /&gt;
Calculations will be divided in different folders:&lt;br /&gt;
 &lt;br /&gt;
* &#039;&#039;&#039;pseudo&#039;&#039;&#039; the pseudo potential folder &lt;br /&gt;
* &#039;&#039;&#039;scf&#039;&#039;&#039; for the self-consistent calculation&lt;br /&gt;
* &#039;&#039;&#039;nscf&#039;&#039;&#039; for the non-self-consistent calculation with a larger number of bands&lt;br /&gt;
* &#039;&#039;&#039;phonon&#039;&#039;&#039; for the phonon calculations&lt;br /&gt;
* &#039;&#039;&#039;dvscf&#039;&#039;&#039; for the calculation of the electron-phonon matrix elements&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how to calculate electron-phonon induced corrections to the bands and optical properties for bulk silicon.&lt;br /&gt;
All input file are availabe in the following tgz file: [https://www.yambo-code.org/educational/tutorials/files/si.epc.tgz si.epc.tgz]&lt;br /&gt;
===SCF===&lt;br /&gt;
In &#039;&#039;&#039;scf&#039;&#039;&#039; we run a standard scf calculation using pw.x choosing a large k-grid in such a way to converge density. Do not forget to set  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;force_symmorphic=.true.&#039;&#039;&amp;lt;/span&amp;gt;, because not symmorphic symmetries are not supported yet in Yambo. Notice that:&lt;br /&gt;
&lt;br /&gt;
a) If you are working with 2D systems, not our case, we have to add the flag  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;assume_isolated=&amp;quot;2D&amp;quot;&#039;&#039;&amp;lt;/span&amp;gt; in such a way correct 2D phonons. &lt;br /&gt;
&lt;br /&gt;
b) If the cell is an &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;FCC&amp;lt;/span&amp;gt;, set manually the cell parameters by using the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;ibrav=0&#039;&#039;&amp;lt;/span&amp;gt; in your scf input file. This allows to generate correctly the uniform q grid over which phonons and electron-phonon databases are calculated, for example for Silicon you can use:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
  ......&lt;br /&gt;
  ibrav=  0,&lt;br /&gt;
  celldm(1) =5.09150&lt;br /&gt;
  .....&lt;br /&gt;
 /&lt;br /&gt;
 .....&lt;br /&gt;
 CELL_PARAMETERS alat&lt;br /&gt;
 0.0  1.0  1.0&lt;br /&gt;
 1.0  0.0  1.0&lt;br /&gt;
 1.0  1.0  0.0&lt;br /&gt;
&lt;br /&gt;
===NSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, and then copy the ${PREFIX}.save folder from &#039;&#039;&#039;scf&#039;&#039;&#039; to &#039;&#039;&#039;nscf&#039;&#039;&#039;, in the present example just do  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
In the nscf input you have to choose the number of k-points and bands you will use for the electron-phonon coupling and Yambo calculations, in our case we will use a 4x4x4 grid and 12 bands.&lt;br /&gt;
&lt;br /&gt;
===Q-points list ===&lt;br /&gt;
1. Read the q-points list. In the &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, enter in the ${PREFIX}.save then run &#039;&#039;p2y&#039;&#039; to read the wave-functions.&lt;br /&gt;
&lt;br /&gt;
2. Generate the setup file with the command &#039;&#039;yambo_ph -i -V all&#039;&#039; and uncomment the flag &#039;&#039;&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;BSEscatt&amp;lt;/span&amp;gt;&#039;&#039; then run the setup.&lt;br /&gt;
&lt;br /&gt;
3. Generate the input file to read the electron-phonon matrix elements with the command &#039;&#039;ypp_ph -k q&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 bzgrids                          # [R] BZ Grid generator&lt;br /&gt;
 Q_grid                           # [R] Q-grid analysis&lt;br /&gt;
 OutputAlat= 0.000000             # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 #NoWeights                     #  Do not print points weight&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                     # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;cooOut= &amp;quot;alat&amp;quot;&amp;lt;/span&amp;gt;                    # Points coordinates (out) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ListPts                      &amp;lt;/span&amp;gt; #  List the internal q/k points also in the parser format&lt;br /&gt;
 #ExpandPts                     #  Expand the internal q/k points in the BZ&lt;br /&gt;
 #ForceUserPts                  #  Do not check the correcteness of the user points&lt;br /&gt;
 %Qpts                            # Q points list&lt;br /&gt;
  0.000000| 0.000000| 0.000000| &lt;br /&gt;
 %&lt;br /&gt;
and uncomment the flag &#039;&#039;&#039;ListPts&#039;&#039;&#039; and q-point coordinates units in &#039;&#039;&#039;alat&#039;&#039;&#039;, the units used by QuantumEspresso. For particular cells, like the FCC, there could be an inconsistency between Yambo and QE definition of alat, in this case you can specify &#039;&#039;&#039;OutputAlat&#039;&#039;&#039; equal to the &#039;&#039;&#039;celldm(1)&#039;&#039;&#039; of QE. Then if you run ypp_ph it will generate the list of q-points for the phonon calculations:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 &amp;lt;---&amp;gt; Q-points (IBZ) PW-formatted&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.125000000  0.125000000 -0.125000000 1&lt;br /&gt;
      -0.250000000 -0.250000000  0.250000000 1&lt;br /&gt;
       0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.375000000  0.125000000 -0.125000000 1&lt;br /&gt;
       0.000000000 -0.250000000  0.250000000 1&lt;br /&gt;
      -0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.500000000  0.250000000  0.000000000 1&lt;br /&gt;
 &amp;lt;---&amp;gt; [08] Timing Overview&lt;br /&gt;
 ......&lt;br /&gt;
&lt;br /&gt;
===Phonons===&lt;br /&gt;
Plug into &#039;&#039;&#039;phonon&#039;&#039;&#039; directory.  You have to copy the self-consistent calculation in this folder&lt;br /&gt;
with the command &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./ &#039;&#039;&amp;lt;/span&amp;gt;. Then you can prepare an input file for phonons using the q-points list you generated in the previous step multiplied by -1, &lt;br /&gt;
the final input will be:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
            verbosity = &#039;high&#039;&lt;br /&gt;
               tr2_ph = 1e-12&lt;br /&gt;
               prefix = &#039;si&#039;&lt;br /&gt;
             fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
               fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
      electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
                epsil = .false.&lt;br /&gt;
                trans = .true.&lt;br /&gt;
                ldisp = .false.&lt;br /&gt;
                qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
===DVSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;dvscf&#039;&#039;&#039; folder. From the nscf folder copy density and wave-functions (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../nscf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;), from the phonon folder copy the dynamical matrices and the dvscf files (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../phonon/_ph0 ../phonon/*.dyn* ./&#039;&#039;&amp;lt;/span&amp;gt;).  Then  modify the phonon input to generate electron-phonon matrix elements for Yambo, by changing &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;epsil = .false.&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;trans = .false.&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;electron_phonon = yambo&amp;lt;/span&amp;gt;. You do not need to specify the k-point grid because it is read from the nscf wave-functions. In this way we will not recalculate phonons, but only the electron-phonon matrix elements for the number of bands present in the nscf input file, in our case 8 bands:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;&lt;br /&gt;
     electron_phonon = &#039;yambo&#039;,&lt;br /&gt;
               epsil = .false.&lt;br /&gt;
               trans = .false.&lt;br /&gt;
               ldisp = .false.&lt;br /&gt;
               qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
this run will generate a new folder &#039;&#039;elph_dir&#039;&#039; with all electron-phonon matrix elements in a format compatible with Yambo.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;IMPORTANT&amp;lt;/span&amp;gt;: do not parallelize on k-points in the &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculation, it is not supported yet!!&lt;br /&gt;
&lt;br /&gt;
===Import in Yambo===&lt;br /&gt;
Now you have to read the electron-phonon matrix elements. Go in the &#039;&#039;dvscf/si.save&#039;&#039; folder, and use ypp_ph to import electron-phonon coupling, by doing &#039;&#039;ypp_ph -g g&#039;&#039; and the PW el-ph folder:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;DBsPATH= &amp;quot;../elph_dir/&amp;quot; &amp;lt;/span&amp;gt;                    # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 #GkkpExpand                    # Expand the gkkp in the whole BZ&lt;br /&gt;
 #UseQindxB                     # Use qindx_B to expand gkkp (for testing purposes)&lt;br /&gt;
&lt;br /&gt;
run ypp_ph, and if everything went well you will get in output&lt;br /&gt;
&lt;br /&gt;
 ..... &lt;br /&gt;
 &amp;lt;---&amp;gt; [06] == Electron-Phonon Databases ==&lt;br /&gt;
 &amp;lt;---&amp;gt; Inspecting databases ...PWscf (dressed)...found 8 Q-points&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: phonon frequencies and eigenvectors |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: K+Q-grid check |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [07] == Q-points list in the DBS (iku units) ==&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Code generator        :PWscf&lt;br /&gt;
 &amp;lt;---&amp;gt; :: DB Kind               :dressed&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Expanded              :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(read)        :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(written)     :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: K-points              : 20&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Bands                 : 12&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Branches              :  6&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Uniform sampling      :yes&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Symmetry expanded     :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Debye Energy          : 63.09927 [meV]&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Notice that Yambo recognized that you are using a regular q-grid: &#039;&#039;Uniform sampling      :yes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Quasi-particle band structure ==&lt;br /&gt;
The first quantity we will calculate is the correction to the band structure induced by the electron-phonon coupling. In order to generate the corresponding input do &amp;lt;code&amp;gt;yambo_ph -g n -p fan -c ep -V gen&amp;lt;/code&amp;gt;. In the input we require the correction only at gamma point:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  1 | 12 |                           # [ELPH] G[W] bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
If you run &amp;lt;code&amp;gt;yambo_ph -J T0&amp;lt;/code&amp;gt; you will get correction at zero kelvin to the band structure. &lt;br /&gt;
You can change the temperature to 300 K by doing:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BoseTemp= 300.0            Kn &amp;lt;/span&amp;gt;   # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 12 |                           # [ELPH] G[W] bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
run again &amp;lt;code&amp;gt;yambo_ph -J T300&amp;lt;/code&amp;gt; and compare the two output files o-T0.qp and o-T300.qp, to find how much the gap change with the temperature.&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that in this calculation we set a small damping factor for the Green function of about 0.01 eV, this value should be of the order of the phonon life-time.&amp;lt;br&amp;gt;&lt;br /&gt;
If you repeat the calculation for different temperature you can obtain the trend of the gap vs temperature. The figure below report the Silicon gap at Gamma Point at different temperature obtained in this tutorial. You can recreate the file with the data needed for this plot with the following command instruction:&lt;br /&gt;
&lt;br /&gt;
 for i in 0 50 100 150 200 250 300; do echo -n &amp;quot;$i  &amp;quot;; echo &amp;quot;$(grep &amp;quot;^ *1 *5&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;) - $(grep &amp;quot;^ *1 *4&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;)&amp;quot; | bc; done &amp;gt; gap_vs_T.dat&lt;br /&gt;
&lt;br /&gt;
[[File:Si_gap_finite_t.png|600px|center]]&lt;br /&gt;
If you uncomment the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt; the code saves information about the Eliashberg functions that can be plotted using the &#039;&#039;ypp_ph&#039;&#039;, see below.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally if you add &#039;&#039;-V qp&#039;&#039; in the input generation a new flag appears &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;OnMassShell&amp;lt;/span&amp;gt;, if you un-comment this flag calculation will be performed in the &amp;quot;on mass shell&amp;quot; approximation, namely the static limit the Quasi-Particle approximation, for a discussion see reference &amp;lt;ref&amp;gt;H. Kawai et al. [https://arxiv.org/abs/1310.2038 Phys. Rev. B &#039;&#039;&#039;89&#039;&#039;&#039;, 085202 (2014)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the last column in the quasi-particle file &amp;quot;o.QP&amp;quot; contains the &#039;&#039;&#039;quasi-particle width&#039;&#039;&#039;, that is related to their life-time. You can plot the band structure including this width to get quasi-particle spectra&lt;br /&gt;
similar to the one measured in ARPES experiments, see Fig. 2 in ref. &amp;lt;ref&amp;gt; G. Antonius, S. Poncé, E. Lantagne-Hurtubise, G. Auclair, X. Gonze, and M. Côté&lt;br /&gt;
 [https://arxiv.org/abs/1505.07738 Phys. Rev. B 92, 085137 (2015)] &amp;lt;/ref&amp;gt;.&lt;br /&gt;
This parameter will be used in the next tutorial on [https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature optical properties at finite temperature].&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; Yambo average the electron-phonon correction on the degenerate states, please &amp;lt;b&amp;gt;include all degenerate states in your calculations&amp;lt;/b&amp;gt;. For example in the silicon case you need correction from the 2nd band to the 8th band.&lt;br /&gt;
&lt;br /&gt;
== Convergence ==&lt;br /&gt;
&lt;br /&gt;
The results of this tutorial are not converged. This is due to the poor parameters used in this tutorial to make the calculations fast. In order to have converged results, first of all you have to be sure to have converged phonons, in order to do that increase  plane-wave cutoff,  number of k-points and if necessary reduce &#039;&#039;tr2_ph&#039;&#039;.&lt;br /&gt;
Then change the parameters for the Yambo calculations, increasing the number of &#039;&#039;&#039;k&#039;&#039;&#039; and &#039;&#039;&#039;q&#039;&#039;&#039; points and the number of bands. If you want to increase only the number of bands, just repeat the &#039;&#039;&#039;nscf&#039;&#039;&#039; and &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculations without recalculate  &#039;&#039;&#039;phonons&#039;&#039;&#039;. In the following section we will describe a smart way to accelerate convergence.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene: &amp;lt;/span&amp;gt; At present Yambo neither implements the Fröhlich term at q=0&amp;lt;ref&amp;gt;Carla Verdi and Feliciano Giustino&lt;br /&gt;
[https://arxiv.org/abs/1510.06373 Phys. Rev. Lett. &#039;&#039;&#039;115&#039;&#039;&#039;, 176401 (2015)] &amp;lt;/ref&amp;gt; nor the quadrupolar correction,&amp;lt;ref&amp;gt;G. Brunin et al.  [https://arxiv.org/abs/2002.00628  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 136601 (2020)]&amp;lt;/ref&amp;gt; therefore convergence in polar material can be very slow with the number of q-points.&lt;br /&gt;
&lt;br /&gt;
== Double-grid method for the electron-phonon coupling (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simplifying at most the matrix elements of the electron-phonon self-energy have the structure:&lt;br /&gt;
&lt;br /&gt;
[[File:Self elph.png|center|Yambo tutorial image | 270px ]]&lt;br /&gt;
&lt;br /&gt;
where we omitted the electronic band and the phonon branches indexes. In order to speed up calculation one can average the denominators on an additional fine grid around each &#039;&#039;&#039;q&#039;&#039;&#039; points as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula dbgrid.png|center|Yambo tutorial image| 500px]]&lt;br /&gt;
&lt;br /&gt;
In order to exploit the double-grid tool we need the phonon energies calculated on a fine grid. If you just want to test the functionality of Yambo you can download here some files with the phononic frequencies already calculated on different silicon grids: [https://www.yambo-code.org/educational/tutorials/files/si_freqs_files.tgz si_freqs_files.tgz] &amp;lt;br&amp;gt;&lt;br /&gt;
Otherwise you generate them by following the instructions below.&lt;br /&gt;
For a general tutorial on phonon calculation with Quantum Espresso you can have a look at [https://www.quantum-espresso.org/wp-content/uploads/phonons_tutorial_shanghai1.pdf Hands on phonons].&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from a well converged phonon calculation &#039;&#039;matdyn.x&#039;&#039; can interpolate phonon dispersion on a given q-sampling (for example a regular 14x14x14 grid, as shown in the input file below) and give the desired phonon energies. &lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;si.fc&#039;,&lt;br /&gt;
     flfrq=&#039;si.freq&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;si.dos&#039;,&lt;br /&gt;
     deltaE=1.d0,&lt;br /&gt;
     nk1=14, nk2=14, nk3=14&lt;br /&gt;
 /&lt;br /&gt;
Alternatively you can generate a random q-sampling using Yambo (&#039;&#039;ypp -k r&#039;&#039;) and insert the corresponding q points list into a matdyn file. &lt;br /&gt;
&lt;br /&gt;
Once you generated the phonon energies you can read them with the command &#039;&#039;ypp_ph -g d&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_dg                          # [R] GKKP double grid&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PHfreqF= &amp;quot;si.freq&amp;quot;&amp;lt;/span&amp;gt;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 FineGd_mode= &amp;quot;mixed&amp;quot;             # Fine Grid mode. Symmetry expanded, unexpanded or mixed.&lt;br /&gt;
 #SkipBorderPts                 # Skip points in the Fine Grid that are on the surface of coarse gride smal BZ`s&lt;br /&gt;
 EkplusQmode= &amp;quot;interp&amp;quot;            # E(k+q) energies calculation mode (interp | dftp )&lt;br /&gt;
 #TestPHDGrid                   # Test double-grid: set all values of the fine grid equal to the couse ones&lt;br /&gt;
&lt;br /&gt;
then run &#039;&#039;ypp_ph&#039;&#039; an it will generate a new file &#039;&#039;SAVE/ndb.PH_Double_Grid&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
In the calculation the new phonon energies will be expanded &lt;br /&gt;
using the symmetries of the systems, while the electronic energies at &#039;&#039;&#039;k+q&#039;&#039;&#039; will be interpolated using a smooth Fourier interpolation&amp;lt;ref&amp;gt;Warren E. Pickett, Henry Krakauer, and Philip B. Allen, &lt;br /&gt;
Phys. Rev. B &#039;&#039;&#039;38&#039;&#039;&#039;, 2721(1988)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
In order to perform calculation with the double grid remove the &#039;&#039;SAVE/ndb.QP&#039;&#039; file and repeat the calculation. &amp;lt;br&amp;gt;&lt;br /&gt;
The best strategy to converge electron-phonon coupling calculations is to converge the double-grid for a fixed course grid and the increase the second one. Hereafter an example of Silicon band gap correction convergence versus the number of &#039;&#039;&#039;q&#039;&#039;&#039;-points in the course grid, using a double-grid with 4096 random &#039;&#039;&#039;q&#039;&#039;&#039;-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Gap conv.png|center|Yambo tutorial image | 750px]]&lt;br /&gt;
&lt;br /&gt;
The double-grid implementation is described in this paper&amp;lt;ref&amp;gt;Double-grid for the electron-phonon problem, (to be published) E. Cannuccia, C. Attaccalite and V. Olevano (2022)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon coupling using different &#039;&#039;&#039;q&#039;&#039;&#039; and &#039;&#039;&#039;k&#039;&#039;&#039; grids (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
NOT WORKING!!!!!&lt;br /&gt;
&lt;br /&gt;
The procedure to create electron-phonon matrix elements and import them in Yambo is quite complicated.&lt;br /&gt;
For this reason in Yambo 5.x we decided to simplify this kind of calculations.&lt;br /&gt;
Now you can generate the &#039;&#039;&#039;q&#039;&#039;&#039; grid independently from the &#039;&#039;&#039;k&#039;&#039;&#039; grid. &lt;br /&gt;
You follow the previous steps to generate EPC matrix elements but in the phonon/dvscf input file&lt;br /&gt;
you specify the standard QE q-grid:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12h&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
     electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
               epsil = .true.&lt;br /&gt;
               trans = .true.&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;              ldisp = .true.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;         nq1=6, nq2=6, nq3=2&amp;lt;/span&amp;gt;&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
then when you read the electron-phonon matrix elements you need to add the flag&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 DBsPATH= &amp;quot;../elph_dir/&amp;quot;          # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpExpand &amp;lt;/span&amp;gt;                   # Expand the gkkp in the whole BZ&lt;br /&gt;
&lt;br /&gt;
In this way you can converge &#039;&#039;&#039;q&#039;&#039;&#039; grid independently for the &#039;&#039;&#039;k&#039;&#039;&#039; one. This is important because in general a larger set of q-points&lt;br /&gt;
is required to have converged results compared to the k-one. Add the flag &amp;quot;-V ph&amp;quot;  in the input generation for the electron-phonon self-energy and set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpDB= &amp;quot;gkkp_expanded&amp;quot; &amp;lt;/span&amp;gt;                  # [ELPH] GKKP database (gkkp | gkkp_expanded | genFroh )&lt;br /&gt;
&lt;br /&gt;
Notice that the double-grid works also with k/q different grids.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and post-processing ==&lt;br /&gt;
&#039;&#039;&#039;Automatic generation of electron-phonon matrix elements&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Getting electron-phonon matrix elements from QuantumEspresso to Yambo is a complicated process, &amp;lt;br&amp;gt;&lt;br /&gt;
we advice you to create a script to automatize the procedure, here an example of a bash script for the silicon case: [https://www.yambo-code.org/educational/tutorials/files/SILICON_CONV.tgz SILICON-SCRIPT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are a list of utilities to analyze electron-phonon coupling results:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phonon density of states&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot phonon density of states with the command: &#039;&#039;ypp_ph -p d&#039;&#039;. In order to get a nice plot set in the input&lt;br /&gt;
&lt;br /&gt;
 phonons                          # [R] Phononic properties&lt;br /&gt;
 dos                              # [R] DOS&lt;br /&gt;
 PhBroad= 0.0005000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps=1000                      # Energy steps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
notice that this is an easy quantity to check for the convergence in q-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Ph_dos.png|600px|center| Phonon Density of States]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Eliashberg Functions&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot Eliashberg functions&amp;lt;ref&amp;gt;F. Marsiglio, J.P. Carbotte [https://arxiv.org/abs/cond-mat/0106143 Electron - Phonon Superconductivity]&amp;lt;/ref&amp;gt; for both electrons and excitons. In order to plot Eliashberg functions you must have calculated Quasi-Particle correction with the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt;, see above.&lt;br /&gt;
The command  &#039;&#039;ypp_ph -s e&#039;&#039; generate the input for the electronic Eliashberg functions:&lt;br /&gt;
&lt;br /&gt;
 electrons                        # [R] Electronic properties&lt;br /&gt;
 eliashberg                       # [R] Eliashberg&lt;br /&gt;
 PhBroad= 0.0010000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps= 200                      # Energy steps&lt;br /&gt;
 %QPkrange                        #  generalized Kpoint/Band indices&lt;br /&gt;
  1|1|4|5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
in this example we plot Eliashberg functions for the top valence and bottom conduction band at Gamma point:&lt;br /&gt;
&lt;br /&gt;
[[File:Eliashberg functions.png|600px|center| Eliashberg functions]]&lt;br /&gt;
&lt;br /&gt;
For a discussion on how to interprete Eliashberg functions  and use them to understand the different phonon contribution you can have a look to ref.&amp;lt;ref&amp;gt;E. Cannuccia and A. Gali&lt;br /&gt;
[https://arxiv.org/abs/1907.06089 Phys. Rev. Materials 4, 014601 (2020)] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Atomic displacement amplitudes&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Running &#039;&#039;ypp_ph -p a&#039;&#039; will plot the atomic displacement for each atom in the cell each direction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Other variables in the input files &#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In the input files of the present tutorial there are other variable not used in this tutorial.&lt;br /&gt;
In particular &#039;&#039;GkkpExpand&#039;&#039; is used for other calculations not present in the GPL, while  &#039;&#039;GkkpConvert&#039;&#039; is used to checking purpose the IO for different versions&lt;br /&gt;
of the databases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5728</id>
		<title>Electron Phonon Coupling</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5728"/>
		<updated>2022-04-07T09:57:38Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Electron phonon.png|thumb|200px| Electron-phonon coupling]]&lt;br /&gt;
Here we show step-by-step how to use [https://www.quantum-espresso.org/ Quantum Espresso] to calculate phonons and electron-phonon matrix-elements on a regular q-grid. &lt;br /&gt;
The final aim is to allow Yambo to read them and calculate the temperature-dependent correction to the electronic states.&lt;br /&gt;
This tutorial&amp;lt;ref&amp;gt; This tutorial is based on [http://www.attaccalite.com/elena/news/ Elena Cannuccia blog]&amp;lt;/ref&amp;gt; is quite articulated, take your time to do it patiently.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Sections 1 is presented for this school only as a template of how to generate the electron-phonon matrix elements using QuantumEspresso. As some of the steps there take quite a long time to finish, students can skip this section and move directly to section 2, &amp;quot;Quasi-particle band structure&amp;quot; where they will compute the corrections to the energy levels coming from the electron-phonon interaction. The necessary databases are provided in the link below.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon matrix elements ==&lt;br /&gt;
If you just want to see how Yambo works and leave the database generation for later, or use YamboPy to generate them, &amp;lt;br&amp;gt;&lt;br /&gt;
you can skip this section and download ready-made databases here:   [https://www.yambo-code.org/educational/tutorials/files/Si_elph_dbs.tgz Si_elph_dbs.tgz]&lt;br /&gt;
&lt;br /&gt;
Otherwise, in the cloud you need to load the quantum-espresso module:&lt;br /&gt;
 spack load quantum-espresso&lt;br /&gt;
&lt;br /&gt;
In this first section we will explain how to generate electron-phonon matrix elements in Quantum-Espresso, and how to import them in Yambo.&lt;br /&gt;
Calculations will be divided in different folders:&lt;br /&gt;
 &lt;br /&gt;
* &#039;&#039;&#039;pseudo&#039;&#039;&#039; the pseudo potential folder &lt;br /&gt;
* &#039;&#039;&#039;scf&#039;&#039;&#039; for the self-consistent calculation&lt;br /&gt;
* &#039;&#039;&#039;nscf&#039;&#039;&#039; for the non-self-consistent calculation with a larger number of bands&lt;br /&gt;
* &#039;&#039;&#039;phonon&#039;&#039;&#039; for the phonon calculations&lt;br /&gt;
* &#039;&#039;&#039;dvscf&#039;&#039;&#039; for the calculation of the electron-phonon matrix elements&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how to calculate electron-phonon induced corrections to the bands and optical properties for bulk silicon.&lt;br /&gt;
All input file are availabe in the following tgz file: [https://www.yambo-code.org/educational/tutorials/files/si.epc.tgz si.epc.tgz]&lt;br /&gt;
===SCF===&lt;br /&gt;
In &#039;&#039;&#039;scf&#039;&#039;&#039; we run a standard scf calculation using pw.x choosing a large k-grid in such a way to converge density. Do not forget to set  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;force_symmorphic=.true.&#039;&#039;&amp;lt;/span&amp;gt;, because not symmorphic symmetries are not supported yet in Yambo. Notice that:&lt;br /&gt;
&lt;br /&gt;
a) If you are working with 2D systems, not our case, we have to add the flag  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;assume_isolated=&amp;quot;2D&amp;quot;&#039;&#039;&amp;lt;/span&amp;gt; in such a way correct 2D phonons. &lt;br /&gt;
&lt;br /&gt;
b) If the cell is an &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;FCC&amp;lt;/span&amp;gt;, set manually the cell parameters by using the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;ibrav=0&#039;&#039;&amp;lt;/span&amp;gt; in your scf input file. This allows to generate correctly the uniform q grid over which phonons and electron-phonon databases are calculated, for example for Silicon you can use:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
  ......&lt;br /&gt;
  ibrav=  0,&lt;br /&gt;
  celldm(1) =5.09150&lt;br /&gt;
  .....&lt;br /&gt;
 /&lt;br /&gt;
 .....&lt;br /&gt;
 CELL_PARAMETERS alat&lt;br /&gt;
 0.0  1.0  1.0&lt;br /&gt;
 1.0  0.0  1.0&lt;br /&gt;
 1.0  1.0  0.0&lt;br /&gt;
&lt;br /&gt;
===NSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, and then copy the ${PREFIX}.save folder from &#039;&#039;&#039;scf&#039;&#039;&#039; to &#039;&#039;&#039;nscf&#039;&#039;&#039;, in the present example just do  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
In the nscf input you have to choose the number of k-points and bands you will use for the electron-phonon coupling and Yambo calculations, in our case we will use a 4x4x4 grid and 12 bands.&lt;br /&gt;
&lt;br /&gt;
===Q-points list ===&lt;br /&gt;
1. Read the q-points list. In the &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, enter in the ${PREFIX}.save then run &#039;&#039;p2y&#039;&#039; to read the wave-functions.&lt;br /&gt;
&lt;br /&gt;
2. Generate the setup file with the command &#039;&#039;yambo_ph -i -V all&#039;&#039; and uncomment the flag &#039;&#039;&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;BSEscatt&amp;lt;/span&amp;gt;&#039;&#039; then run the setup.&lt;br /&gt;
&lt;br /&gt;
3. Generate the input file to read the electron-phonon matrix elements with the command &#039;&#039;ypp_ph -k q&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 bzgrids                          # [R] BZ Grid generator&lt;br /&gt;
 Q_grid                           # [R] Q-grid analysis&lt;br /&gt;
 OutputAlat= 0.000000             # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 #NoWeights                     #  Do not print points weight&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                     # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;cooOut= &amp;quot;alat&amp;quot;&amp;lt;/span&amp;gt;                    # Points coordinates (out) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ListPts                      &amp;lt;/span&amp;gt; #  List the internal q/k points also in the parser format&lt;br /&gt;
 #ExpandPts                     #  Expand the internal q/k points in the BZ&lt;br /&gt;
 #ForceUserPts                  #  Do not check the correcteness of the user points&lt;br /&gt;
 %Qpts                            # Q points list&lt;br /&gt;
  0.000000| 0.000000| 0.000000| &lt;br /&gt;
 %&lt;br /&gt;
and uncomment the flag &#039;&#039;&#039;ListPts&#039;&#039;&#039; and q-point coordinates units in &#039;&#039;&#039;alat&#039;&#039;&#039;, the units used by QuantumEspresso. For particular cells, like the FCC, there could be an inconsistency between Yambo and QE definition of alat, in this case you can specify &#039;&#039;&#039;OutputAlat&#039;&#039;&#039; equal to the &#039;&#039;&#039;celldm(1)&#039;&#039;&#039; of QE. Then if you run ypp_ph it will generate the list of q-points for the phonon calculations:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 &amp;lt;---&amp;gt; Q-points (IBZ) PW-formatted&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.125000000  0.125000000 -0.125000000 1&lt;br /&gt;
      -0.250000000 -0.250000000  0.250000000 1&lt;br /&gt;
       0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.375000000  0.125000000 -0.125000000 1&lt;br /&gt;
       0.000000000 -0.250000000  0.250000000 1&lt;br /&gt;
      -0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.500000000  0.250000000  0.000000000 1&lt;br /&gt;
 &amp;lt;---&amp;gt; [08] Timing Overview&lt;br /&gt;
 ......&lt;br /&gt;
&lt;br /&gt;
===Phonons===&lt;br /&gt;
Plug into &#039;&#039;&#039;phonon&#039;&#039;&#039; directory.  You have to copy the self-consistent calculation in this folder&lt;br /&gt;
with the command &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./ &#039;&#039;&amp;lt;/span&amp;gt;. Then you can prepare an input file for phonons using the q-points list you generated in the previous step multiplied by -1, &lt;br /&gt;
the final input will be:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
            verbosity = &#039;high&#039;&lt;br /&gt;
               tr2_ph = 1e-12&lt;br /&gt;
               prefix = &#039;si&#039;&lt;br /&gt;
             fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
               fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
      electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
                epsil = .false.&lt;br /&gt;
                trans = .true.&lt;br /&gt;
                ldisp = .false.&lt;br /&gt;
                qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
===DVSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;dvscf&#039;&#039;&#039; folder. From the nscf folder copy density and wave-functions (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../nscf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;), from the phonon folder copy the dynamical matrices and the dvscf files (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../phonon/_ph0 ../phonon/*.dyn* ./&#039;&#039;&amp;lt;/span&amp;gt;).  Then  modify the phonon input to generate electron-phonon matrix elements for Yambo, by changing &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;epsil = .false.&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;trans = .false.&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;electron_phonon = yambo&amp;lt;/span&amp;gt;. You do not need to specify the k-point grid because it is read from the nscf wave-functions. In this way we will not recalculate phonons, but only the electron-phonon matrix elements for the number of bands present in the nscf input file, in our case 8 bands:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;&lt;br /&gt;
     electron_phonon = &#039;yambo&#039;,&lt;br /&gt;
               epsil = .false.&lt;br /&gt;
               trans = .false.&lt;br /&gt;
               ldisp = .false.&lt;br /&gt;
               qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
this run will generate a new folder &#039;&#039;elph_dir&#039;&#039; with all electron-phonon matrix elements in a format compatible with Yambo.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;IMPORTANT&amp;lt;/span&amp;gt;: do not parallelize on k-points in the &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculation, it is not supported yet!!&lt;br /&gt;
&lt;br /&gt;
===Import in Yambo===&lt;br /&gt;
Now you have to read the electron-phonon matrix elements. Go in the &#039;&#039;dvscf/si.save&#039;&#039; folder, and use ypp_ph to import electron-phonon coupling, by doing &#039;&#039;ypp_ph -g g&#039;&#039; and the PW el-ph folder:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;DBsPATH= &amp;quot;../elph_dir/&amp;quot; &amp;lt;/span&amp;gt;                    # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 #GkkpExpand                    # Expand the gkkp in the whole BZ&lt;br /&gt;
 #UseQindxB                     # Use qindx_B to expand gkkp (for testing purposes)&lt;br /&gt;
&lt;br /&gt;
run ypp_ph, and if everything went well you will get in output&lt;br /&gt;
&lt;br /&gt;
 ..... &lt;br /&gt;
 &amp;lt;---&amp;gt; [06] == Electron-Phonon Databases ==&lt;br /&gt;
 &amp;lt;---&amp;gt; Inspecting databases ...PWscf (dressed)...found 8 Q-points&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: phonon frequencies and eigenvectors |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: K+Q-grid check |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [07] == Q-points list in the DBS (iku units) ==&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Code generator        :PWscf&lt;br /&gt;
 &amp;lt;---&amp;gt; :: DB Kind               :dressed&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Expanded              :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(read)        :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(written)     :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: K-points              : 20&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Bands                 : 12&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Branches              :  6&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Uniform sampling      :yes&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Symmetry expanded     :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Debye Energy          : 63.09927 [meV]&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Notice that Yambo recognized that you are using a regular q-grid: &#039;&#039;Uniform sampling      :yes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Quasi-particle band structure ==&lt;br /&gt;
The first quantity we will calculate is the correction to the band structure induced by the electron-phonon coupling. In order to generate the corresponding input do &amp;lt;code&amp;gt;yambo_ph -g n -p fan -c ep -V gen&amp;lt;/code&amp;gt;. In the input we require the correction only at gamma point:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  1 | 12 |                           # [ELPH] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
If you run &amp;lt;code&amp;gt;yambo_ph -J T0&amp;lt;/code&amp;gt; you will get correction at zero kelvin to the band structure. &lt;br /&gt;
You can change the temperature to 300 K by doing:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BoseTemp= 300.0            Kn &amp;lt;/span&amp;gt;   # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  1 | 12 |                           # [ELPH] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
run again &amp;lt;code&amp;gt;yambo_ph -J T300&amp;lt;/code&amp;gt; and compare the two output files o-T0.qp and o-T300.qp, to find how much the gap change with the temperature.&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that in this calculation we set a small damping factor for the Green function of about 0.01 eV, this value should be of the order of the phonon life-time.&amp;lt;br&amp;gt;&lt;br /&gt;
If you repeat the calculation for different temperature you can obtain the trend of the gap vs temperature. The figure below report the Silicon gap at Gamma Point at different temperature obtained in this tutorial. You can recreate the file with the data needed for this plot with the following command instruction:&lt;br /&gt;
&lt;br /&gt;
 for i in 0 50 100 150 200 250 300; do echo -n &amp;quot;$i  &amp;quot;; echo &amp;quot;$(grep &amp;quot;^ *1 *5&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;) - $(grep &amp;quot;^ *1 *4&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;)&amp;quot; | bc; done &amp;gt; gap_vs_T.dat&lt;br /&gt;
&lt;br /&gt;
[[File:Si_gap_finite_t.png|600px|center]]&lt;br /&gt;
If you uncomment the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt; the code saves information about the Eliashberg functions that can be plotted using the &#039;&#039;ypp_ph&#039;&#039;, see below.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally if you add &#039;&#039;-V qp&#039;&#039; in the input generation a new flag appears &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;OnMassShell&amp;lt;/span&amp;gt;, if you un-comment this flag calculation will be performed in the &amp;quot;on mass shell&amp;quot; approximation, namely the static limit the Quasi-Particle approximation, for a discussion see reference &amp;lt;ref&amp;gt;H. Kawai et al. [https://arxiv.org/abs/1310.2038 Phys. Rev. B &#039;&#039;&#039;89&#039;&#039;&#039;, 085202 (2014)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the last column in the quasi-particle file &amp;quot;o.QP&amp;quot; contains the &#039;&#039;&#039;quasi-particle width&#039;&#039;&#039;, that is related to their life-time. You can plot the band structure including this width to get quasi-particle spectra&lt;br /&gt;
similar to the one measured in ARPES experiments, see Fig. 2 in ref. &amp;lt;ref&amp;gt; G. Antonius, S. Poncé, E. Lantagne-Hurtubise, G. Auclair, X. Gonze, and M. Côté&lt;br /&gt;
 [https://arxiv.org/abs/1505.07738 Phys. Rev. B 92, 085137 (2015)] &amp;lt;/ref&amp;gt;.&lt;br /&gt;
This parameter will be used in the next tutorial on [https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature optical properties at finite temperature].&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; Yambo average the electron-phonon correction on the degenerate states, please &amp;lt;b&amp;gt;include all degenerate states in your calculations&amp;lt;/b&amp;gt;. For example in the silicon case you need correction from the 2nd band to the 8th band.&lt;br /&gt;
&lt;br /&gt;
== Convergence ==&lt;br /&gt;
&lt;br /&gt;
The results of this tutorial are not converged. This is due to the poor parameters used in this tutorial to make the calculations fast. In order to have converged results, first of all you have to be sure to have converged phonons, in order to do that increase  plane-wave cutoff,  number of k-points and if necessary reduce &#039;&#039;tr2_ph&#039;&#039;.&lt;br /&gt;
Then change the parameters for the Yambo calculations, increasing the number of &#039;&#039;&#039;k&#039;&#039;&#039; and &#039;&#039;&#039;q&#039;&#039;&#039; points and the number of bands. If you want to increase only the number of bands, just repeat the &#039;&#039;&#039;nscf&#039;&#039;&#039; and &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculations without recalculate  &#039;&#039;&#039;phonons&#039;&#039;&#039;. In the following section we will describe a smart way to accelerate convergence.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene: &amp;lt;/span&amp;gt; At present Yambo neither implements the Fröhlich term at q=0&amp;lt;ref&amp;gt;Carla Verdi and Feliciano Giustino&lt;br /&gt;
[https://arxiv.org/abs/1510.06373 Phys. Rev. Lett. &#039;&#039;&#039;115&#039;&#039;&#039;, 176401 (2015)] &amp;lt;/ref&amp;gt; nor the quadrupolar correction,&amp;lt;ref&amp;gt;G. Brunin et al.  [https://arxiv.org/abs/2002.00628  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 136601 (2020)]&amp;lt;/ref&amp;gt; therefore convergence in polar material can be very slow with the number of q-points.&lt;br /&gt;
&lt;br /&gt;
== Double-grid method for the electron-phonon coupling (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simplifying at most the matrix elements of the electron-phonon self-energy have the structure:&lt;br /&gt;
&lt;br /&gt;
[[File:Self elph.png|center|Yambo tutorial image | 270px ]]&lt;br /&gt;
&lt;br /&gt;
where we omitted the electronic band and the phonon branches indexes. In order to speed up calculation one can average the denominators on an additional fine grid around each &#039;&#039;&#039;q&#039;&#039;&#039; points as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula dbgrid.png|center|Yambo tutorial image| 500px]]&lt;br /&gt;
&lt;br /&gt;
In order to exploit the double-grid tool we need the phonon energies calculated on a fine grid. If you just want to test the functionality of Yambo you can download here some files with the phononic frequencies already calculated on different silicon grids: [https://www.yambo-code.org/educational/tutorials/files/si_freqs_files.tgz si_freqs_files.tgz] &amp;lt;br&amp;gt;&lt;br /&gt;
Otherwise you generate them by following the instructions below.&lt;br /&gt;
For a general tutorial on phonon calculation with Quantum Espresso you can have a look at [https://www.quantum-espresso.org/wp-content/uploads/phonons_tutorial_shanghai1.pdf Hands on phonons].&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from a well converged phonon calculation &#039;&#039;matdyn.x&#039;&#039; can interpolate phonon dispersion on a given q-sampling (for example a regular 14x14x14 grid, as shown in the input file below) and give the desired phonon energies. &lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;si.fc&#039;,&lt;br /&gt;
     flfrq=&#039;si.freq&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;si.dos&#039;,&lt;br /&gt;
     deltaE=1.d0,&lt;br /&gt;
     nk1=14, nk2=14, nk3=14&lt;br /&gt;
 /&lt;br /&gt;
Alternatively you can generate a random q-sampling using Yambo (&#039;&#039;ypp -k r&#039;&#039;) and insert the corresponding q points list into a matdyn file. &lt;br /&gt;
&lt;br /&gt;
Once you generated the phonon energies you can read them with the command &#039;&#039;ypp_ph -g d&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_dg                          # [R] GKKP double grid&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PHfreqF= &amp;quot;si.freq&amp;quot;&amp;lt;/span&amp;gt;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 FineGd_mode= &amp;quot;mixed&amp;quot;             # Fine Grid mode. Symmetry expanded, unexpanded or mixed.&lt;br /&gt;
 #SkipBorderPts                 # Skip points in the Fine Grid that are on the surface of coarse gride smal BZ`s&lt;br /&gt;
 EkplusQmode= &amp;quot;interp&amp;quot;            # E(k+q) energies calculation mode (interp | dftp )&lt;br /&gt;
 #TestPHDGrid                   # Test double-grid: set all values of the fine grid equal to the couse ones&lt;br /&gt;
&lt;br /&gt;
then run &#039;&#039;ypp_ph&#039;&#039; an it will generate a new file &#039;&#039;SAVE/ndb.PH_Double_Grid&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
In the calculation the new phonon energies will be expanded &lt;br /&gt;
using the symmetries of the systems, while the electronic energies at &#039;&#039;&#039;k+q&#039;&#039;&#039; will be interpolated using a smooth Fourier interpolation&amp;lt;ref&amp;gt;Warren E. Pickett, Henry Krakauer, and Philip B. Allen, &lt;br /&gt;
Phys. Rev. B &#039;&#039;&#039;38&#039;&#039;&#039;, 2721(1988)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
In order to perform calculation with the double grid remove the &#039;&#039;SAVE/ndb.QP&#039;&#039; file and repeat the calculation. &amp;lt;br&amp;gt;&lt;br /&gt;
The best strategy to converge electron-phonon coupling calculations is to converge the double-grid for a fixed course grid and the increase the second one. Hereafter an example of Silicon band gap correction convergence versus the number of &#039;&#039;&#039;q&#039;&#039;&#039;-points in the course grid, using a double-grid with 4096 random &#039;&#039;&#039;q&#039;&#039;&#039;-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Gap conv.png|center|Yambo tutorial image | 750px]]&lt;br /&gt;
&lt;br /&gt;
The double-grid implementation is described in this paper&amp;lt;ref&amp;gt;Double-grid for the electron-phonon problem, (to be published) E. Cannuccia, C. Attaccalite and V. Olevano (2022)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon coupling using different &#039;&#039;&#039;q&#039;&#039;&#039; and &#039;&#039;&#039;k&#039;&#039;&#039; grids (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
NOT WORKING!!!!!&lt;br /&gt;
&lt;br /&gt;
The procedure to create electron-phonon matrix elements and import them in Yambo is quite complicated.&lt;br /&gt;
For this reason in Yambo 5.x we decided to simplify this kind of calculations.&lt;br /&gt;
Now you can generate the &#039;&#039;&#039;q&#039;&#039;&#039; grid independently from the &#039;&#039;&#039;k&#039;&#039;&#039; grid. &lt;br /&gt;
You follow the previous steps to generate EPC matrix elements but in the phonon/dvscf input file&lt;br /&gt;
you specify the standard QE q-grid:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12h&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
     electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
               epsil = .true.&lt;br /&gt;
               trans = .true.&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;              ldisp = .true.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;         nq1=6, nq2=6, nq3=2&amp;lt;/span&amp;gt;&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
then when you read the electron-phonon matrix elements you need to add the flag&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 DBsPATH= &amp;quot;../elph_dir/&amp;quot;          # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpExpand &amp;lt;/span&amp;gt;                   # Expand the gkkp in the whole BZ&lt;br /&gt;
&lt;br /&gt;
In this way you can converge &#039;&#039;&#039;q&#039;&#039;&#039; grid independently for the &#039;&#039;&#039;k&#039;&#039;&#039; one. This is important because in general a larger set of q-points&lt;br /&gt;
is required to have converged results compared to the k-one. Add the flag &amp;quot;-V ph&amp;quot;  in the input generation for the electron-phonon self-energy and set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpDB= &amp;quot;gkkp_expanded&amp;quot; &amp;lt;/span&amp;gt;                  # [ELPH] GKKP database (gkkp | gkkp_expanded | genFroh )&lt;br /&gt;
&lt;br /&gt;
Notice that the double-grid works also with k/q different grids.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and post-processing ==&lt;br /&gt;
&#039;&#039;&#039;Automatic generation of electron-phonon matrix elements&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Getting electron-phonon matrix elements from QuantumEspresso to Yambo is a complicated process, &amp;lt;br&amp;gt;&lt;br /&gt;
we advice you to create a script to automatize the procedure, here an example of a bash script for the silicon case: [https://www.yambo-code.org/educational/tutorials/files/SILICON_CONV.tgz SILICON-SCRIPT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are a list of utilities to analyze electron-phonon coupling results:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phonon density of states&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot phonon density of states with the command: &#039;&#039;ypp_ph -p d&#039;&#039;. In order to get a nice plot set in the input&lt;br /&gt;
&lt;br /&gt;
 phonons                          # [R] Phononic properties&lt;br /&gt;
 dos                              # [R] DOS&lt;br /&gt;
 PhBroad= 0.0005000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps=1000                      # Energy steps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
notice that this is an easy quantity to check for the convergence in q-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Ph_dos.png|600px|center| Phonon Density of States]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Eliashberg Functions&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot Eliashberg functions&amp;lt;ref&amp;gt;F. Marsiglio, J.P. Carbotte [https://arxiv.org/abs/cond-mat/0106143 Electron - Phonon Superconductivity]&amp;lt;/ref&amp;gt; for both electrons and excitons. In order to plot Eliashberg functions you must have calculated Quasi-Particle correction with the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt;, see above.&lt;br /&gt;
The command  &#039;&#039;ypp_ph -s e&#039;&#039; generate the input for the electronic Eliashberg functions:&lt;br /&gt;
&lt;br /&gt;
 electrons                        # [R] Electronic properties&lt;br /&gt;
 eliashberg                       # [R] Eliashberg&lt;br /&gt;
 PhBroad= 0.0010000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps= 200                      # Energy steps&lt;br /&gt;
 %QPkrange                        #  generalized Kpoint/Band indices&lt;br /&gt;
  1|1|4|5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
in this example we plot Eliashberg functions for the top valence and bottom conduction band at Gamma point:&lt;br /&gt;
&lt;br /&gt;
[[File:Eliashberg functions.png|600px|center| Eliashberg functions]]&lt;br /&gt;
&lt;br /&gt;
For a discussion on how to interprete Eliashberg functions  and use them to understand the different phonon contribution you can have a look to ref.&amp;lt;ref&amp;gt;E. Cannuccia and A. Gali&lt;br /&gt;
[https://arxiv.org/abs/1907.06089 Phys. Rev. Materials 4, 014601 (2020)] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Atomic displacement amplitudes&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Running &#039;&#039;ypp_ph -p a&#039;&#039; will plot the atomic displacement for each atom in the cell each direction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Other variables in the input files &#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In the input files of the present tutorial there are other variable not used in this tutorial.&lt;br /&gt;
In particular &#039;&#039;GkkpExpand&#039;&#039; is used for other calculations not present in the GPL, while  &#039;&#039;GkkpConvert&#039;&#039; is used to checking purpose the IO for different versions&lt;br /&gt;
of the databases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5727</id>
		<title>Electron Phonon Coupling</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5727"/>
		<updated>2022-04-07T09:56:14Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Electron phonon.png|thumb|200px| Electron-phonon coupling]]&lt;br /&gt;
Here we show step-by-step how to use [https://www.quantum-espresso.org/ Quantum Espresso] to calculate phonons and electron-phonon matrix-elements on a regular q-grid. &lt;br /&gt;
The final aim is to allow Yambo to read them and calculate the temperature-dependent correction to the electronic states.&lt;br /&gt;
This tutorial&amp;lt;ref&amp;gt; This tutorial is based on [http://www.attaccalite.com/elena/news/ Elena Cannuccia blog]&amp;lt;/ref&amp;gt; is quite articulated, take your time to do it patiently.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Sections 1 is presented for this school only as a template of how to generate the electron-phonon matrix elements using QuantumEspresso. As some of the steps there take quite a long time to finish, students can skip this section and move directly to section 2, &amp;quot;Quasi-particle band structure&amp;quot; where they will compute the corrections to the energy levels coming from the electron-phonon interaction. The necessary databases are provided in the link below.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon matrix elements ==&lt;br /&gt;
If you just want to see how Yambo works and leave the database generation for later, or use YamboPy to generate them, &amp;lt;br&amp;gt;&lt;br /&gt;
you can skip this section and download ready-made databases here:   [https://www.yambo-code.org/educational/tutorials/files/Si_elph_dbs.tgz Si_elph_dbs.tgz]&lt;br /&gt;
&lt;br /&gt;
Otherwise, in the cloud you need to load the quantum-espresso module:&lt;br /&gt;
 spack load quantum-espresso&lt;br /&gt;
&lt;br /&gt;
In this first section we will explain how to generate electron-phonon matrix elements in Quantum-Espresso, and how to import them in Yambo.&lt;br /&gt;
Calculations will be divided in different folders:&lt;br /&gt;
 &lt;br /&gt;
* &#039;&#039;&#039;pseudo&#039;&#039;&#039; the pseudo potential folder &lt;br /&gt;
* &#039;&#039;&#039;scf&#039;&#039;&#039; for the self-consistent calculation&lt;br /&gt;
* &#039;&#039;&#039;nscf&#039;&#039;&#039; for the non-self-consistent calculation with a larger number of bands&lt;br /&gt;
* &#039;&#039;&#039;phonon&#039;&#039;&#039; for the phonon calculations&lt;br /&gt;
* &#039;&#039;&#039;dvscf&#039;&#039;&#039; for the calculation of the electron-phonon matrix elements&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how to calculate electron-phonon induced corrections to the bands and optical properties for bulk silicon.&lt;br /&gt;
All input file are availabe in the following tgz file: [https://www.yambo-code.org/educational/tutorials/files/si.epc.tgz si.epc.tgz]&lt;br /&gt;
===SCF===&lt;br /&gt;
In &#039;&#039;&#039;scf&#039;&#039;&#039; we run a standard scf calculation using pw.x choosing a large k-grid in such a way to converge density. Do not forget to set  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;force_symmorphic=.true.&#039;&#039;&amp;lt;/span&amp;gt;, because not symmorphic symmetries are not supported yet in Yambo. Notice that:&lt;br /&gt;
&lt;br /&gt;
a) If you are working with 2D systems, not our case, we have to add the flag  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;assume_isolated=&amp;quot;2D&amp;quot;&#039;&#039;&amp;lt;/span&amp;gt; in such a way correct 2D phonons. &lt;br /&gt;
&lt;br /&gt;
b) If the cell is an &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;FCC&amp;lt;/span&amp;gt;, set manually the cell parameters by using the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;ibrav=0&#039;&#039;&amp;lt;/span&amp;gt; in your scf input file. This allows to generate correctly the uniform q grid over which phonons and electron-phonon databases are calculated, for example for Silicon you can use:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
  ......&lt;br /&gt;
  ibrav=  0,&lt;br /&gt;
  celldm(1) =5.09150&lt;br /&gt;
  .....&lt;br /&gt;
 /&lt;br /&gt;
 .....&lt;br /&gt;
 CELL_PARAMETERS alat&lt;br /&gt;
 0.0  1.0  1.0&lt;br /&gt;
 1.0  0.0  1.0&lt;br /&gt;
 1.0  1.0  0.0&lt;br /&gt;
&lt;br /&gt;
===NSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, and then copy the ${PREFIX}.save folder from &#039;&#039;&#039;scf&#039;&#039;&#039; to &#039;&#039;&#039;nscf&#039;&#039;&#039;, in the present example just do  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
In the nscf input you have to choose the number of k-points and bands you will use for the electron-phonon coupling and Yambo calculations, in our case we will use a 4x4x4 grid and 12 bands.&lt;br /&gt;
&lt;br /&gt;
===Q-points list ===&lt;br /&gt;
1. Read the q-points list. In the &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, enter in the ${PREFIX}.save then run &#039;&#039;p2y&#039;&#039; to read the wave-functions.&lt;br /&gt;
&lt;br /&gt;
2. Generate the setup file with the command &#039;&#039;yambo_ph -i -V all&#039;&#039; and uncomment the flag &#039;&#039;&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;BSEscatt&amp;lt;/span&amp;gt;&#039;&#039; then run the setup.&lt;br /&gt;
&lt;br /&gt;
3. Generate the input file to read the electron-phonon matrix elements with the command &#039;&#039;ypp_ph -k q&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 bzgrids                          # [R] BZ Grid generator&lt;br /&gt;
 Q_grid                           # [R] Q-grid analysis&lt;br /&gt;
 OutputAlat= 0.000000             # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 #NoWeights                     #  Do not print points weight&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                     # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;cooOut= &amp;quot;alat&amp;quot;&amp;lt;/span&amp;gt;                    # Points coordinates (out) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ListPts                      &amp;lt;/span&amp;gt; #  List the internal q/k points also in the parser format&lt;br /&gt;
 #ExpandPts                     #  Expand the internal q/k points in the BZ&lt;br /&gt;
 #ForceUserPts                  #  Do not check the correcteness of the user points&lt;br /&gt;
 %Qpts                            # Q points list&lt;br /&gt;
  0.000000| 0.000000| 0.000000| &lt;br /&gt;
 %&lt;br /&gt;
and uncomment the flag &#039;&#039;&#039;ListPts&#039;&#039;&#039; and q-point coordinates units in &#039;&#039;&#039;alat&#039;&#039;&#039;, the units used by QuantumEspresso. For particular cells, like the FCC, there could be an inconsistency between Yambo and QE definition of alat, in this case you can specify &#039;&#039;&#039;OutputAlat&#039;&#039;&#039; equal to the &#039;&#039;&#039;celldm(1)&#039;&#039;&#039; of QE. Then if you run ypp_ph it will generate the list of q-points for the phonon calculations:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 &amp;lt;---&amp;gt; Q-points (IBZ) PW-formatted&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.125000000  0.125000000 -0.125000000 1&lt;br /&gt;
      -0.250000000 -0.250000000  0.250000000 1&lt;br /&gt;
       0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.375000000  0.125000000 -0.125000000 1&lt;br /&gt;
       0.000000000 -0.250000000  0.250000000 1&lt;br /&gt;
      -0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.500000000  0.250000000  0.000000000 1&lt;br /&gt;
 &amp;lt;---&amp;gt; [08] Timing Overview&lt;br /&gt;
 ......&lt;br /&gt;
&lt;br /&gt;
===Phonons===&lt;br /&gt;
Plug into &#039;&#039;&#039;phonon&#039;&#039;&#039; directory.  You have to copy the self-consistent calculation in this folder&lt;br /&gt;
with the command &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./ &#039;&#039;&amp;lt;/span&amp;gt;. Then you can prepare an input file for phonons using the q-points list you generated in the previous step multiplied by -1, &lt;br /&gt;
the final input will be:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
            verbosity = &#039;high&#039;&lt;br /&gt;
               tr2_ph = 1e-12&lt;br /&gt;
               prefix = &#039;si&#039;&lt;br /&gt;
             fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
               fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
      electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
                epsil = .false.&lt;br /&gt;
                trans = .true.&lt;br /&gt;
                ldisp = .false.&lt;br /&gt;
                qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
===DVSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;dvscf&#039;&#039;&#039; folder. From the nscf folder copy density and wave-functions (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../nscf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;), from the phonon folder copy the dynamical matrices and the dvscf files (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../phonon/_ph0 ../phonon/*.dyn* ./&#039;&#039;&amp;lt;/span&amp;gt;).  Then  modify the phonon input to generate electron-phonon matrix elements for Yambo, by changing &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;epsil = .false.&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;trans = .false.&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;electron_phonon = yambo&amp;lt;/span&amp;gt;. You do not need to specify the k-point grid because it is read from the nscf wave-functions. In this way we will not recalculate phonons, but only the electron-phonon matrix elements for the number of bands present in the nscf input file, in our case 8 bands:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;&lt;br /&gt;
     electron_phonon = &#039;yambo&#039;,&lt;br /&gt;
               epsil = .false.&lt;br /&gt;
               trans = .false.&lt;br /&gt;
               ldisp = .false.&lt;br /&gt;
               qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
this run will generate a new folder &#039;&#039;elph_dir&#039;&#039; with all electron-phonon matrix elements in a format compatible with Yambo.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;IMPORTANT&amp;lt;/span&amp;gt;: do not parallelize on k-points in the &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculation, it is not supported yet!!&lt;br /&gt;
&lt;br /&gt;
===Import in Yambo===&lt;br /&gt;
Now you have to read the electron-phonon matrix elements. Go in the &#039;&#039;dvscf/si.save&#039;&#039; folder, and use ypp_ph to import electron-phonon coupling, by doing &#039;&#039;ypp_ph -g g&#039;&#039; and the PW el-ph folder:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;DBsPATH= &amp;quot;../elph_dir/&amp;quot; &amp;lt;/span&amp;gt;                    # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 #GkkpExpand                    # Expand the gkkp in the whole BZ&lt;br /&gt;
 #UseQindxB                     # Use qindx_B to expand gkkp (for testing purposes)&lt;br /&gt;
&lt;br /&gt;
run ypp_ph, and if everything went well you will get in output&lt;br /&gt;
&lt;br /&gt;
 ..... &lt;br /&gt;
 &amp;lt;---&amp;gt; [06] == Electron-Phonon Databases ==&lt;br /&gt;
 &amp;lt;---&amp;gt; Inspecting databases ...PWscf (dressed)...found 8 Q-points&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: phonon frequencies and eigenvectors |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: K+Q-grid check |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [07] == Q-points list in the DBS (iku units) ==&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Code generator        :PWscf&lt;br /&gt;
 &amp;lt;---&amp;gt; :: DB Kind               :dressed&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Expanded              :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(read)        :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(written)     :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: K-points              : 20&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Bands                 : 12&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Branches              :  6&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Uniform sampling      :yes&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Symmetry expanded     :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Debye Energy          : 63.09927 [meV]&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Notice that Yambo recognized that you are using a regular q-grid: &#039;&#039;Uniform sampling      :yes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Quasi-particle band structure ==&lt;br /&gt;
The first quantity we will calculate is the correction to the band structure induced by the electron-phonon coupling. In order to generate the corresponding input do &amp;lt;code&amp;gt;yambo_ph -g n -p fan -c ep -V gen&amp;lt;/code&amp;gt;. In the input we require the correction only at gamma point:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  1 | 12 |                           # [ELPH] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
If you run &amp;lt;code&amp;gt;yambo_ph -J T0&amp;lt;/code&amp;gt; you will get correction at zero kelvin to the band structure. &lt;br /&gt;
You can change the temperature to 300 K by doing:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BoseTemp= 300.0            Kn &amp;lt;/span&amp;gt;   # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  1 | 12 |                           # [ELPH] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
run again &amp;lt;code&amp;gt;yambo_ph -J T300&amp;lt;/code&amp;gt; and compare the two output files o-T0.qp and o-T300.qp, to find how much the gap change with the temperature.&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that in this calculation we set a small damping factor for the Green function of about 0.01 eV, this value should be of the order of the phonon life-time.&amp;lt;br&amp;gt;&lt;br /&gt;
If you repeat the calculation for different temperature you can obtain the trend of the gap vs temperature. The figure below report the Silicon gap at Gamma Point at different temperature obtained in this tutorial. You can recreate the file with the data needed for this plot with the following command instruction:&lt;br /&gt;
&lt;br /&gt;
for i in 0 50 100 150 200 250 300; do echo -n &amp;quot;$i  &amp;quot;; echo &amp;quot;$(grep &amp;quot;^ *1 *5&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;) - $(grep &amp;quot;^ *1 *4&amp;quot; o-T${i}.qp  | awk &#039;{print ($3+$4)}&#039;)&amp;quot; | bc; done &amp;gt; gap_vs_T.dat&lt;br /&gt;
&lt;br /&gt;
[[File:Si_gap_finite_t.png|600px|center]]&lt;br /&gt;
If you uncomment the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt; the code saves information about the Eliashberg functions that can be plotted using the &#039;&#039;ypp_ph&#039;&#039;, see below.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally if you add &#039;&#039;-V qp&#039;&#039; in the input generation a new flag appears &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;OnMassShell&amp;lt;/span&amp;gt;, if you un-comment this flag calculation will be performed in the &amp;quot;on mass shell&amp;quot; approximation, namely the static limit the Quasi-Particle approximation, for a discussion see reference &amp;lt;ref&amp;gt;H. Kawai et al. [https://arxiv.org/abs/1310.2038 Phys. Rev. B &#039;&#039;&#039;89&#039;&#039;&#039;, 085202 (2014)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the last column in the quasi-particle file &amp;quot;o.QP&amp;quot; contains the &#039;&#039;&#039;quasi-particle width&#039;&#039;&#039;, that is related to their life-time. You can plot the band structure including this width to get quasi-particle spectra&lt;br /&gt;
similar to the one measured in ARPES experiments, see Fig. 2 in ref. &amp;lt;ref&amp;gt; G. Antonius, S. Poncé, E. Lantagne-Hurtubise, G. Auclair, X. Gonze, and M. Côté&lt;br /&gt;
 [https://arxiv.org/abs/1505.07738 Phys. Rev. B 92, 085137 (2015)] &amp;lt;/ref&amp;gt;.&lt;br /&gt;
This parameter will be used in the next tutorial on [https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature optical properties at finite temperature].&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; Yambo average the electron-phonon correction on the degenerate states, please &amp;lt;b&amp;gt;include all degenerate states in your calculations&amp;lt;/b&amp;gt;. For example in the silicon case you need correction from the 2nd band to the 8th band.&lt;br /&gt;
&lt;br /&gt;
== Convergence ==&lt;br /&gt;
&lt;br /&gt;
The results of this tutorial are not converged. This is due to the poor parameters used in this tutorial to make the calculations fast. In order to have converged results, first of all you have to be sure to have converged phonons, in order to do that increase  plane-wave cutoff,  number of k-points and if necessary reduce &#039;&#039;tr2_ph&#039;&#039;.&lt;br /&gt;
Then change the parameters for the Yambo calculations, increasing the number of &#039;&#039;&#039;k&#039;&#039;&#039; and &#039;&#039;&#039;q&#039;&#039;&#039; points and the number of bands. If you want to increase only the number of bands, just repeat the &#039;&#039;&#039;nscf&#039;&#039;&#039; and &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculations without recalculate  &#039;&#039;&#039;phonons&#039;&#039;&#039;. In the following section we will describe a smart way to accelerate convergence.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene: &amp;lt;/span&amp;gt; At present Yambo neither implements the Fröhlich term at q=0&amp;lt;ref&amp;gt;Carla Verdi and Feliciano Giustino&lt;br /&gt;
[https://arxiv.org/abs/1510.06373 Phys. Rev. Lett. &#039;&#039;&#039;115&#039;&#039;&#039;, 176401 (2015)] &amp;lt;/ref&amp;gt; nor the quadrupolar correction,&amp;lt;ref&amp;gt;G. Brunin et al.  [https://arxiv.org/abs/2002.00628  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 136601 (2020)]&amp;lt;/ref&amp;gt; therefore convergence in polar material can be very slow with the number of q-points.&lt;br /&gt;
&lt;br /&gt;
== Double-grid method for the electron-phonon coupling (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simplifying at most the matrix elements of the electron-phonon self-energy have the structure:&lt;br /&gt;
&lt;br /&gt;
[[File:Self elph.png|center|Yambo tutorial image | 270px ]]&lt;br /&gt;
&lt;br /&gt;
where we omitted the electronic band and the phonon branches indexes. In order to speed up calculation one can average the denominators on an additional fine grid around each &#039;&#039;&#039;q&#039;&#039;&#039; points as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula dbgrid.png|center|Yambo tutorial image| 500px]]&lt;br /&gt;
&lt;br /&gt;
In order to exploit the double-grid tool we need the phonon energies calculated on a fine grid. If you just want to test the functionality of Yambo you can download here some files with the phononic frequencies already calculated on different silicon grids: [https://www.yambo-code.org/educational/tutorials/files/si_freqs_files.tgz si_freqs_files.tgz] &amp;lt;br&amp;gt;&lt;br /&gt;
Otherwise you generate them by following the instructions below.&lt;br /&gt;
For a general tutorial on phonon calculation with Quantum Espresso you can have a look at [https://www.quantum-espresso.org/wp-content/uploads/phonons_tutorial_shanghai1.pdf Hands on phonons].&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from a well converged phonon calculation &#039;&#039;matdyn.x&#039;&#039; can interpolate phonon dispersion on a given q-sampling (for example a regular 14x14x14 grid, as shown in the input file below) and give the desired phonon energies. &lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;si.fc&#039;,&lt;br /&gt;
     flfrq=&#039;si.freq&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;si.dos&#039;,&lt;br /&gt;
     deltaE=1.d0,&lt;br /&gt;
     nk1=14, nk2=14, nk3=14&lt;br /&gt;
 /&lt;br /&gt;
Alternatively you can generate a random q-sampling using Yambo (&#039;&#039;ypp -k r&#039;&#039;) and insert the corresponding q points list into a matdyn file. &lt;br /&gt;
&lt;br /&gt;
Once you generated the phonon energies you can read them with the command &#039;&#039;ypp_ph -g d&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_dg                          # [R] GKKP double grid&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PHfreqF= &amp;quot;si.freq&amp;quot;&amp;lt;/span&amp;gt;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 FineGd_mode= &amp;quot;mixed&amp;quot;             # Fine Grid mode. Symmetry expanded, unexpanded or mixed.&lt;br /&gt;
 #SkipBorderPts                 # Skip points in the Fine Grid that are on the surface of coarse gride smal BZ`s&lt;br /&gt;
 EkplusQmode= &amp;quot;interp&amp;quot;            # E(k+q) energies calculation mode (interp | dftp )&lt;br /&gt;
 #TestPHDGrid                   # Test double-grid: set all values of the fine grid equal to the couse ones&lt;br /&gt;
&lt;br /&gt;
then run &#039;&#039;ypp_ph&#039;&#039; an it will generate a new file &#039;&#039;SAVE/ndb.PH_Double_Grid&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
In the calculation the new phonon energies will be expanded &lt;br /&gt;
using the symmetries of the systems, while the electronic energies at &#039;&#039;&#039;k+q&#039;&#039;&#039; will be interpolated using a smooth Fourier interpolation&amp;lt;ref&amp;gt;Warren E. Pickett, Henry Krakauer, and Philip B. Allen, &lt;br /&gt;
Phys. Rev. B &#039;&#039;&#039;38&#039;&#039;&#039;, 2721(1988)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
In order to perform calculation with the double grid remove the &#039;&#039;SAVE/ndb.QP&#039;&#039; file and repeat the calculation. &amp;lt;br&amp;gt;&lt;br /&gt;
The best strategy to converge electron-phonon coupling calculations is to converge the double-grid for a fixed course grid and the increase the second one. Hereafter an example of Silicon band gap correction convergence versus the number of &#039;&#039;&#039;q&#039;&#039;&#039;-points in the course grid, using a double-grid with 4096 random &#039;&#039;&#039;q&#039;&#039;&#039;-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Gap conv.png|center|Yambo tutorial image | 750px]]&lt;br /&gt;
&lt;br /&gt;
The double-grid implementation is described in this paper&amp;lt;ref&amp;gt;Double-grid for the electron-phonon problem, (to be published) E. Cannuccia, C. Attaccalite and V. Olevano (2022)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon coupling using different &#039;&#039;&#039;q&#039;&#039;&#039; and &#039;&#039;&#039;k&#039;&#039;&#039; grids (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
NOT WORKING!!!!!&lt;br /&gt;
&lt;br /&gt;
The procedure to create electron-phonon matrix elements and import them in Yambo is quite complicated.&lt;br /&gt;
For this reason in Yambo 5.x we decided to simplify this kind of calculations.&lt;br /&gt;
Now you can generate the &#039;&#039;&#039;q&#039;&#039;&#039; grid independently from the &#039;&#039;&#039;k&#039;&#039;&#039; grid. &lt;br /&gt;
You follow the previous steps to generate EPC matrix elements but in the phonon/dvscf input file&lt;br /&gt;
you specify the standard QE q-grid:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12h&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
     electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
               epsil = .true.&lt;br /&gt;
               trans = .true.&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;              ldisp = .true.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;         nq1=6, nq2=6, nq3=2&amp;lt;/span&amp;gt;&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
then when you read the electron-phonon matrix elements you need to add the flag&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 DBsPATH= &amp;quot;../elph_dir/&amp;quot;          # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpExpand &amp;lt;/span&amp;gt;                   # Expand the gkkp in the whole BZ&lt;br /&gt;
&lt;br /&gt;
In this way you can converge &#039;&#039;&#039;q&#039;&#039;&#039; grid independently for the &#039;&#039;&#039;k&#039;&#039;&#039; one. This is important because in general a larger set of q-points&lt;br /&gt;
is required to have converged results compared to the k-one. Add the flag &amp;quot;-V ph&amp;quot;  in the input generation for the electron-phonon self-energy and set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpDB= &amp;quot;gkkp_expanded&amp;quot; &amp;lt;/span&amp;gt;                  # [ELPH] GKKP database (gkkp | gkkp_expanded | genFroh )&lt;br /&gt;
&lt;br /&gt;
Notice that the double-grid works also with k/q different grids.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and post-processing ==&lt;br /&gt;
&#039;&#039;&#039;Automatic generation of electron-phonon matrix elements&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Getting electron-phonon matrix elements from QuantumEspresso to Yambo is a complicated process, &amp;lt;br&amp;gt;&lt;br /&gt;
we advice you to create a script to automatize the procedure, here an example of a bash script for the silicon case: [https://www.yambo-code.org/educational/tutorials/files/SILICON_CONV.tgz SILICON-SCRIPT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are a list of utilities to analyze electron-phonon coupling results:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phonon density of states&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot phonon density of states with the command: &#039;&#039;ypp_ph -p d&#039;&#039;. In order to get a nice plot set in the input&lt;br /&gt;
&lt;br /&gt;
 phonons                          # [R] Phononic properties&lt;br /&gt;
 dos                              # [R] DOS&lt;br /&gt;
 PhBroad= 0.0005000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps=1000                      # Energy steps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
notice that this is an easy quantity to check for the convergence in q-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Ph_dos.png|600px|center| Phonon Density of States]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Eliashberg Functions&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot Eliashberg functions&amp;lt;ref&amp;gt;F. Marsiglio, J.P. Carbotte [https://arxiv.org/abs/cond-mat/0106143 Electron - Phonon Superconductivity]&amp;lt;/ref&amp;gt; for both electrons and excitons. In order to plot Eliashberg functions you must have calculated Quasi-Particle correction with the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt;, see above.&lt;br /&gt;
The command  &#039;&#039;ypp_ph -s e&#039;&#039; generate the input for the electronic Eliashberg functions:&lt;br /&gt;
&lt;br /&gt;
 electrons                        # [R] Electronic properties&lt;br /&gt;
 eliashberg                       # [R] Eliashberg&lt;br /&gt;
 PhBroad= 0.0010000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps= 200                      # Energy steps&lt;br /&gt;
 %QPkrange                        #  generalized Kpoint/Band indices&lt;br /&gt;
  1|1|4|5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
in this example we plot Eliashberg functions for the top valence and bottom conduction band at Gamma point:&lt;br /&gt;
&lt;br /&gt;
[[File:Eliashberg functions.png|600px|center| Eliashberg functions]]&lt;br /&gt;
&lt;br /&gt;
For a discussion on how to interprete Eliashberg functions  and use them to understand the different phonon contribution you can have a look to ref.&amp;lt;ref&amp;gt;E. Cannuccia and A. Gali&lt;br /&gt;
[https://arxiv.org/abs/1907.06089 Phys. Rev. Materials 4, 014601 (2020)] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Atomic displacement amplitudes&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Running &#039;&#039;ypp_ph -p a&#039;&#039; will plot the atomic displacement for each atom in the cell each direction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Other variables in the input files &#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In the input files of the present tutorial there are other variable not used in this tutorial.&lt;br /&gt;
In particular &#039;&#039;GkkpExpand&#039;&#039; is used for other calculations not present in the GPL, while  &#039;&#039;GkkpConvert&#039;&#039; is used to checking purpose the IO for different versions&lt;br /&gt;
of the databases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5721</id>
		<title>Electron Phonon Coupling</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Electron_Phonon_Coupling&amp;diff=5721"/>
		<updated>2022-04-07T09:42:55Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Electron phonon.png|thumb|200px| Electron-phonon coupling]]&lt;br /&gt;
Here we show step-by-step how to use [https://www.quantum-espresso.org/ Quantum Espresso] to calculate phonons and electron-phonon matrix-elements on a regular q-grid. &lt;br /&gt;
The final aim is to allow Yambo to read them and calculate the temperature-dependent correction to the electronic states.&lt;br /&gt;
This tutorial&amp;lt;ref&amp;gt; This tutorial is based on [http://www.attaccalite.com/elena/news/ Elena Cannuccia blog]&amp;lt;/ref&amp;gt; is quite articulated, take your time to do it patiently.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Sections 1 is presented for this school only as a template of how to generate the electron-phonon matrix elements using QuantumEspresso. As some of the steps there take quite a long time to finish, students can skip this section and move directly to section 2, &amp;quot;Quasi-particle band structure&amp;quot; where they will compute the corrections to the energy levels coming from the electron-phonon interaction. The necessary databases are provided in the link below.&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon matrix elements ==&lt;br /&gt;
If you just want to see how Yambo works and leave the database generation for later, or use YamboPy to generate them, &amp;lt;br&amp;gt;&lt;br /&gt;
you can skip this section and download ready-made databases here:   [https://www.yambo-code.org/educational/tutorials/files/Si_elph_dbs.tgz Si_elph_dbs.tgz]&lt;br /&gt;
&lt;br /&gt;
Otherwise, in the cloud you need to load the quantum-espresso module:&lt;br /&gt;
 spack load quantum-espresso&lt;br /&gt;
&lt;br /&gt;
In this first section we will explain how to generate electron-phonon matrix elements in Quantum-Espresso, and how to import them in Yambo.&lt;br /&gt;
Calculations will be divided in different folders:&lt;br /&gt;
 &lt;br /&gt;
* &#039;&#039;&#039;pseudo&#039;&#039;&#039; the pseudo potential folder &lt;br /&gt;
* &#039;&#039;&#039;scf&#039;&#039;&#039; for the self-consistent calculation&lt;br /&gt;
* &#039;&#039;&#039;nscf&#039;&#039;&#039; for the non-self-consistent calculation with a larger number of bands&lt;br /&gt;
* &#039;&#039;&#039;phonon&#039;&#039;&#039; for the phonon calculations&lt;br /&gt;
* &#039;&#039;&#039;dvscf&#039;&#039;&#039; for the calculation of the electron-phonon matrix elements&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how to calculate electron-phonon induced corrections to the bands and optical properties for bulk silicon.&lt;br /&gt;
All input file are availabe in the following tgz file: [https://www.yambo-code.org/educational/tutorials/files/si.epc.tgz si.epc.tgz]&lt;br /&gt;
===SCF===&lt;br /&gt;
In &#039;&#039;&#039;scf&#039;&#039;&#039; we run a standard scf calculation using pw.x choosing a large k-grid in such a way to converge density. Do not forget to set  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;force_symmorphic=.true.&#039;&#039;&amp;lt;/span&amp;gt;, because not symmorphic symmetries are not supported yet in Yambo. Notice that:&lt;br /&gt;
&lt;br /&gt;
a) If you are working with 2D systems, not our case, we have to add the flag  &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;assume_isolated=&amp;quot;2D&amp;quot;&#039;&#039;&amp;lt;/span&amp;gt; in such a way correct 2D phonons. &lt;br /&gt;
&lt;br /&gt;
b) If the cell is an &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;FCC&amp;lt;/span&amp;gt;, set manually the cell parameters by using the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;&#039;&#039;ibrav=0&#039;&#039;&amp;lt;/span&amp;gt; in your scf input file. This allows to generate correctly the uniform q grid over which phonons and electron-phonon databases are calculated, for example for Silicon you can use:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
  ......&lt;br /&gt;
  ibrav=  0,&lt;br /&gt;
  celldm(1) =5.09150&lt;br /&gt;
  .....&lt;br /&gt;
 /&lt;br /&gt;
 .....&lt;br /&gt;
 CELL_PARAMETERS alat&lt;br /&gt;
 0.0  1.0  1.0&lt;br /&gt;
 1.0  0.0  1.0&lt;br /&gt;
 1.0  1.0  0.0&lt;br /&gt;
&lt;br /&gt;
===NSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, and then copy the ${PREFIX}.save folder from &#039;&#039;&#039;scf&#039;&#039;&#039; to &#039;&#039;&#039;nscf&#039;&#039;&#039;, in the present example just do  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
In the nscf input you have to choose the number of k-points and bands you will use for the electron-phonon coupling and Yambo calculations, in our case we will use a 4x4x4 grid and 12 bands.&lt;br /&gt;
&lt;br /&gt;
===Q-points list ===&lt;br /&gt;
1. Read the q-points list. In the &#039;&#039;&#039;nscf&#039;&#039;&#039; folder, enter in the ${PREFIX}.save then run &#039;&#039;p2y&#039;&#039; to read the wave-functions.&lt;br /&gt;
&lt;br /&gt;
2. Generate the setup file with the command &#039;&#039;yambo_ph -i -V all&#039;&#039; and uncomment the flag &#039;&#039;&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;BSEscatt&amp;lt;/span&amp;gt;&#039;&#039; then run the setup.&lt;br /&gt;
&lt;br /&gt;
3. Generate the input file to read the electron-phonon matrix elements with the command &#039;&#039;ypp_ph -k q&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 bzgrids                          # [R] BZ Grid generator&lt;br /&gt;
 Q_grid                           # [R] Q-grid analysis&lt;br /&gt;
 OutputAlat= 0.000000             # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 #NoWeights                     #  Do not print points weight&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                     # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;cooOut= &amp;quot;alat&amp;quot;&amp;lt;/span&amp;gt;                    # Points coordinates (out) cc/rlu/iku/alat&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ListPts                      &amp;lt;/span&amp;gt; #  List the internal q/k points also in the parser format&lt;br /&gt;
 #ExpandPts                     #  Expand the internal q/k points in the BZ&lt;br /&gt;
 #ForceUserPts                  #  Do not check the correcteness of the user points&lt;br /&gt;
 %Qpts                            # Q points list&lt;br /&gt;
  0.000000| 0.000000| 0.000000| &lt;br /&gt;
 %&lt;br /&gt;
and uncomment the flag &#039;&#039;&#039;ListPts&#039;&#039;&#039; and q-point coordinates units in &#039;&#039;&#039;alat&#039;&#039;&#039;, the units used by QuantumEspresso. For particular cells, like the FCC, there could be an inconsistency between Yambo and QE definition of alat, in this case you can specify &#039;&#039;&#039;OutputAlat&#039;&#039;&#039; equal to the &#039;&#039;&#039;celldm(1)&#039;&#039;&#039; of QE. Then if you run ypp_ph it will generate the list of q-points for the phonon calculations:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 &amp;lt;---&amp;gt; Q-points (IBZ) PW-formatted&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.125000000  0.125000000 -0.125000000 1&lt;br /&gt;
      -0.250000000 -0.250000000  0.250000000 1&lt;br /&gt;
       0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.375000000  0.125000000 -0.125000000 1&lt;br /&gt;
       0.000000000 -0.250000000  0.250000000 1&lt;br /&gt;
      -0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.500000000  0.250000000  0.000000000 1&lt;br /&gt;
 &amp;lt;---&amp;gt; [08] Timing Overview&lt;br /&gt;
 ......&lt;br /&gt;
&lt;br /&gt;
===Phonons===&lt;br /&gt;
Plug into &#039;&#039;&#039;phonon&#039;&#039;&#039; directory.  You have to copy the self-consistent calculation in this folder&lt;br /&gt;
with the command &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../scf/si.save ./ &#039;&#039;&amp;lt;/span&amp;gt;. Then you can prepare an input file for phonons using the q-points list you generated in the previous step multiplied by -1, &lt;br /&gt;
the final input will be:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
            verbosity = &#039;high&#039;&lt;br /&gt;
               tr2_ph = 1e-12&lt;br /&gt;
               prefix = &#039;si&#039;&lt;br /&gt;
             fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
               fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
      electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
                epsil = .false.&lt;br /&gt;
                trans = .true.&lt;br /&gt;
                ldisp = .false.&lt;br /&gt;
                qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
===DVSCF===&lt;br /&gt;
Plug into &#039;&#039;&#039;dvscf&#039;&#039;&#039; folder. From the nscf folder copy density and wave-functions (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../nscf/si.save ./&#039;&#039;&amp;lt;/span&amp;gt;), from the phonon folder copy the dynamical matrices and the dvscf files (&amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;&#039;&#039;cp -r ../phonon/_ph0 ../phonon/*.dyn* ./&#039;&#039;&amp;lt;/span&amp;gt;).  Then  modify the phonon input to generate electron-phonon matrix elements for Yambo, by changing &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;epsil = .false.&amp;lt;/span&amp;gt;, &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;trans = .false.&amp;lt;/span&amp;gt; and &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;electron_phonon = yambo&amp;lt;/span&amp;gt;. You do not need to specify the k-point grid because it is read from the nscf wave-functions. In this way we will not recalculate phonons, but only the electron-phonon matrix elements for the number of bands present in the nscf input file, in our case 8 bands:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;&lt;br /&gt;
     electron_phonon = &#039;yambo&#039;,&lt;br /&gt;
               epsil = .false.&lt;br /&gt;
               trans = .false.&lt;br /&gt;
               ldisp = .false.&lt;br /&gt;
               qplot = .true.&lt;br /&gt;
 /&lt;br /&gt;
 8&lt;br /&gt;
       0.000000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.125000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.250000000  0.250000000 -0.250000000 1&lt;br /&gt;
      -0.250000000  0.000000000  0.000000000 1&lt;br /&gt;
      -0.375000000 -0.125000000  0.125000000 1&lt;br /&gt;
       0.000000000  0.250000000 -0.250000000 1&lt;br /&gt;
       0.500000000  0.000000000  0.000000000 1&lt;br /&gt;
       0.500000000 -0.250000000  0.000000000 1&lt;br /&gt;
&lt;br /&gt;
this run will generate a new folder &#039;&#039;elph_dir&#039;&#039; with all electron-phonon matrix elements in a format compatible with Yambo.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;IMPORTANT&amp;lt;/span&amp;gt;: do not parallelize on k-points in the &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculation, it is not supported yet!!&lt;br /&gt;
&lt;br /&gt;
===Import in Yambo===&lt;br /&gt;
Now you have to read the electron-phonon matrix elements. Go in the &#039;&#039;dvscf/si.save&#039;&#039; folder, and use ypp_ph to import electron-phonon coupling, by doing &#039;&#039;ypp_ph -g g&#039;&#039; and the PW el-ph folder:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;DBsPATH= &amp;quot;../elph_dir/&amp;quot; &amp;lt;/span&amp;gt;                    # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 #GkkpExpand                    # Expand the gkkp in the whole BZ&lt;br /&gt;
 #UseQindxB                     # Use qindx_B to expand gkkp (for testing purposes)&lt;br /&gt;
&lt;br /&gt;
run ypp_ph, and if everything went well you will get in output&lt;br /&gt;
&lt;br /&gt;
 ..... &lt;br /&gt;
 &amp;lt;---&amp;gt; [06] == Electron-Phonon Databases ==&lt;br /&gt;
 &amp;lt;---&amp;gt; Inspecting databases ...PWscf (dressed)...found 8 Q-points&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: phonon frequencies and eigenvectors |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; ELPH databases: K+Q-grid check |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [07] == Q-points list in the DBS (iku units) ==&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Code generator        :PWscf&lt;br /&gt;
 &amp;lt;---&amp;gt; :: DB Kind               :dressed&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Expanded              :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(read)        :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Q-points(written)     :  8&lt;br /&gt;
 &amp;lt;---&amp;gt; :: K-points              : 20&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Bands                 : 12&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Branches              :  6&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Uniform sampling      :yes&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Symmetry expanded     :no&lt;br /&gt;
 &amp;lt;---&amp;gt; :: Debye Energy          : 63.09927 [meV]&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Notice that Yambo recognized that you are using a regular q-grid: &#039;&#039;Uniform sampling      :yes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Quasi-particle band structure ==&lt;br /&gt;
The first quantity we will calculate is the correction to the band structure induced by the electron-phonon coupling. In order to generate the corresponding input do &amp;quot;&#039;&#039;&#039;yambo_ph -g n -p fan -c ep -V gen&#039;&#039;&#039;&amp;quot;. In the input we require the correction only at gamma point:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  1 | 12 |                           # [ELPH] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
If you run yambo_ph -J T0 you will get correction at zero kelvin to the band structure. You can change the temperature to 300 K by doing:&lt;br /&gt;
&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 el_ph_corr                       # [R] Electron-Phonon Correlation&lt;br /&gt;
 Nelectro= 8.000000               # Electrons number&lt;br /&gt;
 ElecTemp= 0.000000         eV    # Electronic Temperature&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BoseTemp= 300.0            Kn &amp;lt;/span&amp;gt;   # Bosonic Temperature&lt;br /&gt;
 OccTresh= 0.100000E-4            # Occupation treshold (metallic bands)&lt;br /&gt;
 SE_Threads=0                     # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;                   # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 % GphBRnge&lt;br /&gt;
  1 | 12 |                           # [ELPH] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 |  6 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GDamping= 0.0100000         eV   # [GW] G[W] damping&amp;lt;/span&amp;gt;&lt;br /&gt;
 RandQpts=0                       # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 #WRgFsq                        # [ELPH] Dump on file gFsq coefficients&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1|1|2|8|&amp;lt;/span&amp;gt;&lt;br /&gt;
 %&lt;br /&gt;
run again &#039;&#039;yambo_ph -J T300&#039;&#039; and compare the two output file o-T0.qp and o-T300.qp, to find how much the gap change with the temperature.&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that in this calculation we set a small damping factor for the Green function of about 0.01 eV, this value should be of the order of the phonon life-time.&amp;lt;br&amp;gt;&lt;br /&gt;
If you repeat the calculation for different temperature you can obtain the trend of the gap vs temperature. The figure below report the Silicon gap at Gamma Point at different temperature obtained in this tutorial:&lt;br /&gt;
[[File:Si_gap_finite_t.png|600px|center]]&lt;br /&gt;
If you uncomment the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt; the code saves information about the Eliashberg functions that can be plotted using the &#039;&#039;ypp_ph&#039;&#039;, see below.&amp;lt;br&amp;gt;&lt;br /&gt;
Finally if you add &#039;&#039;-V qp&#039;&#039; in the input generation a new flag appears &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;OnMassShell&amp;lt;/span&amp;gt;, if you un-comment this flag calculation will be performed in the &amp;quot;on mass shell&amp;quot; approximation, namely the static limit the Quasi-Particle approximation, for a discussion see reference &amp;lt;ref&amp;gt;H. Kawai et al. [https://arxiv.org/abs/1310.2038 Phys. Rev. B &#039;&#039;&#039;89&#039;&#039;&#039;, 085202 (2014)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the last column in the quasi-particle file &amp;quot;o.QP&amp;quot; contains the &#039;&#039;&#039;quasi-particle width&#039;&#039;&#039;, that is related to their life-time. You can plot the band structure including this width to get quasi-particle spectra&lt;br /&gt;
similar to the one measured in ARPES experiments, see Fig. 2 in ref. &amp;lt;ref&amp;gt; G. Antonius, S. Poncé, E. Lantagne-Hurtubise, G. Auclair, X. Gonze, and M. Côté&lt;br /&gt;
 [https://arxiv.org/abs/1505.07738 Phys. Rev. B 92, 085137 (2015)] &amp;lt;/ref&amp;gt;.&lt;br /&gt;
This parameter will be used in the next tutorial on [https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature optical properties at finite temperature].&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt;&amp;lt;/span&amp;gt; Yambo average the electron-phonon correction on the degenerate states, please &amp;lt;b&amp;gt;include all degenerate states in your calculations&amp;lt;/b&amp;gt;. For example in the silicon case you need correction from the 2nd band to the 8th band.&lt;br /&gt;
&lt;br /&gt;
== Convergence ==&lt;br /&gt;
&lt;br /&gt;
The results of this tutorial are not converged. This is due to the poor parameters used in this tutorial to make the calculations fast. In order to have converged results, first of all you have to be sure to have converged phonons, in order to do that increase  plane-wave cutoff,  number of k-points and if necessary reduce &#039;&#039;tr2_ph&#039;&#039;.&lt;br /&gt;
Then change the parameters for the Yambo calculations, increasing the number of &#039;&#039;&#039;k&#039;&#039;&#039; and &#039;&#039;&#039;q&#039;&#039;&#039; points and the number of bands. If you want to increase only the number of bands, just repeat the &#039;&#039;&#039;nscf&#039;&#039;&#039; and &#039;&#039;&#039;dvscf&#039;&#039;&#039; calculations without recalculate  &#039;&#039;&#039;phonons&#039;&#039;&#039;. In the following section we will describe a smart way to accelerate convergence.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene: &amp;lt;/span&amp;gt; At present Yambo neither implements the Fröhlich term at q=0&amp;lt;ref&amp;gt;Carla Verdi and Feliciano Giustino&lt;br /&gt;
[https://arxiv.org/abs/1510.06373 Phys. Rev. Lett. &#039;&#039;&#039;115&#039;&#039;&#039;, 176401 (2015)] &amp;lt;/ref&amp;gt; nor the quadrupolar correction,&amp;lt;ref&amp;gt;G. Brunin et al.  [https://arxiv.org/abs/2002.00628  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 136601 (2020)]&amp;lt;/ref&amp;gt; therefore convergence in polar material can be very slow with the number of q-points.&lt;br /&gt;
&lt;br /&gt;
== Double-grid method for the electron-phonon coupling (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Simplifying at most the matrix elements of the electron-phonon self-energy have the structure:&lt;br /&gt;
&lt;br /&gt;
[[File:Self elph.png|center|Yambo tutorial image | 270px ]]&lt;br /&gt;
&lt;br /&gt;
where we omitted the electronic band and the phonon branches indexes. In order to speed up calculation one can average the denominators on an additional fine grid around each &#039;&#039;&#039;q&#039;&#039;&#039; points as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula dbgrid.png|center|Yambo tutorial image| 500px]]&lt;br /&gt;
&lt;br /&gt;
In order to exploit the double-grid tool we need the phonon energies calculated on a fine grid. If you just want to test the functionality of Yambo you can download here some files with the phononic frequencies already calculated on different silicon grids: [https://www.yambo-code.org/educational/tutorials/files/si_freqs_files.tgz si_freqs_files.tgz] &amp;lt;br&amp;gt;&lt;br /&gt;
Otherwise you generate them by following the instructions below.&lt;br /&gt;
For a general tutorial on phonon calculation with Quantum Espresso you can have a look at [https://www.quantum-espresso.org/wp-content/uploads/phonons_tutorial_shanghai1.pdf Hands on phonons].&amp;lt;br&amp;gt;&lt;br /&gt;
Starting from a well converged phonon calculation &#039;&#039;matdyn.x&#039;&#039; can interpolate phonon dispersion on a given q-sampling (for example a regular 14x14x14 grid, as shown in the input file below) and give the desired phonon energies. &lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;si.fc&#039;,&lt;br /&gt;
     flfrq=&#039;si.freq&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;si.dos&#039;,&lt;br /&gt;
     deltaE=1.d0,&lt;br /&gt;
     nk1=14, nk2=14, nk3=14&lt;br /&gt;
 /&lt;br /&gt;
Alternatively you can generate a random q-sampling using Yambo (&#039;&#039;ypp -k r&#039;&#039;) and insert the corresponding q points list into a matdyn file. &lt;br /&gt;
&lt;br /&gt;
Once you generated the phonon energies you can read them with the command &#039;&#039;ypp_ph -g d&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_dg                          # [R] GKKP double grid&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;PHfreqF= &amp;quot;si.freq&amp;quot;&amp;lt;/span&amp;gt;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 FineGd_mode= &amp;quot;mixed&amp;quot;             # Fine Grid mode. Symmetry expanded, unexpanded or mixed.&lt;br /&gt;
 #SkipBorderPts                 # Skip points in the Fine Grid that are on the surface of coarse gride smal BZ`s&lt;br /&gt;
 EkplusQmode= &amp;quot;interp&amp;quot;            # E(k+q) energies calculation mode (interp | dftp )&lt;br /&gt;
 #TestPHDGrid                   # Test double-grid: set all values of the fine grid equal to the couse ones&lt;br /&gt;
&lt;br /&gt;
then run &#039;&#039;ypp_ph&#039;&#039; an it will generate a new file &#039;&#039;SAVE/ndb.PH_Double_Grid&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
In the calculation the new phonon energies will be expanded &lt;br /&gt;
using the symmetries of the systems, while the electronic energies at &#039;&#039;&#039;k+q&#039;&#039;&#039; will be interpolated using a smooth Fourier interpolation&amp;lt;ref&amp;gt;Warren E. Pickett, Henry Krakauer, and Philip B. Allen, &lt;br /&gt;
Phys. Rev. B &#039;&#039;&#039;38&#039;&#039;&#039;, 2721(1988)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
In order to perform calculation with the double grid remove the &#039;&#039;SAVE/ndb.QP&#039;&#039; file and repeat the calculation. &amp;lt;br&amp;gt;&lt;br /&gt;
The best strategy to converge electron-phonon coupling calculations is to converge the double-grid for a fixed course grid and the increase the second one. Hereafter an example of Silicon band gap correction convergence versus the number of &#039;&#039;&#039;q&#039;&#039;&#039;-points in the course grid, using a double-grid with 4096 random &#039;&#039;&#039;q&#039;&#039;&#039;-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Gap conv.png|center|Yambo tutorial image | 750px]]&lt;br /&gt;
&lt;br /&gt;
The double-grid implementation is described in this paper&amp;lt;ref&amp;gt;Double-grid for the electron-phonon problem, (to be published) E. Cannuccia, C. Attaccalite and V. Olevano (2022)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon coupling using different &#039;&#039;&#039;q&#039;&#039;&#039; and &#039;&#039;&#039;k&#039;&#039;&#039; grids (only in Yambo 5.x) ==&lt;br /&gt;
&lt;br /&gt;
NOT WORKING!!!!!&lt;br /&gt;
&lt;br /&gt;
The procedure to create electron-phonon matrix elements and import them in Yambo is quite complicated.&lt;br /&gt;
For this reason in Yambo 5.x we decided to simplify this kind of calculations.&lt;br /&gt;
Now you can generate the &#039;&#039;&#039;q&#039;&#039;&#039; grid independently from the &#039;&#039;&#039;k&#039;&#039;&#039; grid. &lt;br /&gt;
You follow the previous steps to generate EPC matrix elements but in the phonon/dvscf input file&lt;br /&gt;
you specify the standard QE q-grid:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
           verbosity = &#039;high&#039;&lt;br /&gt;
              tr2_ph = 1e-12h&lt;br /&gt;
              prefix = &#039;si&#039;&lt;br /&gt;
            fildvscf = &#039;si-dvscf&#039;&lt;br /&gt;
              fildyn = &#039;si.dyn&#039;,&lt;br /&gt;
     electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
               epsil = .true.&lt;br /&gt;
               trans = .true.&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;              ldisp = .true.&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;         nq1=6, nq2=6, nq3=2&amp;lt;/span&amp;gt;&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
then when you read the electron-phonon matrix elements you need to add the flag&lt;br /&gt;
&lt;br /&gt;
 gkkp                             # [R] gkkp databases&lt;br /&gt;
 gkkp_db                          # [R] GKKP database&lt;br /&gt;
 #GkkpReadBare                  # Read the bare gkkp&lt;br /&gt;
 DBsPATH= &amp;quot;../elph_dir/&amp;quot;          # Path to the PW el-ph databases&lt;br /&gt;
 PHfreqF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon frequencies&lt;br /&gt;
 PHmodeF= &amp;quot;none&amp;quot;                  # PWscf format file containing the phonon modes&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpExpand &amp;lt;/span&amp;gt;                   # Expand the gkkp in the whole BZ&lt;br /&gt;
&lt;br /&gt;
In this way you can converge &#039;&#039;&#039;q&#039;&#039;&#039; grid independently for the &#039;&#039;&#039;k&#039;&#039;&#039; one. This is important because in general a larger set of q-points&lt;br /&gt;
is required to have converged results compared to the k-one. Add the flag &amp;quot;-V ph&amp;quot;  in the input generation for the electron-phonon self-energy and set:&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GkkpDB= &amp;quot;gkkp_expanded&amp;quot; &amp;lt;/span&amp;gt;                  # [ELPH] GKKP database (gkkp | gkkp_expanded | genFroh )&lt;br /&gt;
&lt;br /&gt;
Notice that the double-grid works also with k/q different grids.&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous and post-processing ==&lt;br /&gt;
&#039;&#039;&#039;Automatic generation of electron-phonon matrix elements&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Getting electron-phonon matrix elements from QuantumEspresso to Yambo is a complicated process, &amp;lt;br&amp;gt;&lt;br /&gt;
we advice you to create a script to automatize the procedure, here an example of a bash script for the silicon case: [https://www.yambo-code.org/educational/tutorials/files/SILICON_CONV.tgz SILICON-SCRIPT].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are a list of utilities to analyze electron-phonon coupling results:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Phonon density of states&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot phonon density of states with the command: &#039;&#039;ypp_ph -p d&#039;&#039;. In order to get a nice plot set in the input&lt;br /&gt;
&lt;br /&gt;
 phonons                          # [R] Phononic properties&lt;br /&gt;
 dos                              # [R] DOS&lt;br /&gt;
 PhBroad= 0.0005000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps=1000                      # Energy steps&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
notice that this is an easy quantity to check for the convergence in q-points.&lt;br /&gt;
&lt;br /&gt;
[[File:Ph_dos.png|600px|center| Phonon Density of States]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Eliashberg Functions&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
You can plot Eliashberg functions&amp;lt;ref&amp;gt;F. Marsiglio, J.P. Carbotte [https://arxiv.org/abs/cond-mat/0106143 Electron - Phonon Superconductivity]&amp;lt;/ref&amp;gt; for both electrons and excitons. In order to plot Eliashberg functions you must have calculated Quasi-Particle correction with the flag &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;WRgFsq&amp;lt;/span&amp;gt;, see above.&lt;br /&gt;
The command  &#039;&#039;ypp_ph -s e&#039;&#039; generate the input for the electronic Eliashberg functions:&lt;br /&gt;
&lt;br /&gt;
 electrons                        # [R] Electronic properties&lt;br /&gt;
 eliashberg                       # [R] Eliashberg&lt;br /&gt;
 PhBroad= 0.0010000          eV    # Phonon broadening (Eliashberg &amp;amp; DOS)&lt;br /&gt;
 PhStps= 200                      # Energy steps&lt;br /&gt;
 %QPkrange                        #  generalized Kpoint/Band indices&lt;br /&gt;
  1|1|4|5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
in this example we plot Eliashberg functions for the top valence and bottom conduction band at Gamma point:&lt;br /&gt;
&lt;br /&gt;
[[File:Eliashberg functions.png|600px|center| Eliashberg functions]]&lt;br /&gt;
&lt;br /&gt;
For a discussion on how to interprete Eliashberg functions  and use them to understand the different phonon contribution you can have a look to ref.&amp;lt;ref&amp;gt;E. Cannuccia and A. Gali&lt;br /&gt;
[https://arxiv.org/abs/1907.06089 Phys. Rev. Materials 4, 014601 (2020)] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Atomic displacement amplitudes&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
Running &#039;&#039;ypp_ph -p a&#039;&#039; will plot the atomic displacement for each atom in the cell each direction.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Other variables in the input files &#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In the input files of the present tutorial there are other variable not used in this tutorial.&lt;br /&gt;
In particular &#039;&#039;GkkpExpand&#039;&#039; is used for other calculations not present in the GPL, while  &#039;&#039;GkkpConvert&#039;&#039; is used to checking purpose the IO for different versions&lt;br /&gt;
of the databases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=5688</id>
		<title>GW hBN Yambo Virtual 2021 version</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=5688"/>
		<updated>2022-04-05T13:37:33Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the tutorial prepared for the Yambo 2021 virtual school.&lt;br /&gt;
In case you are interested you can find the extended version of the tutorial here: [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial.&lt;br /&gt;
&lt;br /&gt;
One can also skip this step and go directly to the input file generation for GW (browse below), which already includes the calculation of the exchange self-energy&lt;br /&gt;
(simply, this is not discussed in detail as done in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; module).&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will take into account the dynamical effects by setting proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
It is also possible to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies: for this, you may have a look at the [[Real Axis and Lifetimes]] tutorial. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; you should understand that the correct option is&lt;br /&gt;
&amp;lt;code&amp;gt;yambo -hf -gw0 p -dyson n&amp;lt;/code&amp;gt; (or in short &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -hf -gw0 p -dyson n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Here the input file is redirected by the &amp;lt;code&amp;gt;-F&amp;lt;/code&amp;gt; option to &amp;lt;code&amp;gt;gw_ppa.in&amp;lt;/code&amp;gt; (the default name is &amp;lt;code&amp;gt;yambo.in&amp;lt;/code&amp;gt;).&lt;br /&gt;
Depending on the version of &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;, you may need to open the file for editing.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;40         Ry&amp;lt;/span&amp;gt;&#039;&#039;&#039;    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;3187        RL&amp;lt;/span&amp;gt;&#039;&#039;&#039;      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;10&amp;lt;/span&amp;gt;&#039;&#039;&#039; |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1000          mRy&amp;lt;/span&amp;gt;&#039;&#039;&#039;    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1.000000 | 1.000000 | 1.000000 |&amp;lt;/span&amp;gt;&#039;&#039;&#039;        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;40&amp;lt;/span&amp;gt;&#039;&#039;&#039; |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;7|  7|  8|  9|&amp;lt;/span&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
A brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will focus on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #    K-point            Band               Eo [eV]            E-Eo [eV]          Sc|Eo [eV]&lt;br /&gt;
 #&lt;br /&gt;
         7                  8                -0.411876          -0.567816           2.322433&lt;br /&gt;
         7                  9                 3.877976           2.413679          -2.232244&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  [07.02] QP properties and I/O &lt;br /&gt;
  =============================&lt;br /&gt;
 &lt;br /&gt;
  Legend (energies in eV) &lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
 &lt;br /&gt;
  - lXC: Local XC (Slater exchange(X)+Perdew &amp;amp; Zunger(C))&lt;br /&gt;
  -nlXC: non-Local XC (Hartree-Fock)&lt;br /&gt;
 &lt;br /&gt;
  QP [eV] @ K [7] (iku):  0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.93 E-Eo= -0.52 Re(Z)=0.81 Im(Z)=-0.248518E-2 nlXC= -19.1293 lXC= -16.1072 So=  2.37503&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.23 E-Eo=  2.35 Re(Z)=0.83 Im(Z)=-0.215043E-2 nlXC= -5.53648 lXC= -10.6698 So= -2.28481&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-points sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1 to 5 Ry. To do this by hand, file by file, open the &#039;&#039;gw_ppa.in&#039;&#039; file in an editor and change to:&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = &#039;&#039;&#039;2 Ry&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3 Ry, 4 Ry etc. Next, for each &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; change to:&lt;br /&gt;
 % [[Variables#BndsRnXp|BndsRnXp]]&lt;br /&gt;
   1 | 20 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
and repeat for 30, 40 and so on. Give a &#039;&#039;&#039;different name&#039;&#039;&#039; to each file: &#039;&#039;gw_ppa_Xb_YRy.in&#039;&#039; with X=10,20,30,40 and Y=1,2,3,4,5 Ry.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (if interested you can see and learn how to use python scripts using the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;^ *7 *8&amp;quot; |  awk &#039;{print $3+$4}&#039;&lt;br /&gt;
to parse the valence band quasiparticle energies  and &lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;^ *7 *9&amp;quot; |  awk &#039;{print $3+$4}&#039;&lt;br /&gt;
for the conduction band; and put all the data in the &#039;&#039;10b.dat&#039;&#039; files. As there are many files to process you can use the [[bash_scripts|parse_qps.sh]] script to create the &#039;&#039;10b.dat&#039;&#039; file and edit the script changing the number of &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; for the other output files. &lt;br /&gt;
&lt;br /&gt;
Once we have collected all the quasiparticle values we can plot the gap, or the valence and conduction band energies separately, as a function of the block size or energy cutoff:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 2:3 w lp t &amp;quot;Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 2:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,..  &amp;lt;place here all other datasets&amp;gt; &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 2:4 w lp t &amp;quot;Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 2:4 w lp t &amp;quot;Conduction BndsRnXp=20&amp;quot;,..&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 2:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 2:($4-$3) w lp t &amp;quot;gap BndsRnXp=20&amp;quot;,..  &lt;br /&gt;
or both using e.g. the [[gnuplot_scripts|ppa_gap.gnu]] gnuplot script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=1 caption=&amp;quot;Quasiparticle energies with respect screening parameters&amp;quot;&amp;gt;&lt;br /&gt;
File:ppa2.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
File:ppa3.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:ppa1.png|center|600px|caption]]&lt;br /&gt;
&lt;br /&gt;
Looking at the plot we can see that:&lt;br /&gt;
* The two parameters are not totally independent (see e.g. the valence quasiparticle convergence) and this is the reason why we converged them simultaneously &lt;br /&gt;
* The gap (energy difference) converge faster than single quasiparticle state&lt;br /&gt;
* The convergence criteria depends on the degree of accuracy we look for, but considering the approximations behind the calculations (plasmon-pole etc.), it is not always a good idea to enforce too strict a criteria.  &lt;br /&gt;
* Even if not totally converged we can consider that the upper limit of &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;=30, and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=3Ry are reasonable parameters.&lt;br /&gt;
&lt;br /&gt;
====Converging the sum over states in the correlation self-energy====&lt;br /&gt;
From now on we will keep fixed these parameters and will perform a convergence study on the sum over state summation in the correlation self-energy (Σc) &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In order to use the screening previously calculated we can copy the plasmon pole parameters saved in the &amp;lt;code&amp;gt;30b_3Ry&amp;lt;/code&amp;gt; directory in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory. In this way the screening will be read by Yambo and not calculated again:&lt;br /&gt;
&lt;br /&gt;
 $ cp ./30b_3Ry/ndb.pp* ./SAVE/.&lt;br /&gt;
&lt;br /&gt;
(Note: you may have to delete these files before running the BSE tutorials)&lt;br /&gt;
&lt;br /&gt;
In order to use the databases we have to be sure to have the same plasmon-pole parameters in our input files.&lt;br /&gt;
Edit &amp;lt;code&amp;gt;gw_ppa_30b_3Ry.in&amp;lt;/code&amp;gt; and modify &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to order to have a number of bands in the range from 10 to 80 inside different files named &amp;lt;code&amp;gt;gw_ppa_Gbnd10.in&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;gw_ppa_Gbnd20.in&amp;lt;/code&amp;gt;, etc. You can also run the the [[bash_scripts|generate_inputs_2.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next, launch yambo for each input:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and as done before we can inspect the obtained quasiparticle energies: &lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;^ *7 *9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &amp;lt;code&amp;gt;Gbnd_conv.dat&amp;lt;/code&amp;gt; containing: the number of &amp;lt;code&amp;gt;Gbnd&amp;lt;/code&amp;gt;, the valence energy, and the conduction energy.&lt;br /&gt;
Now, as done before we can plot the valence and conduction quasiparticle levels separately as well as the gap, as a function of the number of bands used in the summation:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:2 w lp lt 7  t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3 w lp lt 7  t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2) w lp lt 7  t &amp;quot;Gap&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=2 caption=&amp;quot;Quasiparticle energies with respect sum over states in correlation self-energy&amp;quot;&amp;gt;&lt;br /&gt;
File:Gbnd_val.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
File:Gbnd_cond.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Gbnd_gap.png|center|600px|caption]]&lt;br /&gt;
&lt;br /&gt;
Inspecting the plot we can see that:&lt;br /&gt;
* The convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; is rather slow and many bands are needed to get converged results.&lt;br /&gt;
* As observed above the gap (energy difference) converges faster than the single quasiparticle state energies.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Interpolating Band Structures==&lt;br /&gt;
Up to now we have checked convergence for the gap. Now we want to calculate the quasiparticle corrections across the Brillouin zone in order to visualize the entire band structure along a path connecting high symmetry points.&lt;br /&gt;
&lt;br /&gt;
To do that we start by calculating the QP correction in the plasmon-pole approximation for all the k points of our sampling and for a number of bands around the gap. You can use a previous input file or generate a new one: &amp;lt;code&amp;gt; yambo -F gw_ppa_all_Bz.in -x -p p -g n &amp;lt;/code&amp;gt; and set the parameters found in the previous tests:&lt;br /&gt;
&lt;br /&gt;
 EXXRLvcs=  40        Ry &lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 30 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 3            Ry    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 PPAPntXp= 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
and we calculate it for all the available kpoints by setting:&lt;br /&gt;
 %QPkrange                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  1| 14|  6|11|&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
Note that as we have already calculated the screening with these parameters you can save time and use that database either by running in the previous directory by using &amp;lt;code&amp;gt; -J 30b_3Ry &amp;lt;/code&amp;gt; or if you prefer to put the new databases in the new all_Bz directory you can create a new directory and copy there the screening databases:&lt;br /&gt;
&lt;br /&gt;
 $ mkdir all_Bz &lt;br /&gt;
 $ cp ./30b_3Ry/ndb.pp* ./all_Bz/&lt;br /&gt;
&lt;br /&gt;
and launch the calculation:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_all_Bz.in -J all_Bz&lt;br /&gt;
&lt;br /&gt;
Now we can inspect the output and see that it contains the correction for all the k points for the bands we asked:&lt;br /&gt;
&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
    1.000000     6.000000    -1.299712    -0.219100     3.788044&lt;br /&gt;
    1.000000     7.000000    -1.296430    -0.241496     3.788092&lt;br /&gt;
    1.000000     8.000000    -1.296420    -0.243115     3.785947&lt;br /&gt;
    1.000000     9.000000     4.832399     0.952386    -3.679259&lt;br /&gt;
    1.00000     10.00000     10.76416      2.09915     -4.38743&lt;br /&gt;
    1.00000     11.00000     11.36167      2.48053     -3.91021&lt;br /&gt;
....&lt;br /&gt;
By plotting some of the &#039;o-all_Bz.qp&amp;quot; columns it is possible to discuss some physical properties of the hBN QPs. Using columns 3 and (3+4), ie plotting the GW energies with respect to the LDA energies we can deduce the band gap renormalization and the stretching of the conduction/valence bands:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;o-all_Bz.qp&amp;quot; u 3:($3+$4) w p  t &amp;quot;Eqp vs Elda&amp;quot; &lt;br /&gt;
&lt;br /&gt;
[[File:EqpvE0.png|center|350px|caption]] &lt;br /&gt;
&lt;br /&gt;
Essentially we can see that the effect of the GW self-energy is the opening of the gap and a linear stretching of the conduction/valence bands that can be estimated by performing a linear fit of the positive and negative energies (the zero is set at top of the valence band). &lt;br /&gt;
&lt;br /&gt;
In order to calculate the band structure, however, we need to interpolate the values we have calculated above on a given path. In Yambo the interpolation is done by the executable &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; (Yambo Post Processing).&lt;br /&gt;
By typing: &lt;br /&gt;
 $ ypp -h  &lt;br /&gt;
you will recognize that in order to interpolate the bands we need to build a ypp input file using&lt;br /&gt;
 $ ypp -s b&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Before editing the &#039;&#039;ypp.in&#039;&#039; input file and running the interpolation, it is important to know that &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; uses an algorithm &amp;lt;ref&amp;gt; Warren E. Pickett, Henry Krakauer, and Philip B. Allen Phys. Rev. B 38, 2721 &amp;lt;/ref&amp;gt;  that cannot be used in presence of time-reversal (TR) symmetry. &lt;br /&gt;
As a first step we therefore remove the TR symmetry by typing:&lt;br /&gt;
&lt;br /&gt;
 $ ypp -y&lt;br /&gt;
&lt;br /&gt;
and we uncomment the corresponding line to remove the TR.&lt;br /&gt;
&lt;br /&gt;
 fixsyms                      # [R] Reduce Symmetries&lt;br /&gt;
 #RmAllSymm                   # Remove all symmetries&lt;br /&gt;
 #RmTimeRev                   # Remove Time Reversal&lt;br /&gt;
&lt;br /&gt;
and launch&lt;br /&gt;
 &lt;br /&gt;
 $ ypp&lt;br /&gt;
&lt;br /&gt;
This will create a new directory called &amp;lt;code&amp;gt;FixSymm&amp;lt;/code&amp;gt; where a &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory containing the electronic structure in the absence of TR is present. &lt;br /&gt;
We will calculate the band structure in the &amp;lt;code&amp;gt;FixSymm&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
 $ cd FixSymmm&lt;br /&gt;
&lt;br /&gt;
After having performed the usual setup&lt;br /&gt;
&lt;br /&gt;
 $yambo&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
we can generate the input for the band interpolation:&lt;br /&gt;
&lt;br /&gt;
 $ypp -s b -F ypp_bands.in&lt;br /&gt;
&lt;br /&gt;
and edit the &#039;&#039;ypp_bands.in&#039;&#039; file:&lt;br /&gt;
&lt;br /&gt;
 electrons                    # [R] Electrons (and holes)&lt;br /&gt;
 bnds                         # [R] Bands&lt;br /&gt;
 INTERP_mode= &amp;quot;none&amp;quot;              # Interpolation mode (NN=nearest point, BOLTZ=boltztrap aproach) &lt;br /&gt;
 OutputAlat= 4.716000           # [a.u.] Lattice constant used for &amp;quot;alat&amp;quot; ouput format&lt;br /&gt;
 cooIn= &amp;quot;rlu&amp;quot;                   # Points coordinates (in) cc/rlu/iku/alat&lt;br /&gt;
 cooOut= &amp;quot;rlu&amp;quot;     &lt;br /&gt;
 % BANDS_bands&lt;br /&gt;
   1 | 100 |                   # Number of bands&lt;br /&gt;
 %&lt;br /&gt;
 % INTERP_Grid&lt;br /&gt;
 -1 |-1 |-1 |                             # Interpolation BZ Grid&lt;br /&gt;
 %&lt;br /&gt;
 INTERP_Shell_Fac= 20.00000     # The bigger it is a higher number of shells is used&lt;br /&gt;
 CIRCUIT_E_DB_path= &amp;quot;none&amp;quot;      # SAVE obtained from the QE `bands` run (alternative to %BANDS_kpts)&lt;br /&gt;
 BANDS_path= &amp;quot;&amp;quot;                 # BANDS path points labels (G,M,K,L...)&lt;br /&gt;
 BANDS_steps= 10  &lt;br /&gt;
 #BANDS_built_in                # Print the bands of the generating points of the circuit using the nearest internal point&lt;br /&gt;
 %BANDS_kpts   &lt;br /&gt;
 % &lt;br /&gt;
&lt;br /&gt;
We modify the following lines:&lt;br /&gt;
 INTERP_mode= &amp;quot;BOLTZ&amp;quot;        # Interpolation mode (NN=nearest point, BOLTZ=boltztrap aproach)&lt;br /&gt;
 BANDS_steps=30&lt;br /&gt;
 % BANDS_bands&lt;br /&gt;
   6 | 11 |                   # Number of bands &lt;br /&gt;
 %&lt;br /&gt;
 %BANDS_kpts                    # K points of the bands circuit&lt;br /&gt;
  0.33300 |-.66667 |0.00000 |&lt;br /&gt;
  0.00000 |0.00000 |0.00000 |&lt;br /&gt;
  0.50000 |-.50000 |0.00000 |&lt;br /&gt;
  0.33300 |-.66667 |0.00000 |&lt;br /&gt;
  0.33300 |-.66667 |0.50000 |&lt;br /&gt;
  0.00000 |0.00000 |0.50000 |&lt;br /&gt;
  0.50000 |-.50000 |0.50000 |&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
which means we use the best interpolation method for band structures, we assign 30 points in each segment, we ask to interpolate 3 occupied and 3 empty bands and we assign the following path passing from the high symmetry points: K Γ M K H A L.&lt;br /&gt;
Launching:&lt;br /&gt;
 $ ypp -F ypp_bands.in&lt;br /&gt;
will produce the output file &#039;&#039;o.bands_interpolated&#039;&#039; containing:&lt;br /&gt;
&lt;br /&gt;
                 &lt;br /&gt;
 #&lt;br /&gt;
 #   |k|        b6         b7         b8         b9         b10        b11        kx         ky         kz&lt;br /&gt;
 #&lt;br /&gt;
 #&lt;br /&gt;
     0.00000   -7.22092   -0.13402   -0.13395    4.67691    4.67694   10.08905    0.33300   -0.66667    0.00000&lt;br /&gt;
     0.03725   -7.18857   -0.17190   -0.12684    4.66126    4.71050   10.12529    0.32190   -0.64445    0.00000&lt;br /&gt;
...&lt;br /&gt;
 &lt;br /&gt;
and we can plot the bands using gnuplot:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;o.bands_interpolated&amp;quot; u 0:2 w l, &amp;quot;o.bands_interpolated&amp;quot; u 0:3 w l, ...&lt;br /&gt;
&lt;br /&gt;
[[File:bands_lda.png|center|350px|caption]] &lt;br /&gt;
&lt;br /&gt;
and you can recognize the index of the high symmetry point by inspecting the last three columns.&lt;br /&gt;
Note that up to now we have interpolated the LDA band structure. In order to plot the GW band structure, we need to tell &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; in the input file where the &#039;&#039;ndb.QP&#039;&#039; database is found. This is achieved by adding in the &#039;&#039;ypp_bands.in&#039;&#039; file the line:&lt;br /&gt;
&lt;br /&gt;
  GfnQPdb= &amp;quot;E &amp;lt; ./all_Bz/ndb.QP&amp;quot;&lt;br /&gt;
&lt;br /&gt;
and relaunch &lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_bands.in&lt;br /&gt;
&lt;br /&gt;
Now the file &#039;&#039;o.bands_interpolated_01&#039;&#039; contains the GW interpolated band structure. We can plot the LDA and GW band structure together by using the gnuplot script [[gnuplot_scripts|bands.gnu]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines  widths=500px heights=500px  perrow=2 caption=&amp;quot;Band structure of bulk hBN&amp;quot;&amp;gt;&lt;br /&gt;
File:hBN_bands.png| LDA and GW bands structure &lt;br /&gt;
File:hBN_bands_lit.png| LDA and GW bands structure from Ref. &amp;lt;ref name=&amp;quot;Arnaud&amp;quot; /&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*As expected the effect of the GW correction is to open the gap.&lt;br /&gt;
*Comparing the obtained band structure with the one found in the literature by Arnaud and coworkers &amp;lt;ref name=&amp;quot;Arnaud&amp;quot;&amp;gt; B. Arnaud, S. Lebegue,P. Rabiller, and M. Alouani Phys, Rev. Lett. 96, 026402 (2006)&amp;lt;/ref&amp;gt; we found a very nice qualitative agreement. &lt;br /&gt;
*Quantitatively we found a smaller gap: about 5.2 eV (indirect gap), 5.7 eV (direct gap) while in Ref.&amp;lt;ref name=&amp;quot;Arnaud&amp;quot; /&amp;gt;  is found  5.95 eV for the indirect gap and a minimum direct band gap of 6.47 eV. Other values are also reported in the literature depending on the used pseudopotentials, starting functional and type of self-consistency (see below). &lt;br /&gt;
*The present tutorial has been done with a small k point grid which is an important parameter to be checked, so convergence with respect the k point sampling has to be validated.&lt;br /&gt;
&lt;br /&gt;
==Step 4: Summary of the convergence parameters==&lt;br /&gt;
We have calculated the band structure of hBN starting from a DFT calculation, here we summarize the main variable we have checked to achieve convergence:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; # [XX] Exchange RL components&lt;br /&gt;
Number of G-vectors in the exchange. This number should be checked carefully. Generally a large number is needed as the QP energies show a slow convergence. The calcualtion of the exchange part is rather fast. &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; #[Xp] Polarization function bands&lt;br /&gt;
Number of bands in the independent response function form which the dielectric matrix is calculated. Also this paramater has to be checked carefully,together with NGsBlkXp as the two variables are interconnected&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;  # [Xp] Response block size&lt;br /&gt;
Number of G-vectors block in the dielectric constant. Also this paramater has to be checked carefully, to be checked together with BndsRnXp. A large number of bands and block can make the calculation very demanding.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]] &amp;lt;/code&amp;gt; # [Xp] [cc] Electric Field&lt;br /&gt;
Direction of the electric field for the calculation of the q=0 component of the dielectric constant e(q,w). In a bulk can be set to (1,1,1), attention must be paid for non 3D systems.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]] &amp;lt;/code&amp;gt; # [Xp] Plasmon pole imaginary energy: this is the second frequency used to fit the Godby-Needs plasmon-pole model (PPM). If results depend consistently by changing this frequency, the PPM is not adequate for your calculation and it is need to gp beyond that, e.g. Real-axis. &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]] &amp;lt;/code&amp;gt; # [GW] G[W] bands range&lt;br /&gt;
Number of bands used to expand the Green&#039;s function. This number is usually larger than the number of bands used to calculated the dielectricconstant. Single quasiparticle energies converge slowly with respect GbndRnge, energy difference behave better. You can use terminator technique to mitigate the slow dependence. &lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#GDamping|GDamping]] &amp;lt;/code&amp;gt; # [GW] G[W] damping&lt;br /&gt;
Small damping in the Green&#039;s function definition, the delta &lt;br /&gt;
parameter. The final result shouuld not depend on that, usually set at 0.1 eV&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#dScStep|dScStep]] &amp;lt;/code&amp;gt; # [GW] &lt;br /&gt;
Energy step to evaluate Z factors&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#DysSolver|DysSolver]] &amp;lt;/code&amp;gt; # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
Parameters related to the  solution of the Dyson equation, &amp;quot;n&amp;quot; Newton linearization, &#039;s&#039; non linear secant method&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#GTermKind|GTermKind]] &amp;lt;/code&amp;gt; [GW] GW terminator &lt;br /&gt;
Terminator for the self-energy&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt; . We have seen how this spped up the convergence with respect empty bands.&lt;br /&gt;
&lt;br /&gt;
*&amp;lt;code&amp;gt;[[Variables#%QPkrange |QPkrange ]] &amp;lt;/code&amp;gt; # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
K-points and band range where you want to calculate the GW correction. The syntax is&lt;br /&gt;
first kpoint | last kpoint | first band | last band&lt;br /&gt;
&lt;br /&gt;
==Step 5: Eigenvalue only self-consistent evGW0 and evGW ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;For self-consistent GW please follow this tutorial:&amp;lt;/span&amp;gt; [http://www.yambo-code.org/wiki/index.php?title=Self-consistent_GW_on_eigenvalues_only Self-consistent GW on eigenvalues only]&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we want to see how we can compute an eigenvalue only evGW0 or evGW correction in Yambo. In the new version of Yambo there are two flags for these kind of self-consistency: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[[Variables#GWoIter|GWoIter]]&amp;lt;/code&amp;gt;  number of GW0 iterations&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;[[Variables#GWoIter|GWIter]]&amp;lt;/code&amp;gt;  number of GW iterations&lt;br /&gt;
&lt;br /&gt;
you can set one of them to 10 for example, the code will stop when convergence is reached, usually in less than 5 iterations.&lt;br /&gt;
For example if you consider the input file below:&lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 EXXRLvcs = 40.000     mRy    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 PPAPntXp = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %GbndRnge&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 % &lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 GWoIter=0                    # [GW] GWo self-consistent (evGWo) iterations on eigenvalues&lt;br /&gt;
 GWIter =0                    # [GW] GW  self-consistent (evGW)  iterations on eigenvalues&lt;br /&gt;
 %QPkrange        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  1|  14|  7|  10|&lt;br /&gt;
 % &lt;br /&gt;
if you set both GWIter and GWoIter to zero you get a gap correction of 4.15 eV.&lt;br /&gt;
If you perform self-consistency on G (GWoIter/=)  &lt;br /&gt;
the gap will be 4.713 eV and finally if you perform &lt;br /&gt;
self-consistency in both G and W (GWIter /=0) the gap will be  5.506 eV.&lt;br /&gt;
&lt;br /&gt;
Notice that these values are absolutely not converged because we used very few&lt;br /&gt;
bands and a small block size.&lt;br /&gt;
&lt;br /&gt;
It&#039;s important to note that the final result of the self-consistent GW may&lt;br /&gt;
depend from the number of bands you decide to correct, because they are used&lt;br /&gt;
to reconstruct G and W. For the non-corrected bands Yambo applied a rigid shift&lt;br /&gt;
of their energy based on the closed corrected band.&lt;br /&gt;
&lt;br /&gt;
==Step 6: A better integration of the q=0 point ==&lt;br /&gt;
&lt;br /&gt;
The integration of the q=0 of the Coulomb potential is problematic because the 1/q diverges.&lt;br /&gt;
Usually in Yambo this integration is performed analytically in a small sphere around q=0.&lt;br /&gt;
&lt;br /&gt;
[[File:Circle box.gif|center|frame]]&lt;br /&gt;
&lt;br /&gt;
however in this way the code lost part of the integral out of the circle. This usually &lt;br /&gt;
is not problematic because for a large number of q and k point the missing term goes to zero.&lt;br /&gt;
However in system that requires few k-points or even only the gamma one, it is possible&lt;br /&gt;
to perform a better integration of this term by adding the flag -r to generate the input&lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 rim_cut                      # [R] Coulomb potential&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 RandQpts=&amp;lt;span style=&amp;quot;color:red&lt;br /&gt;
&amp;gt; 3000000&amp;lt;/span&amp;gt;                     # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1&amp;lt;/span&amp;gt;            RL      # [RIM] Coulomb interaction RS components&lt;br /&gt;
 #QpgFull                       # [F RIM] Coulomb interaction: Full matrix&lt;br /&gt;
 EXXRLvcs = 40.000     mRy    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 PPAPntXp = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %GbndRnge&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;) &lt;br /&gt;
 %QPkrange        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
in this input  &amp;lt;code&amp;gt;[[Variables#RandGvec|RandGvec]]&amp;lt;/code&amp;gt; is the component of the Coulomb potential we want integrate numerically,&lt;br /&gt;
in this case only the first one G=G&#039;=0, and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points&lt;br /&gt;
used to perform the integral by Monte Carlo.&lt;br /&gt;
&lt;br /&gt;
If you turn one this integration you will get a slightly different band gap,&lt;br /&gt;
but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only.&lt;br /&gt;
&lt;br /&gt;
==Step 7: Taking into account the material anisotropy (only available in Yambo 4.6) ==&lt;br /&gt;
&lt;br /&gt;
Hexagonal Boron Nitride is an anisotropic material so there is the question in which direction&lt;br /&gt;
one shold calculate the dielectric constant the enters in the GW. &lt;br /&gt;
If you run again this tutorial changing the direction of the q=0 point in GW calculation,&lt;br /&gt;
the variable &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;, you will realize that the there gap correction changes.&lt;br /&gt;
In Yambo there is a way to take into account this anisitropy of the dielectri tensor.&lt;br /&gt;
&lt;br /&gt;
First of all you need to calculate the dielectric constant in the three cartesian directions with the command &amp;lt;code&amp;gt; yambo -o c -k hartree&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 optics                         # [R] Linear Response optical properties&lt;br /&gt;
 kernel                         # [R] Kernel&lt;br /&gt;
 chi                            # [R][CHI] Dyson equation for Chi.&lt;br /&gt;
 dipoles                        # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;              # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 NGsBlkXd= 3000        mRy      # [Xd] Response block size&lt;br /&gt;
 % QpntsRXd&lt;br /&gt;
   1 | 1 |                       # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXd&lt;br /&gt;
    1 | 100 |                   # [Xd] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % EnRngeXd&lt;br /&gt;
   0.00000 | 10.00000 | eV      # [Xd] Energy range &lt;br /&gt;
 %&lt;br /&gt;
 % DmRngeXd&lt;br /&gt;
   0.10000 |  0.10000 | eV      # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 ETStpsXd= 1                    # [Xd] Total Energy steps&lt;br /&gt;
 % LongDrXd&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
From the result in the output file &amp;lt;code&amp;gt; o.eps_q1_inv_rpa_dyson&amp;lt;/code&amp;gt; you can calculate the zero component of inverse dielectric matrix, in this case 1.0/5.044076 = 0.198252.&lt;br /&gt;
&lt;br /&gt;
Repeat this calculation with the field in the other two directions y and z. The y-direction is equal to x, while in z direction the zero component of the inverse dielectric matrix is 1.0/2.872451 = 0.348134.&lt;br /&gt;
&lt;br /&gt;
Now generate a new input file for the GW, with the command &amp;lt;code&amp;gt; yambo -g n -p p -r -V RL&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 rim_cut                      # [R] Coulomb potential&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 RandQpts=&amp;lt;span style=&amp;quot;color:red&amp;gt;3000000&amp;lt;/span&amp;gt;                     # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 1            RL      # [RIM] Coulomb interaction RS components&lt;br /&gt;
 #QpgFull                       # [F RIM] Coulomb interaction: Full matrix&lt;br /&gt;
 % Em1Anys&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.198252 &amp;lt;/span&amp;gt;    | &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.198252 &amp;lt;/span&amp;gt;    |  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.348134 &amp;lt;/span&amp;gt;  |        # [RIM] X Y Z Static Inverse dielectric matrix&lt;br /&gt;
 %&lt;br /&gt;
 IDEm1Ref= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;  &lt;br /&gt;
 EXXRLvcs = 40.000     mRy    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 PPAPntXp = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %GbndRnge&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %QPkrange        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
run the calculations anbed you will find a correction of the gap intermediate between the one with the field in x and z directions.&lt;br /&gt;
&lt;br /&gt;
==Step 8: Exercise: Convergence with respect K points==&lt;br /&gt;
As an exercise now you can check the convergence with respect the K point sampling:&lt;br /&gt;
# perform a new non-scf calculation with a bigger k point grid: 9x9x3 and 12x12x4 ...&lt;br /&gt;
# convert wave functions and electronic structure to Yambo databases in a different directory as explained in the [[Bulk material: h-BN|DFT and p2y module]], &lt;br /&gt;
# [[initialization |Initialize]] the Yambo databases,&lt;br /&gt;
# Redo the steps explained in this section (exchange self energy, plasmon pole GW, band structure interpolation)&lt;br /&gt;
# The PPA-GW calculation using 12x12x4 grid depending on your machine can take several minutes in serial mode. You can think to perform the exercise after having learned some basic on the parallelization strategy.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;br /&gt;
* Back to [[CECAM VIRTUAL 2021#Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:15%; text-align:left&amp;quot;|Prev: [[Tutorials|Tutorials Home]] &lt;br /&gt;
|style=&amp;quot;width:50%; text-align:center&amp;quot;|Now: [[Tutorials|Tutorials Home]] -&amp;gt; [[How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN|GW]] &lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: Back to [[CECAM VIRTUAL 2021|CECAM 2021 page]]  &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4964</id>
		<title>CECAM VIRTUAL 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4964"/>
		<updated>2021-04-16T10:21:55Z</updated>

		<summary type="html">&lt;p&gt;Pedro: /* Thursday 8 April */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Plan for the CECAM VIRTUAL 2021 school tutorials.&lt;br /&gt;
https://www.cecam.org/workshop-details/1081&lt;br /&gt;
&lt;br /&gt;
[[File:Cecam_school_program.png|thumb|160px| Click to enlarge the full program]]&lt;br /&gt;
&lt;br /&gt;
== Setting up Yambo ==&lt;br /&gt;
&lt;br /&gt;
In order to get the yambo code in your machine you have multiple options:&lt;br /&gt;
&lt;br /&gt;
* Yambo Virtual Machine&lt;br /&gt;
* Yambo Container&lt;br /&gt;
* Install the Yambo source in your computer&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Yambo Virtual Machine ===&lt;br /&gt;
The tutorials can be run on a dedicated Virtual Machine (called &#039;&#039;&#039;Yambo Quantum Mobile&#039;&#039;&#039; and adapted from the [https://quantum-mobile.readthedocs.io/en/latest/ Quantum Mobile] VM). &lt;br /&gt;
This is run by installing it as Virtual Machine with the VirtualBox program.&lt;br /&gt;
To install the Yambo VM in your computer you need to:&lt;br /&gt;
* Download and install Virtualbox software&lt;br /&gt;
* Download the Yambo Virtual Machine image&lt;br /&gt;
* Install the Yambo Virtual Machine&lt;br /&gt;
* Start the Yambo Virtual Machine&lt;br /&gt;
* Update and install the Tutorials&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Yambo_Virtual_Machine#Install_the_Yambo_Quantum_Mobile_VM|Install the Yambo Quantum Mobile VM]]&lt;br /&gt;
* [[Yambo_Virtual_Machine#Starting_the_Virtual_Machine|Start the Yambo Virtual Machine]]&lt;br /&gt;
* [[Yambo_Virtual_Machine#Updating_the_Yambo_tutorial_files|Update and install the Tutorials]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
To this end follow exactly the step listed here: [[Yambo_Virtual_Machine#Install_the_Yambo_Quantum_Mobile_VM|Install the Yambo Quantum Mobile VM]]&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Yambo Container===&lt;br /&gt;
&lt;br /&gt;
An alternative to get the Yambo code is to install the Yambo container in your machine and this can be done in few steps:&lt;br /&gt;
&lt;br /&gt;
* Install the docker platform (Linux or Mac). Follow the instruction  in the docker [https://docs.docker.com/engine/install/ website].&lt;br /&gt;
* Pull the Yambo container:&lt;br /&gt;
&lt;br /&gt;
  sudo docker pull nicspalla/yambo-gcc_openmp_petsc:latest&lt;br /&gt;
&lt;br /&gt;
sudo it is not necessary if your user is part of the group named docker (suggested on Linux!).&lt;br /&gt;
&lt;br /&gt;
For Linux users:&lt;br /&gt;
&lt;br /&gt;
  sudo groupadd docker&lt;br /&gt;
  sudo usermod -aG docker $USER&lt;br /&gt;
&lt;br /&gt;
For Mac users:&lt;br /&gt;
&lt;br /&gt;
  sudo dscl . create /Groups/docker&lt;br /&gt;
  sudo dseditgroup -o edit -a $USER -t user docker&lt;br /&gt;
&lt;br /&gt;
Log out and log back in so that your group membership is re-evaluated.&lt;br /&gt;
&lt;br /&gt;
* You are done. To run Yambo into the container:&lt;br /&gt;
&lt;br /&gt;
 docker run -ti --user $(id -u):$(id -g) \&lt;br /&gt;
    --mount type=bind,source=&amp;quot;$(pwd)&amp;quot;,target=/tmpdir \&lt;br /&gt;
    -e OMP_NUM_THREADS=4  \&lt;br /&gt;
    nicspalla/yambo-gcc_openmp_petsc:latest \&lt;br /&gt;
    yambo -F yambo.in -J yambo.out&lt;br /&gt;
&lt;br /&gt;
Otherwise (suggested!), copy and paste the code below in a file, i.e called drun.sh:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 docker run -ti --user $(id -u):$(id -g) \&lt;br /&gt;
    --mount type=bind,source=&amp;quot;$(pwd)&amp;quot;,target=/tmpdir \&lt;br /&gt;
    -e OMP_NUM_THREADS=4  \&lt;br /&gt;
    nicspalla/yambo-gcc_openmp_petsc:latest $@&lt;br /&gt;
&lt;br /&gt;
then give the file execute privileges:&lt;br /&gt;
&lt;br /&gt;
 chmod +x drun.sh&lt;br /&gt;
&lt;br /&gt;
Move (or copy) this file in the directory where you want to use Yambo and use it as prefix of your Yambo calculation:&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo -F yambo.in -J yambo.out&lt;br /&gt;
&lt;br /&gt;
If the yambo container is working correctly you should obtain:&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo&lt;br /&gt;
 &lt;br /&gt;
 yambo: cannot access CORE database (SAVE/*db1 and/or SAVE/*wf)&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo -h&lt;br /&gt;
&lt;br /&gt;
should provide in output the help for yambo usage.&lt;br /&gt;
&lt;br /&gt;
=== Install Yambo === &lt;br /&gt;
If you have some experience with compiling codes, you can  [[Download| get the source]] and [[Installation | install]] it. If you never compiled a code, it is better to choose one of the above options as the technical assistance we can offer is limited.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Before starting, [[Get_Tutorial_files_CECAM2021|get the tutorial files]].&lt;br /&gt;
&lt;br /&gt;
=== Thursday 8 April ===&lt;br /&gt;
&#039;&#039;&#039;14:00 - 14:30 Hands-on setup &#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:30 - 17:00 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039;, Davide Sangalli (CNR-ISM, Italy), Pedro Melo (University of Utrecht, the Netherlands)&lt;br /&gt;
&amp;lt;!-- * [[First steps: a walk through from DFT to optical properties]] (modular) --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * [[First steps: walk through from DFT to RPA (standalone)]] --&amp;gt;&lt;br /&gt;
* [[First steps: walk through from DFT(standalone)|First steps: Initialization and more ]]&lt;br /&gt;
* [[Next steps: RPA calculations (standalone)|Next steps: RPA calculations ]]&lt;br /&gt;
&lt;br /&gt;
=== Friday 9 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;13:30 - 16:30 A complete tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039;, Daniele Varsano (CNR-NANO, Italy), Andrea Ferretti (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
* [[GW hBN Yambo Virtual 2021 version|How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
=== Thursday 15 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;13:30 to 15: Calculating optical spectra including excitonic effects: a step-by-step guide&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;15 to 16:30: Analysis of excitonic spectra, BSE solvers and convergence&#039;&#039;&#039; Fulvio Paleari (CNR-ISM, Italy), Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
* [[BSE hBN Yambo Virtual 2021 version|How to obtain an optical spectrum]]&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
All the lectures will be available in the Yambo-code YouTube [https://www.youtube.com/channel/UCO3LzAqb9W2Qk4EbG_83ATw channel]&lt;br /&gt;
&lt;br /&gt;
=== Thursday 8 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:10 - Welcome &amp;amp; Introduction&#039;&#039;&#039;, Daniele Varsano (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:10 to 10:30 - [https://www.youtube.com/watch?v=Slk_wrAwekk&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr Material Science and Yambo, what we can calculate]&#039;&#039;&#039;,  Andrea Marini (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:40 to 11:00 - [https://www.youtube.com/watch?v=63VJgClpQn8&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr Introduction to Many Body Perturbation Theory]&#039;&#039;&#039;, Pedro Melo (University of Utrecht, the Netherlands)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:25 to 11:45 - [https://www.youtube.com/watch?v=jF5ABGPPsvo&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr The linear response theory]&#039;&#039;&#039;, Claudio Attaccalite (CNRS Marseille, France)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;12:00 to 12:20 - [https://www.youtube.com/watch?v=J6TvJuv3QqI&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr From equations to simulations: the hard life of a Materials scientist]&#039;&#039;&#039;, Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
=== Friday 9 April ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:30 - [https://www.youtube.com/watch?v=odtuNbM1WRE&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr ARPES, quasiparticles and lifetimes: A theory overview]&#039;&#039;&#039;, Andrea Ferretti (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:10 to 11:40 - [https://www.youtube.com/watch?v=w-UUL43tNDQ&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr GW implementation and common approximations]&#039;&#039;&#039;, Daniele Varsano (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
=== Thursday 15 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:20 - Optical properties &amp;amp; excitons&#039;&#039;&#039;, Maurizia Palummo (Uni Roma2 Tor Vergata, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:30 to 10:50 - Derivation of the Bethe-Salpeter Equation and main physical concepts&#039;&#039;&#039;, Claudio Attaccalite (CNRS Marseille, France)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:20 to 11:40 - BSE implementation and common approximations&#039;&#039;&#039;, Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
=== Friday 16 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:00 to 14:30 - Electron-phonon coupling  in Yambo &#039;&#039;&#039; A.Marini &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:40 to 15:10 -  Yambo parallelism and HPC &#039;&#039;&#039;  A. Ferretti&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;15:30 to 16:10 - Parallel session in thematic rooms&#039;&#039;&#039;&lt;br /&gt;
*Room A :  Non-linear optics C. Attaccalite and M. Gruning&lt;br /&gt;
*Room B : Automatisation and post processing with python layers F. Paleari and M. Bonacci&lt;br /&gt;
&#039;&#039;&#039;16:10 to 16:15 - Concluding remarks &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Lecturers ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Claudio Attaccalite (CNRS Marseille, France)&lt;br /&gt;
&lt;br /&gt;
Miki Bonacci (CNR-Nano, University of Modena, Italy)&lt;br /&gt;
&lt;br /&gt;
Andrea Ferretti (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
Andrea Marini (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Pedro Melo (University of Utrecht, the Netherlands)&lt;br /&gt;
&lt;br /&gt;
Fulvio Paleari  (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Maurizia Palummo (Uni Roma2 Tor Vergata, Italy)&lt;br /&gt;
&lt;br /&gt;
Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Daniele Varsano (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
== Tutors ==&lt;br /&gt;
&lt;br /&gt;
Ridwan Agbaoye (Federal University of Agriculture, Abeokuta, Nigeria)&lt;br /&gt;
&lt;br /&gt;
Ignacio Alliati (Queen&#039;s University Belfast, UK)&lt;br /&gt;
&lt;br /&gt;
Samaneh Ataei (Shahid Beheshti University, Iran)&lt;br /&gt;
&lt;br /&gt;
Claudia Cardoso  (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
Alberto Guandalini (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
Conor Hogan (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Antimo Marrazzo (EPFL, Switzerland)&lt;br /&gt;
&lt;br /&gt;
Elena Molteni  (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Daniel Murphy (Queen&#039;s University Belfast, UK)&lt;br /&gt;
&lt;br /&gt;
Bo Peng (University of Cambridge, UK)&lt;br /&gt;
&lt;br /&gt;
Michele Re Fiorentin (Politecnico di Torino, Italy) &lt;br /&gt;
&lt;br /&gt;
Dario A. Leon Valido  (CNR-Nano, University of Modena, Italy)&lt;br /&gt;
&lt;br /&gt;
Matteo Zanfrognini  (CNR-Nano, University of Modena, Italy)&lt;br /&gt;
&lt;br /&gt;
== Technical Support ==&lt;br /&gt;
&lt;br /&gt;
Nicola Spallanzani (CNR-NANO, Italy)&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4963</id>
		<title>CECAM VIRTUAL 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4963"/>
		<updated>2021-04-16T10:21:32Z</updated>

		<summary type="html">&lt;p&gt;Pedro: /* Lecturers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Plan for the CECAM VIRTUAL 2021 school tutorials.&lt;br /&gt;
https://www.cecam.org/workshop-details/1081&lt;br /&gt;
&lt;br /&gt;
[[File:Cecam_school_program.png|thumb|160px| Click to enlarge the full program]]&lt;br /&gt;
&lt;br /&gt;
== Setting up Yambo ==&lt;br /&gt;
&lt;br /&gt;
In order to get the yambo code in your machine you have multiple options:&lt;br /&gt;
&lt;br /&gt;
* Yambo Virtual Machine&lt;br /&gt;
* Yambo Container&lt;br /&gt;
* Install the Yambo source in your computer&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Yambo Virtual Machine ===&lt;br /&gt;
The tutorials can be run on a dedicated Virtual Machine (called &#039;&#039;&#039;Yambo Quantum Mobile&#039;&#039;&#039; and adapted from the [https://quantum-mobile.readthedocs.io/en/latest/ Quantum Mobile] VM). &lt;br /&gt;
This is run by installing it as Virtual Machine with the VirtualBox program.&lt;br /&gt;
To install the Yambo VM in your computer you need to:&lt;br /&gt;
* Download and install Virtualbox software&lt;br /&gt;
* Download the Yambo Virtual Machine image&lt;br /&gt;
* Install the Yambo Virtual Machine&lt;br /&gt;
* Start the Yambo Virtual Machine&lt;br /&gt;
* Update and install the Tutorials&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Yambo_Virtual_Machine#Install_the_Yambo_Quantum_Mobile_VM|Install the Yambo Quantum Mobile VM]]&lt;br /&gt;
* [[Yambo_Virtual_Machine#Starting_the_Virtual_Machine|Start the Yambo Virtual Machine]]&lt;br /&gt;
* [[Yambo_Virtual_Machine#Updating_the_Yambo_tutorial_files|Update and install the Tutorials]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
To this end follow exactly the step listed here: [[Yambo_Virtual_Machine#Install_the_Yambo_Quantum_Mobile_VM|Install the Yambo Quantum Mobile VM]]&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Yambo Container===&lt;br /&gt;
&lt;br /&gt;
An alternative to get the Yambo code is to install the Yambo container in your machine and this can be done in few steps:&lt;br /&gt;
&lt;br /&gt;
* Install the docker platform (Linux or Mac). Follow the instruction  in the docker [https://docs.docker.com/engine/install/ website].&lt;br /&gt;
* Pull the Yambo container:&lt;br /&gt;
&lt;br /&gt;
  sudo docker pull nicspalla/yambo-gcc_openmp_petsc:latest&lt;br /&gt;
&lt;br /&gt;
sudo it is not necessary if your user is part of the group named docker (suggested on Linux!).&lt;br /&gt;
&lt;br /&gt;
For Linux users:&lt;br /&gt;
&lt;br /&gt;
  sudo groupadd docker&lt;br /&gt;
  sudo usermod -aG docker $USER&lt;br /&gt;
&lt;br /&gt;
For Mac users:&lt;br /&gt;
&lt;br /&gt;
  sudo dscl . create /Groups/docker&lt;br /&gt;
  sudo dseditgroup -o edit -a $USER -t user docker&lt;br /&gt;
&lt;br /&gt;
Log out and log back in so that your group membership is re-evaluated.&lt;br /&gt;
&lt;br /&gt;
* You are done. To run Yambo into the container:&lt;br /&gt;
&lt;br /&gt;
 docker run -ti --user $(id -u):$(id -g) \&lt;br /&gt;
    --mount type=bind,source=&amp;quot;$(pwd)&amp;quot;,target=/tmpdir \&lt;br /&gt;
    -e OMP_NUM_THREADS=4  \&lt;br /&gt;
    nicspalla/yambo-gcc_openmp_petsc:latest \&lt;br /&gt;
    yambo -F yambo.in -J yambo.out&lt;br /&gt;
&lt;br /&gt;
Otherwise (suggested!), copy and paste the code below in a file, i.e called drun.sh:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 docker run -ti --user $(id -u):$(id -g) \&lt;br /&gt;
    --mount type=bind,source=&amp;quot;$(pwd)&amp;quot;,target=/tmpdir \&lt;br /&gt;
    -e OMP_NUM_THREADS=4  \&lt;br /&gt;
    nicspalla/yambo-gcc_openmp_petsc:latest $@&lt;br /&gt;
&lt;br /&gt;
then give the file execute privileges:&lt;br /&gt;
&lt;br /&gt;
 chmod +x drun.sh&lt;br /&gt;
&lt;br /&gt;
Move (or copy) this file in the directory where you want to use Yambo and use it as prefix of your Yambo calculation:&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo -F yambo.in -J yambo.out&lt;br /&gt;
&lt;br /&gt;
If the yambo container is working correctly you should obtain:&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo&lt;br /&gt;
 &lt;br /&gt;
 yambo: cannot access CORE database (SAVE/*db1 and/or SAVE/*wf)&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo -h&lt;br /&gt;
&lt;br /&gt;
should provide in output the help for yambo usage.&lt;br /&gt;
&lt;br /&gt;
=== Install Yambo === &lt;br /&gt;
If you have some experience with compiling codes, you can  [[Download| get the source]] and [[Installation | install]] it. If you never compiled a code, it is better to choose one of the above options as the technical assistance we can offer is limited.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Before starting, [[Get_Tutorial_files_CECAM2021|get the tutorial files]].&lt;br /&gt;
&lt;br /&gt;
=== Thursday 8 April ===&lt;br /&gt;
&#039;&#039;&#039;14:00 - 14:30 Hands-on setup &#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:30 - 17:00 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039;, Davide Sangalli (CNR-ISM, Italy), Pedro Melo (University of Utrecht, the Netherlands)&lt;br /&gt;
&amp;lt;!-- * [[First steps: a walk through from DFT to optical properties]] (modular) --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * [[First steps: walk through from DFT to RPA (standalone)]] --&amp;gt;&lt;br /&gt;
* [[First steps: walk through from DFT(standalone)|First steps: Initialization and more ]]&lt;br /&gt;
* [[Next steps: RPA calculations (standalone)|Next steps: RPA calculations ]]&lt;br /&gt;
&lt;br /&gt;
=== Friday 9 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;13:30 - 16:30 A complete tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039;, Daniele Varsano (CNR-NANO, Italy), Andrea Ferretti (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
* [[GW hBN Yambo Virtual 2021 version|How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
=== Thursday 15 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;13:30 to 15: Calculating optical spectra including excitonic effects: a step-by-step guide&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;15 to 16:30: Analysis of excitonic spectra, BSE solvers and convergence&#039;&#039;&#039; Fulvio Paleari (CNR-ISM, Italy), Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
* [[BSE hBN Yambo Virtual 2021 version|How to obtain an optical spectrum]]&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
All the lectures will be available in the Yambo-code YouTube [https://www.youtube.com/channel/UCO3LzAqb9W2Qk4EbG_83ATw channel]&lt;br /&gt;
&lt;br /&gt;
=== Thursday 8 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:10 - Welcome &amp;amp; Introduction&#039;&#039;&#039;, Daniele Varsano (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:10 to 10:30 - [https://www.youtube.com/watch?v=Slk_wrAwekk&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr Material Science and Yambo, what we can calculate]&#039;&#039;&#039;,  Andrea Marini (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:40 to 11:00 - [https://www.youtube.com/watch?v=63VJgClpQn8&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr Introduction to Many Body Perturbation Theory]&#039;&#039;&#039;, Pedro Melo (University of Utrecht, the Nederlands)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:25 to 11:45 - [https://www.youtube.com/watch?v=jF5ABGPPsvo&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr The linear response theory]&#039;&#039;&#039;, Claudio Attaccalite (CNRS Marseille, France)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;12:00 to 12:20 - [https://www.youtube.com/watch?v=J6TvJuv3QqI&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr From equations to simulations: the hard life of a Materials scientist]&#039;&#039;&#039;, Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
=== Friday 9 April ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:30 - [https://www.youtube.com/watch?v=odtuNbM1WRE&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr ARPES, quasiparticles and lifetimes: A theory overview]&#039;&#039;&#039;, Andrea Ferretti (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:10 to 11:40 - [https://www.youtube.com/watch?v=w-UUL43tNDQ&amp;amp;list=PLOvKdkt7HrnJp8nXvphzYHyPbnuBog4Dr GW implementation and common approximations]&#039;&#039;&#039;, Daniele Varsano (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
=== Thursday 15 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:20 - Optical properties &amp;amp; excitons&#039;&#039;&#039;, Maurizia Palummo (Uni Roma2 Tor Vergata, Italy)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:30 to 10:50 - Derivation of the Bethe-Salpeter Equation and main physical concepts&#039;&#039;&#039;, Claudio Attaccalite (CNRS Marseille, France)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:20 to 11:40 - BSE implementation and common approximations&#039;&#039;&#039;, Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
=== Friday 16 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:00 to 14:30 - Electron-phonon coupling  in Yambo &#039;&#039;&#039; A.Marini &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:40 to 15:10 -  Yambo parallelism and HPC &#039;&#039;&#039;  A. Ferretti&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;15:30 to 16:10 - Parallel session in thematic rooms&#039;&#039;&#039;&lt;br /&gt;
*Room A :  Non-linear optics C. Attaccalite and M. Gruning&lt;br /&gt;
*Room B : Automatisation and post processing with python layers F. Paleari and M. Bonacci&lt;br /&gt;
&#039;&#039;&#039;16:10 to 16:15 - Concluding remarks &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Lecturers ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Claudio Attaccalite (CNRS Marseille, France)&lt;br /&gt;
&lt;br /&gt;
Miki Bonacci (CNR-Nano, University of Modena, Italy)&lt;br /&gt;
&lt;br /&gt;
Andrea Ferretti (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
Andrea Marini (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Pedro Melo (University of Utrecht, the Netherlands)&lt;br /&gt;
&lt;br /&gt;
Fulvio Paleari  (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Maurizia Palummo (Uni Roma2 Tor Vergata, Italy)&lt;br /&gt;
&lt;br /&gt;
Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Daniele Varsano (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
== Tutors ==&lt;br /&gt;
&lt;br /&gt;
Ridwan Agbaoye (Federal University of Agriculture, Abeokuta, Nigeria)&lt;br /&gt;
&lt;br /&gt;
Ignacio Alliati (Queen&#039;s University Belfast, UK)&lt;br /&gt;
&lt;br /&gt;
Samaneh Ataei (Shahid Beheshti University, Iran)&lt;br /&gt;
&lt;br /&gt;
Claudia Cardoso  (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
Alberto Guandalini (CNR-Nano, Italy)&lt;br /&gt;
&lt;br /&gt;
Conor Hogan (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Antimo Marrazzo (EPFL, Switzerland)&lt;br /&gt;
&lt;br /&gt;
Elena Molteni  (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
Daniel Murphy (Queen&#039;s University Belfast, UK)&lt;br /&gt;
&lt;br /&gt;
Bo Peng (University of Cambridge, UK)&lt;br /&gt;
&lt;br /&gt;
Michele Re Fiorentin (Politecnico di Torino, Italy) &lt;br /&gt;
&lt;br /&gt;
Dario A. Leon Valido  (CNR-Nano, University of Modena, Italy)&lt;br /&gt;
&lt;br /&gt;
Matteo Zanfrognini  (CNR-Nano, University of Modena, Italy)&lt;br /&gt;
&lt;br /&gt;
== Technical Support ==&lt;br /&gt;
&lt;br /&gt;
Nicola Spallanzani (CNR-NANO, Italy)&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4848</id>
		<title>CECAM VIRTUAL 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4848"/>
		<updated>2021-04-07T09:04:48Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Plan for the CECAM VIRTUAL 2021 school tutorials.&lt;br /&gt;
https://www.cecam.org/workshop-details/1081&lt;br /&gt;
&lt;br /&gt;
[[File:Cecam_school_program.png|thumb|160px| Click to enlarge the full program]]&lt;br /&gt;
&lt;br /&gt;
== Setting up Yambo ==&lt;br /&gt;
&lt;br /&gt;
In order to get the yambo code in your machine you have multiple options:&lt;br /&gt;
&lt;br /&gt;
* Yambo Virtual Machine&lt;br /&gt;
* Yambo Container&lt;br /&gt;
* Install the Yambo source in your computer&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Yambo Virtual Machine ===&lt;br /&gt;
The tutorials can be run on a dedicated Virtual Machine (called &#039;&#039;&#039;Yambo Quantum Mobile&#039;&#039;&#039; and adapted from the [https://quantum-mobile.readthedocs.io/en/latest/ Quantum Mobile] VM). &lt;br /&gt;
This is run by installing it as Virtual Machine with the VirtualBox program.&lt;br /&gt;
To install the Yambo VM in your computer you need to:&lt;br /&gt;
* Download and install Virtualbox software&lt;br /&gt;
* Download the Yambo Virtual Machine image&lt;br /&gt;
* Install the Yambo Virtual Machine&lt;br /&gt;
* Start the Yambo Virtual Machine&lt;br /&gt;
* Update and install the Tutorials&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Yambo_Virtual_Machine#Install_the_Yambo_Quantum_Mobile_VM|Install the Yambo Quantum Mobile VM]]&lt;br /&gt;
* [[Yambo_Virtual_Machine#Starting_the_Virtual_Machine|Start the Yambo Virtual Machine]]&lt;br /&gt;
* [[Yambo_Virtual_Machine#Updating_the_Yambo_tutorial_files|Update and install the Tutorials]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
To this end follow exactly the step listed here: [[Yambo_Virtual_Machine#Install_the_Yambo_Quantum_Mobile_VM|Install the Yambo Quantum Mobile VM]]&lt;br /&gt;
&lt;br /&gt;
=== Setting up the Yambo Container===&lt;br /&gt;
&lt;br /&gt;
An alternative to get the Yambo code is to install the Yambo container in your machine and this can be done in few steps:&lt;br /&gt;
&lt;br /&gt;
* Install the docker platform (Linux or Mac). Follow the instruction  in the docker [https://docs.docker.com/engine/install/ website].&lt;br /&gt;
* Pull the Yambo container:&lt;br /&gt;
&lt;br /&gt;
  sudo docker pull nicspalla/yambo-gcc_openmp_mkl:latest&lt;br /&gt;
&lt;br /&gt;
sudo it is not necessary if your user is part of the group named docker (suggested on Linux!).&lt;br /&gt;
&lt;br /&gt;
For Linux users:&lt;br /&gt;
&lt;br /&gt;
  sudo groupadd docker&lt;br /&gt;
  sudo usermod -aG docker $USER&lt;br /&gt;
&lt;br /&gt;
For Mac users:&lt;br /&gt;
&lt;br /&gt;
  sudo dscl . create /Groups/docker&lt;br /&gt;
  sudo dseditgroup -o edit -a $USER -t user docker&lt;br /&gt;
&lt;br /&gt;
Log out and log back in so that your group membership is re-evaluated.&lt;br /&gt;
&lt;br /&gt;
* You are done. To run Yambo into the container:&lt;br /&gt;
&lt;br /&gt;
 docker run -ti --user $(id -u):$(id -g) \&lt;br /&gt;
    --mount type=bind,source=&amp;quot;$(pwd)&amp;quot;,target=/tmpdir \&lt;br /&gt;
    -e OMP_NUM_THREADS=4  \&lt;br /&gt;
    nicspalla/yambo-gcc_openmp_mkl:latest \&lt;br /&gt;
    yambo -F yambo.in -J yambo.out&lt;br /&gt;
&lt;br /&gt;
Otherwise (suggested!), copy and paste the code below in a file, i.e called drun.sh:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 docker run -ti --user $(id -u):$(id -g) \&lt;br /&gt;
    --mount type=bind,source=&amp;quot;$(pwd)&amp;quot;,target=/tmpdir \&lt;br /&gt;
    -e OMP_NUM_THREADS=4  \&lt;br /&gt;
    nicspalla/yambo-gcc_openmp_mkl:latest $@&lt;br /&gt;
&lt;br /&gt;
then give the file execute privileges:&lt;br /&gt;
&lt;br /&gt;
 chmod +x drun.sh&lt;br /&gt;
&lt;br /&gt;
Move (or copy) this file in the directory where you want to use Yambo and use it as prefix of your Yambo calculation:&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo -F yambo.in -J yambo.out&lt;br /&gt;
&lt;br /&gt;
If the yambo container is working correctly you should obtain:&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo&lt;br /&gt;
 &lt;br /&gt;
 yambo: cannot access CORE database (SAVE/*db1 and/or SAVE/*wf)&lt;br /&gt;
&lt;br /&gt;
 ./drun.sh yambo -h&lt;br /&gt;
&lt;br /&gt;
should provide in output the help for yambo usage.&lt;br /&gt;
&lt;br /&gt;
=== Install Yambo === &lt;br /&gt;
If you have some experience with compiling codes, you can  [[Download| get the source]] and [[Installation | install]] it. If you never compiled a code, it is better to choose one of the above options as the technical assistance we can offer is limited.&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Before starting, [[Get_Tutorial_files_CECAM2021|get the tutorial files]].&lt;br /&gt;
&lt;br /&gt;
=== Thursday 8 April ===&lt;br /&gt;
&#039;&#039;&#039;14:30 - 17:00 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039; Davide Sangalli (CNR-ISM, Italy), Pedro Melo (University of Utrecht, the Netherlands)&lt;br /&gt;
&amp;lt;!-- * [[First steps: a walk through from DFT to optical properties]] (modular) --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * [[First steps: walk through from DFT to RPA (standalone)]] --&amp;gt;&lt;br /&gt;
* [[First steps: walk through from DFT(standalone)|First steps: Initialization and more ]]&lt;br /&gt;
* [[Next steps: RPA calculations (standalone)|Next steps: RPA calculations ]]&lt;br /&gt;
&lt;br /&gt;
=== Friday 9 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;13:30 - 16:30 A complete tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039; Daniele Varsano (CNR-NANO, Italy), Andrea Ferretti (CNR-NANO, Italy)&lt;br /&gt;
&lt;br /&gt;
* [[GW hBN Yambo Virtual 2021 version|How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
=== Thursday 15 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;13:30 - 15:00 A guided tour through calculations of spectroscopic properties using the BSE approach&#039;&#039;&#039; Fulvio Paleari (CNR-ISM, Italy), Myrta Gr&amp;amp;#252;ning (Queen&#039;s University Belfast, Northern Ireland)&lt;br /&gt;
&lt;br /&gt;
* [[BSE hBN Yambo Virtual 2021 version|How to obtain an optical spectrum]]&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
=== Thursday 8 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:10 - Welcome &amp;amp; Introduction&#039;&#039;&#039; Andrea Marini&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:10 to 10:30 - Material Science and Yambo, what we can calculate&#039;&#039;&#039;  Andrea Marini&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:40 to 11:00 - Introduction to Many Body Perturbation Theory&#039;&#039;&#039; Pedro Melo&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:25 to 11:45 - The linear response theory&#039;&#039;&#039; Claudio Attaccalite&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;12:00 to 12:20 - From equations to simulations: the hard life of a Materials scientist&#039;&#039;&#039; Myrta Gr&amp;amp;#252;ning&lt;br /&gt;
&lt;br /&gt;
=== Friday 9 April ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:20 - from ARPES to quasiparticles&#039;&#039;&#039; Andrea Ferretti&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:30 to 10:50 - The Quasi Particle concept and the GW method&#039;&#039;&#039; Andrea Ferretti &amp;amp; Daniele Varsano&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:20 to 11:40 - GW implementation and common approximations&#039;&#039;&#039; Daniele Varsano&lt;br /&gt;
&lt;br /&gt;
=== Thursday 15 April ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:00 to 10:20 - Optical properties &amp;amp; excitons&#039;&#039;&#039; Maurizia Palummo&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;10:30 to 10:50 - Derivation of the Bethe-Salpeter Equation and main physical concepts&#039;&#039;&#039; Claudio Attaccalite&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:20 to 11:40 - BSE implementation and common approximations&#039;&#039;&#039; Davide Sangalli&lt;br /&gt;
&lt;br /&gt;
=== Friday 16 April ===&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4847</id>
		<title>First steps: walk through from DFT(standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4847"/>
		<updated>2021-04-07T08:50:54Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to calculate optical spectra using Yambo, starting from a DFT calculation and ending with a look at local field effects in the optical response. &lt;br /&gt;
&lt;br /&gt;
== System characteristics ==&lt;br /&gt;
We will use a 3D system (bulk hBN) and a 2D system (hBN sheet). &lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Hexagonal boron nitride - hBN&#039;&#039;&#039;:&lt;br /&gt;
* HCP lattice, ABAB stacking&lt;br /&gt;
* Four atoms per cell, B and N (16 electrons)&lt;br /&gt;
* Lattice constants: &#039;&#039;a&#039;&#039; = 4.716 [a.u.], &#039;&#039;c/a&#039;&#039; = 2.582&lt;br /&gt;
* Plane wave cutoff 40 Ry (~1500 RL vectors in wavefunctions)&lt;br /&gt;
* SCF run: shifted &#039;&#039;6x6x2&#039;&#039; grid (12 k-points) with 8 bands &lt;br /&gt;
* Non-SCF run: gamma-centred &#039;&#039;6x6x2&#039;&#039; (14 k-points) grid with 100 bands&lt;br /&gt;
&lt;br /&gt;
=== Prerequisites ===&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* PWSCF input files and pseudopotentials for hBN bulk &lt;br /&gt;
* &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; executable, version 5.0 or later&lt;br /&gt;
* &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executables&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; for plotting spectra&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* Before starting, [[Get_Tutorial_files_CECAM2021|get the tutorial files]]&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; for plotting spectra&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
==Download the Files==&lt;br /&gt;
&lt;br /&gt;
Download and unpack the followint files:&lt;br /&gt;
[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz] [15 MB],&lt;br /&gt;
[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz] [8,6 MB]&lt;br /&gt;
&lt;br /&gt;
In the next days you could also use this file which you may like to download now&lt;br /&gt;
[http://www.yambo-code.org/educational/tutorials/files/hBN-convergence-kpoints.tar.gz hBN-convergence-kpoints.tar.gz] [254 MB]&lt;br /&gt;
&lt;br /&gt;
After downloading the tar.gz files just unpack them in the &#039;&#039;&#039;YAMBO_TUTORIALS&#039;&#039;&#039; folder. For example&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ mv hBN.tar.gz YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ tar -xvfz hBN.tar.gz&lt;br /&gt;
 $ ls YAMBO_TUTORIALS&lt;br /&gt;
   hBN&lt;br /&gt;
 $ cd hBN&lt;br /&gt;
 $ ls&lt;br /&gt;
 $ PWSCF YAMBO&lt;br /&gt;
&lt;br /&gt;
(Advanced users can download and install all tutorial files using git. See the main  [[Tutorials#Files|Tutorial Files]] page.)&lt;br /&gt;
&lt;br /&gt;
Now you can go directly in &#039;&#039;&#039;YAMBO&#039;&#039;&#039; folder where you can find the &#039;&#039;&#039;SAVE&#039;&#039;&#039; folder which is needed to start  and go directly to &#039;&#039;&#039;[Initialization of Yambo databases]&#039;&#039;&#039;  below, which is always the first step you have to perform for any simulation using the Yambo code.&lt;br /&gt;
&lt;br /&gt;
Or if you wish you can learn  also how to start from the DFT simulations doing a scf and nscf calculation, entering in &#039;&#039;&#039;PWSCF&#039;&#039;&#039; folder. In this way you will see how you can create the &#039;&#039;&#039;SAVE&#039;&#039;&#039; folder starting from *.save directory produced by pw.x.&lt;br /&gt;
&lt;br /&gt;
==DFT calculation of bulk hBN and conversion to Yambo==&lt;br /&gt;
&lt;br /&gt;
In this module you will learn how to generate the Yambo &#039;&#039;SAVE&#039;&#039; folder for bulk hBN starting from a PWscf calculation.&lt;br /&gt;
&lt;br /&gt;
=== DFT calculations ===&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/PWSCF&lt;br /&gt;
 $ ls&lt;br /&gt;
 Inputs		Pseudos		PostProcessing		References&lt;br /&gt;
 hBN_scf.in	hBN_nscf.in     hBN_scf_plot_bands.in  hBN_nscf_plot_bands.in &lt;br /&gt;
&lt;br /&gt;
First run the SCF calculation to generate the ground-state charge density, occupations, Fermi level, and so on:&lt;br /&gt;
 $ pw.x &amp;lt; hBN_scf.in &amp;gt; hBN_scf.out&lt;br /&gt;
Inspection of the output shows that the valence band maximum lies at 5.06eV.&lt;br /&gt;
&lt;br /&gt;
Next run a non-SCF calculation to generate a set of Kohn-Sham eigenvalues and eigenvectors for both occupied and unoccupied states (100 bands): &lt;br /&gt;
 $ pw.x &amp;lt; hBN_nscf.in &amp;gt; hBN_nscf.out                  &#039;&#039;(serial run, ~1 min) OR&#039;&#039;&lt;br /&gt;
 $ mpirun -np 2 pw.x &amp;lt; hBN_nscf.in &amp;gt; hBN_nscf.out       &#039;&#039;(parallel run, 40s)&#039;&#039;&lt;br /&gt;
Here we use a &#039;&#039;6x6x2&#039;&#039; grid giving 14 k-points, but denser grids should be used for checking convergence of Yambo runs.&lt;br /&gt;
&lt;br /&gt;
Note the presence of the following flags in the input file:&lt;br /&gt;
 wf_collect=.true.&lt;br /&gt;
 force_symmorphic=.true.&lt;br /&gt;
 diago_thr_init=5.0e-6,&lt;br /&gt;
 diago_full_acc=.true.&lt;br /&gt;
which are needed for generating the Yambo databases accurately. Full explanations of these variables are given on the [http://www.quantum-espresso.org/wp-content/uploads/Doc/INPUT_PW.html quantum-ESPRESSO input variables page]. &lt;br /&gt;
&lt;br /&gt;
After these two runs, you should have a &#039;&#039;hBN.save&#039;&#039; directory:&lt;br /&gt;
 $ ls hBN.save&lt;br /&gt;
 data-file.xml charge-density.dat gvectors.dat B.pz-vbc.UPF N.pz-vbc.UPF&lt;br /&gt;
 K00001	K00002 .... 	K00035	K00036&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
Once you have performed a nscf simulation with pw.x the PWscf &#039;&#039;bBN.save&#039;&#039; should not be empty and you can then convert it to the Yambo format using the &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt; executable (pwscf to yambo), found in the yambo &#039;&#039;bin&#039;&#039; directory.&lt;br /&gt;
Enter &#039;&#039;hBN.save&#039;&#039; and launch &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd hBN.save&lt;br /&gt;
 $ p2y&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;--%-&amp;gt; DBs path set to .&lt;br /&gt;
 &amp;lt;--%-&amp;gt; Index file set to data-file.xml&lt;br /&gt;
 &amp;lt;--%-&amp;gt; Header/K-points/Energies... done&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;--%-&amp;gt; == DB1 (Gvecs and more) ...&lt;br /&gt;
 &amp;lt;--%-&amp;gt; ... Database done&lt;br /&gt;
 &amp;lt;--%-&amp;gt; == DB2 (wavefunctions)  ... done ==&lt;br /&gt;
 &amp;lt;--%-&amp;gt; == DB3 (PseudoPotential) ... done ==&lt;br /&gt;
 &amp;lt;--%-&amp;gt;  == P2Y completed ==&lt;br /&gt;
&lt;br /&gt;
This output repeats some information about the system and generates a &#039;&#039;SAVE&#039;&#039; directory:&lt;br /&gt;
 $ ls SAVE&lt;br /&gt;
 ns.db1  ns.wf  ns.kb_pp_pwscf&lt;br /&gt;
 ns.wf_fragments_1_1 ...&lt;br /&gt;
 ns.kb_pp_pwscf_fragment_1 ...&lt;br /&gt;
These files, with an &#039;&#039;n&#039;&#039; prefix, indicate that they are in netCDF format, and thus not human readable. However, they are perfectly transferable across different architectures. You can check that the databases contain the information you expect by launching Yambo using the &amp;lt;code&amp;gt;-D&amp;lt;/code&amp;gt; option:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -D&lt;br /&gt;
 [RD./SAVE//ns.db1]------------------------------------------&lt;br /&gt;
 Bands                           : 100&lt;br /&gt;
 K-points                        : 14&lt;br /&gt;
 G-vectors             [RL space]:  8029&lt;br /&gt;
 Components       [wavefunctions]: 1016&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./SAVE//ns.wf]-------------------------------------------&lt;br /&gt;
 Fragmentation                    :yes&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./SAVE//ns.kb_pp_pwscf]----------------------------------&lt;br /&gt;
 Fragmentation                    :yes&lt;br /&gt;
 - S/N 006626 -------------------------- v.04.01.02 r.00000 -&lt;br /&gt;
&lt;br /&gt;
In practice we suggest to move the &#039;&#039;SAVE&#039;&#039; folder into a new clean folder. &lt;br /&gt;
&lt;br /&gt;
In this tutorial however, we ask instead that you continue using a &#039;&#039;SAVE&#039;&#039; folder that we prepared previously:&lt;br /&gt;
 $ cd ../../YAMBO&lt;br /&gt;
 $ ls&lt;br /&gt;
 SAVE&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
&amp;lt;!-- Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously.  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every Yambo run &#039;&#039;&#039;must&#039;&#039;&#039; start with this step. Go to the folder &#039;&#039;containing&#039;&#039; the hBN-bulk &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ ls&lt;br /&gt;
 SAVE&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TIP&#039;&#039;&#039;: do not run yambo from &#039;&#039;inside&#039;&#039; the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder!&lt;br /&gt;
&#039;&#039;&#039;This is the wrong way .. &#039;&#039;&#039;&lt;br /&gt;
 $ cd SAVE&lt;br /&gt;
 $ yambo&lt;br /&gt;
 yambo: cannot access CORE database (SAVE/*db1 and/or SAVE/*wf)&lt;br /&gt;
In fact, if you ever see such message:&lt;br /&gt;
it usually means you are trying to launch Yambo &#039;&#039;&#039;from the wrong place&#039;&#039;&#039;.&lt;br /&gt;
 $ cd ..&lt;br /&gt;
&lt;br /&gt;
Now you are in the proper place and&lt;br /&gt;
 $ ls&lt;br /&gt;
 SAVE&lt;br /&gt;
you can simply launch the code&lt;br /&gt;
 $ yambo &lt;br /&gt;
This will run the initialization (setup) &#039;&#039;runlevel&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
===Run-time output===&lt;br /&gt;
This is typically written to standard output (on screen) and tracks the progress of the run in real time:&lt;br /&gt;
 &amp;lt;---&amp;gt; [01] MPI/OPENMP structure, Files &amp;amp; I/O Directories&lt;br /&gt;
 &amp;lt;---&amp;gt; [02] CORE Variables Setup&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.01] Unit cells&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.02] Symmetries&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.03] Reciprocal space&lt;br /&gt;
 &amp;lt;---&amp;gt; Shells finder |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.04] K-grid lattice&lt;br /&gt;
 &amp;lt;---&amp;gt; Grid dimensions      :   6   6   2&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.05] Energies &amp;amp; Occupations&lt;br /&gt;
 &amp;lt;---&amp;gt; [03] Transferred momenta grid and indexing&lt;br /&gt;
 &amp;lt;---&amp;gt; BZ -&amp;gt; IBZ reduction |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [03.01] X indexes&lt;br /&gt;
 &amp;lt;---&amp;gt; X [eval] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; X[REDUX] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [03.01.01] Sigma indexes&lt;br /&gt;
 &amp;lt;---&amp;gt; Sigma [eval] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; Sigma[REDUX] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Timing Overview&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Memory Overview&lt;br /&gt;
 &amp;lt;---&amp;gt; [06] Game Over &amp;amp; Game summary&lt;br /&gt;
Specific runlevels are indicated with numeric labels like [02.02]. &amp;lt;br&amp;gt;&lt;br /&gt;
The hashes (#) indicate progress of the run in Wall Clock time, indicating the elapsed (E) and expected (X) time to complete a runlevel, and the percentage of the task complete.&lt;br /&gt;
In this case the simulation was so fast that there is not output. On longer simulations you will be able to appreciate this feature.&lt;br /&gt;
&lt;br /&gt;
===New core databases===&lt;br /&gt;
New databases appear in the &#039;&#039;SAVE&#039;&#039; folder:&lt;br /&gt;
 $ ls SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf &#039;&#039;&#039;ndb.gops ndb.kindx&#039;&#039;&#039;&lt;br /&gt;
 ns.wf_fragments_1_1 ...&lt;br /&gt;
 ns.kb_pp_pwscf_fragment_1 ...&lt;br /&gt;
These contain information about the &#039;&#039;G&#039;&#039;-vector shells and &#039;&#039;k/q&#039;&#039;-point meshes as defined by the DFT calculation.&lt;br /&gt;
&lt;br /&gt;
In general: a database called &#039;&#039;n&#039;&#039;&#039;s&#039;&#039;&#039;.xxx&#039;&#039; is a &#039;&#039;static&#039;&#039; database, generated once by &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt;, while databases called &#039;&#039;n&#039;&#039;&#039;db&#039;&#039;&#039;.xxx&#039;&#039; are &#039;&#039;dynamically&#039;&#039; generated while you use &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TIP&#039;&#039;&#039;: if you launch &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;, but it does not seem to do anything, check that these files are present.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Report file===&lt;br /&gt;
A report file &#039;&#039;r_setup&#039;&#039; is generated in the run directory. &lt;br /&gt;
This mostly reports information about the ground state system as defined by the DFT run, but also adds information about the band gaps, occupations, shells of G-vectors, IBZ/BZ grids, the CPU structure (for parallel runs), and so on. Some points of note:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Up to Yambo version 4.5&lt;br /&gt;
  [02.03] RL shells&lt;br /&gt;
  =================&lt;br /&gt;
  Shells, format: [S#] G_RL(mHa)&lt;br /&gt;
   [S453]:8029(0.7982E+5) [S452]:8005(0.7982E+5) [S451]:7981(0.7982E+5) [S450]:7957(0.7942E+5)&lt;br /&gt;
   ...&lt;br /&gt;
   [S4]:11( 1183.) [S3]:5( 532.5123) [S2]:3( 133.1281) [S1]:1( 0.000000)&lt;br /&gt;
&lt;br /&gt;
From Yambo version 5.0&lt;br /&gt;
  [02.03] Reciprocal space&lt;br /&gt;
  ========================&lt;br /&gt;
  &lt;br /&gt;
  nG shells         :  217&lt;br /&gt;
  nG charge         :   3187&lt;br /&gt;
  nG WFs            :  1477&lt;br /&gt;
  nC WFs            :  1016&lt;br /&gt;
  G-vecs. in first 21 shells:  [ Number ]&lt;br /&gt;
     1    3    5   11   13   25   37   39   51&lt;br /&gt;
    63   65   71   83   95  107  113  125  127&lt;br /&gt;
   139  151  163&lt;br /&gt;
  ...&lt;br /&gt;
  Shell energy in first 21 shells:  [ mHa ]&lt;br /&gt;
    0.00000      133.128      532.512      1183.37      1198.15      1316.50      1715.88      2130.05      2381.52&lt;br /&gt;
    3313.42      3328.20      3550.11      3683.24      4082.62      4511.57      4733.48      4748.27      4792.61&lt;br /&gt;
    4866.61      5266.00      5680.16&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This reports the set of closed reciprocal lattice (RL) shells defined internally that contain G-vectors with the same modulus. &lt;br /&gt;
The highest number of RL vectors we can use is 8029.  Yambo will always redefine any input variable in RL units to the nearest closed shell.&lt;br /&gt;
&lt;br /&gt;
Up to Yambo version 4.5&lt;br /&gt;
  [02.05] Energies [ev] &amp;amp; Occupations&lt;br /&gt;
  ===================================&lt;br /&gt;
  Fermi Level        [ev]:  5.112805&lt;br /&gt;
  VBM / CBm          [ev]:  0.000000  3.876293&lt;br /&gt;
  Electronic Temp. [ev K]:  0.00      0.00&lt;br /&gt;
  Bosonic    Temp. [ev K]:  0.00      0.00&lt;br /&gt;
  El. density      [cm-3]: 0.460E+24&lt;br /&gt;
  States summary         : Full        Metallic    Empty&lt;br /&gt;
                           0001-0008               0009-0100&lt;br /&gt;
  Indirect Gaps      [ev]: 3.876293  7.278081&lt;br /&gt;
  Direct Gaps        [ev]:  4.28829  11.35409&lt;br /&gt;
  X BZ K-points :  72&lt;br /&gt;
&lt;br /&gt;
From Yambo version 5.0&lt;br /&gt;
  [02.05] Energies &amp;amp; Occupations&lt;br /&gt;
  ==============================&lt;br /&gt;
  &lt;br /&gt;
  [X] === General ===&lt;br /&gt;
  [X] Electronic Temperature                        :  0.000000  0.000000 [eV K]&lt;br /&gt;
  [X] Bosonic    Temperature                        :  0.000000  0.000000 [eV K]&lt;br /&gt;
  [X] Finite Temperature mode                       : no&lt;br /&gt;
  [X] El. density                                   :  0.46037E+24 [cm-3]&lt;br /&gt;
  [X] Fermi Level                                   :  5.110835 [eV]&lt;br /&gt;
  &lt;br /&gt;
  [X] === Gaps and Widths ===&lt;br /&gt;
  [X] Conduction Band Min                           :  3.877976 [eV]&lt;br /&gt;
  [X] Valence Band Max                              :  0.000000 [eV]&lt;br /&gt;
  [X] Filled Bands                                  :   8&lt;br /&gt;
  [X] Empty Bands                                   :    9  100&lt;br /&gt;
  [X] Direct Gap                                    :  4.289853 [eV]&lt;br /&gt;
  [X] Direct Gap localized at k-point               :   7&lt;br /&gt;
  [X] Indirect Gap                                  :  3.877976 [eV]&lt;br /&gt;
  [X] Indirect Gap between k-points                 :  14   7&lt;br /&gt;
  [X] Last valence band width                       :  3.401086 [eV]&lt;br /&gt;
  [X] 1st conduction band width                     :  4.266292 [eV]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Yambo recalculates again the Fermi level (close to the value of 5.06 noted in the PWscf SCF calculation). From here on, however, the Fermi level is set to zero, and other eigenvalues are shifted accordingly. The system is insulating (8 filled, 92 empty) with an indirect band gap of 3.87 eV. The minimum and maximum direct and indirect gaps are indicated. There are 72 k-points in the full BZ, generated using symmetry from the 14 k-points in our user-defined grid.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;TIP&#039;&#039;&#039;: You should inspect the report file after &#039;&#039;every&#039;&#039; run for errors and warnings.&lt;br /&gt;
&lt;br /&gt;
===Different ways of running yambo===&lt;br /&gt;
We just run Yambo interactively.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s try to re-run the setup with the command&lt;br /&gt;
 $ nohup yambo &amp;amp;&lt;br /&gt;
 $ ls&lt;br /&gt;
 l_setup  nohup.out  r_setup  r_setup_01  SAVE&lt;br /&gt;
&lt;br /&gt;
If Yambo is launched using a script, or as a background process, or in parallel, this output will appear in a log file prefixed by the letter &#039;&#039;l&#039;&#039;, in this case as &#039;&#039;l_setup&#039;&#039;.&lt;br /&gt;
If this log file already exists from a previous run, it will not be overwritten. Instead, a new file will be created with an incrementing numerical label, e.g. &#039;&#039;l_setup_01, l_setup_02&#039;&#039;, etc. &#039;&#039;&#039;This applies to all files created by Yambo&#039;&#039;&#039;. Here we see that l_setup was created for the first time, but r_setup already existed from the previous run, so now we have r_setup_01&lt;br /&gt;
If you check the differences between the two you will notice that in the second run yambo is reading the previously created ndb.kindx in place of re-computing the indexes.&lt;br /&gt;
Indeed the output inside l_setup does not show the timing for X and Sigma&lt;br /&gt;
&lt;br /&gt;
As a last step we run the setup in parallel, but first we delete the ndb.kindx file &lt;br /&gt;
 $ rm SAVE/ndb.kindx&lt;br /&gt;
 $ mpirun -np 4 yambo &lt;br /&gt;
 $ ls&lt;br /&gt;
 LOG  l_setup  nohup.out  r_setup  r_setup_01  r_setup_02  SAVE&lt;br /&gt;
There is now r_setup_02&lt;br /&gt;
In the case of parallel runs, CPU-dependent log files will appear inside a &#039;&#039;LOG&#039;&#039; folder, e.g. &lt;br /&gt;
 $ ls LOG&lt;br /&gt;
 l_setup_CPU_1   l_setup_CPU_2  l_setup_CPU_3  l_setup_CPU_4&lt;br /&gt;
This behaviour can be controlled at runtime - see the Parallel tutorial for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===2D hBN===&lt;br /&gt;
Simply repeat the steps above. Go to the folder &#039;&#039;containing&#039;&#039; the hBN-sheet &#039;&#039;SAVE&#039;&#039; directory and launch &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;:&lt;br /&gt;
 $ cd TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls&lt;br /&gt;
 SAVE&lt;br /&gt;
 $ yambo&lt;br /&gt;
Again, inspect the &#039;&#039;r_setup&#039;&#039; file, output logs, and verify that &#039;&#039;ndb.gops&#039;&#039; and &#039;&#039;ndb.kpts&#039;&#039; have been created inside the SAVE folder.&lt;br /&gt;
&lt;br /&gt;
You are now ready to use Yambo!&lt;br /&gt;
&lt;br /&gt;
==Yambo&#039;s command line interface==&lt;br /&gt;
Yambo uses a command line interface to select tasks, generate input files, and control the runtime behaviour. &lt;br /&gt;
&lt;br /&gt;
In this module you will learn how to select tasks, generate and modify input files, and control the runtime behaviour by using Yambo&#039;s command line interface.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Command line options are divided into &#039;&#039;&#039;uppercase&#039;&#039;&#039; and &#039;&#039;&#039;lowercase&#039;&#039;&#039; options:&lt;br /&gt;
* Lowercase: select tasks, generate input files, and (by default) launch a file editor&lt;br /&gt;
* Uppercase: modify Yambo&#039;s default settings, at run time and when generating input files&lt;br /&gt;
Lowercase and uppercase options can be used together.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Input file generator ===&lt;br /&gt;
First, move to the appropriate folder and initialize the Yambo databases if you haven&#039;t already done so.&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo                    &#039;&#039;(initialize)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Yambo generates its own input files: you just tell the code what you want to calculate by launching Yambo along with one or more options. &lt;br /&gt;
To see the list of possible options, run &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt;  (we report here only the part we are focusing in)&lt;br /&gt;
 $ yambo -h&lt;br /&gt;
 &#039;A shiny pot of fun and happiness [C.D.Hogan]&#039; &lt;br /&gt;
 &lt;br /&gt;
 This is      : yambo&lt;br /&gt;
 Version      : 5.0.1 Revision 19547 Hash e90d90f2d&lt;br /&gt;
 Configuration: MPI+OpenMP+SLK+SLEPC+HDF5_MPI_IO&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 Initializations:&lt;br /&gt;
 -setup           (-i)            :Initialization&lt;br /&gt;
 -coulomb         (-r)            :Coulomb potential&lt;br /&gt;
 &lt;br /&gt;
 Response Functions:&lt;br /&gt;
 -optics          (-o) &amp;lt;string&amp;gt;   :Linear Response optical properties (more with -h optics)&lt;br /&gt;
 -X               (-d) &amp;lt;string&amp;gt;   :Inverse Dielectric Matrix (more with -h X)&lt;br /&gt;
 -dipoles         (-q)            :Oscillator strenghts (or dipoles)&lt;br /&gt;
 -kernel          (-k) &amp;lt;string&amp;gt;   :Kernel (more with -h kernel)&lt;br /&gt;
 &lt;br /&gt;
 Self-Energy:&lt;br /&gt;
 -hf              (-x)            :Hartree-Fock&lt;br /&gt;
 -gw0             (-p) &amp;lt;string&amp;gt;   :GW approximation (more with -h gw0)&lt;br /&gt;
 -dyson           (-g) &amp;lt;string&amp;gt;   :Dyson Equation solver (more with -h dyson)&lt;br /&gt;
 -lifetimes       (-l)            :GoWo Quasiparticle lifetimes&lt;br /&gt;
 &lt;br /&gt;
 Bethe-Salpeter Equation:&lt;br /&gt;
 -Ksolver         (-y) &amp;lt;string&amp;gt;   :BSE solver (more with -h Ksolver)&lt;br /&gt;
 &lt;br /&gt;
 Total Energy:&lt;br /&gt;
 -acfdt                           :ACFDT Total Energy&lt;br /&gt;
 &lt;br /&gt;
 Utilites:&lt;br /&gt;
 ...&lt;br /&gt;
 -slktest                         :ScaLapacK test&lt;br /&gt;
&lt;br /&gt;
The options can be split into two sets: &amp;lt;br&amp;gt;&lt;br /&gt;
* A set of options which is needed to generate the appropriate input file (default name: &#039;&#039;yambo.in&#039;&#039;) selecting the kind of simulation you would like to perform  &amp;lt;br&amp;gt;&lt;br /&gt;
* A set of options which can be used to manage auxiliary functions (like redirect the I/O, choose a specific name for the input file, etc ..). &lt;br /&gt;
&lt;br /&gt;
===Runlevel selection===&lt;br /&gt;
First of all, you would like to specify which kind of simulation you are going to perform and generate an input file with the first set of options. &lt;br /&gt;
By default, when generating the input file, Yambo will launch the &amp;lt;code&amp;gt;vi&amp;lt;/code&amp;gt; editor.&lt;br /&gt;
Editor choice can be changed when launching the configure before compilation; alternatively you can use the &amp;lt;code&amp;gt;-Q&amp;lt;/code&amp;gt; run time option to skip the automatic editing (do this if you are not familiar with &amp;lt;code&amp;gt;vi&amp;lt;/code&amp;gt;!):&lt;br /&gt;
 $ yambo -hf -Q&lt;br /&gt;
 yambo: input file yambo.in created&lt;br /&gt;
 $ emacs yambo.in     &#039;&#039;or your favourite editing tool&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Multiple options can be used together to activate various tasks or runlevels (in some cases this is actually a necessity). &lt;br /&gt;
For instance, to generate an input file for optical spectra including local field effects (Hartree approximation), do (and then exit)&lt;br /&gt;
 $ yambo -optics c -kernel hartree       &#039;&#039;which switches on:&#039;&#039;&lt;br /&gt;
 optics                       # [R OPT] Optics&lt;br /&gt;
 chi                          # [R CHI] Dyson equation for Chi.&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
To perform a Hartree-Fock and GW calculation using a plasmon-pole approximation, do (and then exit):&lt;br /&gt;
 $ yambo -hf -gw0 p -dyson n        &#039;&#039;which switches on:&#039;&#039;&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix      &lt;br /&gt;
Each runlevel activates its own list of variables and flags.&lt;br /&gt;
&lt;br /&gt;
The previous command is also equivalent to&lt;br /&gt;
 $ yambo -hf -gw0 r -dyson n -X p&lt;br /&gt;
&lt;br /&gt;
===Changing input parameters ===&lt;br /&gt;
Yambo reads various parameters from existing database files and/or input files and uses them to suggest values or ranges. &lt;br /&gt;
Let&#039;s illustrate this by generating the input file for a Hartree-Fock calculation. &lt;br /&gt;
&lt;br /&gt;
 $ yambo -hf&lt;br /&gt;
Inside the generated input file you should find:&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] =  3187        RL    # [XX] Exchange RL components&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
   1| 14|  6|10|&lt;br /&gt;
 %&lt;br /&gt;
The &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable (follow the link for a &amp;quot;detailed&amp;quot; explanation for any variable) suggests a range of k-points (1 to 14) and bands (1 to 100) based on what it finds in the core database &#039;&#039;SAVE/ns.db1&#039;&#039;, i.e. as defined by the DFT code. &amp;lt;br&amp;gt;&lt;br /&gt;
Leave that variable alone, and instead modify the previous variable to &amp;lt;code&amp;gt;EXXRLvcs=  1000        RL&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file, and now generate the input a second time with &amp;lt;code&amp;gt;yambo -x&amp;lt;/code&amp;gt;. You will see:&lt;br /&gt;
  [[Variables#EXXRLvcs|EXXRLvcs]]=  1009        RL&lt;br /&gt;
This indicates that Yambo has read the new input value (1000 G-vectors), checked the database of G-vector shells &#039;&#039;(SAVE/ndb.gops)&#039;&#039;, &lt;br /&gt;
and changed the input value to one that fits a completely closed shell.&lt;br /&gt;
&lt;br /&gt;
Last, note that Yambo variables can be expressed in different &#039;&#039;&#039;units&#039;&#039;&#039;. In this case, &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; can be replaced by an energy unit like Ry, eV, Ha, etc. Energy units are generally better as they are independent of the cell size. Technical information is available on the [[Variables]] page. &lt;br /&gt;
&lt;br /&gt;
The input file generator of Yambo is thus an &#039;&#039;intelligent&#039;&#039; parser, which interacts with the user and the existing databases. For this reason we recommend that you always use Yambo to generate the input files, rather than making them yourself.&lt;br /&gt;
&lt;br /&gt;
===Extra options===&lt;br /&gt;
Extra options modify some of the code&#039;s default settings. They can be used when launching the code but also when generating input files. &lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look again to the possible options (we report here only the part we are focusing in):&lt;br /&gt;
 $ yambo -h&lt;br /&gt;
 This is      : yambo&lt;br /&gt;
 Version      : 5.0.1 Revision 19547 Hash e90d90f2d &lt;br /&gt;
 Configuration: MPI+OpenMP+SLK+SLEPC+HDF5_MPI_IO &lt;br /&gt;
 &lt;br /&gt;
 Help &amp;amp; version:&lt;br /&gt;
 -help            (-h) &amp;lt;string&amp;gt;   :&amp;lt;string&amp;gt; can be an option (e.g. -h optics)&lt;br /&gt;
 -version                         :Code version &amp;amp; libraries&lt;br /&gt;
 &lt;br /&gt;
 Input file &amp;amp; Directories:&lt;br /&gt;
 -Input           (-F) &amp;lt;string&amp;gt;   :Input file&lt;br /&gt;
 -Verbosity       (-V) &amp;lt;string&amp;gt;   :Input file variables verbosity (more with -h Verbosity)&lt;br /&gt;
 -Job             (-J) &amp;lt;string&amp;gt;   :Job string&lt;br /&gt;
 -Idir            (-I) &amp;lt;string&amp;gt;   :Input directory&lt;br /&gt;
 -Odir            (-O) &amp;lt;string&amp;gt;   :I/O directory&lt;br /&gt;
 -Cdir            (-C) &amp;lt;string&amp;gt;   :Communication directory&lt;br /&gt;
 &lt;br /&gt;
 Parallel Control:&lt;br /&gt;
 -parenv          (-E) &amp;lt;string&amp;gt;   :Environment Parallel Variables file&lt;br /&gt;
 -nompi                           :Switch off MPI support&lt;br /&gt;
 -noopenmp                        :Switch off OPENMP support&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 Utilites:&lt;br /&gt;
 -Quiet           (-Q)            :Quiet input file creation&lt;br /&gt;
 -fatlog                          :Verbose (fatter) log(s)&lt;br /&gt;
 -DBlist          (-D)            :Databases properties&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Command line options are extremely important to master if you want to use yambo productively. &lt;br /&gt;
Often, the meaning is clear from the help menu:&lt;br /&gt;
 $ yambo -F yambo.in_HF -hf   &#039;&#039;Make a Hartree-Fock input file called yambo.in_HF&#039;&#039;&lt;br /&gt;
 $ yambo -D                   &#039;&#039;Summarize the content of the databases in the SAVE folder&#039;&#039;&lt;br /&gt;
 $ yambo -I ../               &#039;&#039;Run the code, using a SAVE folder in a directory one level up&#039;&#039;&lt;br /&gt;
 $ yambo -C MyTest            &#039;&#039;Run the code, putting all report, log, plot files inside a folder MyTest&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
Other options deserve a closer look.&lt;br /&gt;
&lt;br /&gt;
===Verbosity===&lt;br /&gt;
Yambo uses &#039;&#039;many&#039;&#039; input variables, many of which can be left at their default values. To keep input files short and manageable, only a few variables appear by default  in the inout file. More advanced variables can be switched on by using the &amp;lt;code&amp;gt;-V&amp;lt;/code&amp;gt; verbosity option. These are grouped according to the type of variable. For instance, &amp;lt;code&amp;gt;-V RL&amp;lt;/code&amp;gt; switches on variables related to G vector summations, and &amp;lt;code&amp;gt;-V io&amp;lt;/code&amp;gt; switches on options related to I/O control. Try: &lt;br /&gt;
&lt;br /&gt;
 $ yambo -optics c -V RL       &#039;&#039;switches on:&#039;&#039;&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 &lt;br /&gt;
 $ yambo -optics c -V io       &#039;&#039;switches on:&#039;&#039;&lt;br /&gt;
 StdoHash=  40                # [IO] Live-timing Hashes&lt;br /&gt;
 DBsIOoff= &amp;quot;none&amp;quot;             # [IO] Space-separated list of DB with NO I/O. DB= ...&lt;br /&gt;
 DBsFRAGpm= &amp;quot;none&amp;quot;            # [IO] Space-separated list of +DB to be FRAG and ...&lt;br /&gt;
 #WFbuffIO                    # [IO] Wave-functions buffered I/O&lt;br /&gt;
&lt;br /&gt;
Unfortunately, -V options must be invoked and changed &#039;&#039;one at a time&#039;&#039;. When you are more expert, you may go straight to &amp;lt;code&amp;gt;-V all&amp;lt;/code&amp;gt;, which turns on all possible variables. However note that &amp;lt;code&amp;gt;yambo -o c -V all&amp;lt;/code&amp;gt; adds an extra 30 variables to the input file, which can be confusing: use it with care.&lt;br /&gt;
&lt;br /&gt;
===Job script label===&lt;br /&gt;
The best way to keep track of different runs using different parameters is through the &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag. This inserts a label in all output and report files, and creates a new folder containing any new databases (i.e. they are not written in the core &#039;&#039;SAVE&#039;&#039; folder). Try:&lt;br /&gt;
 $ yambo -V RL -hf -F yambo_hf.in        &#039;&#039;and modify to&#039;&#039;&lt;br /&gt;
 FFTGvecs = 1 Ry&lt;br /&gt;
 EXXGvecs = 1 Ry&lt;br /&gt;
 $ yambo -J 1Ry -F yambo_hf.in           &#039;&#039;Run the code&#039;&#039;&lt;br /&gt;
 $ ls&lt;br /&gt;
 yambo_hf.in SAVE  &lt;br /&gt;
 o-1Ry.hf r-1Ry_HF_and_locXC 1Ry 1Ry/ndb.HF_and_locXC&lt;br /&gt;
This is extremely useful when running convergence tests, trying out different parameters, etc.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Exercise&#039;&#039;: use &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; to report the properties of all database files (including &#039;&#039;ndb.HF_and_locXC&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:15%; text-align:left&amp;quot;|Prev: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|style=&amp;quot;width:50%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4820</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4820"/>
		<updated>2021-04-06T16:12:31Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Optical absorption in hBN: independent particle approximation ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
The dielectric function in the long-wavelength limit, at the independent particle level (RPA without local fields), is essentially given by the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{\alpha, \alpha}(\omega)=1+\frac{16 \pi}{\Omega} \sum_{c, v} \sum_{\mathbf{k}} \frac{1}{E_{c \mathbf{k}}-E_{v \mathbf{k}}} \frac{\left|\left\langle v \mathbf{k}\left|\mathbf{p}_{\alpha}+\mathrm i\left[V^{\mathrm{NL}}, \mathbf{r}_{\alpha}\right]\right| c \mathbf{k}\right\rangle\right|^{2}}{\left(E_{c \mathbf{k}}-E_{v \mathbf{k}}\right)^{2}-(\omega+\mathrm i \gamma)^{2}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, Yambo does not use this expression directly but solves the Dyson equation for the susceptibility &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt;, which is described in the [[Local fields]] module.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for bulk hBN that contains the &#039;&#039;SAVE&#039;&#039; directory, run the initialization and generate the input file.&lt;br /&gt;
You can type &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; and see the available options for different run-levels.  For an RPA optical spectrum calculation the correct option is &amp;lt;code&amp;gt;yambo -optics c&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;yambo -o c&amp;lt;/code&amp;gt;). Let&#039;s add some command line options:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo               &#039;&#039;(initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -o c&lt;br /&gt;
This corresponds to optical properties in G-space at the independent particle level: in the input file this is indicated by (&amp;lt;code&amp;gt;Chimod= &amp;quot;IP&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Optics runlevel===&lt;br /&gt;
For optical properties we are interested just in the long-wavelength limit &amp;lt;math&amp;gt;\mathbf q = 0&amp;lt;/math&amp;gt;. This always corresponds to the &#039;&#039;first&#039;&#039; &amp;lt;math&amp;gt;\mathbf q&amp;lt;/math&amp;gt;-point in the set of possible &amp;lt;math&amp;gt;\mathbf q =\mathbf k - \mathbf k&#039;&amp;lt;/math&amp;gt;-points. &lt;br /&gt;
Change the following variables in the input file to:&lt;br /&gt;
 % [[Variables#QpntsRX|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsX|ETStpsXd]]= &#039;&#039;&#039;1001&#039;&#039;&#039;               # [Xd] Total Energy steps&lt;br /&gt;
in order to select just the first &amp;lt;math&amp;gt;\mathbf q&amp;lt;/math&amp;gt;. The last variable ensures we generate a smooth spectrum. &lt;br /&gt;
Save the input file and launch the code, keeping the command line options as before (i.e., just remove the lower case options):&lt;br /&gt;
 $ yambo -F yambo.in_IP -J Full&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Optics&lt;br /&gt;
 &amp;lt;---&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Checking dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [X-CG] R(p) Tot o/o(of R):    5499   52992     100&lt;br /&gt;
 &amp;lt;02s&amp;gt; Xo@q[1] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;02s&amp;gt; [06] Timing Overview&lt;br /&gt;
 &amp;lt;02s&amp;gt; [07] Memory Overview&lt;br /&gt;
 &amp;lt;02s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
  &lt;br /&gt;
 $ ls&lt;br /&gt;
 Full   SAVE  yambo.in_IP   r_setup&lt;br /&gt;
 o-Full.eel_q1_ip  o-Full.eps_q1_ip  r-Full_optics_chi&lt;br /&gt;
Let&#039;s take a moment to understand what Yambo has done inside the Optics runlevel:&lt;br /&gt;
# Compute the &amp;lt;math&amp;gt;[\mathbf r, V^\mathrm{NL}]&amp;lt;/math&amp;gt; term&lt;br /&gt;
# Read the wavefunctions from disc [WF]&lt;br /&gt;
# Compute the &#039;&#039;dipoles&#039;&#039;, i.e. matrix elements of &amp;lt;math&amp;gt;\mathbf p&amp;lt;/math&amp;gt;&lt;br /&gt;
# Write the dipoles to disk as &#039;&#039;Full/ndb.dip*&#039;&#039; databases. This you can see in the report file:&lt;br /&gt;
 $ grep -A20 &amp;quot;WR&amp;quot; r-Full_optics_*&lt;br /&gt;
 [WR./Full//ndb.dipoles]---------------------------------------------------------&lt;br /&gt;
  Brillouin Zone Q/K grids (IBZ/BZ)                :   14   72   14   72&lt;br /&gt;
  RL vectors                                       :  1491 [WF]&lt;br /&gt;
  Fragmentation                                    : yes&lt;br /&gt;
  Electronic Temperature                           :  0.000000 [K]&lt;br /&gt;
  Bosonic    Temperature                           :  0.000000 [K]&lt;br /&gt;
  DIP band range                                   :    1  100&lt;br /&gt;
  DIP band range limits                            :   8   9&lt;br /&gt;
  DIP e/h energy range                             : -1.000000 -1.000000 [eV]&lt;br /&gt;
  RL vectors in the sum                            :  1491&lt;br /&gt;
  [r,Vnl] included                                 : yes&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, Yambo computes the non-interacting susceptibility &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; for this &amp;lt;math&amp;gt;\mathbf q&amp;lt;/math&amp;gt;, and writes the dielectric function inside the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; file for plotting&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Energy cut off===&lt;br /&gt;
&lt;br /&gt;
Before plotting the output, let&#039;s change a few more variables. The previous calculation used &#039;&#039;all&#039;&#039; the G-vectors in expanding the wavefunctions, up to 1491 (~1016 components). This corresponds roughly to the cut off energy of 40Ry we used in the DFT calculation. Generally, however, we can use a smaller value. We use the verbosity to switch on this variable, and a new &#039;&#039;-J&#039;&#039; flag to avoid reading the previous database:&lt;br /&gt;
 $ yambo -F yambo.in_IP &#039;&#039;&#039;-V RL&#039;&#039;&#039; -o c&lt;br /&gt;
Change the &#039;&#039;&#039;value&#039;&#039;&#039; of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; and also its &#039;&#039;&#039;unit&#039;&#039;&#039; from &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; (number of G-vectors) to &amp;lt;code&amp;gt;Ry&amp;lt;/code&amp;gt; (energy in Rydberg):&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]= &#039;&#039;&#039;6&#039;&#039;&#039;           &#039;&#039;&#039;Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
Save the input file and launch the code again:&lt;br /&gt;
  $ yambo -F yambo.in_IP &#039;&#039;&#039;-J 6Ry &#039;&#039;&#039;&lt;br /&gt;
and then plot the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; and &#039;&#039;o-6Ry.eps_q1_ip&#039;&#039; files:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-Full.eps_q1_ip&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip&amp;quot; w p&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-6Ry.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
There is very little difference between the two spectra. This highlights an important point in calculating excited state properties: generally, fewer G-vectors are needed than what are needed in DFT calculations. Regarding the spectrum itself, the first peak occurs at about 4.4eV. This is consistent with the minimum direct gap reported by Yambo: 4.28eV. The comparison with experiment (not shown) is very poor however. &lt;br /&gt;
&lt;br /&gt;
If you made some mistake and cannot reproduce this figure, you should check the value of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; in the input file, delete the &#039;&#039;6Ry&#039;&#039; folder, and try again - taking care to plot the right file! (e.g. &#039;&#039;o-6Ry.eps_q1_ip_01&#039;&#039;. The &amp;quot;_01&amp;quot; suffix means that while writing the output Yambo found another existing file with the name &amp;quot;o-6Ry.eps_q1_ip&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===q-direction===&lt;br /&gt;
Now let&#039;s select a different component of the dielectric tensor:&lt;br /&gt;
 $ yambo -F yambo.in_IP -V RL -o c&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry&lt;br /&gt;
This time yambo reads from the &#039;&#039;6Ry&#039;&#039; folder, so it does not need to compute the dipole matrix elements again, and the calculation is fast. Plotting gives:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-6Ry.eps_q1_ip&amp;quot; t &amp;quot;q || x-axis&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip_01&amp;quot; t &amp;quot;q || c-axis&amp;quot; w l&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-ac.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
The absorption is suppressed in the stacking direction. As the interplanar spacing is increased, we would eventually arrive at the absorption of the BN sheet (see [[Local fields]] tutorial).&lt;br /&gt;
&lt;br /&gt;
===Non-local commutator===&lt;br /&gt;
Last, we show the effect of switching off the non-local commutator term (the term with &amp;lt;math&amp;gt; V^\mathrm{NL} &amp;lt;/math&amp;gt; in the equation at the start of this tutorial) due to the pseudopotential. As there is no option to do this inside yambo, you need to hide the database file. Change back to the &#039;&#039;q || (1 0 0)&#039;&#039; direction, and launch yambo with a different &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ mv SAVE/ns.kb_pp_pwscf SAVE/ns.kb_pp_pwscf_&#039;&#039;&#039;OFF&#039;&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J &#039;&#039;&#039;6Ry_NoVnl&#039;&#039;&#039; -o c             &lt;br /&gt;
&lt;br /&gt;
Change &lt;br /&gt;
&lt;br /&gt;
  %LonDrXd&lt;br /&gt;
&lt;br /&gt;
back to &lt;br /&gt;
&lt;br /&gt;
  &#039;&#039;&#039;1.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;0.000000&#039;&#039;&#039; | &lt;br /&gt;
&lt;br /&gt;
and run&lt;br /&gt;
 &lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry_NoVnl&lt;br /&gt;
&lt;br /&gt;
Note the warning in the output:&lt;br /&gt;
 &amp;lt;---&amp;gt; [WARNING] Missing commutator with non-local pseudopotential contribution in position and velocity dipoles&lt;br /&gt;
which also appears in the report file &amp;lt;code&amp;gt;r-6Ry_NoVnl_optics_dipoles_chi&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;[r,Vnl] included       :no&amp;lt;/code&amp;gt;. The difference is tiny:&lt;br /&gt;
[[File:CH-hBN-Vnl.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
However, when your system is larger, with more projectors in the pseudopotential or more k-points (see the BSE tutorial), the inclusion of &amp;lt;math&amp;gt;V^\mathrm{NL}&amp;lt;/math&amp;gt; can make a huge difference in the computational load, so it is always worth checking to see if the terms are important in your system.&lt;br /&gt;
&lt;br /&gt;
==Optical absorption in 2D BN: local field effects ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
[[File:Yambo-Cheatsheet-5.0_P7.png|thumb|Cheatsheet on LFE|150px]]&lt;br /&gt;
The macroscopic dielectric function is obtained by including the so-called local field effects (LFE) in the calculation of the response function. Within the time-dependent DFT formalism this is achieved by solving the Dyson equation for the susceptibility &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt;. In reciprocal space this is given by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\chi_{\mathbf{G}, \mathbf{G}^{\prime}}(\mathbf{q}, \omega) = \chi_{\mathbf{G}, \mathbf{G}^{\prime}}^{0}(\mathbf{q}, \omega)+\sum_{\mathbf{G}_{1}, \mathbf{G}_{2}} \chi_{\mathbf{G}, \mathbf{G}_{1}}^{0}(\mathbf{q}, \omega)\left[v_{\mathbf{G}_{1}}(\mathbf{q}) \delta_{\mathbf{G}_{1}, \mathbf{G}_{2}}+f_{\mathbf{G}_{1}, \mathbf{G}_{2}}^{x c}\right] \chi_{\mathbf{G}_{2}, \mathbf{G}^{\prime}}(\mathbf{q}, \omega)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The microscopic dielectric function is related to &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{\mathbf{G}, \mathbf{G}^{\prime}}^{-1}(\mathbf{q}, \omega)=\delta_{\mathbf{G}, \mathbf{G}^{\prime}}+v_{\mathbf{G}}(\mathbf{q}) \chi_{\mathbf{G}, \mathbf{G}^{\prime}}(\mathbf{q}, \omega)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the macroscopic dielectric function is obtained by taking the (0,0) component of the inverse microscopic one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{M}(\omega)=\lim _{\mathrm{q} \rightarrow 0} \frac{1}{\epsilon_{\mathrm{G}=0, \mathrm{G}^{\prime}=0}^{-1}(\mathbf{q}, \omega)}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experimental observables like the optical absorption and the electron energy loss can be obtained from the macroscopic dielectric function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\operatorname{Abs}(\omega)=\operatorname{Im} \epsilon_{M}(\omega) \quad \operatorname{EELS}(\omega)=-\operatorname{Im} \frac{1}{\epsilon_{M}(\omega)}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the following we will neglect the &amp;lt;math&amp;gt;f^{xc}&amp;lt;/math&amp;gt; term: we perform the calculation at the RPA level and consider just the Hartree term (from &amp;lt;math&amp;gt;v_G&amp;lt;/math&amp;gt;) in the kernel. If we also neglect the Hartree term, we arrive back at the independent particle approximation, since there is no kernel and &amp;lt;math&amp;gt;\chi = \chi_0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for 2D hBN that contains the SAVE directory, and generate the input file. To include local the local fields variables in the input file the correct option is &amp;lt;code&amp;gt;yambo -o c -k hartree&amp;lt;/code&amp;gt; (once again you can check it with &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt;). Let&#039;s start by running the calculation for light polarization &#039;&#039;q&#039;&#039; in the plane of the BN sheet:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree&lt;br /&gt;
We thus use a new input file &#039;&#039;yambo.in_RPA&#039;&#039;, switch on the &amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt; variable, and label all outputs/databases with a &#039;&#039;q100&#039;&#039; tag. Make sure to set/modify all of the following variables to:&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]=     &#039;&#039;&#039;6        Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
 [[Variables#Chimod|Chimod]]= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]= &#039;&#039;&#039;    3        Ry&#039;&#039;&#039;    # [Xd] Response block size&lt;br /&gt;
 % [[Variables#QpntsRXd|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#EnRngeXd|EnRngeXd]]&lt;br /&gt;
  0.00000 | &#039;&#039;&#039;20.00000&#039;&#039;&#039; | eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#DmRngeXd|DmRngeXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.200000&#039;&#039;&#039; | &#039;&#039;&#039;0.200000&#039;&#039;&#039; | eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsXd|ETStpsXd]]= 2001               # [Xd] Total Energy steps&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
In this input file:&lt;br /&gt;
* We evaluate the &amp;lt;math&amp;gt;\mathbf q \rightarrow 0&amp;lt;/math&amp;gt; response function choosing the direction for the limit parallel in the plane of the hBN sheet; &lt;br /&gt;
* We set a wider energy range than before, and a larger broadening;&lt;br /&gt;
* We select the Hartree kernel, and expanded G-vectors in the screening up to 3 Ry (about 85 G-vectors);&lt;br /&gt;
&lt;br /&gt;
===LFEs in periodic direction===&lt;br /&gt;
Now let&#039;s run the code with this new input file (CECAM in serial: about 2mins; parallel 4 tasks: 50s)&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J q100 &lt;br /&gt;
and let&#039;s compare the absorption with and without the local fields included. By inspecting the &#039;&#039;o-q100.eps_q1_inv_rpa_dyson&#039;&#039; file we find that this information is given in the 2&amp;lt;math&amp;gt;^\mathrm{nd}&amp;lt;/math&amp;gt; and 4&amp;lt;math&amp;gt;^\mathrm{th}&amp;lt;/math&amp;gt; columns, respectively:&lt;br /&gt;
 $ head -n 40 o-q100.eps_q1_inv_rpa_dyson&lt;br /&gt;
 # Absorption @ Q(1) [q-&amp;gt;0 direction] : 1.0000000  0.0000000  0.0000000&lt;br /&gt;
 #  E/ev[1]     EPS-Im[2]   EPS-Re[3]   EPSo-Im[4]  EPSo-Re[5]&lt;br /&gt;
Plot the result:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; plot &amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l t &amp;quot;RPA-LFA&amp;quot;,&amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l t &amp;quot;noLFE&amp;quot;, &amp;quot;o-q100.eel_q1_inv_rpa_dyson&amp;quot; u 1:4 w l ls 7 dt 2 t &amp;quot;EELS&amp;quot;&lt;br /&gt;
[[File:CH-LFE4.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
There is little influence of local fields in this case. This is generally the case for semiconductors or materials with a smoothly varying electronic density. We have also shown the EELS spectrum (&#039;&#039;o-q100.eel_q1_inv_rpa_dyson&#039;&#039;) for comparison.&lt;br /&gt;
&lt;br /&gt;
===LFEs in non-periodic direction===&lt;br /&gt;
Now let&#039;s switch to &#039;&#039;q&#039;&#039; perpendicular to the BN plane:&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree        &#039;&#039;and set&#039;&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 0.000000 | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
You can try out the default parallel usage now, or run again in serial, i.e.&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039;       &#039;&#039;(serial)&#039;&#039;&lt;br /&gt;
 $ mpirun -np 4 yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039; &amp;amp;      &#039;&#039;(parallel, MPI only, 4 tasks)&#039;&#039;&lt;br /&gt;
As noted previously, the &#039;&#039;log&#039;&#039; files in parallel appear in the LOG folder, you can follow the execution with &amp;lt;code&amp;gt;tail -F LOG/l-q001_optics_chi_CPU_1&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Plotting the output file:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l,&amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l&lt;br /&gt;
[[File:CH-LFE6.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
In this case, the absorption is strongly blueshifted with respect to the in-plane absorption. Furthermore, the influence of local fields is striking, and quenches the spectrum strongly. This is the well known depolarization effect. Local field effects are much stronger in the perpendicular direction because the charge inhomogeneity is dramatic. Many G-vectors are needed to account for the sharp change in the potential across the BN-vacuum interface.&lt;br /&gt;
&lt;br /&gt;
===Absorption versus EELS===&lt;br /&gt;
In order to understand this further, we plot the electron energy loss spectrum for this component and compare with the absorption:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot &amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; w l,&amp;quot;o-q001.eel_q1_inv_rpa_dyson&amp;quot; w l&lt;br /&gt;
[[File:CH-LFE5.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
The conclusion is that the absorption and EELS coincide for isolated systems. &lt;br /&gt;
To understand why this is, you need to consider the role of the &#039;&#039;macroscopic&#039;&#039; screening in the response function and the long-range part of the Coulomb potential. &lt;br /&gt;
See e.g.&amp;lt;ref&amp;gt;TDDFT from molecules to solids: The role of long‐range interactions, F. Sottile et al, International journal of quantum chemistry 102 (5), 684-701 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:40%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Back to: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4816</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4816"/>
		<updated>2021-04-06T15:53:36Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Optical absorption in hBN: independent particle approximation ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
The dielectric function in the long-wavelength limit, at the independent particle level (RPA without local fields), is essentially given by the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{\alpha, \alpha}(\omega)=1+\frac{16 \pi}{\Omega} \sum_{c, v} \sum_{\mathbf{k}} \frac{1}{E_{c \mathbf{k}}-E_{v \mathbf{k}}} \frac{\left|\left\langle v \mathbf{k}\left|\mathbf{p}_{\alpha}+\mathrm i\left[V^{\mathrm{NL}}, \mathbf{r}_{\alpha}\right]\right| c \mathbf{k}\right\rangle\right|^{2}}{\left(E_{c \mathbf{k}}-E_{v \mathbf{k}}\right)^{2}-(\omega+\mathrm i \gamma)^{2}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, Yambo does not use this expression directly but solves the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;, which is described in the [[Local fields]] module.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for bulk hBN that contains the &#039;&#039;SAVE&#039;&#039; directory, run the initialization and generate the input file.&lt;br /&gt;
You can type &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; and see the available options for different run-levels.  For an RPA optical spectrum calculation the correct option is &amp;lt;code&amp;gt;yambo -optics c&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;yambo -o c&amp;lt;/code&amp;gt;). Let&#039;s add some command line options:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo               &#039;&#039;(initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -o c&lt;br /&gt;
This corresponds to optical properties in G-space at the independent particle level: in the input file this is indicated by (&amp;lt;code&amp;gt;Chimod= &amp;quot;IP&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Optics runlevel===&lt;br /&gt;
For optical properties we are interested just in the long-wavelength limit &#039;&#039;q = 0&#039;&#039;. This always corresponds to the &#039;&#039;first&#039;&#039; &#039;&#039;q&#039;&#039;-point in the set of possible &#039;&#039;q=k-k&#039; &#039;&#039;-points. &lt;br /&gt;
Change the following variables in the input file to:&lt;br /&gt;
 % [[Variables#QpntsRX|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsX|ETStpsXd]]= &#039;&#039;&#039;1001&#039;&#039;&#039;               # [Xd] Total Energy steps&lt;br /&gt;
in order to select just the first &#039;&#039;q&#039;&#039;. The last variable ensures we generate a smooth spectrum. &lt;br /&gt;
Save the input file and launch the code, keeping the command line options as before (i.e., just remove the lower case options):&lt;br /&gt;
 $ yambo -F yambo.in_IP -J Full&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Optics&lt;br /&gt;
 &amp;lt;---&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Checking dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [x,Vnl] computed using 4 projectors&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY] Alloc WF%c( 16.307001Mb) TOTAL:  17.951000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [WF] Performing Wave-Functions I/O from ./SAVE&lt;br /&gt;
 &amp;lt;---&amp;gt; Dipoles: P and iR (T): |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY]  Free WF%c( 16.307001Mb) TOTAL:  1.4700000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Writing dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [X-CG] R(p) Tot o/o(of R)  :   5499   52992     100&lt;br /&gt;
 &amp;lt;01s&amp;gt; Xo@q[1] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [MEMORY]TOTAL not deallocated :  907.0000Kb&lt;br /&gt;
 &amp;lt;01s&amp;gt; [05] Timing Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] Memory Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [07] Game Over &amp;amp; Game summary&lt;br /&gt;
  &lt;br /&gt;
 $ ls&lt;br /&gt;
 Full   SAVE  yambo.in_IP   r_setup&lt;br /&gt;
 o-Full.eel_q1_ip  o-Full.eps_q1_ip  r-Full_optics_chi&lt;br /&gt;
Let&#039;s take a moment to understand what Yambo has done inside the Optics runlevel:&lt;br /&gt;
# Compute the &#039;&#039;[x,Vnl]&#039;&#039; term&lt;br /&gt;
# Read the wavefunctions from disc [WF]&lt;br /&gt;
# Compute the &#039;&#039;dipoles&#039;&#039;, i.e. matrix elements of &#039;&#039;&#039;p&#039;&#039;&#039;&lt;br /&gt;
# Write the dipoles to disk as &#039;&#039;Full/ndb.dip*&#039;&#039; databases. This you can see in the report file:&lt;br /&gt;
 $ grep -A20 &amp;quot;WR&amp;quot; r-Full_optics_*&lt;br /&gt;
 [WR./Full//ndb.dip_iR_and_P]--------------------------------&lt;br /&gt;
  Brillouin Zone Q/K grids (IBZ/BZ):  14   72   14   72&lt;br /&gt;
  RL vectors                   (WF): 1491&lt;br /&gt;
  Fragmentation                    :yes&lt;br /&gt;
  Electronic Temperature        [K]: 0.0000000&lt;br /&gt;
  Bosonic    Temperature        [K]: 0.0000000&lt;br /&gt;
  X band range           :   1  100&lt;br /&gt;
  X band range limits    :  8   9&lt;br /&gt;
  X e/h energy range [ev]:-1.0000000 -1.0000000&lt;br /&gt;
  RL vectors in the sum  : 1491&lt;br /&gt;
  [r,Vnl] included       :yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, Yambo computes the non-interacting susceptibility &#039;&#039;X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; for this &#039;&#039;q&#039;&#039;, and writes the dielectric function inside the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; file for plotting&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Energy cut off===&lt;br /&gt;
&lt;br /&gt;
Before plotting the output, let&#039;s change a few more variables. The previous calculation used &#039;&#039;all&#039;&#039; the G-vectors in expanding the wavefunctions, up to 1491 (~1016 components). This corresponds roughly to the cut off energy of 40Ry we used in the DFT calculation. Generally, however, we can use a smaller value. We use the verbosity to switch on this variable, and a new &#039;&#039;-J&#039;&#039; flag to avoid reading the previous database:&lt;br /&gt;
 $ yambo -F yambo.in_IP &#039;&#039;&#039;-V RL&#039;&#039;&#039; -o c&lt;br /&gt;
Change the &#039;&#039;&#039;value&#039;&#039;&#039; of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; and also its &#039;&#039;&#039;unit&#039;&#039;&#039; from &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; (number of G-vectors) to &amp;lt;code&amp;gt;Ry&amp;lt;/code&amp;gt; (energy in Rydberg):&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]= &#039;&#039;&#039;6&#039;&#039;&#039;           &#039;&#039;&#039;Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
Save the input file and launch the code again:&lt;br /&gt;
  $ yambo -F yambo.in_IP &#039;&#039;&#039;-J 6Ry &#039;&#039;&#039;&lt;br /&gt;
and then plot the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; and &#039;&#039;o-6Ry.eps_q1_ip&#039;&#039; files:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-Full.eps_q1_ip&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip&amp;quot; w p&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-6Ry.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
There is very little difference between the two spectra. This highlights an important point in calculating excited state properties: generally, fewer G-vectors are needed than what are needed in DFT calculations. Regarding the spectrum itself, the first peak occurs at about 4.4eV. This is consistent with the minimum direct gap reported by Yambo: 4.28eV. The comparison with experiment (not shown) is very poor however. &lt;br /&gt;
&lt;br /&gt;
If you made some mistake and cannot reproduce this figure, you should check the value of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; in the input file, delete the &#039;&#039;6Ry&#039;&#039; folder, and try again - taking care to plot the right file! (e.g. &#039;&#039;o-6Ry.eps_q1_ip_01&#039;&#039;. The &amp;quot;_01&amp;quot; suffix means that while writing the output Yambo found another existing file with the name &amp;quot;o-6Ry.eps_q1_ip&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===q-direction===&lt;br /&gt;
Now let&#039;s select a different component of the dielectric tensor:&lt;br /&gt;
 $ yambo -F yambo.in_IP -V RL -o c&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry&lt;br /&gt;
This time yambo reads from the &#039;&#039;6Ry&#039;&#039; folder, so it does not need to compute the dipole matrix elements again, and the calculation is fast. Plotting gives:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-6Ry.eps_q1_ip&amp;quot; t &amp;quot;q || x-axis&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip_01&amp;quot; t &amp;quot;q || c-axis&amp;quot; w l&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-ac.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
The absorption is suppressed in the stacking direction. As the interplanar spacing is increased, we would eventually arrive at the absorption of the BN sheet (see [[Local fields]] tutorial).&lt;br /&gt;
&lt;br /&gt;
===Non-local commutator===&lt;br /&gt;
Last, we show the effect of switching off the non-local commutator term (the term with &amp;lt;math&amp;gt; V^\mathrm{NL} &amp;lt;/math&amp;gt; in the equation at the start of this tutorial due to the pseudopotential. As there is no option to do this inside yambo, you need to hide the database file. Change back to the &#039;&#039;q || (1 0 0)&#039;&#039; direction, and launch yambo with a different &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ mv SAVE/ns.kb_pp_pwscf SAVE/ns.kb_pp_pwscf_&#039;&#039;&#039;OFF&#039;&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J &#039;&#039;&#039;6Ry_NoVnl&#039;&#039;&#039; -o c             &lt;br /&gt;
&lt;br /&gt;
Change &lt;br /&gt;
&lt;br /&gt;
  %LonDrXd&lt;br /&gt;
&lt;br /&gt;
back to &lt;br /&gt;
&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 | &lt;br /&gt;
&lt;br /&gt;
and run&lt;br /&gt;
 &lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry_NoVnl&lt;br /&gt;
&lt;br /&gt;
Note the warning in the output:&lt;br /&gt;
 &amp;lt;---&amp;gt; [WARNING] Missing non-local pseudopotential contribution&lt;br /&gt;
which also appears in the report file, and noted in the database as &amp;lt;code&amp;gt;[r,Vnl] included       :no&amp;lt;/code&amp;gt;. The difference is tiny:&lt;br /&gt;
[[File:CH-hBN-Vnl.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
However, when your system is larger, with more projectors in the pseudopotential or more k-points (see the BSE tutorial), the inclusion of &amp;lt;math&amp;gt;V^\mathrm{NL}&amp;lt;/math&amp;gt; can make a huge difference in the computational load, so it is always worth checking to see if the terms are important in your system.&lt;br /&gt;
&lt;br /&gt;
==Optical absorption in 2D BN: local field effects ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
[[File:Yambo-Cheatsheet-5.0_P7.png|thumb|Cheatsheet on LFE|150px]]&lt;br /&gt;
The macroscopic dielectric function is obtained by including the so-called local field effects (LFE) in the calculation of the response function. Within the time-dependent DFT formalism this is achieved by solving the Dyson equation for the susceptibility &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt;. In reciprocal space this is given by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\chi_{\mathbf{G}, \mathbf{G}^{\prime}}(\mathbf{q}, \omega) = \chi_{\mathbf{G}, \mathbf{G}^{\prime}}^{0}(\mathbf{q}, \omega)+\sum_{\mathbf{G}_{1}, \mathbf{G}_{2}} \chi_{\mathbf{G}, \mathbf{G}_{1}}^{0}(\mathbf{q}, \omega)\left[v_{\mathbf{G}_{1}}(\mathbf{q}) \delta_{\mathbf{G}_{1}, \mathbf{G}_{2}}+f_{\mathbf{G}_{1}, \mathbf{G}_{2}}^{x c}\right] \chi_{\mathbf{G}_{2}, \mathbf{G}^{\prime}}(\mathbf{q}, \omega)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The microscopic dielectric function is related to &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; by:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{\mathbf{G}, \mathbf{G}^{\prime}}^{-1}(\mathbf{q}, \omega)=\delta_{\mathbf{G}, \mathbf{G}^{\prime}}+v_{\mathbf{G}}(\mathbf{q}) \chi_{\mathbf{G}, \mathbf{G}^{\prime}}(\mathbf{q}, \omega)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the macroscopic dielectric function is obtained by taking the (0,0) component of the inverse microscopic one:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{M}(\omega)=\lim _{\mathrm{q} \rightarrow 0} \frac{1}{\epsilon_{\mathrm{G}=0, \mathrm{G}^{\prime}=0}^{-1}(\mathbf{q}, \omega)}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Experimental observables like the optical absorption and the electron energy loss can be obtained from the macroscopic dielectric function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\operatorname{Abs}(\omega)=\operatorname{Im} \epsilon_{M}(\omega) \quad \operatorname{EELS}(\omega)=-\operatorname{Im} \frac{1}{\epsilon_{M}(\omega)}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the following we will neglect the &amp;lt;math&amp;gt;f^{xc}&amp;lt;/math&amp;gt; term: we perform the calculation at the RPA level and consider just the Hartree term (from &amp;lt;math&amp;gt;v_G&amp;lt;/math&amp;gt;) in the kernel. If we also neglect the Hartree term, we arrive back at the independent particle approximation, since there is no kernel and &amp;lt;math&amp;gt;\chi = \chi_0&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for 2D hBN that contains the SAVE directory, and generate the input file. To include local the local fields variables in the input file the correct option is &amp;lt;code&amp;gt;yambo -o c -k hartree&amp;lt;/code&amp;gt; (once again you can check it with &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt;). Let&#039;s start by running the calculation for light polarization &#039;&#039;q&#039;&#039; in the plane of the BN sheet:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree&lt;br /&gt;
We thus use a new input file &#039;&#039;yambo.in_RPA&#039;&#039;, switch on the &amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt; variable, and label all outputs/databases with a &#039;&#039;q100&#039;&#039; tag. Make sure to set/modify all of the following variables to:&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]=     &#039;&#039;&#039;6        Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
 [[Variables#Chimod|Chimod]]= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]= &#039;&#039;&#039;    3        Ry&#039;&#039;&#039;    # [Xd] Response block size&lt;br /&gt;
 % [[Variables#QpntsRXd|QpntsRXd]]&lt;br /&gt;
  1 |  1 |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#EnRngeXd|EnRngeXd]]&lt;br /&gt;
  0.00000 | 20.00000 | eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#DmRngeXd|DmRngeXd]]&lt;br /&gt;
 0.200000 | 0.200000 | eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsXd|ETStpsXd]]= 2001               # [Xd] Total Energy steps&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
In this input file:&lt;br /&gt;
* We evaluate the q--&amp;gt;0 response function choosing the direction for the limit parallel in the plane of the hBN sheet; &lt;br /&gt;
* We set a wider energy range than before, and a larger broadening;&lt;br /&gt;
* We select the Hartree kernel, and expanded G-vectors in the screening up to 3 Ry (about 85 G-vectors);&lt;br /&gt;
&lt;br /&gt;
===LFEs in periodic direction===&lt;br /&gt;
Now let&#039;s run the code with this new input file (CECAM in serial: about 2mins; parallel 4 tasks: 50s)&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J q100 &lt;br /&gt;
and let&#039;s compare the absorption with and without the local fields included. By inspecting the &#039;&#039;o-q100.eps_q1_inv_rpa_dyson&#039;&#039; file we find that this information is given in the 2&amp;lt;math&amp;gt;^\mathrm{nd}&amp;lt;/math&amp;gt; and 4&amp;lt;math&amp;gt;^\mathrm{th}&amp;lt;/math&amp;gt; columns, respectively:&lt;br /&gt;
 $ head -n 40 o-q100.eps_q1_inv_rpa_dyson&lt;br /&gt;
 # Absorption @ Q(1) [q-&amp;gt;0 direction] : 1.0000000  0.0000000  0.0000000&lt;br /&gt;
 #  E/ev[1]     EPS-Im[2]   EPS-Re[3]   EPSo-Im[4]  EPSo-Re[5]&lt;br /&gt;
Plot the result:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; plot &amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l t &amp;quot;RPA-LFA&amp;quot;,&amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l t &amp;quot;noLFE&amp;quot;, &amp;quot;o-q100.eel_q1_inv_rpa_dyson&amp;quot; u 1:4 w l ls 7 dt 2 t &amp;quot;EELS&amp;quot;&lt;br /&gt;
[[File:CH-LFE4.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
There is little influence of local fields in this case. This is generally the case for semiconductors or materials with a smoothly varying electronic density. We have also shown the EELS spectrum (&#039;&#039;o-q100.eel_q1_inv_rpa_dyson&#039;&#039;) for comparison.&lt;br /&gt;
&lt;br /&gt;
===LFEs in non-periodic direction===&lt;br /&gt;
Now let&#039;s switch to &#039;&#039;q&#039;&#039; perpendicular to the BN plane:&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree        &#039;&#039;and set&#039;&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 0.000000 | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
You can try out the default parallel usage now, or run again in serial, i.e.&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039;       &#039;&#039;(serial)&#039;&#039;&lt;br /&gt;
 $ mpirun -np 4 yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039; &amp;amp;      &#039;&#039;(parallel, MPI only, 4 tasks)&#039;&#039;&lt;br /&gt;
As noted previously, the &#039;&#039;log&#039;&#039; files in parallel appear in the LOG folder, you can follow the execution with &amp;lt;code&amp;gt;tail -F LOG/l-q001_optics_chi_CPU_1&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Plotting the output file:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l,&amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l&lt;br /&gt;
[[File:CH-LFE6.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
In this case, the absorption is strongly blueshifted with respect to the in-plane absorption. Furthermore, the influence of local fields is striking, and quenches the spectrum strongly. This is the well known depolarization effect. Local field effects are much stronger in the perpendicular direction because the charge inhomogeneity is dramatic. Many G-vectors are needed to account for the sharp change in the potential across the BN-vacuum interface.&lt;br /&gt;
&lt;br /&gt;
===Absorption versus EELS===&lt;br /&gt;
In order to understand this further, we plot the electron energy loss spectrum for this component and compare with the absorption:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot &amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; w l,&amp;quot;o-q001.eel_q1_inv_rpa_dyson&amp;quot; w l&lt;br /&gt;
[[File:CH-LFE5.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
The conclusion is that the absorption and EELS coincide for isolated systems. &lt;br /&gt;
To understand why this is, you need to consider the role of the &#039;&#039;macroscopic&#039;&#039; screening in the response function and the long-range part of the Coulomb potential. &lt;br /&gt;
See e.g.&amp;lt;ref&amp;gt;TDDFT from molecules to solids: The role of long‐range interactions, F. Sottile et al, International journal of quantum chemistry 102 (5), 684-701 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:40%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Back to: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4814</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4814"/>
		<updated>2021-04-06T15:22:31Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Optical absorption in hBN: independent particle approximation ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
The dielectric function in the long-wavelength limit, at the independent particle level (RPA without local fields), is essentially given by the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\epsilon_{\alpha, \alpha}(\omega)=1+\frac{16 \pi}{\Omega} \sum_{c, v} \sum_{\mathbf{k}} \frac{1}{E_{c \mathbf{k}}-E_{v \mathbf{k}}} \frac{\left|\left\langle v \mathbf{k}\left|\mathbf{p}_{\alpha}+\mathrm i\left[V^{\mathrm{NL}}, \mathbf{r}_{\alpha}\right]\right| c \mathbf{k}\right\rangle\right|^{2}}{\left(E_{c \mathbf{k}}-E_{v \mathbf{k}}\right)^{2}-(\omega+\mathrm i \gamma)^{2}}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In practice, Yambo does not use this expression directly but solves the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;, which is described in the [[Local fields]] module.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for bulk hBN that contains the &#039;&#039;SAVE&#039;&#039; directory, run the initialization and generate the input file.&lt;br /&gt;
From &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -optics c&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;yambo -o c&amp;lt;/code&amp;gt;). Let&#039;s add some command line options:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo               &#039;&#039;(initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -o c&lt;br /&gt;
This corresponds to optical properties in G-space at the independent particle level: in the input file this is indicated by (&amp;lt;code&amp;gt;Chimod= &amp;quot;IP&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Optics runlevel===&lt;br /&gt;
For optical properties we are interested just in the long-wavelength limit &#039;&#039;q = 0&#039;&#039;. This always corresponds to the &#039;&#039;first&#039;&#039; &#039;&#039;q&#039;&#039;-point in the set of possible &#039;&#039;q=k-k&#039; &#039;&#039;-points. &lt;br /&gt;
Change the following variables in the input file to:&lt;br /&gt;
 % [[Variables#QpntsRX|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsX|ETStpsXd]]= &#039;&#039;&#039;1001&#039;&#039;&#039;               # [Xd] Total Energy steps&lt;br /&gt;
in order to select just the first &#039;&#039;q&#039;&#039;. The last variable ensures we generate a smooth spectrum. &lt;br /&gt;
Save the input file and launch the code, keeping the command line options as before (i.e., just remove the lower case options):&lt;br /&gt;
 $ yambo -F yambo.in_IP -J Full&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Optics&lt;br /&gt;
 &amp;lt;---&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Checking dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [x,Vnl] computed using 4 projectors&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY] Alloc WF%c( 16.307001Mb) TOTAL:  17.951000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [WF] Performing Wave-Functions I/O from ./SAVE&lt;br /&gt;
 &amp;lt;---&amp;gt; Dipoles: P and iR (T): |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY]  Free WF%c( 16.307001Mb) TOTAL:  1.4700000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Writing dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [X-CG] R(p) Tot o/o(of R)  :   5499   52992     100&lt;br /&gt;
 &amp;lt;01s&amp;gt; Xo@q[1] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [MEMORY]TOTAL not deallocated :  907.0000Kb&lt;br /&gt;
 &amp;lt;01s&amp;gt; [05] Timing Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] Memory Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [07] Game Over &amp;amp; Game summary&lt;br /&gt;
  &lt;br /&gt;
 $ ls&lt;br /&gt;
 Full   SAVE  yambo.in_IP   r_setup&lt;br /&gt;
 o-Full.eel_q1_ip  o-Full.eps_q1_ip  r-Full_optics_chi&lt;br /&gt;
Let&#039;s take a moment to understand what Yambo has done inside the Optics runlevel:&lt;br /&gt;
# Compute the &#039;&#039;[x,Vnl]&#039;&#039; term&lt;br /&gt;
# Read the wavefunctions from disc [WF]&lt;br /&gt;
# Compute the &#039;&#039;dipoles&#039;&#039;, i.e. matrix elements of &#039;&#039;&#039;p&#039;&#039;&#039;&lt;br /&gt;
# Write the dipoles to disk as &#039;&#039;Full/ndb.dip*&#039;&#039; databases. This you can see in the report file:&lt;br /&gt;
 $ grep -A20 &amp;quot;WR&amp;quot; r-Full_optics_*&lt;br /&gt;
 [WR./Full//ndb.dip_iR_and_P]--------------------------------&lt;br /&gt;
  Brillouin Zone Q/K grids (IBZ/BZ):  14   72   14   72&lt;br /&gt;
  RL vectors                   (WF): 1491&lt;br /&gt;
  Fragmentation                    :yes&lt;br /&gt;
  Electronic Temperature        [K]: 0.0000000&lt;br /&gt;
  Bosonic    Temperature        [K]: 0.0000000&lt;br /&gt;
  X band range           :   1  100&lt;br /&gt;
  X band range limits    :  8   9&lt;br /&gt;
  X e/h energy range [ev]:-1.0000000 -1.0000000&lt;br /&gt;
  RL vectors in the sum  : 1491&lt;br /&gt;
  [r,Vnl] included       :yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, Yambo computes the non-interacting susceptibility &#039;&#039;X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; for this &#039;&#039;q&#039;&#039;, and writes the dielectric function inside the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; file for plotting&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Energy cut off===&lt;br /&gt;
&lt;br /&gt;
Before plotting the output, let&#039;s change a few more variables. The previous calculation used &#039;&#039;all&#039;&#039; the G-vectors in expanding the wavefunctions, up to 1491 (~1016 components). This corresponds roughly to the cut off energy of 40Ry we used in the DFT calculation. Generally, however, we can use a smaller value. We use the verbosity to switch on this variable, and a new &#039;&#039;-J&#039;&#039; flag to avoid reading the previous database:&lt;br /&gt;
 $ yambo -F yambo.in_IP &#039;&#039;&#039;-V RL&#039;&#039;&#039; -o c&lt;br /&gt;
Change the &#039;&#039;&#039;value&#039;&#039;&#039; of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; and also its &#039;&#039;&#039;unit&#039;&#039;&#039; from &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; (number of G-vectors) to &amp;lt;code&amp;gt;Ry&amp;lt;/code&amp;gt; (energy in Rydberg):&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]= &#039;&#039;&#039;6&#039;&#039;&#039;           &#039;&#039;&#039;Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
Save the input file and launch the code again:&lt;br /&gt;
  $ yambo -F yambo.in_IP &#039;&#039;&#039;-J 6Ry &#039;&#039;&#039;&lt;br /&gt;
and then plot the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; and &#039;&#039;o-6Ry.eps_q1_ip&#039;&#039; files:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-Full.eps_q1_ip&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip&amp;quot; w p&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-6Ry.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Clearly there is very little difference between the two spectra. This highlights an important point in calculating excited state properties: generally, fewer G-vectors are needed than what are needed in DFT calculations. Regarding the spectrum itself, the first peak occurs at about 4.4eV. This is consistent with the minimum direct gap reported by Yambo: 4.28eV. The comparison with experiment (not shown) is very poor however. &lt;br /&gt;
&lt;br /&gt;
If you made some mistake and cannot reproduce this figure, you should check the value of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; in the input file, delete the &#039;&#039;6Ry&#039;&#039; folder, and try again - taking care to plot the right file! (e.g. &#039;&#039;o-6Ry.eps_q1_ip_01&#039;&#039;. The &amp;quot;_01&amp;quot; suffix means that while writing the output Yambo found another existing file with the name &amp;quot;o-6Ry.eps_q1_ip&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===q-direction===&lt;br /&gt;
Now let&#039;s select a different component of the dielectric tensor:&lt;br /&gt;
 $ yambo -F yambo.in_IP -V RL -o c&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry&lt;br /&gt;
This time yambo reads from the &#039;&#039;6Ry&#039;&#039; folder, so it does not need to compute the dipole matrix elements again, and the calculation is fast. Plotting gives:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-6Ry.eps_q1_ip&amp;quot; t &amp;quot;q || x-axis&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip_01&amp;quot; t &amp;quot;q || c-axis&amp;quot; w l&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-ac.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
The absorption is suppressed in the stacking direction. As the interplanar spacing is increased, we would eventually arrive at the absorption of the BN sheet (see [[Local fields]] tutorial).&lt;br /&gt;
&lt;br /&gt;
===Non-local commutator===&lt;br /&gt;
Last, we show the effect of switching off the non-local commutator term (the term with &amp;lt;math&amp;gt; V^\mathrm{NL} &amp;lt;/math&amp;gt; in the equation at the start of this tutorial due to the pseudopotential. As there is no option to do this inside yambo, you need to hide the database file. Change back to the &#039;&#039;q || (1 0 0)&#039;&#039; direction, and launch yambo with a different &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ mv SAVE/ns.kb_pp_pwscf SAVE/ns.kb_pp_pwscf_&#039;&#039;&#039;OFF&#039;&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J &#039;&#039;&#039;6Ry_NoVnl&#039;&#039;&#039; -o c             &lt;br /&gt;
&lt;br /&gt;
Change &lt;br /&gt;
&lt;br /&gt;
  %LonDrXd&lt;br /&gt;
&lt;br /&gt;
back to &lt;br /&gt;
&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 | &lt;br /&gt;
&lt;br /&gt;
and run&lt;br /&gt;
 &lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry_NoVnl&lt;br /&gt;
&lt;br /&gt;
Note the warning in the output:&lt;br /&gt;
 &amp;lt;---&amp;gt; [WARNING] Missing non-local pseudopotential contribution&lt;br /&gt;
which also appears in the report file, and noted in the database as &amp;lt;code&amp;gt;[r,Vnl] included       :no&amp;lt;/code&amp;gt;. The difference is tiny:&lt;br /&gt;
[[File:CH-hBN-Vnl.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
However, when your system is larger, with more projectors in the pseudopotential or more k-points (see the BSE tutorial), the inclusion of &#039;&#039;Vnl&#039;&#039; can make a huge difference in the computational load, so it&#039;s always worth checking to see if the terms are important in your system.&lt;br /&gt;
&lt;br /&gt;
==Optical absorption in 2D BN: local field effects ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
[[File:Yambo-Cheatsheet-5.0_P7.png|thumb|Cheatsheet on LFE|150px]]&lt;br /&gt;
The macroscopic dielectric function is obtained by including the so-called local field effects (LFE) in the calculation of the response function. Within the time-dependent DFT formalism this is achieved by solving the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;. In reciprocal space this is given by:&lt;br /&gt;
[[File:Yambo-CH7.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
The microscopic dielectric function is related to &#039;&#039;X&#039;&#039; by:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
and the macroscopic dielectric function is obtained by taking the (0,0) component of the inverse microscopic one:&lt;br /&gt;
[[File:Yambo-CH6.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
Experimental observables like the optical absorption and the electron energy loss can be obtained from the macroscopic dielectric function:&lt;br /&gt;
[[File:Yambo-CH8.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In the following we will neglect the &#039;&#039;f &amp;lt;sup&amp;gt; xc&amp;lt;/sup&amp;gt;&#039;&#039; term: we perform the calculation at the RPA level and consider just the Hartree term (from &#039;&#039;v&amp;lt;sub&amp;gt;G&amp;lt;/sub&amp;gt;&#039;&#039;) in the kernel. If we also neglect the Hartree term, we arrive back at the independent particle approximation, since there is no kernel and &#039;&#039;X = X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for 2D hBN that contains the SAVE directory, and generate the input file. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -o c -k hartree&amp;lt;/code&amp;gt;. Let&#039;s start by running the calculation for light polarization &#039;&#039;q&#039;&#039; in the plane of the BN sheet:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree&lt;br /&gt;
We thus use a new input file &#039;&#039;yambo.in_RPA&#039;&#039;, switch on the &amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt; variable, and label all outputs/databases with a &#039;&#039;q100&#039;&#039; tag. Make sure to set/modify all of the following variables to:&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]=     &#039;&#039;&#039;6        Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
 [[Variables#Chimod|Chimod]]= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]= &#039;&#039;&#039;    3        Ry&#039;&#039;&#039;    # [Xd] Response block size&lt;br /&gt;
 % [[Variables#QpntsRXd|QpntsRXd]]&lt;br /&gt;
  1 |  1 |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#EnRngeXd|EnRngeXd]]&lt;br /&gt;
  0.00000 | 20.00000 | eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#DmRngeXd|DmRngeXd]]&lt;br /&gt;
 0.200000 | 0.200000 | eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsXd|ETStpsXd]]= 2001               # [Xd] Total Energy steps&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
In this input file, we have:&lt;br /&gt;
* We evaluate the q--&amp;gt;0 response function choosing the direction for the limit parallel in the plane of the hBN sheet &lt;br /&gt;
* A wider energy range than before, and more broadening&lt;br /&gt;
* Selected the Hartree kernel, and expanded G-vectors in the screening up to 3 Ry (about 85 G-vectors)&lt;br /&gt;
&lt;br /&gt;
===LFEs in periodic direction===&lt;br /&gt;
Now let&#039;s run the code with this new input file (CECAM in serial: about 2mins; parallel 4 tasks: 50s)&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J q100 &lt;br /&gt;
and let&#039;s compare the absorption with and without the local fields included. By inspecting the &#039;&#039;o-q100.eps_q1_inv_rpa_dyson&#039;&#039; file we find&lt;br /&gt;
that this information is given in the 2nd and 4th columns, respectively:&lt;br /&gt;
 $ head -n 40 o-q100.eps_q1_inv_rpa_dyson&lt;br /&gt;
 # Absorption @ Q(1) [q-&amp;gt;0 direction] : 1.0000000  0.0000000  0.0000000&lt;br /&gt;
 #  E/ev[1]     EPS-Im[2]   EPS-Re[3]   EPSo-Im[4]  EPSo-Re[5]&lt;br /&gt;
Plot the result:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; plot &amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l t &amp;quot;RPA-LFA&amp;quot;,&amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l t &amp;quot;noLFE&amp;quot;, &amp;quot;o-q100.eel_q1_inv_rpa_dyson&amp;quot; u 1:4 w l ls 7 dt 2 t &amp;quot;EELS&amp;quot;&lt;br /&gt;
[[File:CH-LFE4.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
It is clear that there is little influence of local fields in this case. This is generally the case for semiconductors or materials with a smoothly varying electronic density. We have also shown the EELS spectrum (&#039;&#039;o-q100.eel_q1_inv_rpa_dyson&#039;&#039;) for comparison.&lt;br /&gt;
&lt;br /&gt;
===LFEs in non-periodic direction===&lt;br /&gt;
Now let&#039;s switch to &#039;&#039;q&#039;&#039; perpendicular to the BN plane:&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree        &#039;&#039;and set&#039;&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 0.000000 | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
You can try out the default parallel usage now, or run again in serial, i.e.&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039;       &#039;&#039;(serial)&#039;&#039;&lt;br /&gt;
 $ mpirun -np 4 yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039; &amp;amp;      &#039;&#039;(parallel, MPI only, 4 tasks)&#039;&#039;&lt;br /&gt;
As noted previously, the &#039;&#039;log&#039;&#039; files in parallel appear in the LOG folder, you can follow the execution with &amp;lt;code&amp;gt;tail -F LOG/l-q001_optics_chi_CPU_1&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Plotting the output file:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l,&amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l&lt;br /&gt;
[[File:CH-LFE6.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
In this case, the absorption is strongly blueshifted with respect to the in-plane absorption. Furthermore, the influence of local fields is striking, and quenches the spectrum strongly. This is the well known depolarization effect. Local field effects are much stronger in the perpendicular direction because the charge inhomogeneity is dramatic. Many G-vectors are needed to account for the sharp change in the potential across the BN-vacuum interface.&lt;br /&gt;
&lt;br /&gt;
===Absorption versus EELS===&lt;br /&gt;
In order to understand this further, we plot the electron energy loss spectrum for this component and compare with the absorption:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot &amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; w l,&amp;quot;o-q001.eel_q1_inv_rpa_dyson&amp;quot; w l&lt;br /&gt;
[[File:CH-LFE5.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
The conclusion is that the absorption and EELS coincide for isolated systems. &lt;br /&gt;
To understand why this is, you need to consider the role of the &#039;&#039;macroscopic&#039;&#039; screening in the response function and the long-range part of the Coulomb potential. &lt;br /&gt;
See e.g.&amp;lt;ref&amp;gt;TDDFT from molecules to solids: The role of long‐range interactions, F. Sottile et al, International journal of quantum chemistry 102 (5), 684-701 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:40%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Back to: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4813</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4813"/>
		<updated>2021-04-06T13:56:09Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Optical absorption in hBN: independent particle approximation ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
The dielectric function in the long-wavelength limit, at the independent particle level (RPA without local fields), is essentially given by the following:&lt;br /&gt;
&amp;lt;math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
\epsilon_{\alpha,\alpha}(\omega) = 1 + \frac&lt;br /&gt;
&amp;lt;/math&amp;gt;&lt;br /&gt;
[[File:CH1.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
In practice, Yambo does not use this expression directly but solves the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;, which is described in the [[Local fields]] module.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for bulk hBN that contains the &#039;&#039;SAVE&#039;&#039; directory, run the initialization and generate the input file.&lt;br /&gt;
From &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -optics c&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;yambo -o c&amp;lt;/code&amp;gt;). Let&#039;s add some command line options:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo               &#039;&#039;(initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -o c&lt;br /&gt;
This corresponds to optical properties in G-space at the independent particle level: in the input file this is indicated by (&amp;lt;code&amp;gt;Chimod= &amp;quot;IP&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Optics runlevel===&lt;br /&gt;
For optical properties we are interested just in the long-wavelength limit &#039;&#039;q = 0&#039;&#039;. This always corresponds to the &#039;&#039;first&#039;&#039; &#039;&#039;q&#039;&#039;-point in the set of possible &#039;&#039;q=k-k&#039; &#039;&#039;-points. &lt;br /&gt;
Change the following variables in the input file to:&lt;br /&gt;
 % [[Variables#QpntsRX|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsX|ETStpsXd]]= &#039;&#039;&#039;1001&#039;&#039;&#039;               # [Xd] Total Energy steps&lt;br /&gt;
in order to select just the first &#039;&#039;q&#039;&#039;. The last variable ensures we generate a smooth spectrum. &lt;br /&gt;
Save the input file and launch the code, keeping the command line options as before (i.e., just remove the lower case options):&lt;br /&gt;
 $ yambo -F yambo.in_IP -J Full&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Optics&lt;br /&gt;
 &amp;lt;---&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Checking dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [x,Vnl] computed using 4 projectors&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY] Alloc WF%c( 16.307001Mb) TOTAL:  17.951000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [WF] Performing Wave-Functions I/O from ./SAVE&lt;br /&gt;
 &amp;lt;---&amp;gt; Dipoles: P and iR (T): |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY]  Free WF%c( 16.307001Mb) TOTAL:  1.4700000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Writing dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [X-CG] R(p) Tot o/o(of R)  :   5499   52992     100&lt;br /&gt;
 &amp;lt;01s&amp;gt; Xo@q[1] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [MEMORY]TOTAL not deallocated :  907.0000Kb&lt;br /&gt;
 &amp;lt;01s&amp;gt; [05] Timing Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] Memory Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [07] Game Over &amp;amp; Game summary&lt;br /&gt;
  &lt;br /&gt;
 $ ls&lt;br /&gt;
 Full   SAVE  yambo.in_IP   r_setup&lt;br /&gt;
 o-Full.eel_q1_ip  o-Full.eps_q1_ip  r-Full_optics_chi&lt;br /&gt;
Let&#039;s take a moment to understand what Yambo has done inside the Optics runlevel:&lt;br /&gt;
# Compute the &#039;&#039;[x,Vnl]&#039;&#039; term&lt;br /&gt;
# Read the wavefunctions from disc [WF]&lt;br /&gt;
# Compute the &#039;&#039;dipoles&#039;&#039;, i.e. matrix elements of &#039;&#039;&#039;p&#039;&#039;&#039;&lt;br /&gt;
# Write the dipoles to disk as &#039;&#039;Full/ndb.dip*&#039;&#039; databases. This you can see in the report file:&lt;br /&gt;
 $ grep -A20 &amp;quot;WR&amp;quot; r-Full_optics_*&lt;br /&gt;
 [WR./Full//ndb.dip_iR_and_P]--------------------------------&lt;br /&gt;
  Brillouin Zone Q/K grids (IBZ/BZ):  14   72   14   72&lt;br /&gt;
  RL vectors                   (WF): 1491&lt;br /&gt;
  Fragmentation                    :yes&lt;br /&gt;
  Electronic Temperature        [K]: 0.0000000&lt;br /&gt;
  Bosonic    Temperature        [K]: 0.0000000&lt;br /&gt;
  X band range           :   1  100&lt;br /&gt;
  X band range limits    :  8   9&lt;br /&gt;
  X e/h energy range [ev]:-1.0000000 -1.0000000&lt;br /&gt;
  RL vectors in the sum  : 1491&lt;br /&gt;
  [r,Vnl] included       :yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, Yambo computes the non-interacting susceptibility &#039;&#039;X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; for this &#039;&#039;q&#039;&#039;, and writes the dielectric function inside the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; file for plotting&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Energy cut off===&lt;br /&gt;
&lt;br /&gt;
Before plotting the output, let&#039;s change a few more variables. The previous calculation used &#039;&#039;all&#039;&#039; the G-vectors in expanding the wavefunctions, up to 1491 (~1016 components). This corresponds roughly to the cut off energy of 40Ry we used in the DFT calculation. Generally, however, we can use a smaller value. We use the verbosity to switch on this variable, and a new &#039;&#039;-J&#039;&#039; flag to avoid reading the previous database:&lt;br /&gt;
 $ yambo -F yambo.in_IP &#039;&#039;&#039;-V RL&#039;&#039;&#039; -o c&lt;br /&gt;
Change the &#039;&#039;&#039;value&#039;&#039;&#039; of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; and also its &#039;&#039;&#039;unit&#039;&#039;&#039; from &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; (number of G-vectors) to &amp;lt;code&amp;gt;Ry&amp;lt;/code&amp;gt; (energy in Rydberg):&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]= &#039;&#039;&#039;6&#039;&#039;&#039;           &#039;&#039;&#039;Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
Save the input file and launch the code again:&lt;br /&gt;
  $ yambo -F yambo.in_IP &#039;&#039;&#039;-J 6Ry &#039;&#039;&#039;&lt;br /&gt;
and then plot the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; and &#039;&#039;o-6Ry.eps_q1_ip&#039;&#039; files:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-Full.eps_q1_ip&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip&amp;quot; w p&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-6Ry.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Clearly there is very little difference between the two spectra. This highlights an important point in calculating excited state properties: generally, fewer G-vectors are needed than what are needed in DFT calculations. Regarding the spectrum itself, the first peak occurs at about 4.4eV. This is consistent with the minimum direct gap reported by Yambo: 4.28eV. The comparison with experiment (not shown) is very poor however. &lt;br /&gt;
&lt;br /&gt;
If you made some mistake and cannot reproduce this figure, you should check the value of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; in the input file, delete the &#039;&#039;6Ry&#039;&#039; folder, and try again - taking care to plot the right file! (e.g. &#039;&#039;o-6Ry.eps_q1_ip_01&#039;&#039;. The &amp;quot;_01&amp;quot; suffix means that while writing the output Yambo found another existing file with the name &amp;quot;o-6Ry.eps_q1_ip&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===q-direction===&lt;br /&gt;
Now let&#039;s select a different component of the dielectric tensor:&lt;br /&gt;
 $ yambo -F yambo.in_IP -V RL -o c&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry&lt;br /&gt;
This time yambo reads from the &#039;&#039;6Ry&#039;&#039; folder, so it does not need to compute the dipole matrix elements again, and the calculation is fast. Plotting gives:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-6Ry.eps_q1_ip&amp;quot; t &amp;quot;q || x-axis&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip_01&amp;quot; t &amp;quot;q || c-axis&amp;quot; w l&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-ac.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
The absorption is suppressed in the stacking direction. As the interplanar spacing is increased, we would eventually arrive at the absorption of the BN sheet (see [[Local fields]] tutorial).&lt;br /&gt;
&lt;br /&gt;
===Non-local commutator===&lt;br /&gt;
Last, we show the effect of switching off the non-local commutator term (the term with &amp;lt;math&amp;gt; V^\mathrm{NL} &amp;lt;/math&amp;gt; in the equation ({{EquationNote|1}})) due to the pseudopotential. As there is no option to do this inside yambo, you need to hide the database file. Change back to the &#039;&#039;q || (1 0 0)&#039;&#039; direction, and launch yambo with a different &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ mv SAVE/ns.kb_pp_pwscf SAVE/ns.kb_pp_pwscf_&#039;&#039;&#039;OFF&#039;&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J &#039;&#039;&#039;6Ry_NoVnl&#039;&#039;&#039; -o c             &#039;&#039;(change to q || 100)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry_NoVnl&lt;br /&gt;
Note the warning in the output:&lt;br /&gt;
 &amp;lt;---&amp;gt; [WARNING] Missing non-local pseudopotential contribution&lt;br /&gt;
which also appears in the report file, and noted in the database as &amp;lt;code&amp;gt;[r,Vnl] included       :no&amp;lt;/code&amp;gt;. The difference is tiny:&lt;br /&gt;
[[File:CH-hBN-Vnl.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
However, when your system is larger, with more projectors in the pseudopotential or more k-points (see the BSE tutorial), the inclusion of &#039;&#039;Vnl&#039;&#039; can make a huge difference in the computational load, so it&#039;s always worth checking to see if the terms are important in your system.&lt;br /&gt;
&lt;br /&gt;
==Optical absorption in 2D BN: local field effects ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
[[File:Yambo-Cheatsheet-5.0_P7.png|thumb|Cheatsheet on LFE|150px]]&lt;br /&gt;
The macroscopic dielectric function is obtained by including the so-called local field effects (LFE) in the calculation of the response function. Within the time-dependent DFT formalism this is achieved by solving the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;. In reciprocal space this is given by:&lt;br /&gt;
[[File:Yambo-CH7.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
The microscopic dielectric function is related to &#039;&#039;X&#039;&#039; by:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
and the macroscopic dielectric function is obtained by taking the (0,0) component of the inverse microscopic one:&lt;br /&gt;
[[File:Yambo-CH6.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
Experimental observables like the optical absorption and the electron energy loss can be obtained from the macroscopic dielectric function:&lt;br /&gt;
[[File:Yambo-CH8.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In the following we will neglect the &#039;&#039;f &amp;lt;sup&amp;gt; xc&amp;lt;/sup&amp;gt;&#039;&#039; term: we perform the calculation at the RPA level and consider just the Hartree term (from &#039;&#039;v&amp;lt;sub&amp;gt;G&amp;lt;/sub&amp;gt;&#039;&#039;) in the kernel. If we also neglect the Hartree term, we arrive back at the independent particle approximation, since there is no kernel and &#039;&#039;X = X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for 2D hBN that contains the SAVE directory, and generate the input file. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -o c -k hartree&amp;lt;/code&amp;gt;. Let&#039;s start by running the calculation for light polarization &#039;&#039;q&#039;&#039; in the plane of the BN sheet:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree&lt;br /&gt;
We thus use a new input file &#039;&#039;yambo.in_RPA&#039;&#039;, switch on the &amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt; variable, and label all outputs/databases with a &#039;&#039;q100&#039;&#039; tag. Make sure to set/modify all of the following variables to:&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]=     &#039;&#039;&#039;6        Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
 [[Variables#Chimod|Chimod]]= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]= &#039;&#039;&#039;    3        Ry&#039;&#039;&#039;    # [Xd] Response block size&lt;br /&gt;
 % [[Variables#QpntsRXd|QpntsRXd]]&lt;br /&gt;
  1 |  1 |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#EnRngeXd|EnRngeXd]]&lt;br /&gt;
  0.00000 | 20.00000 | eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#DmRngeXd|DmRngeXd]]&lt;br /&gt;
 0.200000 | 0.200000 | eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsXd|ETStpsXd]]= 2001               # [Xd] Total Energy steps&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
In this input file, we have:&lt;br /&gt;
* We evaluate the q--&amp;gt;0 response function choosing the direction for the limit parallel in the plane of the hBN sheet &lt;br /&gt;
* A wider energy range than before, and more broadening&lt;br /&gt;
* Selected the Hartree kernel, and expanded G-vectors in the screening up to 3 Ry (about 85 G-vectors)&lt;br /&gt;
&lt;br /&gt;
===LFEs in periodic direction===&lt;br /&gt;
Now let&#039;s run the code with this new input file (CECAM in serial: about 2mins; parallel 4 tasks: 50s)&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J q100 &lt;br /&gt;
and let&#039;s compare the absorption with and without the local fields included. By inspecting the &#039;&#039;o-q100.eps_q1_inv_rpa_dyson&#039;&#039; file we find&lt;br /&gt;
that this information is given in the 2nd and 4th columns, respectively:&lt;br /&gt;
 $ head -n 40 o-q100.eps_q1_inv_rpa_dyson&lt;br /&gt;
 # Absorption @ Q(1) [q-&amp;gt;0 direction] : 1.0000000  0.0000000  0.0000000&lt;br /&gt;
 #  E/ev[1]     EPS-Im[2]   EPS-Re[3]   EPSo-Im[4]  EPSo-Re[5]&lt;br /&gt;
Plot the result:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; plot &amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l t &amp;quot;RPA-LFA&amp;quot;,&amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l t &amp;quot;noLFE&amp;quot;, &amp;quot;o-q100.eel_q1_inv_rpa_dyson&amp;quot; u 1:4 w l ls 7 dt 2 t &amp;quot;EELS&amp;quot;&lt;br /&gt;
[[File:CH-LFE4.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
It is clear that there is little influence of local fields in this case. This is generally the case for semiconductors or materials with a smoothly varying electronic density. We have also shown the EELS spectrum (&#039;&#039;o-q100.eel_q1_inv_rpa_dyson&#039;&#039;) for comparison.&lt;br /&gt;
&lt;br /&gt;
===LFEs in non-periodic direction===&lt;br /&gt;
Now let&#039;s switch to &#039;&#039;q&#039;&#039; perpendicular to the BN plane:&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree        &#039;&#039;and set&#039;&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 0.000000 | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
You can try out the default parallel usage now, or run again in serial, i.e.&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039;       &#039;&#039;(serial)&#039;&#039;&lt;br /&gt;
 $ mpirun -np 4 yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039; &amp;amp;      &#039;&#039;(parallel, MPI only, 4 tasks)&#039;&#039;&lt;br /&gt;
As noted previously, the &#039;&#039;log&#039;&#039; files in parallel appear in the LOG folder, you can follow the execution with &amp;lt;code&amp;gt;tail -F LOG/l-q001_optics_chi_CPU_1&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Plotting the output file:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l,&amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l&lt;br /&gt;
[[File:CH-LFE6.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
In this case, the absorption is strongly blueshifted with respect to the in-plane absorption. Furthermore, the influence of local fields is striking, and quenches the spectrum strongly. This is the well known depolarization effect. Local field effects are much stronger in the perpendicular direction because the charge inhomogeneity is dramatic. Many G-vectors are needed to account for the sharp change in the potential across the BN-vacuum interface.&lt;br /&gt;
&lt;br /&gt;
===Absorption versus EELS===&lt;br /&gt;
In order to understand this further, we plot the electron energy loss spectrum for this component and compare with the absorption:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot &amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; w l,&amp;quot;o-q001.eel_q1_inv_rpa_dyson&amp;quot; w l&lt;br /&gt;
[[File:CH-LFE5.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
The conclusion is that the absorption and EELS coincide for isolated systems. &lt;br /&gt;
To understand why this is, you need to consider the role of the &#039;&#039;macroscopic&#039;&#039; screening in the response function and the long-range part of the Coulomb potential. &lt;br /&gt;
See e.g.&amp;lt;ref&amp;gt;TDDFT from molecules to solids: The role of long‐range interactions, F. Sottile et al, International journal of quantum chemistry 102 (5), 684-701 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:40%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Back to: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4812</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4812"/>
		<updated>2021-04-06T13:38:48Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Optical absorption in hBN: independent particle approximation ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
The dielectric function in the long-wavelength limit, at the independent particle level (RPA without local fields), is essentially given by the following:&lt;br /&gt;
[[File:CH1.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
In practice, Yambo does not use this expression directly but solves the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;, which is described in the [[Local fields]] module.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for bulk hBN that contains the &#039;&#039;SAVE&#039;&#039; directory, run the initialization and generate the input file.&lt;br /&gt;
From &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -optics c&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;yambo -o c&amp;lt;/code&amp;gt;). Let&#039;s add some command line options:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo               &#039;&#039;(initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -o c&lt;br /&gt;
This corresponds to optical properties in G-space at the independent particle level: in the input file this is indicated by (&amp;lt;code&amp;gt;Chimod= &amp;quot;IP&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Optics runlevel===&lt;br /&gt;
For optical properties we are interested just in the long-wavelength limit &#039;&#039;q = 0&#039;&#039;. This always corresponds to the &#039;&#039;first&#039;&#039; &#039;&#039;q&#039;&#039;-point in the set of possible &#039;&#039;q=k-k&#039; &#039;&#039;-points. &lt;br /&gt;
Change the following variables in the input file to:&lt;br /&gt;
 % [[Variables#QpntsRX|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsX|ETStpsXd]]= &#039;&#039;&#039;1001&#039;&#039;&#039;               # [Xd] Total Energy steps&lt;br /&gt;
in order to select just the first &#039;&#039;q&#039;&#039;. The last variable ensures we generate a smooth spectrum. &lt;br /&gt;
Save the input file and launch the code, keeping the command line options as before (i.e., just remove the lower case options):&lt;br /&gt;
 $ yambo -F yambo.in_IP -J Full&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Optics&lt;br /&gt;
 &amp;lt;---&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Checking dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [x,Vnl] computed using 4 projectors&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY] Alloc WF%c( 16.307001Mb) TOTAL:  17.951000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [WF] Performing Wave-Functions I/O from ./SAVE&lt;br /&gt;
 &amp;lt;---&amp;gt; Dipoles: P and iR (T): |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY]  Free WF%c( 16.307001Mb) TOTAL:  1.4700000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Writing dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [X-CG] R(p) Tot o/o(of R)  :   5499   52992     100&lt;br /&gt;
 &amp;lt;01s&amp;gt; Xo@q[1] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [MEMORY]TOTAL not deallocated :  907.0000Kb&lt;br /&gt;
 &amp;lt;01s&amp;gt; [05] Timing Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] Memory Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [07] Game Over &amp;amp; Game summary&lt;br /&gt;
  &lt;br /&gt;
 $ ls&lt;br /&gt;
 Full   SAVE  yambo.in_IP   r_setup&lt;br /&gt;
 o-Full.eel_q1_ip  o-Full.eps_q1_ip  r-Full_optics_chi&lt;br /&gt;
Let&#039;s take a moment to understand what Yambo has done inside the Optics runlevel:&lt;br /&gt;
# Compute the &#039;&#039;[x,Vnl]&#039;&#039; term&lt;br /&gt;
# Read the wavefunctions from disc [WF]&lt;br /&gt;
# Compute the &#039;&#039;dipoles&#039;&#039;, i.e. matrix elements of &#039;&#039;&#039;p&#039;&#039;&#039;&lt;br /&gt;
# Write the dipoles to disk as &#039;&#039;Full/ndb.dip*&#039;&#039; databases. This you can see in the report file:&lt;br /&gt;
 $ grep -A20 &amp;quot;WR&amp;quot; r-Full_optics_*&lt;br /&gt;
 [WR./Full//ndb.dip_iR_and_P]--------------------------------&lt;br /&gt;
  Brillouin Zone Q/K grids (IBZ/BZ):  14   72   14   72&lt;br /&gt;
  RL vectors                   (WF): 1491&lt;br /&gt;
  Fragmentation                    :yes&lt;br /&gt;
  Electronic Temperature        [K]: 0.0000000&lt;br /&gt;
  Bosonic    Temperature        [K]: 0.0000000&lt;br /&gt;
  X band range           :   1  100&lt;br /&gt;
  X band range limits    :  8   9&lt;br /&gt;
  X e/h energy range [ev]:-1.0000000 -1.0000000&lt;br /&gt;
  RL vectors in the sum  : 1491&lt;br /&gt;
  [r,Vnl] included       :yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, Yambo computes the non-interacting susceptibility &#039;&#039;X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; for this &#039;&#039;q&#039;&#039;, and writes the dielectric function inside the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; file for plotting&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Energy cut off===&lt;br /&gt;
&lt;br /&gt;
Before plotting the output, let&#039;s change a few more variables. The previous calculation used &#039;&#039;all&#039;&#039; the G-vectors in expanding the wavefunctions, up to 1491 (~1016 components). This corresponds roughly to the cut off energy of 40Ry we used in the DFT calculation. Generally, however, we can use a smaller value. We use the verbosity to switch on this variable, and a new &#039;&#039;-J&#039;&#039; flag to avoid reading the previous database:&lt;br /&gt;
 $ yambo -F yambo.in_IP &#039;&#039;&#039;-V RL&#039;&#039;&#039; -o c&lt;br /&gt;
Change the &#039;&#039;&#039;value&#039;&#039;&#039; of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; and also its &#039;&#039;&#039;unit&#039;&#039;&#039; from &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; (number of G-vectors) to &amp;lt;code&amp;gt;Ry&amp;lt;/code&amp;gt; (energy in Rydberg):&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]= &#039;&#039;&#039;6&#039;&#039;&#039;           &#039;&#039;&#039;Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
Save the input file and launch the code again:&lt;br /&gt;
  $ yambo -F yambo.in_IP &#039;&#039;&#039;-J 6Ry &#039;&#039;&#039;&lt;br /&gt;
and then plot the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; and &#039;&#039;o-6Ry.eps_q1_ip&#039;&#039; files:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-Full.eps_q1_ip&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip&amp;quot; w p&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-6Ry.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Clearly there is very little difference between the two spectra. This highlights an important point in calculating excited state properties: generally, fewer G-vectors are needed than what are needed in DFT calculations. Regarding the spectrum itself, the first peak occurs at about 4.4eV. This is consistent with the minimum direct gap reported by Yambo: 4.28eV. The comparison with experiment (not shown) is very poor however. &lt;br /&gt;
&lt;br /&gt;
If you made some mistake and cannot reproduce this figure, you should check the value of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; in the input file, delete the &#039;&#039;6Ry&#039;&#039; folder, and try again - taking care to plot the right file! (e.g. &#039;&#039;o-6Ry.eps_q1_ip_01&#039;&#039;. The &amp;quot;_01&amp;quot; suffix means that while writing the output Yambo found another existing file with the name &amp;quot;o-6Ry.eps_q1_ip&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
===q-direction===&lt;br /&gt;
Now let&#039;s select a different component of the dielectric tensor:&lt;br /&gt;
 $ yambo -F yambo.in_IP -V RL -o c&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry&lt;br /&gt;
This time yambo reads from the &#039;&#039;6Ry&#039;&#039; folder, so it does not need to compute the dipole matrix elements again, and the calculation is fast. Plotting gives:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-6Ry.eps_q1_ip&amp;quot; t &amp;quot;q || x-axis&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip_01&amp;quot; t &amp;quot;q || c-axis&amp;quot; w l&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-ac.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
The absorption is suppressed in the stacking direction. As the interplanar spacing is increased, we would eventually arrive at the absorption of the BN sheet (see [[Local fields]] tutorial).&lt;br /&gt;
&lt;br /&gt;
===Non-local commutator===&lt;br /&gt;
Last, we show the effect of switching off the non-local commutator term (see &#039;&#039;[Vnl,r]&#039;&#039; in the equation at the top of the page) due to the pseudopotential. As there is no option to do this inside yambo, you need to hide the database file. Change back to the &#039;&#039;q || (1 0 0)&#039;&#039; direction, and launch yambo with a different &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ mv SAVE/ns.kb_pp_pwscf SAVE/ns.kb_pp_pwscf_&#039;&#039;&#039;OFF&#039;&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J &#039;&#039;&#039;6Ry_NoVnl&#039;&#039;&#039; -o c             &#039;&#039;(change to q || 100)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry_NoVnl&lt;br /&gt;
Note the warning in the output:&lt;br /&gt;
 &amp;lt;---&amp;gt; [WARNING] Missing non-local pseudopotential contribution&lt;br /&gt;
which also appears in the report file, and noted in the database as &amp;lt;code&amp;gt;[r,Vnl] included       :no&amp;lt;/code&amp;gt;. The difference is tiny:&lt;br /&gt;
[[File:CH-hBN-Vnl.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
However, when your system is larger, with more projectors in the pseudopotential or more k-points (see the BSE tutorial), the inclusion of &#039;&#039;Vnl&#039;&#039; can make a huge difference in the computational load, so it&#039;s always worth checking to see if the terms are important in your system.&lt;br /&gt;
&lt;br /&gt;
==Optical absorption in 2D BN: local field effects ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
[[File:Yambo-Cheatsheet-5.0_P7.png|thumb|Cheatsheet on LFE|150px]]&lt;br /&gt;
The macroscopic dielectric function is obtained by including the so-called local field effects (LFE) in the calculation of the response function. Within the time-dependent DFT formalism this is achieved by solving the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;. In reciprocal space this is given by:&lt;br /&gt;
[[File:Yambo-CH7.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
The microscopic dielectric function is related to &#039;&#039;X&#039;&#039; by:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
and the macroscopic dielectric function is obtained by taking the (0,0) component of the inverse microscopic one:&lt;br /&gt;
[[File:Yambo-CH6.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
Experimental observables like the optical absorption and the electron energy loss can be obtained from the macroscopic dielectric function:&lt;br /&gt;
[[File:Yambo-CH8.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In the following we will neglect the &#039;&#039;f &amp;lt;sup&amp;gt; xc&amp;lt;/sup&amp;gt;&#039;&#039; term: we perform the calculation at the RPA level and consider just the Hartree term (from &#039;&#039;v&amp;lt;sub&amp;gt;G&amp;lt;/sub&amp;gt;&#039;&#039;) in the kernel. If we also neglect the Hartree term, we arrive back at the independent particle approximation, since there is no kernel and &#039;&#039;X = X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for 2D hBN that contains the SAVE directory, and generate the input file. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -o c -k hartree&amp;lt;/code&amp;gt;. Let&#039;s start by running the calculation for light polarization &#039;&#039;q&#039;&#039; in the plane of the BN sheet:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree&lt;br /&gt;
We thus use a new input file &#039;&#039;yambo.in_RPA&#039;&#039;, switch on the &amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt; variable, and label all outputs/databases with a &#039;&#039;q100&#039;&#039; tag. Make sure to set/modify all of the following variables to:&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]=     &#039;&#039;&#039;6        Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
 [[Variables#Chimod|Chimod]]= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]= &#039;&#039;&#039;    3        Ry&#039;&#039;&#039;    # [Xd] Response block size&lt;br /&gt;
 % [[Variables#QpntsRXd|QpntsRXd]]&lt;br /&gt;
  1 |  1 |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#EnRngeXd|EnRngeXd]]&lt;br /&gt;
  0.00000 | 20.00000 | eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#DmRngeXd|DmRngeXd]]&lt;br /&gt;
 0.200000 | 0.200000 | eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsXd|ETStpsXd]]= 2001               # [Xd] Total Energy steps&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
In this input file, we have:&lt;br /&gt;
* We evaluate the q--&amp;gt;0 response function choosing the direction for the limit parallel in the plane of the hBN sheet &lt;br /&gt;
* A wider energy range than before, and more broadening&lt;br /&gt;
* Selected the Hartree kernel, and expanded G-vectors in the screening up to 3 Ry (about 85 G-vectors)&lt;br /&gt;
&lt;br /&gt;
===LFEs in periodic direction===&lt;br /&gt;
Now let&#039;s run the code with this new input file (CECAM in serial: about 2mins; parallel 4 tasks: 50s)&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J q100 &lt;br /&gt;
and let&#039;s compare the absorption with and without the local fields included. By inspecting the &#039;&#039;o-q100.eps_q1_inv_rpa_dyson&#039;&#039; file we find&lt;br /&gt;
that this information is given in the 2nd and 4th columns, respectively:&lt;br /&gt;
 $ head -n 40 o-q100.eps_q1_inv_rpa_dyson&lt;br /&gt;
 # Absorption @ Q(1) [q-&amp;gt;0 direction] : 1.0000000  0.0000000  0.0000000&lt;br /&gt;
 #  E/ev[1]     EPS-Im[2]   EPS-Re[3]   EPSo-Im[4]  EPSo-Re[5]&lt;br /&gt;
Plot the result:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; plot &amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l t &amp;quot;RPA-LFA&amp;quot;,&amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l t &amp;quot;noLFE&amp;quot;, &amp;quot;o-q100.eel_q1_inv_rpa_dyson&amp;quot; u 1:4 w l ls 7 dt 2 t &amp;quot;EELS&amp;quot;&lt;br /&gt;
[[File:CH-LFE4.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
It is clear that there is little influence of local fields in this case. This is generally the case for semiconductors or materials with a smoothly varying electronic density. We have also shown the EELS spectrum (&#039;&#039;o-q100.eel_q1_inv_rpa_dyson&#039;&#039;) for comparison.&lt;br /&gt;
&lt;br /&gt;
===LFEs in non-periodic direction===&lt;br /&gt;
Now let&#039;s switch to &#039;&#039;q&#039;&#039; perpendicular to the BN plane:&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree        &#039;&#039;and set&#039;&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 0.000000 | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
You can try out the default parallel usage now, or run again in serial, i.e.&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039;       &#039;&#039;(serial)&#039;&#039;&lt;br /&gt;
 $ mpirun -np 4 yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039; &amp;amp;      &#039;&#039;(parallel, MPI only, 4 tasks)&#039;&#039;&lt;br /&gt;
As noted previously, the &#039;&#039;log&#039;&#039; files in parallel appear in the LOG folder, you can follow the execution with &amp;lt;code&amp;gt;tail -F LOG/l-q001_optics_chi_CPU_1&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Plotting the output file:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l,&amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l&lt;br /&gt;
[[File:CH-LFE6.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
In this case, the absorption is strongly blueshifted with respect to the in-plane absorption. Furthermore, the influence of local fields is striking, and quenches the spectrum strongly. This is the well known depolarization effect. Local field effects are much stronger in the perpendicular direction because the charge inhomogeneity is dramatic. Many G-vectors are needed to account for the sharp change in the potential across the BN-vacuum interface.&lt;br /&gt;
&lt;br /&gt;
===Absorption versus EELS===&lt;br /&gt;
In order to understand this further, we plot the electron energy loss spectrum for this component and compare with the absorption:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot &amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; w l,&amp;quot;o-q001.eel_q1_inv_rpa_dyson&amp;quot; w l&lt;br /&gt;
[[File:CH-LFE5.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
The conclusion is that the absorption and EELS coincide for isolated systems. &lt;br /&gt;
To understand why this is, you need to consider the role of the &#039;&#039;macroscopic&#039;&#039; screening in the response function and the long-range part of the Coulomb potential. &lt;br /&gt;
See e.g.&amp;lt;ref&amp;gt;TDDFT from molecules to solids: The role of long‐range interactions, F. Sottile et al, International journal of quantum chemistry 102 (5), 684-701 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:40%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Back to: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4811</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=4811"/>
		<updated>2021-04-06T13:35:44Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Optical absorption in hBN: independent particle approximation ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN-bulk-3x3-annotated.png|x200px|Atomic structure of bulk hBN]]&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
The dielectric function in the long-wavelength limit, at the independent particle level (RPA without local fields), is essentially given by the following:&lt;br /&gt;
[[File:CH1.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
In practice, Yambo does not use this expression directly but solves the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;, which is described in the [[Local fields]] module.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for bulk hBN that contains the &#039;&#039;SAVE&#039;&#039; directory, run the initialization and generate the input file.&lt;br /&gt;
From &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -optics c&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;yambo -o c&amp;lt;/code&amp;gt;). Let&#039;s add some command line options:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo               &#039;&#039;(initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -o c&lt;br /&gt;
This corresponds to optical properties in G-space at the independent particle level: in the input file this is indicated by (&amp;lt;code&amp;gt;Chimod= &amp;quot;IP&amp;quot;&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
===Optics runlevel===&lt;br /&gt;
For optical properties we are interested just in the long-wavelength limit &#039;&#039;q = 0&#039;&#039;. This always corresponds to the &#039;&#039;first&#039;&#039; &#039;&#039;q&#039;&#039;-point in the set of possible &#039;&#039;q=k-k&#039; &#039;&#039;-points. &lt;br /&gt;
Change the following variables in the input file to:&lt;br /&gt;
 % [[Variables#QpntsRX|QpntsRXd]]&lt;br /&gt;
  1 |  &#039;&#039;&#039;1&#039;&#039;&#039; |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsX|ETStpsXd]]= &#039;&#039;&#039;1001&#039;&#039;&#039;               # [Xd] Total Energy steps&lt;br /&gt;
in order to select just the first &#039;&#039;q&#039;&#039;. The last variable ensures we generate a smooth spectrum. &lt;br /&gt;
Save the input file and launch the code, keeping the command line options as before (i.e., just remove the lower case options):&lt;br /&gt;
 $ yambo -F yambo.in_IP -J Full&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Optics&lt;br /&gt;
 &amp;lt;---&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Checking dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [x,Vnl] computed using 4 projectors&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY] Alloc WF%c( 16.307001Mb) TOTAL:  17.951000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [WF] Performing Wave-Functions I/O from ./SAVE&lt;br /&gt;
 &amp;lt;---&amp;gt; Dipoles: P and iR (T): |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [MEMORY]  Free WF%c( 16.307001Mb) TOTAL:  1.4700000Mb (traced)&lt;br /&gt;
 &amp;lt;---&amp;gt; [DIP] Writing dipoles header&lt;br /&gt;
 &amp;lt;---&amp;gt; [X-CG] R(p) Tot o/o(of R)  :   5499   52992     100&lt;br /&gt;
 &amp;lt;01s&amp;gt; Xo@q[1] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [MEMORY]TOTAL not deallocated :  907.0000Kb&lt;br /&gt;
 &amp;lt;01s&amp;gt; [05] Timing Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] Memory Overview&lt;br /&gt;
 &amp;lt;01s&amp;gt; [07] Game Over &amp;amp; Game summary&lt;br /&gt;
  &lt;br /&gt;
 $ ls&lt;br /&gt;
 Full   SAVE  yambo.in_IP   r_setup&lt;br /&gt;
 o-Full.eel_q1_ip  o-Full.eps_q1_ip  r-Full_optics_chi&lt;br /&gt;
Let&#039;s take a moment to understand what Yambo has done inside the Optics runlevel:&lt;br /&gt;
# Compute the &#039;&#039;[x,Vnl]&#039;&#039; term&lt;br /&gt;
# Read the wavefunctions from disc [WF]&lt;br /&gt;
# Compute the &#039;&#039;dipoles&#039;&#039;, i.e. matrix elements of &#039;&#039;&#039;p&#039;&#039;&#039;&lt;br /&gt;
# Write the dipoles to disk as &#039;&#039;Full/ndb.dip*&#039;&#039; databases. This you can see in the report file:&lt;br /&gt;
 $ grep -A20 &amp;quot;WR&amp;quot; r-Full_optics_*&lt;br /&gt;
 [WR./Full//ndb.dip_iR_and_P]--------------------------------&lt;br /&gt;
  Brillouin Zone Q/K grids (IBZ/BZ):  14   72   14   72&lt;br /&gt;
  RL vectors                   (WF): 1491&lt;br /&gt;
  Fragmentation                    :yes&lt;br /&gt;
  Electronic Temperature        [K]: 0.0000000&lt;br /&gt;
  Bosonic    Temperature        [K]: 0.0000000&lt;br /&gt;
  X band range           :   1  100&lt;br /&gt;
  X band range limits    :  8   9&lt;br /&gt;
  X e/h energy range [ev]:-1.0000000 -1.0000000&lt;br /&gt;
  RL vectors in the sum  : 1491&lt;br /&gt;
  [r,Vnl] included       :yes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=&amp;quot;5&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Finally, Yambo computes the non-interacting susceptibility &#039;&#039;X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039; for this &#039;&#039;q&#039;&#039;, and writes the dielectric function inside the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; file for plotting&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Energy cut off===&lt;br /&gt;
&lt;br /&gt;
Before plotting the output, let&#039;s change a few more variables. The previous calculation used &#039;&#039;all&#039;&#039; the G-vectors in expanding the wavefunctions, up to 1491 (~1016 components). This corresponds roughly to the cut off energy of 40Ry we used in the DFT calculation. Generally, however, we can use a smaller value. We use the verbosity to switch on this variable, and a new &#039;&#039;-J&#039;&#039; flag to avoid reading the previous database:&lt;br /&gt;
 $ yambo -F yambo.in_IP &#039;&#039;&#039;-V RL&#039;&#039;&#039; -o c&lt;br /&gt;
Change the &#039;&#039;&#039;value&#039;&#039;&#039; of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; and also its &#039;&#039;&#039;unit&#039;&#039;&#039; from &amp;lt;code&amp;gt;RL&amp;lt;/code&amp;gt; (number of G-vectors) to &amp;lt;code&amp;gt;Ry&amp;lt;/code&amp;gt; (energy in Rydberg):&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]= &#039;&#039;&#039;6&#039;&#039;&#039;           &#039;&#039;&#039;Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
Save the input file and launch the code again:&lt;br /&gt;
  $ yambo -F yambo.in_IP &#039;&#039;&#039;-J 6Ry &#039;&#039;&#039;&lt;br /&gt;
and then plot the &#039;&#039;o-Full.eps_q1_ip&#039;&#039; and &#039;&#039;o-6Ry.eps_q1_ip&#039;&#039; files:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-Full.eps_q1_ip&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip&amp;quot; w p&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-6Ry.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Clearly there is very little difference between the two spectra. This highlights an important point in calculating excited state properties: generally, fewer G-vectors are needed than what are needed in DFT calculations. Regarding the spectrum itself, the first peak occurs at about 4.4eV. This is consistent with the minimum direct gap reported by Yambo: 4.28eV. The comparison with experiment (not shown) is very poor however. &lt;br /&gt;
&lt;br /&gt;
If you make some mistake, and cannot reproduce this figure, you should check the value of &amp;lt;code&amp;gt;[[Variables#FFTGvecs|FFTGvecs]]&amp;lt;/code&amp;gt; in the input file, delete the &#039;&#039;6Ry&#039;&#039; folder, and try again - taking care to plot the right file! (e.g. &#039;&#039;o-6Ry.eps_q1_ip_01&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
===q-direction===&lt;br /&gt;
Now let&#039;s select a different component of the dielectric tensor:&lt;br /&gt;
 $ yambo -F yambo.in_IP -V RL -o c&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 &#039;&#039;&#039;0.000000&#039;&#039;&#039; | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry&lt;br /&gt;
This time yambo reads from the &#039;&#039;6Ry&#039;&#039; folder, so it does not need to compute the dipole matrix elements again, and the calculation is fast. Plotting gives:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-6Ry.eps_q1_ip&amp;quot; t &amp;quot;q || x-axis&amp;quot; w l,&amp;quot;o-6Ry.eps_q1_ip_01&amp;quot; t &amp;quot;q || c-axis&amp;quot; w l&lt;br /&gt;
&lt;br /&gt;
[[File:CH-hBN-ac.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
The absorption is suppressed in the stacking direction. As the interplanar spacing is increased, we would eventually arrive at the absorption of the BN sheet (see [[Local fields]] tutorial).&lt;br /&gt;
&lt;br /&gt;
===Non-local commutator===&lt;br /&gt;
Last, we show the effect of switching off the non-local commutator term (see &#039;&#039;[Vnl,r]&#039;&#039; in the equation at the top of the page) due to the pseudopotential. As there is no option to do this inside yambo, you need to hide the database file. Change back to the &#039;&#039;q || (1 0 0)&#039;&#039; direction, and launch yambo with a different &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ mv SAVE/ns.kb_pp_pwscf SAVE/ns.kb_pp_pwscf_&#039;&#039;&#039;OFF&#039;&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J &#039;&#039;&#039;6Ry_NoVnl&#039;&#039;&#039; -o c             &#039;&#039;(change to q || 100)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_IP -J 6Ry_NoVnl&lt;br /&gt;
Note the warning in the output:&lt;br /&gt;
 &amp;lt;---&amp;gt; [WARNING] Missing non-local pseudopotential contribution&lt;br /&gt;
which also appears in the report file, and noted in the database as &amp;lt;code&amp;gt;[r,Vnl] included       :no&amp;lt;/code&amp;gt;. The difference is tiny:&lt;br /&gt;
[[File:CH-hBN-Vnl.png|none|500px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
However, when your system is larger, with more projectors in the pseudopotential or more k-points (see the BSE tutorial), the inclusion of &#039;&#039;Vnl&#039;&#039; can make a huge difference in the computational load, so it&#039;s always worth checking to see if the terms are important in your system.&lt;br /&gt;
&lt;br /&gt;
==Optical absorption in 2D BN: local field effects ==&lt;br /&gt;
&lt;br /&gt;
[[File:HBN2.png|x200px|Atomic structure of 2D hBN]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Background ===&lt;br /&gt;
[[File:Yambo-Cheatsheet-5.0_P7.png|thumb|Cheatsheet on LFE|150px]]&lt;br /&gt;
The macroscopic dielectric function is obtained by including the so-called local field effects (LFE) in the calculation of the response function. Within the time-dependent DFT formalism this is achieved by solving the Dyson equation for the susceptibility &#039;&#039;X&#039;&#039;. In reciprocal space this is given by:&lt;br /&gt;
[[File:Yambo-CH7.png|none|x50px|Yambo tutorial image]]&lt;br /&gt;
The microscopic dielectric function is related to &#039;&#039;X&#039;&#039; by:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
and the macroscopic dielectric function is obtained by taking the (0,0) component of the inverse microscopic one:&lt;br /&gt;
[[File:Yambo-CH6.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
Experimental observables like the optical absorption and the electron energy loss can be obtained from the macroscopic dielectric function:&lt;br /&gt;
[[File:Yambo-CH8.png|none|x60px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In the following we will neglect the &#039;&#039;f &amp;lt;sup&amp;gt; xc&amp;lt;/sup&amp;gt;&#039;&#039; term: we perform the calculation at the RPA level and consider just the Hartree term (from &#039;&#039;v&amp;lt;sub&amp;gt;G&amp;lt;/sub&amp;gt;&#039;&#039;) in the kernel. If we also neglect the Hartree term, we arrive back at the independent particle approximation, since there is no kernel and &#039;&#039;X = X&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Choosing input parameters ===&lt;br /&gt;
Enter the folder for 2D hBN that contains the SAVE directory, and generate the input file. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -o c -k hartree&amp;lt;/code&amp;gt;. Let&#039;s start by running the calculation for light polarization &#039;&#039;q&#039;&#039; in the plane of the BN sheet:&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree&lt;br /&gt;
We thus use a new input file &#039;&#039;yambo.in_RPA&#039;&#039;, switch on the &amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt; variable, and label all outputs/databases with a &#039;&#039;q100&#039;&#039; tag. Make sure to set/modify all of the following variables to:&lt;br /&gt;
 [[Variables#FFTGvecs|FFTGvecs]]=     &#039;&#039;&#039;6        Ry&#039;&#039;&#039;    # [FFT] Plane-waves&lt;br /&gt;
 [[Variables#Chimod|Chimod]]= &amp;quot;Hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]= &#039;&#039;&#039;    3        Ry&#039;&#039;&#039;    # [Xd] Response block size&lt;br /&gt;
 % [[Variables#QpntsRXd|QpntsRXd]]&lt;br /&gt;
  1 |  1 |                   # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#EnRngeXd|EnRngeXd]]&lt;br /&gt;
  0.00000 | 20.00000 | eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#DmRngeXd|DmRngeXd]]&lt;br /&gt;
 0.200000 | 0.200000 | eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#ETStpsXd|ETStpsXd]]= 2001               # [Xd] Total Energy steps&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
In this input file, we have:&lt;br /&gt;
* We evaluate the q--&amp;gt;0 response function choosing the direction for the limit parallel in the plane of the hBN sheet &lt;br /&gt;
* A wider energy range than before, and more broadening&lt;br /&gt;
* Selected the Hartree kernel, and expanded G-vectors in the screening up to 3 Ry (about 85 G-vectors)&lt;br /&gt;
&lt;br /&gt;
===LFEs in periodic direction===&lt;br /&gt;
Now let&#039;s run the code with this new input file (CECAM in serial: about 2mins; parallel 4 tasks: 50s)&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J q100 &lt;br /&gt;
and let&#039;s compare the absorption with and without the local fields included. By inspecting the &#039;&#039;o-q100.eps_q1_inv_rpa_dyson&#039;&#039; file we find&lt;br /&gt;
that this information is given in the 2nd and 4th columns, respectively:&lt;br /&gt;
 $ head -n 40 o-q100.eps_q1_inv_rpa_dyson&lt;br /&gt;
 # Absorption @ Q(1) [q-&amp;gt;0 direction] : 1.0000000  0.0000000  0.0000000&lt;br /&gt;
 #  E/ev[1]     EPS-Im[2]   EPS-Re[3]   EPSo-Im[4]  EPSo-Re[5]&lt;br /&gt;
Plot the result:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; plot &amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l t &amp;quot;RPA-LFA&amp;quot;,&amp;quot;o-q100.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l t &amp;quot;noLFE&amp;quot;, &amp;quot;o-q100.eel_q1_inv_rpa_dyson&amp;quot; u 1:4 w l ls 7 dt 2 t &amp;quot;EELS&amp;quot;&lt;br /&gt;
[[File:CH-LFE4.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
It is clear that there is little influence of local fields in this case. This is generally the case for semiconductors or materials with a smoothly varying electronic density. We have also shown the EELS spectrum (&#039;&#039;o-q100.eel_q1_inv_rpa_dyson&#039;&#039;) for comparison.&lt;br /&gt;
&lt;br /&gt;
===LFEs in non-periodic direction===&lt;br /&gt;
Now let&#039;s switch to &#039;&#039;q&#039;&#039; perpendicular to the BN plane:&lt;br /&gt;
 $ yambo -F yambo.in_RPA -V RL -o c -k hartree        &#039;&#039;and set&#039;&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]]&lt;br /&gt;
 0.000000 | 0.000000 | &#039;&#039;&#039;1.000000&#039;&#039;&#039; |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &lt;br /&gt;
You can try out the default parallel usage now, or run again in serial, i.e.&lt;br /&gt;
 $ yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039;       &#039;&#039;(serial)&#039;&#039;&lt;br /&gt;
 $ mpirun -np 4 yambo -F yambo.in_RPA  -J &#039;&#039;&#039;q001&#039;&#039;&#039; &amp;amp;      &#039;&#039;(parallel, MPI only, 4 tasks)&#039;&#039;&lt;br /&gt;
As noted previously, the &#039;&#039;log&#039;&#039; files in parallel appear in the LOG folder, you can follow the execution with &amp;lt;code&amp;gt;tail -F LOG/l-q001_optics_chi_CPU_1&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
Plotting the output file:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:2 w l,&amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; u 1:4 w l&lt;br /&gt;
[[File:CH-LFE6.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
In this case, the absorption is strongly blueshifted with respect to the in-plane absorption. Furthermore, the influence of local fields is striking, and quenches the spectrum strongly. This is the well known depolarization effect. Local field effects are much stronger in the perpendicular direction because the charge inhomogeneity is dramatic. Many G-vectors are needed to account for the sharp change in the potential across the BN-vacuum interface.&lt;br /&gt;
&lt;br /&gt;
===Absorption versus EELS===&lt;br /&gt;
In order to understand this further, we plot the electron energy loss spectrum for this component and compare with the absorption:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot &amp;gt; plot &amp;quot;o-q001.eps_q1_inv_rpa_dyson&amp;quot; w l,&amp;quot;o-q001.eel_q1_inv_rpa_dyson&amp;quot; w l&lt;br /&gt;
[[File:CH-LFE5.png|none|600px|Yambo tutorial image]]&lt;br /&gt;
The conclusion is that the absorption and EELS coincide for isolated systems. &lt;br /&gt;
To understand why this is, you need to consider the role of the &#039;&#039;macroscopic&#039;&#039; screening in the response function and the long-range part of the Coulomb potential. &lt;br /&gt;
See e.g.&amp;lt;ref&amp;gt;TDDFT from molecules to solids: The role of long‐range interactions, F. Sottile et al, International journal of quantum chemistry 102 (5), 684-701 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: CECAM School Home --&amp;gt; [[First_steps:_walk_through_from_DFT(standalone)|First steps]] &lt;br /&gt;
|style=&amp;quot;width:40%; text-align:center&amp;quot;|Now: CECAM School Home --&amp;gt; [[Next steps: RPA calculations (standalone)|Next steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Back to: [[CECAM_VIRTUAL_2021#Tutorials|CECAM School Home]] &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Optical_properties_at_finite_temperature&amp;diff=4316</id>
		<title>Optical properties at finite temperature</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Optical_properties_at_finite_temperature&amp;diff=4316"/>
		<updated>2021-03-15T14:42:09Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:High low.png|thumb | 200px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show you how to calculate optical properties including thermal effects due to the electron-phonon coupling.&amp;lt;br&amp;gt;&lt;br /&gt;
This tutorial assumes that you have completed all the steps from the previous tutorial on [[Electron Phonon Coupling]].&amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial is dived in different steps first we will calculate absorption at independent particle approximation, &amp;lt;br&amp;gt;then we will include excitonic effects,&lt;br /&gt;
and finally we will show how to analyze the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Absorption at finite temperature ==&lt;br /&gt;
&lt;br /&gt;
Now you repeat the previous calculation but including all k-points, the last 3 valence and the first 3 conduction bands:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|8|2|7|&lt;br /&gt;
 %&lt;br /&gt;
 ....&lt;br /&gt;
and save the results of the 0K and 300K temperature in two separate folder with the -J option. &lt;br /&gt;
Now you can use the correction to the energy levels and the induced width to calculate the optical absorption at finite temperature. Generate the input with the command  &#039;&#039;yambo_ph -o c -V qp&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 chi                              # [R][CHI] Dyson equation for Chi.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 Chimod= &amp;quot;IP&amp;quot;                     # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % QpntsRXd&lt;br /&gt;
  1 | 1 |                             # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXd&lt;br /&gt;
   2 |  7 |                           # [Xd] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % EnRngeXd&lt;br /&gt;
  0.000000 | 5.000000 |         eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % DmRngeXd&lt;br /&gt;
  0.0100000 | 0.0100000 |         eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 ETStpsXd=  500                   # [Xd] Total Energy steps&lt;br /&gt;
 % LongDrXd&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;XfnQPdb= &amp;quot;E W &amp;lt; T300/ndb.QP&amp;quot; &amp;lt;/span&amp;gt;     # [EXTQP Xd] Database action&lt;br /&gt;
&lt;br /&gt;
set the path of the &#039;&#039;ndb.QP&#039;&#039; you want to read and perform the calculations. Notice that from the QP database we read two quantities the correction to the energy levels  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;E&amp;lt;/span&amp;gt; and the width  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;W&amp;lt;/span&amp;gt;. In this calculation we also included a small smearing 0.01eV to mimic the electronic smearing. Hereafter the result without and with electron-phonon coupling at two different temperatures:&lt;br /&gt;
[[File:Si absorption finite t.png|800px|center |Absorption of bulk silicon at finite temperature]]&lt;br /&gt;
&lt;br /&gt;
The temperature effect is clearly visible in the figure.&lt;br /&gt;
&lt;br /&gt;
== Bethe-Salpeter at finite temperature ==&lt;br /&gt;
&lt;br /&gt;
In this section we will calculate the Bethe-Salpeter at finite temperature. You can generate the input using the command &amp;lt;code&amp;gt;yambo_ph -X s -o b -k sex -y d -V qp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 em1s                             # [R][Xs] Statically Screened Interaction&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_Threads=0                      # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BSEmod= &amp;quot;coupling&amp;quot;&amp;lt;/span&amp;gt;              # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  9257            RL    # [BSK] Exchange components&lt;br /&gt;
 BSENGBlk=-1                RL    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 #WehCpl                        # [BSK] eh interaction included also in coupling&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot;&amp;lt;/span&amp;gt;       # [EXTQP BSK BSS] Database action&lt;br /&gt;
 KfnQP_INTERP_NN= 1               # [EXTQP BSK BSS] Interpolation neighbours (NN mode)&lt;br /&gt;
 KfnQP_INTERP_shells= 20.00000    # [EXTQP BSK BSS] Interpolation shells (BOLTZ mode)&lt;br /&gt;
 KfnQP_DbGd_INTERP_mode= &amp;quot;NN&amp;quot;     # [EXTQP BSK BSS] Interpolation DbGd mode&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.500000 | 1.000000 | 1.000000 |  &amp;lt;/span&amp;gt;      # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 BSEprop= &amp;quot;abs&amp;quot;                   # [BSS] abs/kerr/magn/dichr trace&lt;br /&gt;
 % BSEQptR&lt;br /&gt;
  1 | 1 |                             # [BSK] Transferred momenta range&lt;br /&gt;
 %&lt;br /&gt;
 % BSEBands&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   2 |  7 |  &amp;lt;/span&amp;gt;                         # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.00000 | 5.00000 | &amp;lt;/span&amp;gt;        eV    # [BSS] Energy range &lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.010000 | 0.010000 |  &amp;lt;/span&amp;gt;       eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BEnSteps= 500  &amp;lt;/span&amp;gt;                  # [BSS] Energy steps&lt;br /&gt;
 % BLongDir &lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 #WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
 XfnQPdb= &amp;quot;none&amp;quot;                  # [EXTQP Xd] Database action&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
   1 | 12 |                           # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 113              RL    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
&lt;br /&gt;
In this input file we asked Yambo to include finite temperature quasi-particle in the BSE with the line &amp;lt;code&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot; &amp;lt;/code&amp;gt;, notice that we also introduce an additional rigid shift of 0.8 eV to mimic the GW correction with the line &amp;lt;code&amp;gt; 0.500000 | 1.000000 | 1.000000 |  \# [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&amp;lt;/code&amp;gt;. In principle you can calculate the GW correction following the [http://www.yambo-code.org/wiki/index.php?title=How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN this tutorial] and then merge the corresponding ndb.QP database with the one of the electron-phonon coupling using the command &amp;lt;code&amp;gt; ypp -qpdb m&amp;lt;/code&amp;gt;.&lt;br /&gt;
Notice that we changed the BSE type to &amp;quot;coupling&amp;quot; because you need the full Bethe-Salpeter to deal with complex quasi-particles.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Si bse optics.png|800px|center |Bethe-Salpeter at finite temperature for bulk silicom]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Approximations:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In this calculation we have made different approximations:&amp;lt;br&amp;gt;&lt;br /&gt;
1) we did not include the renormalization of excitons due to the change of the screening potential W. Including electron-phonon coupling&lt;br /&gt;
in the dielectric constant by changing the line &amp;lt;code&amp;gt; XfnQPdb= &amp;quot;none&amp;quot; &amp;lt;/code&amp;gt; is unfortunately not enough, for a discussion see ref. &amp;lt;ref&amp;gt;L. Adamska and P. Umari, [https://journals.aps.org/prb/abstract/10.1103/PhysRevB.103.075201 Phys. Rev. B 103, 075201 (2021)] &amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2) The electron-phonon coupling should enter in the BSE through the exciton-phonon matrix elements and not from the single-particle self-energy, as we have done in this tutorial. The approximation used in this tutorial is valid for not too strong bound excitons, and in general it generated a finite life-time also for the lowest exciton in direct materials that is not correct. For a discussion see refs. &amp;lt;ref name=&#039;claudio&#039;&amp;gt; see Supp. Mat. of [https://journals.aps.org/prb/abstract/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&#039;fulvio&#039;&amp;gt;F. Paleari, [https://orbilu.uni.lu/handle/10993/41058 Phd Thesis (2019)]&amp;lt;/ref&amp;gt; and &amp;lt;ref&amp;gt;H. Chen, D. Sangalli, and M. Bernardi [https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.125.107401 Phys. Rev. Lett. 125, 107401 (2020)]&amp;lt;/ref&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
3) we did not include scattering between exciton and phonons, therefore our results do not contain phonon-assisted absorption peaks, you can include these terms by finite difference displacements see refs. &amp;lt;ref name=&#039;fulvio&#039;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Result analysis ==&lt;br /&gt;
Results of BSE at finite temperature can be analized in the same way of standard BSE. You can plot exciton binging energy as a function of the temperature, exciton wave-function and so, see [http://www.yambo-code.org/wiki/index.php?title=How_to_analyse_excitons Exciton Plot tutorial].&lt;br /&gt;
For example if you sort exciton with the command &amp;lt;code&amp;gt; ypp_ph -e s&amp;lt;/code&amp;gt; for the case T=0K, in addition to the exciton energy now you will find its line-width in the files .&lt;br /&gt;
&amp;lt;code&amp;gt;o.exc_qpt1_E_sorted&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;o.exc_qpt1_I_sorted&amp;lt;/code&amp;gt;.&lt;br /&gt;
 #&lt;br /&gt;
 #    Maximum Residual Value = .72765E+05&lt;br /&gt;
 #   &lt;br /&gt;
 #    E [ev]             Strength           Index              W [meV]&lt;br /&gt;
 #&lt;br /&gt;
 ...............&lt;br /&gt;
 3.13603616        0.894595146         274.000000         38.3100700&lt;br /&gt;
 3.13607597        0.458951890         276.000000         38.3091507&lt;br /&gt;
 3.13608289        0.936879739E-1      278.000000         38.3060684&lt;br /&gt;
 3.13852167        0.135797265E-3      279.000000         36.6859016&lt;br /&gt;
 3.13854289        0.166505214E-2      277.000000         36.6878891&lt;br /&gt;
 3.13856506        0.185914442E-2      275.000000         36.6866493&lt;br /&gt;
 3.18071890        0.344193308E-3      328.000000         35.5702744&lt;br /&gt;
 3.18077826        0.227900382E-4      329.000000         35.5690689&lt;br /&gt;
 3.19683385        0.355413969E-3      327.000000         34.4151421&lt;br /&gt;
 3.23861122        0.210206732         330.000000         42.7790527&lt;br /&gt;
 3.23862171        0.387398720         332.000000         42.7778893&lt;br /&gt;
 3.23863339        0.522650003         331.000000         42.7766075&lt;br /&gt;
&lt;br /&gt;
Notice that in the files you will find many exciton with negative energy due the full-BSE nature, finally consider line-width numbers with care due to the approximation described above.&lt;br /&gt;
&lt;br /&gt;
== Excitonic Eliashberg Functions ==&lt;br /&gt;
If you run the BSE and save the excitonic wave-functions (uncomment the flag &amp;lt;code&amp;gt;WRbsWF&amp;lt;/code&amp;gt; in the BSE input file), tt is possible to plot the excitonic Eliashberg Functions with the command &amp;lt;code&amp;gt; ypp_ph -e g&amp;lt;/code&amp;gt;.&lt;br /&gt;
For an interpretation of these functions see the discussion in reference &amp;lt;ref&amp;gt;Andrea Marini&lt;br /&gt;
 [https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.101.106405 Phys. Rev. Lett. 101, 106405 (2008)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Phonon-assisted density of states ==&lt;br /&gt;
Even if exciton-phonon scattering is not included in the BSE at finite temperature, it is possible to plot the phonon-assisted density of states (DOS) for light emission, defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula exc ph.png | 600px | center | Phonon-assisted JDOS ]]&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;E&amp;lt;sub&amp;gt;q&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;l&amp;lt;/sup&amp;gt;&#039;&#039;&#039; is the energy of the &#039;&#039;&#039;l&#039;&#039;&#039;-exciton at &#039;&#039;&#039;q&#039;&#039;&#039;-momentum,  &#039;&#039;&#039;ω&amp;lt;sub&amp;gt;q&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;λ&amp;lt;/sup&amp;gt;&#039;&#039;&#039; is the phonon energy, &#039;&#039;&#039;n&amp;lt;sub&amp;gt;B&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is the Bose function,  exciton are weighted with a Boltzamn factor and &#039;&#039;&#039;E&amp;lt;sub&amp;gt;min&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is the lowest exciton energy in the all BZ.&lt;br /&gt;
In order to calculate these DOS you need to solve BSE for all the q-points for the lowest excitons, you can use SLEPC library to speed up calculations, then you need a converged phonon calculations.&lt;br /&gt;
Then you interpolate phonon on a dense phonon grid using &amp;lt;code&amp;gt;matdyn.x&amp;lt;/code&amp;gt; utility in QE, and Yambo will interpolate exicton on the same grid.&lt;br /&gt;
Here we present an example for hBN that is an indirect semiconductor.&lt;br /&gt;
Running &amp;lt;code&amp;gt; ypp_ph -e p&amp;lt;/code&amp;gt; you will get:&lt;br /&gt;
 &lt;br /&gt;
 BoseTemp= 50 K    # Bosonic Temperature&lt;br /&gt;
 excitons                         # [R] Excitonic properties&lt;br /&gt;
 ph_ass_dos                       # [R] Phonon-assisted DOS&lt;br /&gt;
 States= &amp;quot;1 - 4&amp;quot;                  # Index of the BS state(s)&lt;br /&gt;
 PHfreqF= &amp;quot;./bn.freq_54&amp;quot;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 % DOSERange&lt;br /&gt;
  5.000000 | 5.500000 |         eV    # Energy range&lt;br /&gt;
 %&lt;br /&gt;
 DOSESteps= 1000                  # Energy steps&lt;br /&gt;
 DOS_broad= 0.004        eV    # Broadening of the DOS &lt;br /&gt;
&lt;br /&gt;
where &amp;quot;bn.freq_54&amp;quot; is the file produced by matdyn.x with the input:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;bn.fc&#039;,&lt;br /&gt;
     flfrq=&#039;bn.freq_54&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;bn.dos&#039;,&lt;br /&gt;
     ndos=2&lt;br /&gt;
     nk1=54, nk2=54, nk3=18&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
and the BSE was calculated on a 18x18x6 grid. The final spectra will be:&lt;br /&gt;
&lt;br /&gt;
[[File:Test dos pl bulk.png| 700px | center| Phonon-assisted JDOS]]&lt;br /&gt;
&lt;br /&gt;
where the DOS has been shifted to match the experimental peaks. Notice that the peak intensities are complitely off, because of the lack of the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)&amp;diff=3758</id>
		<title>GW tutorial. Convergence and approximations (BN)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)&amp;diff=3758"/>
		<updated>2020-01-30T23:30:41Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
We have selected 2D hexagonal boron nitride to explain the use of yambopy. Throughout this tutorial we show how to use yambopy to make efficient convergence tests, to compare different approximations and to analyse the results.&lt;br /&gt;
&lt;br /&gt;
=== Initial steps with Quantum Espresso ===&lt;br /&gt;
&lt;br /&gt;
Yambopy includes qepy, a module to handle QE-DFT calculations necessary to run Yambo.&lt;br /&gt;
&lt;br /&gt;
The initial step consists of a self-consistent (scf) ground state calculation together with a non-self-consistent (nscf) calculation with QE using the &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py&lt;br /&gt;
python gs_bn.py -sn&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you will be using a predefined lattice parameter for the calculations. You can, however, run a geometry optimisation calculation with &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py -rsn&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which at the end will update the input files for &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; with the relaxed lattice parameters and atomic coordinates. &lt;br /&gt;
&lt;br /&gt;
A quick note: almost all python scripts in this tutorial can be run without any options, but they will only print out the help message. In the case of &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; it will print:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py &lt;br /&gt;
usage: gs_bn.py [-h] [-r] [-s] [-n] [-n2] [-b] [-l] [-o] [-p] [-d]&lt;br /&gt;
                [-t NTHREADS]&lt;br /&gt;
&lt;br /&gt;
Test the yambopy script.&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  -r, --relax           Structural relaxation&lt;br /&gt;
  -s, --scf             Self-consistent calculation&lt;br /&gt;
  -n, --nscf            Non-self consistent calculation&lt;br /&gt;
  -n2, --nscf_double    Non-self consistent calculation for the double grid&lt;br /&gt;
  -b, --bands           Calculate band-structure&lt;br /&gt;
  -l, --plot            Plot band-structure&lt;br /&gt;
  -o, --orbitals        Plot atomic orbital projected band-structure&lt;br /&gt;
  -p, --phonon          Phonon calculation&lt;br /&gt;
  -d, --dispersion      Phonon dispersion&lt;br /&gt;
  -t NTHREADS, --nthreads NTHREADS&lt;br /&gt;
                        Number of threads&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have set the non-self-consistent run with a wave-function cutoff of &#039;&#039;&#039;60 Ry, 70 bands and a k-grid of &amp;lt;code&amp;gt;12x12x1&amp;lt;/code&amp;gt;&#039;&#039;&#039; for Yambo calculations.&lt;br /&gt;
&lt;br /&gt;
In addition, we can check if we get a reasonable band structure for our many-body calculations. We can define a path, for instance, in an hexagonal Brillouin zone:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
p = Path([ [[0.0, 0.0, 0.0],&#039;$\Gamma$&#039;],&lt;br /&gt;
           [[0.5, 0.0, 0.0],&#039;M&#039;],&lt;br /&gt;
           [[1./3,1./3,0.0],&#039;K&#039;],&lt;br /&gt;
           [[0.0, 0.0, 0.0],&#039;$\Gamma$&#039;]], [int(10*2),int(10),int(sqrt(5)*10)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We obtain the band structure by doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py -b&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Plot-bn-band.png|BN Band Structure|500px]]&lt;br /&gt;
&lt;br /&gt;
The horizontal line marks the top of the valence band. The electronic bandgap has a value of 4.73 eV. In the next sections, we will show how to calculate the GW correction and the excitonic effects with BSE using Yambo in an automatic way.&lt;br /&gt;
&lt;br /&gt;
=== GW convergence of the bandgap ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(a) Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We converge the main parameters of a GW calculation independently. In addition, we make use of the plasmon pole approximation for the dielectric function, and the Newton solver to find the GW correction to the LDA eigenvalues. We converge the band gap of BN (difference in energy of the bottom of the conduction and top of the valence band at the K point of the Brillouin zone). We have designed the script &#039;&#039;&#039;gw_conv_bn.py&#039;&#039;&#039; (folder ~/tutorial/bn) for this purpose.&lt;br /&gt;
&lt;br /&gt;
We can select the GW calculation by calling the &amp;lt;code&amp;gt;YamboIn&amp;lt;/code&amp;gt; with the corresponding arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;y = YamboIn.from_runlevel(&#039;yambo -d -p p -g n -V all&#039;,folder=&#039;gw_conv&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main variables of a GW calculation are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;EXXRLvcs&amp;lt;/code&amp;gt;: Exchange self-energy cutoff&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NGsBlkXp&amp;lt;/code&amp;gt;: Cutoff of the dielectric function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BndsRnXp&amp;lt;/code&amp;gt;: Number of bands in the calculation of the dielectric function (PPA).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;GbndRnge&amp;lt;/code&amp;gt;: Self-energy. The number of bands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We define a dictionary with all the parameters that we want to converge. Be aware of setting the right units and format for each parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;conv = { &#039;EXXRLvcs&#039;: [[10,10,20,30,40,50,60,70,80,90,100],&#039;Ry&#039;],&lt;br /&gt;
         &#039;NGsBlkXp&#039;: [[0,0,1,2,3,4,5,6], &#039;Ry&#039;],&lt;br /&gt;
         &#039;BndsRnXp&#039;: [[[1,10],[1,10],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70]],&#039;&#039;] ,&lt;br /&gt;
         &#039;GbndRnge&#039;: [[[1,10],[1,10],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70]],&#039;&#039;] }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class &amp;lt;code&amp;gt;YamboIn&amp;lt;/code&amp;gt; includes the function &amp;lt;code&amp;gt;optimize&amp;lt;/code&amp;gt;, which is called here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
y.optimize(conv,folder=&#039;gw_conv&#039;,run=run,ref_run=False)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function optimize has two main arguments: the convergence dictionary, and a function &#039;&#039;&#039;run&#039;&#039;&#039; with the instructions to run&lt;br /&gt;
the calculation, defined in our case like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    def run(filename):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; Function to be called by the optimize function &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        folder = filename.split(&#039;.&#039;)[0]&lt;br /&gt;
        print(filename,folder)&lt;br /&gt;
        shell = bash() &lt;br /&gt;
        shell.add_command(&#039;cd gw_conv&#039;)&lt;br /&gt;
        shell.add_command(&#039;rm -f *.json %s/o-*&#039;%folder) #cleanup&lt;br /&gt;
        shell.add_command(&#039;%s -F %s -J %s -C %s 2&amp;gt; %s.log&#039;%(yambo,filename,folder,folder,folder))&lt;br /&gt;
        shell.run()&lt;br /&gt;
        shell.clean()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have defined interactive run, in the folder &amp;lt;code&amp;gt;gw_conv&amp;lt;/code&amp;gt;. We have also defined the name for each job, associated with the variable and its value.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(b) Analysis&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once all the calculations are finished it&#039;s time to analyse them. At this point yambopy will facilitate the analysis. Besides &lt;br /&gt;
the python module, &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt; can also be called in the terminal to perform some post-analysis tasks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
     $ yambopy&lt;br /&gt;
     analysebse -&amp;gt;     Using ypp, you can study the convergence of BSE calculations in 2 ways:&lt;br /&gt;
       plotem1s -&amp;gt;     Plot em1s calculation&lt;br /&gt;
      analysegw -&amp;gt;     Study the convergence of GW calculations by looking at the change in bandgap value.&lt;br /&gt;
        mergeqp -&amp;gt;     Merge QP databases&lt;br /&gt;
           test -&amp;gt;     Run yambopy tests&lt;br /&gt;
   plotexcitons -&amp;gt;     Plot excitons calculation&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calling &amp;lt;code&amp;gt;yambopy analysegw&amp;lt;/code&amp;gt; will display the help of the function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    Study the convergence of GW calculations by looking at the change in bandgap value.&lt;br /&gt;
&lt;br /&gt;
    The script reads from &amp;lt;folder&amp;gt; all results from &amp;lt;variable&amp;gt; calculations and display them.&lt;br /&gt;
&lt;br /&gt;
    Use the band and k-point options according to the size of your k-grid&lt;br /&gt;
    and the location of the band extrema.&lt;br /&gt;
&lt;br /&gt;
        Mandatory arguments are:&lt;br /&gt;
            folder   -&amp;gt; Folder containing SAVE and convergence runs.&lt;br /&gt;
            var      -&amp;gt; Variable tested (e.g. FFTGvecs)&lt;br /&gt;
&lt;br /&gt;
        Optional variables are:&lt;br /&gt;
            -bc, --bandc   (int)  -&amp;gt; Lowest conduction band number&lt;br /&gt;
            -kc, --kpointc (int)  -&amp;gt; k-point index for conduction band&lt;br /&gt;
            -bv, --bandv   (int)  -&amp;gt; Highest valence band number&lt;br /&gt;
            -kv, --kpointv (int)  -&amp;gt; k-point index for valence band&lt;br /&gt;
            -np, --nopack  (flag) -&amp;gt; Do not call &#039;pack_files_in_folder&#039;&lt;br /&gt;
            -nt, --notext  (flag) -&amp;gt; Do not print a text file&lt;br /&gt;
            -nd, --nodraw  (flag) -&amp;gt; Do not draw (plot) the result&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running the function selecting the bands and k-points, together with the parameter of convergence we will obtain the convergence plot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv EXXRLvcs &lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv NGsBlkXp&lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv BndsRnXp&lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv GbndRnge&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the convergence plots, we can choose the set of converged parameters and repeat the calculation for finer k-grids until we reach convergence with the k-points. We have&lt;br /&gt;
intentionally used non-converged parameters. Nevertheless, along this week&lt;br /&gt;
you should have gotten enough expertise to push the convergence of the parameters&lt;br /&gt;
and determine the correct convergence set of parameters.&lt;br /&gt;
We invite you to enter in the python script, increase the parameters and check&lt;br /&gt;
again the convergence for larger values!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:EXXRLvcs.png|FFTGvecs|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:NGsBlkXp.png|NGsBlkXp|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BndsRnXp.png|BndsRnXp|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:GbndRnge2.png|GbndRnge|300px]]&lt;br /&gt;
&lt;br /&gt;
In general, the convergence with the &#039;&#039;&#039;k-grid&#039;&#039;&#039; is done after these variables are converged and, in principle, it is also independent of them. We invite you to change the number of k-points in the file &#039;&#039;&#039;gs_bn.py&#039;&#039;&#039; using the variable &#039;&#039;&#039;kpoints_nscf&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== GW calculation in regular k-grid ===&lt;br /&gt;
&lt;br /&gt;
From the bandgap convergence study made above for a &#039;&#039;&#039;k-grid&#039;&#039;&#039; we can decide reasonable parameters. Another option is to decide a convergence threshold to establish&lt;br /&gt;
the accuracy of the convergence. In this tutorial, in order to make calculations lighter, we have chosen the following parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
EXXRLvcs = 60 Ry&lt;br /&gt;
BndsRnXp = 40 bands&lt;br /&gt;
NGsBlkXp =  3  Ry&lt;br /&gt;
GbndRnge = 30 bands&lt;br /&gt;
QPkrange = [1,19,2,6]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can change the &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; scripts to calculate a non self-consistent run for a larger &#039;&#039;&#039;k-grid&#039;&#039;&#039; (12x12x1 will do the job). We can also change the number of bands to 40 in order to speed up a bit the QE calculation.&lt;br /&gt;
&lt;br /&gt;
We can just simply run the code to calculate the GW corrections for all the points of the Brillouin zone by setting the converged parameters in the script &amp;lt;code&amp;gt;gw_bn.py&amp;lt;/code&amp;gt;. If we enter in the script we can check that we define a scheduler (the default is bash):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
scheduler = Scheduler.factory&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We just need to define the run level and the variables we are going to chang:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
y = YamboIn.from_runlevel(&#039;%s -p p -g n -V all&#039;%yambo,folder=&#039;gw&#039;)&lt;br /&gt;
    &lt;br /&gt;
y[&#039;EXXRLvcs&#039;] = [60,&#039;Ry&#039;]       # Self-energy. Exchange&lt;br /&gt;
y[&#039;BndsRnXp&#039;] = [1,40]          # Screening. Number of bands&lt;br /&gt;
y[&#039;NGsBlkXp&#039;] = [3,&#039;Ry&#039;]        # Cutoff Screening&lt;br /&gt;
y[&#039;GbndRnge&#039;] = [1,30]          # Self-energy. Number of bands&lt;br /&gt;
y[&#039;QPkrange&#039;] = [kpoint_start,kpoint_end,2,6]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now run the script and obtain the GW in the full &#039;&#039;&#039;k-grid&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
python gw_bn.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If everything has worked fine now we will have inside the folder &amp;lt;code&amp;gt;gw/yambo&amp;lt;/code&amp;gt; the netCDF file &amp;lt;code&amp;gt;ndb.QP&amp;lt;/code&amp;gt; with the results of the GW calculation. We can analyze the results and/or use them in BSE calculations.&lt;br /&gt;
&lt;br /&gt;
=== Plotting GW calculations. Scissor operator and GW band structure  ===&lt;br /&gt;
&lt;br /&gt;
If everything has worked fine now we can start using the yambopy analysis tools. For this purpose, we have created the script &amp;lt;code&amp;gt;plot-qp.py&amp;lt;/code&amp;gt;. Using this &lt;br /&gt;
script we will be able to read the Yambo databases and plot the results. Notice that we use matplotlib to make the plots. For all the plots we define a figure and axis by&lt;br /&gt;
doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
fig = plt.figure(figsize=(6,4))&lt;br /&gt;
ax  = fig.add_axes( [ 0.20, 0.20, 0.70, 0.70 ])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file is structured as follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A. Define a path&#039;&#039;&#039;. Using qepy we can define a path to plot the band structure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
npoints = 10&lt;br /&gt;
path = Path([ [[  0.0,  0.0,  0.0],&#039;$\Gamma$&#039;],&lt;br /&gt;
              [[  0.5,  0.0,  0.0],&#039;M&#039;],&lt;br /&gt;
              [[1./3.,1./3.,  0.0],&#039;K&#039;],&lt;br /&gt;
              [[  0.0,  0.0,  0.0],&#039;$\Gamma$&#039;]], [int(npoints*2),int(npoints),int(sqrt(5)*npoints)] )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;B. Read Yambo lattice and QP databases.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
lat  = YamboSaveDB.from_db_file(folder=&#039;gw/SAVE&#039;,filename=&#039;ns.db1&#039;)&lt;br /&gt;
ydb  = YamboQPDB.from_db(filename=&#039;ndb.QP&#039;,folder=&#039;gw/yambo&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;C. Plot all QP eigenvalues.&#039;&#039;&#039; A very typical plot when analyzing GW calculations is the plot of the GW eigenvalues versus LDA eigenvalues. You just need to indicate which band index corresponds to the&lt;br /&gt;
top of the valence band.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
n_top_vb = 4&lt;br /&gt;
ydb.plot_scissor_ax(ax,n_top_vb)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Scissor-gw.png|GW results (dots) and linear fitting (solid lines) |300px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;D. Plot exact QP-GW eigenvalues in a path.&#039;&#039;&#039; We can also plot the band structure of calculated points (not interpolated). Yambopy &lt;br /&gt;
will find which k-points belong to a given path. We can add the LDA results for comparison.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ks_bs_0, qp_bs_0 = ydb.get_bs_path(lat,path)&lt;br /&gt;
ks_bs_0.plot_ax(ax,legend=True,color_bands=&#039;r&#039;,label=&#039;KS&#039;)&lt;br /&gt;
qp_bs_0.plot_ax(ax,legend=True,color_bands=&#039;b&#039;,label=&#039;QP-GW&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bands-LDA-GW.png|GW and LDA band structures |300px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;E. Plot interpolated QP-GW eigenvalues in a path.&#039;&#039;&#039; In order to obtain results ready for publication or presentation, we can interpolate the GW calculations.&lt;br /&gt;
&lt;br /&gt;
[[File:Bands-LDA-GW-interpolated.png| Interpolated GW and LDA band structures |300px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;F. Comparison non-interpolated and interpolated results.&#039;&#039;&#039; It is convenient to check how good is the interpolation of GW results.&lt;br /&gt;
&lt;br /&gt;
[[File:Lda-gw-comparison.png| Exact and interpolated GW and LDA band structures |300px]]&lt;br /&gt;
&lt;br /&gt;
=== GW convergence for all k-points ===&lt;br /&gt;
&lt;br /&gt;
If we want to perform GW convergence in all the band states, we can check the &lt;br /&gt;
script &amp;lt;code&amp;gt;plot-gw-conv.py&amp;lt;/code&amp;gt;. Here we plot the band structure for all the k-points. For this, we pack the results in json files and then use the analyzer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pack_files_in_folder(&#039;gw_conv&#039;)&lt;br /&gt;
ya = YamboAnalyser(&#039;gw_conv&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the case of the variable NGsBlkXs, we have set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ya.plot_gw_all_kpoints_convergence(tag=&#039;NGsBlkXs&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Chi-cutoff-kpoints.png||500px]]&lt;br /&gt;
&lt;br /&gt;
=== Approximations of the dielectric function (COHSEX, PPA) ===&lt;br /&gt;
&lt;br /&gt;
We can use yambopy to examine different run levels. For instance, the approximations used to obtain the screening are the: (i) static screening or COHSEX, (ii) plasmon-pole approximations (PPA), or (iii) real axis integration. We have set the same parameters for the first two options, just changing the variable name for the number of bands and the cut-off of the screening.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
COHSEX&lt;br /&gt;
EXXRLvcs = 60 Ry &lt;br /&gt;
BndsRnXs = 40 bands&lt;br /&gt;
NGsBlkXs = 3 Ry&lt;br /&gt;
&lt;br /&gt;
PPA&lt;br /&gt;
EXXRLvcs = 60 Ry &lt;br /&gt;
BndsRnXp = 40 bands&lt;br /&gt;
NGsBlkXp = 3 Ry&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have set the converged parameters and the function works by running:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gw_conv_bn.py -x&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We plot the band structure using the analyzer explained above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gw_conv_bn.py -xp&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We observe a difference between COHSEX and PPA.&lt;br /&gt;
&lt;br /&gt;
[[File:Gw-chi-s.png|GW bands calculated with the COHSEX and PPA|300px]]&lt;br /&gt;
&lt;br /&gt;
You are welcome to refine the calculations using better parameters and check how this difference changes. In the next tutorial,  [[Bethe-Salpeter equation tutorial. Optical absorption (BN)]], you can use the scissor operator computed in section [[#GW_calculation_in_regular_k-grid|GW calculation in regular k-grid]].&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)&amp;diff=3755</id>
		<title>GW tutorial. Convergence and approximations (BN)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)&amp;diff=3755"/>
		<updated>2020-01-30T23:08:49Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
We have selected 2D hexagonal boron nitride to explain the use of yambopy. Throughout this tutorial we show how to use yambopy to make efficient convergence tests, to compare different approximations and to analyse the results.&lt;br /&gt;
&lt;br /&gt;
=== Initial steps with Quantum Espresso ===&lt;br /&gt;
&lt;br /&gt;
Yambopy includes qepy, a module to handle QE-DFT calculations necessary to run Yambo.&lt;br /&gt;
&lt;br /&gt;
The initial step consists of a self-consistent (scf) ground state calculation together with a non-self-consistent (nscf) calculation with QE using the &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py&lt;br /&gt;
python gs_bn.py -sn&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here you will be using a predefined lattice parameter for the calculations. You can, however, run a geometry optimisation calculation with &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py -rsn&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which at the end will update the input files for &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; with the relaxed lattice parameters and atomic coordinates. &lt;br /&gt;
&lt;br /&gt;
A quick note: almost all python scripts in this tutorial can be run without any options, but they will only print out the help message. In the case of &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; it will print:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py &lt;br /&gt;
usage: gs_bn.py [-h] [-r] [-s] [-n] [-n2] [-b] [-l] [-o] [-p] [-d]&lt;br /&gt;
                [-t NTHREADS]&lt;br /&gt;
&lt;br /&gt;
Test the yambopy script.&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  -r, --relax           Structural relaxation&lt;br /&gt;
  -s, --scf             Self-consistent calculation&lt;br /&gt;
  -n, --nscf            Non-self consistent calculation&lt;br /&gt;
  -n2, --nscf_double    Non-self consistent calculation for the double grid&lt;br /&gt;
  -b, --bands           Calculate band-structure&lt;br /&gt;
  -l, --plot            Plot band-structure&lt;br /&gt;
  -o, --orbitals        Plot atomic orbital projected band-structure&lt;br /&gt;
  -p, --phonon          Phonon calculation&lt;br /&gt;
  -d, --dispersion      Phonon dispersion&lt;br /&gt;
  -t NTHREADS, --nthreads NTHREADS&lt;br /&gt;
                        Number of threads&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have set the non-self-consistent run with a wave-function cutoff of &#039;&#039;&#039;60 Ry, 70 bands and a k-grid of &amp;lt;code&amp;gt;12x12x1&amp;lt;/code&amp;gt;&#039;&#039;&#039; for Yambo calculations.&lt;br /&gt;
&lt;br /&gt;
In addition, we can check if we get a reasonable band structure for our many-body calculations. We can define a path, for instance, in an hexagonal Brillouin zone:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
p = Path([ [[0.0, 0.0, 0.0],&#039;$\Gamma$&#039;],&lt;br /&gt;
           [[0.5, 0.0, 0.0],&#039;M&#039;],&lt;br /&gt;
           [[1./3,1./3,0.0],&#039;K&#039;],&lt;br /&gt;
           [[0.0, 0.0, 0.0],&#039;$\Gamma$&#039;]], [int(10*2),int(10),int(sqrt(5)*10)])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We obtain the band structure by doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gs_bn.py -b&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Plot-bn-band.png|BN Band Structure|500px]]&lt;br /&gt;
&lt;br /&gt;
The horizontal line marks the top of the valence band. The electronic bandgap has a value of 4.73 eV. In the next sections, we will show how to calculate the GW correction and the excitonic effects with BSE using Yambo in an automatic way.&lt;br /&gt;
&lt;br /&gt;
=== GW convergence of the bandgap ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(a) Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We converge the main parameters of a GW calculation independently. In addition, we make use of the plasmon pole approximation for the dielectric function, and the Newton solver to find the GW correction to the LDA eigenvalues. We converge the band gap of BN (difference in energy of the bottom of the conduction and top of the valence band at the K point of the Brillouin zone). We have designed the script &#039;&#039;&#039;gw_conv_bn.py&#039;&#039;&#039; (folder ~/tutorial/bn) for this purpose.&lt;br /&gt;
&lt;br /&gt;
We can select the GW calculation by calling the &amp;lt;code&amp;gt;YamboIn&amp;lt;/code&amp;gt; with the corresponding arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;y = YamboIn.from_runlevel(&#039;yambo -d -p p -g n -V all&#039;,folder=&#039;gw_conv&#039;)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main variables of a GW calculation are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;EXXRLvcs&amp;lt;/code&amp;gt;: Exchange self-energy cutoff&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NGsBlkXp&amp;lt;/code&amp;gt;: Cutoff of the dielectric function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BndsRnXp&amp;lt;/code&amp;gt;: Number of bands in the calculation of the dielectric function (PPA).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;GbndRnge&amp;lt;/code&amp;gt;: Self-energy. The number of bands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We define a dictionary with all the parameters that we want to converge. Be aware of setting the right units and format for each parameter.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;conv = { &#039;EXXRLvcs&#039;: [[10,10,20,30,40,50,60,70,80,90,100],&#039;Ry&#039;],&lt;br /&gt;
         &#039;NGsBlkXp&#039;: [[0,0,1,2,3,4,5,6], &#039;Ry&#039;],&lt;br /&gt;
         &#039;BndsRnXp&#039;: [[[1,10],[1,10],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70]],&#039;&#039;] ,&lt;br /&gt;
         &#039;GbndRnge&#039;: [[[1,10],[1,10],[1,20],[1,30],[1,40],[1,50],[1,60],[1,70]],&#039;&#039;] }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class &amp;lt;code&amp;gt;YamboIn&amp;lt;/code&amp;gt; includes the function &amp;lt;code&amp;gt;optimize&amp;lt;/code&amp;gt;, which is called here:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
y.optimize(conv,folder=&#039;gw_conv&#039;,run=run,ref_run=False)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function optimize has two main arguments: the convergence dictionary, and a function &#039;&#039;&#039;run&#039;&#039;&#039; with the instructions to run&lt;br /&gt;
the calculation, defined in our case like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    def run(filename):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot; Function to be called by the optimize function &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        folder = filename.split(&#039;.&#039;)[0]&lt;br /&gt;
        print(filename,folder)&lt;br /&gt;
        shell = bash() &lt;br /&gt;
        shell.add_command(&#039;cd gw_conv&#039;)&lt;br /&gt;
        shell.add_command(&#039;rm -f *.json %s/o-*&#039;%folder) #cleanup&lt;br /&gt;
        shell.add_command(&#039;%s -F %s -J %s -C %s 2&amp;gt; %s.log&#039;%(yambo,filename,folder,folder,folder))&lt;br /&gt;
        shell.run()&lt;br /&gt;
        shell.clean()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have defined interactive run, in the folder &amp;lt;code&amp;gt;gw_conv&amp;lt;/code&amp;gt;. We have also defined the name for each job, associated with the variable and its value.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;(b) Analysis&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once all the calculations are finished it&#039;s time to analyse them. At this point yambopy will facilitate the analysis. Besides &lt;br /&gt;
the python module, &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt; can also be called in the terminal to perform some post-analysis tasks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
     $ yambopy&lt;br /&gt;
     analysebse -&amp;gt;     Using ypp, you can study the convergence of BSE calculations in 2 ways:&lt;br /&gt;
       plotem1s -&amp;gt;     Plot em1s calculation&lt;br /&gt;
      analysegw -&amp;gt;     Study the convergence of GW calculations by looking at the change in bandgap value.&lt;br /&gt;
        mergeqp -&amp;gt;     Merge QP databases&lt;br /&gt;
           test -&amp;gt;     Run yambopy tests&lt;br /&gt;
   plotexcitons -&amp;gt;     Plot excitons calculation&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calling &amp;lt;code&amp;gt;yambopy analysegw&amp;lt;/code&amp;gt; will display the help of the function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    Study the convergence of GW calculations by looking at the change in bandgap value.&lt;br /&gt;
&lt;br /&gt;
    The script reads from &amp;lt;folder&amp;gt; all results from &amp;lt;variable&amp;gt; calculations and display them.&lt;br /&gt;
&lt;br /&gt;
    Use the band and k-point options according to the size of your k-grid&lt;br /&gt;
    and the location of the band extrema.&lt;br /&gt;
&lt;br /&gt;
        Mandatory arguments are:&lt;br /&gt;
            folder   -&amp;gt; Folder containing SAVE and convergence runs.&lt;br /&gt;
            var      -&amp;gt; Variable tested (e.g. FFTGvecs)&lt;br /&gt;
&lt;br /&gt;
        Optional variables are:&lt;br /&gt;
            -bc, --bandc   (int)  -&amp;gt; Lowest conduction band number&lt;br /&gt;
            -kc, --kpointc (int)  -&amp;gt; k-point index for conduction band&lt;br /&gt;
            -bv, --bandv   (int)  -&amp;gt; Highest valence band number&lt;br /&gt;
            -kv, --kpointv (int)  -&amp;gt; k-point index for valence band&lt;br /&gt;
            -np, --nopack  (flag) -&amp;gt; Do not call &#039;pack_files_in_folder&#039;&lt;br /&gt;
            -nt, --notext  (flag) -&amp;gt; Do not print a text file&lt;br /&gt;
            -nd, --nodraw  (flag) -&amp;gt; Do not draw (plot) the result&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running the function selecting the bands and k-points, together with the parameter of convergence we will obtain the convergence plot.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv EXXRLvcs &lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv NGsBlkXp&lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv BndsRnXp&lt;br /&gt;
yambopy analysegw -bc 5 -kc 7 -bv 4 -kv 7 gw_conv GbndRnge&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the convergence plots, we can choose the set of converged parameters and repeat the calculation for finer k-grids until we reach convergence with the k-points. We have&lt;br /&gt;
intentionally used non-converged parameters. Nevertheless, along this week&lt;br /&gt;
you should have gotten enough expertise to push the convergence of the parameters&lt;br /&gt;
and determine the correct convergence set of parameters.&lt;br /&gt;
We invite you to enter in the python script, increase the parameters and check&lt;br /&gt;
again the convergence for larger values!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:EXXRLvcs.png|FFTGvecs|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:NGsBlkXp.png|NGsBlkXp|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:BndsRnXp.png|BndsRnXp|300px]]&lt;br /&gt;
&lt;br /&gt;
[[File:GbndRnge2.png|GbndRnge|300px]]&lt;br /&gt;
&lt;br /&gt;
In general, the convergence with the &#039;&#039;&#039;k-grid&#039;&#039;&#039; is done after these variables are converged and, in principle, it is also independent of them. We invite you to change the number of k-points in the file &#039;&#039;&#039;gs_bn.py&#039;&#039;&#039; using the variable &#039;&#039;&#039;kpoints_nscf&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== GW calculation in regular k-grid ===&lt;br /&gt;
&lt;br /&gt;
From the bandgap convergence study made above for a &#039;&#039;&#039;k-grid&#039;&#039;&#039; we can decide reasonable parameters. Another option is to decide a convergence threshold to establish&lt;br /&gt;
the accuracy of the convergence. In this tutorial, in order to make calculations lighter, we have chosen the following parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
EXXRLvcs = 60 Ry&lt;br /&gt;
BndsRnXp = 40 bands&lt;br /&gt;
NGsBlkXp =  3  Ry&lt;br /&gt;
GbndRnge = 30 bands&lt;br /&gt;
QPkrange = [1,19,2,6]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can change the &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; scripts to calculate a non self-consistent run for a larger &#039;&#039;&#039;k-grid&#039;&#039;&#039; (12x12x1 will do the job). We can also change the number of bands to 40 in order to speed up a bit the QE calculation.&lt;br /&gt;
&lt;br /&gt;
We can just simply run the code to calculate the GW corrections for all the points of the Brillouin zone by setting the converged parameters in the script &amp;lt;code&amp;gt;gw_bn.py&amp;lt;/code&amp;gt;. If we enter in the script we can check that we define a scheduler (the default is bash):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
scheduler = Scheduler.factory&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We just need to define the run level and the variables we are going to chang:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
y = YamboIn.from_runlevel(&#039;%s -p p -g n -V all&#039;%yambo,folder=&#039;gw&#039;)&lt;br /&gt;
    &lt;br /&gt;
y[&#039;EXXRLvcs&#039;] = [60,&#039;Ry&#039;]       # Self-energy. Exchange&lt;br /&gt;
y[&#039;BndsRnXp&#039;] = [1,40]          # Screening. Number of bands&lt;br /&gt;
y[&#039;NGsBlkXp&#039;] = [3,&#039;Ry&#039;]        # Cutoff Screening&lt;br /&gt;
y[&#039;GbndRnge&#039;] = [1,30]          # Self-energy. Number of bands&lt;br /&gt;
y[&#039;QPkrange&#039;] = [kpoint_start,kpoint_end,2,6]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can now run the script and obtain the GW in the full &#039;&#039;&#039;k-grid&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
python gw_bn.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If everything has worked fine now we will have inside the folder &amp;lt;code&amp;gt;gw/yambo&amp;lt;/code&amp;gt; the netCDF file &amp;lt;code&amp;gt;ndb.QP&amp;lt;/code&amp;gt; with the results of the GW calculation. We can analyze the results and/or use them in BSE calculations.&lt;br /&gt;
&lt;br /&gt;
=== Plotting GW calculations. Scissor operator and GW band structure  ===&lt;br /&gt;
&lt;br /&gt;
If everything has worked fine now we can start using the yambopy analysis tools. For this purpose, we have created the script &amp;lt;code&amp;gt;plot-qp.py&amp;lt;/code&amp;gt;. Using this &lt;br /&gt;
script we will be able to read the Yambo databases and plot the results. Notice that we use matplotlib to make the plots. For all the plots we define a figure and axis by&lt;br /&gt;
doing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
fig = plt.figure(figsize=(6,4))&lt;br /&gt;
ax  = fig.add_axes( [ 0.20, 0.20, 0.70, 0.70 ])&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file is structured as follows:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;A. Define a path&#039;&#039;&#039;. Using qepy we can define a path to plot the band structure.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
npoints = 10&lt;br /&gt;
path = Path([ [[  0.0,  0.0,  0.0],&#039;$\Gamma$&#039;],&lt;br /&gt;
              [[  0.5,  0.0,  0.0],&#039;M&#039;],&lt;br /&gt;
              [[1./3.,1./3.,  0.0],&#039;K&#039;],&lt;br /&gt;
              [[  0.0,  0.0,  0.0],&#039;$\Gamma$&#039;]], [int(npoints*2),int(npoints),int(sqrt(5)*npoints)] )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;B. Read Yambo lattice and QP databases.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
lat  = YamboSaveDB.from_db_file(folder=&#039;gw/SAVE&#039;,filename=&#039;ns.db1&#039;)&lt;br /&gt;
ydb  = YamboQPDB.from_db(filename=&#039;ndb.QP&#039;,folder=&#039;gw/yambo&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;C. Plot all QP eigenvalues.&#039;&#039;&#039; A very typical plot when analyzing GW calculations is the plot of the GW eigenvalues versus LDA eigenvalues. You just need to indicate which band index corresponds to the&lt;br /&gt;
top of the valence band.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
n_top_vb = 4&lt;br /&gt;
ydb.plot_scissor_ax(ax,n_top_vb)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Scissor-gw.png|GW results (dots) and linear fitting (solid lines) |300px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;D. Plot exact QP-GW eigenvalues in a path.&#039;&#039;&#039; We can also plot the band structure of calculated points (not interpolated). Yambopy &lt;br /&gt;
will find which k-points belong to a given path. We can add the LDA results for comparison.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ks_bs_0, qp_bs_0 = ydb.get_bs_path(lat,path)&lt;br /&gt;
ks_bs_0.plot_ax(ax,legend=True,color_bands=&#039;r&#039;,label=&#039;KS&#039;)&lt;br /&gt;
qp_bs_0.plot_ax(ax,legend=True,color_bands=&#039;b&#039;,label=&#039;QP-GW&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bands-LDA-GW.png|GW and LDA band structures |300px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;E. Plot interpolated QP-GW eigenvalues in a path.&#039;&#039;&#039; In order to obtain results ready for publication or presentation, we can interpolate the GW calculations.&lt;br /&gt;
&lt;br /&gt;
[[File:Bands-LDA-GW-interpolated.png| Interpolated GW and LDA band structures |300px]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;F. Comparison non-interpolated and interpolated results.&#039;&#039;&#039; It is convenient to check how good is the interpolation of GW results.&lt;br /&gt;
&lt;br /&gt;
[[File:Lda-gw-comparison.png| Exact and interpolated GW and LDA band structures |300px]]&lt;br /&gt;
&lt;br /&gt;
=== GW convergence for all k-points ===&lt;br /&gt;
&lt;br /&gt;
If we want to perform GW convergence in all the band states, we can check the &lt;br /&gt;
script &amp;lt;code&amp;gt;plot-gw-conv.py&amp;lt;/code&amp;gt;. Here we plot the band structure for all the k-points. For this, we pack the results in json files and then use the analyzer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
pack_files_in_folder(&#039;gw_conv&#039;)&lt;br /&gt;
ya = YamboAnalyser(&#039;gw_conv&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the case of the variable NGsBlkXs, we have set:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ya.plot_gw_all_kpoints_convergence(tag=&#039;NGsBlkXs&#039;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Chi-cutoff-kpoints.png||500px]]&lt;br /&gt;
&lt;br /&gt;
=== Approximations of the dielectric function (COHSEX, PPA) ===&lt;br /&gt;
&lt;br /&gt;
We can use yambopy to examine different run levels. For instance, the approximations used to obtain the screening are the: (i) static screening or COHSEX, (ii) plasmon-pole approximations (PPA), or (iii) real axis integration. We have set the same parameters for the first two options, just changing the variable name for the number of bands and the cut-off of the screening.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
COHSEX&lt;br /&gt;
EXXRLvcs = 60 Ry &lt;br /&gt;
BndsRnXs = 40 bands&lt;br /&gt;
NGsBlkXs = 3 Ry&lt;br /&gt;
&lt;br /&gt;
PPA&lt;br /&gt;
EXXRLvcs = 60 Ry &lt;br /&gt;
BndsRnXp = 40 bands&lt;br /&gt;
NGsBlkXp = 3 Ry&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We have set the converged parameters and the function works by running:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gw_conv_bn.py -x&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We plot the band structure using the analyzer explained above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python gw_conv_bn.py -xp&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We observe a large difference between COHSEX and PPA.&lt;br /&gt;
&lt;br /&gt;
[[File:Gw-chi-s.png|GW bands calculated with the COHSEX and PPA|300px]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy&amp;diff=3683</id>
		<title>First steps in Yambopy</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy&amp;diff=3683"/>
		<updated>2020-01-27T13:24:45Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A typical yambo calculation proceeds as follows:&lt;br /&gt;
&lt;br /&gt;
* Obtain the ground state properties from a DFT code (pw.x or abinit) &#039;&#039;&#039;[[First steps: a walk through from DFT to optical properties]]&#039;&#039;&#039;&lt;br /&gt;
* Create the yambo netCDF databases using the corresponding interface: (p2y for pw.x or a2y for abinit)&lt;br /&gt;
* Run yambo once to complete the database&lt;br /&gt;
* Run yambo specifying the run-levels to generate the input file&lt;br /&gt;
* Edit the yambo input file&lt;br /&gt;
* Run various yambo simulations&lt;br /&gt;
* Plot the data results&lt;br /&gt;
&lt;br /&gt;
Since many of the parameters of the calculation have to be converged the user might end up running the last three steps many times. This is rather time-consuming without an automatization script.&lt;br /&gt;
&lt;br /&gt;
The yambopy project aims to provide a simple set of python scripts to (i) read and edit yambo and quantum espresso input files, and (ii) to easily perform pre- and post-processing of the simulation data for these two codes. &lt;br /&gt;
Yambopy was born with the primary objective of making the convergence tests easier.&lt;br /&gt;
&lt;br /&gt;
===Installation instructions for general users===&lt;br /&gt;
&lt;br /&gt;
A quick way to start using Yambopy is described here.&lt;br /&gt;
&lt;br /&gt;
* Make sure that you are using Python 3 and that you have the following python packages: &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;scipy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;netCDF4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;xml.etree&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Go to a directory of your choice and clone yambopy from the git repository&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://github.com/yambo-code/yambopy.git&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Enter into the yambopy folder and install&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cd yambopy&lt;br /&gt;
sudo python setup.py install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have administrative privileges (for example on a computing cluster), type instead&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cd yambopy&lt;br /&gt;
python setup.py install --user&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [OPTIONAL] Install abipy [[https://abinit.github.io/abipy/index.html]] for band structure interpolations&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
pip install abipy&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Now yambopy is ready to use! Just go to the tutorials folder and follow the docs!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cd tutorial/bn&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And go to [[GW tutorial. Convergence and approximations (BN)]] or [[Bethe-Salpeter equation tutorial. Optical absorption (BN)]].&lt;br /&gt;
&lt;br /&gt;
You can find all the documentation of yambopy here http://yambopy.readthedocs.io/en/latest/index.html&lt;br /&gt;
&lt;br /&gt;
===Installation instructions for the hands-on of the 2020 Yambo school at ICTP, Trieste===&lt;br /&gt;
&lt;br /&gt;
* Yambopy is already inside the Yambo Quantum Mobile (YQM). Start the YQM and go to the tutorial folder&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd yambopy/&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and run &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git pull&lt;br /&gt;
sudo python3 setup.py install --user&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the installation finishes, go to [[GW tutorial. Convergence and approximations (BN)]] or [[Bethe-Salpeter equation tutorial. Optical absorption (BN)]].&lt;br /&gt;
&lt;br /&gt;
You can find all the documentation of yambopy here http://yambopy.readthedocs.io/en/latest/index.html&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* Enter in a node and create in the scratch a folder&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
ssh -Y tutoXY@cecam; ssh -Y node0XY&lt;br /&gt;
cd /home/scratch&lt;br /&gt;
mkdir your_name; cd your_name&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_equation_tutorial._Optical_absorption_(BN)&amp;diff=3481</id>
		<title>Bethe-Salpeter equation tutorial. Optical absorption (BN)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_equation_tutorial._Optical_absorption_(BN)&amp;diff=3481"/>
		<updated>2020-01-21T14:02:11Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial we will deal with different aspects of running a Bethe-Salpeter (BSE) calculation for optical absorption spectra using yambopy. We continue using hexagonal boron nitride to illustrate how to perform convergence tests, and how to compare and analyse the results. &lt;br /&gt;
&lt;br /&gt;
Before you start this tutorial, make sure you have run the scf and nscf runs. If you have not, you can calculate the scf &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; and nscf &amp;lt;code&amp;gt;-n&amp;lt;/code&amp;gt; using the &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python gs_bn.py -s -n&amp;lt;/source&amp;gt;&lt;br /&gt;
Once that is over, you can start the tutorial.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;br /&gt;
&lt;br /&gt;
=== BSE convergence of optical spectra ===&lt;br /&gt;
&lt;br /&gt;
In this section of the tutorial we will use the &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt; file. To evaluate the Bethe-Salpeter Kernel we need to first calculate the static dielectric screening, and then the screened Coulomb interaction matrix elements. This will be done with the file &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;a. Static dielectric function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We begin by converging the static screening. In principle, all parameters can be converged independently one-by-one, and then the you can choose the best values for the final, fully converged result. To converge the static screening you will need:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt;: number of planewaves to include. Usually we need fewer planewaves than the total used in the self-consistent cycle that generated the ground state in the &amp;lt;code&amp;gt;scf&amp;lt;/code&amp;gt; run. Reducing the total number of planewaves used diminishes the amount of memory per process that you are going to need. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BndsRnXs&amp;lt;/code&amp;gt;: number of bands to calculate the screening. Typically you need many more bands for the screening to converge. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NGsBlkXs&amp;lt;/code&amp;gt;: number of components for the local fields. Averages the value of the dielectric screening over a number of periodic copies of the unit cell. This parameter increases greatly increases the cost of the calculation and thus should be increased slowly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We create a dictionary with different values for each variable. The python script (&amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt;) will then create a reference input file with the first value in each parameter&#039;s list. It will then create input files with the other parameters changing independently according to the values specified on the list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#list of variables to optimize the dielectric screening&lt;br /&gt;
conv = { &#039;FFTGvecs&#039;: [[10,10,15,20,30],&#039;Ry&#039;],&lt;br /&gt;
         &#039;NGsBlkXs&#039;: [[1,1,2,3,5,6], &#039;Ry&#039;],&lt;br /&gt;
         &#039;BndsRnXs&#039;: [[1,10],[1,10],[1,20],[1,30],[1,40]] }&amp;lt;/source&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To run a calculation for each of the variables in the dictionary, we first define the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    def run(filename):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Function to be called by the optimize function&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        path = filename.split(&#039;.&#039;)[0]&lt;br /&gt;
        print(filename, path)&lt;br /&gt;
        shell = scheduler()&lt;br /&gt;
        shell.add_command(&#039;cd %s&#039;%folder)&lt;br /&gt;
        shell.add_command(&#039;%s mpirun -np %d %s -F %s -J %s -C %s 2&amp;gt; %s.log&#039;%(nohup,threads,yambo,filename,path,path,path))&lt;br /&gt;
        shell.add_command(&#039;touch %s/done&#039;%path)&lt;br /&gt;
        if not os.path.isfile(&amp;quot;%s/%s/done&amp;quot;%(folder,path)):&lt;br /&gt;
            shell.run()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which together with the optimize function in the class &amp;lt;code&amp;gt;YamboIn&amp;lt;/code&amp;gt;, &lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;y.optimize(conv,folder=&#039;bse_conv&#039;,run=run,ref_run=False)&amp;lt;/source&amp;gt; &lt;br /&gt;
will run and manage the calculations as defined in the dictionary. All calculation files and outputs will be in their respective directories inside the folder &amp;lt;code&amp;gt;bse_conv&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
To check which options are available in the script &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt;, run &lt;br /&gt;
&amp;lt;source&amp;gt;$ python bse_conv_bn.py&amp;lt;/source&amp;gt;&lt;br /&gt;
which will give you the following list:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
usage: bse_conv_bn.py [-h] [-r] [-a] [-p] [-e] [-b] [-u] [-t THREADS]&lt;br /&gt;
&lt;br /&gt;
Test the yambopy script.&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  -r, --run             run BSE convergence calculation&lt;br /&gt;
  -a, --analyse         analyse results data&lt;br /&gt;
  -p, --plot            plot the results&lt;br /&gt;
  -e, --epsilon         converge epsilon parameters&lt;br /&gt;
  -b, --bse             converge bse parameters&lt;br /&gt;
  -u, --nohup           run the commands with nohup&lt;br /&gt;
  -t THREADS, --threads THREADS&lt;br /&gt;
                        number of threads to use&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, in order to converge the screening, you will need to run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python bse_conv_bn.py -r -e&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default we have set up the total number of threads to be equal to 2. If you have access to more, you can change this using the &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; option shown on the list, followed by the number of threads you want to use. &lt;br /&gt;
&lt;br /&gt;
As you can see, the python script is running all the calculations changing the value of the input variables. You are free to open the &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt; file and modify it according to your own needs. Using the optimal parameters, you can run a calculation and save the dielectric screening databases &amp;lt;code&amp;gt;ndb.em1s*&amp;lt;/code&amp;gt; to re-use them in the subsequent calculations. For that you can copy these files to the SAVE folder. &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; will only re-calculate any database if it does not find it or some parameter has changed.&lt;br /&gt;
&lt;br /&gt;
Once the calculations are done you can plot resulting optical spectra by running &amp;lt;source&amp;gt;$ python bse_conv_bn.py -a&amp;lt;/source&amp;gt; followed by &amp;lt;source&amp;gt;$ python bse_conv_bn.py -p -e&amp;lt;/source&amp;gt;. It will search the folder &amp;lt;code&amp;gt;bse_conv&amp;lt;/code&amp;gt; for all calculations you performed previously and plot the results, using the class &amp;lt;code&amp;gt;YamboAnalyser&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
[[File:Bse-hbn-conv-2.png|x750px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can obtain the same plots by running the the following script: &amp;lt;source&amp;gt;$ python plot-bse-conv.py &amp;lt;/source&amp;gt;&lt;br /&gt;
If you want to, you can now add new entries to the lists in the dictionary, specially the &amp;lt;code&amp;gt;BndsRnXs&amp;lt;/code&amp;gt;, which usually requires a lot of bands to achieve convergence. Keep its number less than or equal to the number of bands in the nscf calculation, re-run the script and plot the results again. You can also test if some variables can converge with smaller values than the ones you used up to now. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;b. Screened Coulomb interaction&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Up to this point we have been focused on the variables which control the static screening. We still need to deal with the variables which setup the Bethe-Salpeter auxiliary Hamiltonian matrix. Once this matrix is set up, &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; will use a diagonalisation algorithm to obtain the excitonic states and energies. The relevant variables for this process are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;BSEBands&amp;lt;/code&amp;gt;: number of bands to generate the transitions. Should be as small as possible as the size of the BSE auxiliary hamiltonian has (in the resonant approximation) dimensions &amp;lt;code&amp;gt;Nk*Nv*Nc&amp;lt;/code&amp;gt;. Another way to converge the number of transitions is using &amp;lt;code&amp;gt;BSEEhEny&amp;lt;/code&amp;gt;. This variable selects the number of transitions based on the electron-hole energy difference.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BSENGBlk&amp;lt;/code&amp;gt; is the number of blocks for the dielectric screening average over the unit cells. This uses the static screening computed previously and controlled by the variable &amp;lt;code&amp;gt;NGsBlkXs&amp;lt;/code&amp;gt;. So you &amp;lt;code&amp;gt;BSENGBlk&amp;lt;/code&amp;gt; cannot be larger than &amp;lt;code&amp;gt;NGsBlkXs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BSENGexx&amp;lt;/code&amp;gt; in the number of exchange components. Relatively cheap to calculate, but should be kept as small as possible to save memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;KfnQP_E&amp;lt;/code&amp;gt; is the scissor operator for the BSE. The first value is the rigid scissor, the second and third are the stretching for the conduction and valence respectively. The optical absorption spectrum is obtained in a range of energies given by &amp;lt;code&amp;gt;BEnRange&amp;lt;/code&amp;gt; and the number of frequencies in the interval is &amp;lt;code&amp;gt;BEnSteps&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the last variable you will be using a predefined scissor operator. If you want to know how to compute a scissor operator you can go and follow the GW tutorial here [[GW tutorial. Convergence and approximations (BN)]]. &lt;br /&gt;
&lt;br /&gt;
The dictionary of convergence in this case is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#list of variables to optimize the BSE&lt;br /&gt;
        conv = { &#039;BSEEhEny&#039;: [[[1,10],[1,10],[1,12],[1,14]],&#039;eV&#039;],&lt;br /&gt;
                 &#039;BSENGBlk&#039;: [[0,0,1,2], &#039;Ry&#039;],&lt;br /&gt;
                 &#039;BSENGexx&#039;: [[10,10,15,20],&#039;Ry&#039;]}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All these variables do not change the dielectric screening, so optionally you can calculate it once (using the previous section to determine converged parameters) and put the database in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder to make the calculations faster. Otherwise the dielectric screening will be computed for each run (in the case of this tutorial, this is still quite fast). This is a slightly advanced use of &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;, so it is better to leave till you are more familiar with the code and its flow. &lt;br /&gt;
&lt;br /&gt;
To run the convergence calculations for the BSE Hamiltonian write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python bse_conv_bn.py -r -b&amp;lt;/source&amp;gt;&lt;br /&gt;
Once the calculations are done you can plot the optical absorption spectra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python bse_conv_bn.py -p -b&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bse-hbn-conv-1.png|x750px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can obtain the same plots by running the the following script: &amp;lt;source&amp;gt;$ python plot-bse-conv.py &amp;lt;/source&amp;gt;&lt;br /&gt;
Again, we invite you to change the values in the dictionary to check if the calculation would converge better using larger or smaller parameters.&lt;br /&gt;
&lt;br /&gt;
=== Coulomb truncation convergence ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;a. Running for different layer separation distances&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here we will check how the dielectric screening changes with vacuum spacing between layers and including a coulomb truncation technique. For that we define a loop where we do a self-consistent ground state calculation, non self-consistent calculation, create the databases and run a &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; BSE calculation for different vacuum spacings.&lt;br /&gt;
&lt;br /&gt;
To analyze the data we will plot the dielectric screening and check how the different values of the screening change the absorption spectra.&lt;br /&gt;
In the folder &amp;lt;code&amp;gt;tutorials/bn/&amp;lt;/code&amp;gt; you find the python script &amp;lt;code&amp;gt;bse_cutoff.py&amp;lt;/code&amp;gt;. This script takes some time to be executed, you can run both variants without the cutoff and with the cutoff &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; simultaneously to save time. You can run this script with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_cutoff.py -r -t4    # without coulomb cutoff&lt;br /&gt;
python bse_cutoff.py -r -c -t4 # with coulomb cutoff&amp;lt;/source&amp;gt;&lt;br /&gt;
where &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; specifies the number of MPI threads to use. The main loop changes the &amp;lt;code&amp;gt;layer_separation&amp;lt;/code&amp;gt; variable using values from a list in the header of the file. In the script you can find how the functions &amp;lt;code&amp;gt;scf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ncf&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;database&amp;lt;/code&amp;gt; are defined.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;b. Plot the dielectric function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In a similar way as what was done before we can now plot the dielectric function for different layer separations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;yambopy plotem1s bse_cutoff/*/*     # without coulomb cutoff  &lt;br /&gt;
yambopy plotem1s bse_cutoff_cut/*/* # with coulomb cutoff&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bn em1s cutoff cut.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bn em1s cutoff.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In these figures it is clear that the long-range part of the coulomb interaction (q=0 in reciprocal space) is truncated, i. e. it is forced to go to zero.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;c. Plot the absorption spectrum&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also plot how the absorption spectra changes with the cutoff using:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_cutoff.py -p&lt;br /&gt;
python bse_cutoff.py -p -c&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bn bse cutoff.png|bn bse cutoff]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bn bse cutoff cut.png|bn bse cutoff cut]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the spectra is still changing with the vaccum spacing, you should increase the vacuum until convergence. For that you can add larger values to the &amp;lt;code&amp;gt;layer_separations&amp;lt;/code&amp;gt; list and run the calculations and analysis again.&lt;br /&gt;
&lt;br /&gt;
=== Excitonic wavefunctions in reciprocal space ===&lt;br /&gt;
&lt;br /&gt;
In this example we show how to use &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt; to plot the excitonic wavefunction weights that result from a BSE calculation (specifically from the diagonalisation of the excitonic Hamiltonian). The script we will use this time is: &amp;lt;code&amp;gt;bse_bn.py&amp;lt;/code&amp;gt;. Be aware the parameters specified for the calculation are not high enough to obtain a converged result. &lt;br /&gt;
&lt;br /&gt;
To run the BSE calculation do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_bn.py -r&amp;lt;/source&amp;gt;&lt;br /&gt;
Alternatively, you can run  &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; python bse_bn.py -r -c &amp;lt;/source&amp;gt; to add the Coulomb cutoff.&lt;br /&gt;
&lt;br /&gt;
Then, the absorption spectrum is readily plotted by running the auxiliary script&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
python plot-bse.py&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
&lt;br /&gt;
[[File:bse_abs_plt.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Afterwards you can run a basic analysis of the excitonic states and store the wavefunctions of the ones that are the most optically active, plotting them in reciprocal space. Plots in real space (not covered here) are also possible using yambopy (by calling ypp). &lt;br /&gt;
&lt;br /&gt;
In order to proceed we will use the script &amp;lt;code&amp;gt;plot-excitondb.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
After running it as &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
python plot-excitondb.py&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
it will produce three plots.&lt;br /&gt;
&lt;br /&gt;
The first one is a representation of the excitonic weights (or rather their modulus) in reciprocal space, band- and kpoint-resolved, for the lowest-bound exciton.&lt;br /&gt;
You can see that the electronic transitions contributing to this state originate mostly at symmetry point K (direct band gap) and along the KM line (the bands here have pi-type orbital character).&lt;br /&gt;
&lt;br /&gt;
[[File:exc_bands.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
The second figure is an interpolated version of the first, with the bands and excitonic contributions appearing smoother.&lt;br /&gt;
&lt;br /&gt;
[[File:exc_bands_interp.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The final figure is a representation of the excitonic weights, summed over all bands, within the Brillouin zone. The brighter colors indicate where the most important electronic transitions for this excitonic state are located.&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BZ.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
You can obtain plots for different excitonic states by changing the line&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
# List of states to be merged&lt;br /&gt;
states = [1,2]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
in &amp;lt;code&amp;gt;plot-excitondb.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You may also want to test the script with a more converged calculation: to this end you can increase the number of kpoints in the nscf calculation by going to &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; and changing the line&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
kpoints_nscf = [6,6,1]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to your liking (for example to 12x12x1).&lt;br /&gt;
&lt;br /&gt;
Then, run again the following commands (nscf calculation, regeneration of yambo database, new BSE calculation).&lt;br /&gt;
&amp;lt;source lang=bash&amp;gt;&lt;br /&gt;
python gs_bn.py -n&lt;br /&gt;
rm -r database&lt;br /&gt;
python bse_bn.py -r -t 4&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
As for the plotting, you may want to increase the value of &amp;lt;code&amp;gt;lpratio&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;plot-excitondb.py&amp;lt;/code&amp;gt; to ensure that the interpolation works, as well as reduce the value of &amp;lt;code&amp;gt;scale&amp;lt;/code&amp;gt; for a nicer plot in the hexagonal BN.&lt;br /&gt;
The lines to be changed are&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
exc_bands_inter = yexc.interpolate(save,path,states,lpratio=5,f=None,size=0.5,verbose=True)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
yexc.plot_exciton_2D_ax(ax,states,mode=&#039;hexagon&#039;,limfactor=0.8,scale=160)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Then, you can run &amp;lt;code&amp;gt;plot-excitondb.py&amp;lt;/code&amp;gt; again.&lt;br /&gt;
&lt;br /&gt;
Again, be aware that these figures serve only to show the kind of representation that can be obtained with &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt;. Further convergence tests need to be performed to obtain accurate results, but that is left to the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
You can now visualise these wavefunctions in real space using our online tool: [http://henriquemiranda.github.io/excitonwebsite/ http://henriquemiranda.github.io/excitonwebsite/]&lt;br /&gt;
&lt;br /&gt;
For that, go to the website, and in the &amp;lt;code&amp;gt;Excitons&amp;lt;/code&amp;gt; section select &amp;lt;code&amp;gt;absorptionspectra.json&amp;lt;/code&amp;gt; file using the &amp;lt;code&amp;gt;Custom File&amp;lt;/code&amp;gt;. You should see on the right part the absorption spectra and on the left the representation of the wavefunction in real space. Alternatively you can vizualise the individually generated &amp;lt;code&amp;gt;.xsf&amp;lt;/code&amp;gt; files using xcrysden.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
=== Parallel static screening ===&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how you can split the calculation of the dielectric function in different jobs using &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt;. The dielectric function can then be used to calculate the excitonic states using the BSE.&lt;br /&gt;
&lt;br /&gt;
The idea is that in certain clusters it is advantageous to split the jobs as much as possible. The dielectric function is calculated for different momentum transfer (q-points) over the brillouin zone. Each calculation is independent and can run at the same time. Using the &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; parallelization you can separate the dielectric function calculation among many cpus using the variable &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;X_all_q_CPU&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;X_all_q_ROLEs&amp;lt;/code&amp;gt;. The issue is that you still need to make a big reservation and in some cases there is load imbalance (some nodes end up waiting for others). Splitting in smaller jobs can help your jobs to get ahead in the queue and avoid the load imbalance. If there are many free nodes you might end up running all the q-points at the same time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The idea is quite simple:&#039;&#039;&#039; you create an individual input file for each q-point, submit each job separately, collect the results and do the final BSE step (this method should also apply for a GW calculation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Parallel Dielectric function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To run the dielectric function in parallel do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_par_bn.py -r -t2&amp;lt;/source&amp;gt;&lt;br /&gt;
Here we tell &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; to calculate the dielectric function. We read the number of q-points the system has and generate one input file per q-point. Next we tell &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; to calculate the first q-point. &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; will calculate the dipoles and the dielectric function at the first q-point. Once the calculation is done we copy the dipoles to the SAVE directory. After that we run each q-point calculation as a separate job. Here the user can decide to submit one job per q-point on a cluster or use the python &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; module to submit the jobs in parallel. In this example we use the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from yambopy import *&lt;br /&gt;
import os&lt;br /&gt;
import multiprocessing&lt;br /&gt;
&lt;br /&gt;
yambo = &amp;quot;yambo&amp;quot;;&lt;br /&gt;
folder = &amp;quot;bse_par&amp;quot;;&lt;br /&gt;
nthreads = 2 #create two simultaneous jobs&lt;br /&gt;
&lt;br /&gt;
#create the yambo input file&lt;br /&gt;
y = YamboIn(&#039;yambo -r -b -o b -V all&#039;,folder=folder)&lt;br /&gt;
&lt;br /&gt;
y[&#039;FFTGvecs&#039;] = [30,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;NGsBlkXs&#039;] = [1,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;BndsRnXs&#039;] = [[1,30],&#039;&#039;]&lt;br /&gt;
y.write(&#039;%s/yambo_run.in&#039;%folder)&lt;br /&gt;
&lt;br /&gt;
#get the number of q-points&lt;br /&gt;
startk,endk = map(int,y[&#039;QpntsRXs&#039;][0])&lt;br /&gt;
&lt;br /&gt;
#prepare the q-points input files&lt;br /&gt;
jobs = []&lt;br /&gt;
for nk in xrange(1,endk+1):&lt;br /&gt;
    y[&#039;QpntsRXs&#039;] = [[nk,nk],&#039;&#039;]&lt;br /&gt;
    y.write(&#039;%s/yambo_q%d.in&#039;%(folder,nk))&lt;br /&gt;
    if nk != 1:&lt;br /&gt;
        jobs.append(&#039;cd %s; %s -F yambo_q%d.in -J yambo_q%d -C yambo_q%d 2&amp;amp;gt; log%d&#039;%(folder,yambo,nk,nk,nk,nk))&lt;br /&gt;
&lt;br /&gt;
#calculate first q-point and dipoles&lt;br /&gt;
os.system(&#039;cd %s; %s -F yambo_q1.in -J yambo_q1 -C yambo_q1&#039;%(folder,yambo))&lt;br /&gt;
#copy dipoles to save&lt;br /&gt;
os.system(&#039;cp %s/yambo_q1/ndb.dip* %s/SAVE&#039;%(folder,folder))&lt;br /&gt;
&lt;br /&gt;
p = multiprocessing.Pool(nthreads)&lt;br /&gt;
p.map(run_job, jobs)&amp;lt;/source&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;3. BSE&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the dielectric function is calculated, it is time to collect the data in one folder and do the last step of the calculation: generate the BSE Hamiltonian, diagonalize it and calculate the absorption.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#gather all the files&lt;br /&gt;
if not os.path.isdir(&#039;%s/yambo&#039;%folder):&lt;br /&gt;
    os.mkdir(&#039;%s/yambo&#039;%folder)&lt;br /&gt;
os.system(&#039;cp %s/yambo_q1/ndb.em* %s/yambo&#039;%(folder,folder))&lt;br /&gt;
os.system(&#039;cp %s/*/ndb.em*_fragment* %s/yambo&#039;%(folder,folder))&lt;br /&gt;
&lt;br /&gt;
y = YamboIn(&#039;yambo -r -b -o b -k sex -y d -V all&#039;,folder=folder)&lt;br /&gt;
y[&#039;FFTGvecs&#039;] = [30,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;NGsBlkXs&#039;] = [1,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;BndsRnXs&#039;] = [[1,30],&#039;&#039;]&lt;br /&gt;
y[&#039;BSEBands&#039;] = [[3,6],&#039;&#039;]&lt;br /&gt;
y[&#039;BEnSteps&#039;] = [500,&#039;&#039;]&lt;br /&gt;
y[&#039;BEnRange&#039;] = [[0.0,10.0],&#039;eV&#039;]&lt;br /&gt;
y[&#039;KfnQP_E&#039;]  = [2.91355133,1.0,1.0] #some scissor shift&lt;br /&gt;
y.arguments.append(&#039;WRbsWF&#039;)&lt;br /&gt;
y.write(&#039;%s/yambo_run.in&#039;%folder)&lt;br /&gt;
&lt;br /&gt;
print(&#039;running yambo&#039;)&lt;br /&gt;
os.system(&#039;cd %s; %s -F yambo_run.in -J yambo&#039;%(folder,yambo))&amp;lt;/source&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;3. Collect and plot the results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can then plot the data as before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_par_bn.py -p&amp;lt;/source&amp;gt;&lt;br /&gt;
This will execute the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#collect the data&lt;br /&gt;
pack_files_in_folder(&#039;bse_par&#039;)&lt;br /&gt;
&lt;br /&gt;
#plot the results using yambo analyser&lt;br /&gt;
y = YamboAnalyser()&lt;br /&gt;
print y&lt;br /&gt;
y.plot_bse([&#039;eps&#039;,&#039;diago&#039;])&amp;lt;/source&amp;gt;&lt;br /&gt;
You should obtain a plot like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Bethe Salpeter in BN.png|Yambo tutorial image]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_equation_tutorial._Optical_absorption_(BN)&amp;diff=3394</id>
		<title>Bethe-Salpeter equation tutorial. Optical absorption (BN)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_equation_tutorial._Optical_absorption_(BN)&amp;diff=3394"/>
		<updated>2020-01-20T16:51:29Z</updated>

		<summary type="html">&lt;p&gt;Pedro: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial we will deal with different aspects of running a Bethe-Salpeter (BSE) calculation for optical absorption spectra using yambopy. We continue using hexagonal boron nitride to illustrate how to perform convergence tests, and how to compare and analyse the results. &lt;br /&gt;
&lt;br /&gt;
Before you start this tutorial, make sure you have run the scf and nscf runs. If you have not, you can calculate the scf &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; and nscf &amp;lt;code&amp;gt;-n&amp;lt;/code&amp;gt; using the &amp;lt;code&amp;gt;gs_bn.py&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python gs_bn.py -s -n&amp;lt;/source&amp;gt;&lt;br /&gt;
Once that is over, you can start the tutorial.&lt;br /&gt;
&lt;br /&gt;
=== BSE convergence of optical spectra ===&lt;br /&gt;
&lt;br /&gt;
In this section of the tutorial we will use the &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt; file. To evaluate the Bethe-Salpeter Kernel we need to first calculate the static dielectric screening, and then the screened Coulomb interaction matrix elements. This will be done with the file &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;a. Static dielectric function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
We begin by converging the static screening. In principle, all parameters can be converged independently one-by-one, and then the you can choose the best values for the final, fully converged result. To converge the static screening you will need:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;FFTGvecs&amp;lt;/code&amp;gt;: number of planewaves to include. Usually we need fewer planewaves than the total used in the self-consistent cycle that generated the ground state in the &amp;lt;code&amp;gt;scf&amp;lt;/code&amp;gt; run. Reducing the total number of planewaves used diminishes the amount of memory per process that you are going to need. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BndsRnXs&amp;lt;/code&amp;gt;: number of bands to calculate the screening. Typically you need many more bands for the screening to converge. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;NGsBlkXs&amp;lt;/code&amp;gt;: number of components for the local fields. Averages the value of the dielectric screening over a number of periodic copies of the unit cell. This parameter increases greatly increases the cost of the calculation and thus should be increased slowly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We create a dictionary with different values for each variable. The python script (&amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt;) will then create a reference input file with the first value in each parameter&#039;s list. It will then create input files with the other parameters changing independently according to the values specified on the list:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#list of variables to optimize the dielectric screening&lt;br /&gt;
conv = { &#039;FFTGvecs&#039;: [[10,10,15,20,30],&#039;Ry&#039;],&lt;br /&gt;
         &#039;NGsBlkXs&#039;: [[1,1,2,3,5,6], &#039;Ry&#039;],&lt;br /&gt;
         &#039;BndsRnXs&#039;: [[1,10],[1,10],[1,20],[1,30],[1,40]] }&amp;lt;/source&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To run a calculation for each of the variables in the dictionary, we first define the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
    def run(filename):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Function to be called by the optimize function&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        path = filename.split(&#039;.&#039;)[0]&lt;br /&gt;
        print(filename, path)&lt;br /&gt;
        shell = scheduler()&lt;br /&gt;
        shell.add_command(&#039;cd %s&#039;%folder)&lt;br /&gt;
        shell.add_command(&#039;%s mpirun -np %d %s -F %s -J %s -C %s 2&amp;gt; %s.log&#039;%(nohup,threads,yambo,filename,path,path,path))&lt;br /&gt;
        shell.add_command(&#039;touch %s/done&#039;%path)&lt;br /&gt;
        if not os.path.isfile(&amp;quot;%s/%s/done&amp;quot;%(folder,path)):&lt;br /&gt;
            shell.run()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
which together with the optimize function in the class &amp;lt;code&amp;gt;YamboIn&amp;lt;/code&amp;gt;, &lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;y.optimize(conv,folder=&#039;bse_conv&#039;,run=run,ref_run=False)&amp;lt;/source&amp;gt; &lt;br /&gt;
will run and manage the calculations as defined in the dictionary. All calculation files and outputs will be in their respective directories inside the folder &amp;lt;code&amp;gt;bse_conv&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
To check which options are available in the script &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt;, run &lt;br /&gt;
&amp;lt;source&amp;gt;$ python bse_conv_bn.py&amp;lt;/source&amp;gt;&lt;br /&gt;
which will give you the following list:&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
usage: bse_conv_bn.py [-h] [-r] [-a] [-p] [-e] [-b] [-u] [-t THREADS]&lt;br /&gt;
&lt;br /&gt;
Test the yambopy script.&lt;br /&gt;
&lt;br /&gt;
optional arguments:&lt;br /&gt;
  -h, --help            show this help message and exit&lt;br /&gt;
  -r, --run             run BSE convergence calculation&lt;br /&gt;
  -a, --analyse         plot the results&lt;br /&gt;
  -p, --plot            plot the results&lt;br /&gt;
  -e, --epsilon         converge epsilon parameters&lt;br /&gt;
  -b, --bse             converge bse parameters&lt;br /&gt;
  -u, --nohup           run the commands with nohup&lt;br /&gt;
  -t THREADS, --threads THREADS&lt;br /&gt;
                        number of threads to use&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, in order to converge the screening, you will need to run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python bse_conv_bn.py -r -e&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default we have set up the total number of threads to be equal to 2. If you have access to more, you can change this using the &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; option shown on the list, followed by the number of threads you want to use. &lt;br /&gt;
&lt;br /&gt;
As you can see, the python script is running all the calculations changing the value of the input variables. You are free to open the &amp;lt;code&amp;gt;bse_conv_bn.py&amp;lt;/code&amp;gt; file and modify it according to your own needs. Using the optimal parameters, you can run a calculation and save the dielectric screening databases &amp;lt;code&amp;gt;ndb.em1s*&amp;lt;/code&amp;gt; to re-use them in the subsequent calculations. For that you can copy these files to the SAVE folder. &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; will only re-calculate any database if it does not find it or some parameter has changed.&lt;br /&gt;
&lt;br /&gt;
Once the calculations are done you can plot resulting optical spectra by running &amp;lt;source&amp;gt;$ python bse_conv_bn.py -p -e&amp;lt;/source&amp;gt;. It will search the folder &amp;lt;code&amp;gt;bse_conv&amp;lt;/code&amp;gt; for all calculations you performed previously and plot the results, using the class &amp;lt;code&amp;gt;YamboAnalyser&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
[[File:Bse-hbn-conv-2.png|x750px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
If you want to, you can now add new entries to the lists in the dictionary, specially the &amp;lt;code&amp;gt;BndsRnXs&amp;lt;/code&amp;gt;, which usually requires a lot of bands to achieve convergence. Keep its number less than or equal to the number of bands in the nscf calculation, re-run the script and plot the results again. You can also test if some variables can converge with smaller values than the ones you used up to now. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;b. Screened Coulomb interaction&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Up to this point we have been focused on the variables which control the static screening. We still need to deal with the variables which setup the Bethe-Salpeter auxiliary Hamiltonian matrix. Once this matrix is set up, &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; will use a diagonalisation algorithm to obtain the excitonic states and energies. The relevant variables for this process are:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;code&amp;gt;BSEBands&amp;lt;/code&amp;gt;: number of bands to generate the transitions. Should be as small as possible as the size of the BSE auxiliary hamiltonian has (in the resonant approximation) dimensions &amp;lt;code&amp;gt;Nk*Nv*Nc&amp;lt;/code&amp;gt;. Another way to converge the number of transitions is using &amp;lt;code&amp;gt;BSEEhEny&amp;lt;/code&amp;gt;. This variable selects the number of transitions based on the electron-hole energy difference.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BSENGBlk&amp;lt;/code&amp;gt; is the number of blocks for the dielectric screening average over the unit cells. This uses the static screening computed previously and controlled by the variable &amp;lt;code&amp;gt;NGsBlkXs&amp;lt;/code&amp;gt;. So you &amp;lt;code&amp;gt;BSENGBlk&amp;lt;/code&amp;gt; cannot be larger than &amp;lt;code&amp;gt;NGsBlkXs&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;BSENGexx&amp;lt;/code&amp;gt; in the number of exchange components. Relatively cheap to calculate, but should be kept as small as possible to save memory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;KfnQP_E&amp;lt;/code&amp;gt; is the scissor operator for the BSE. The first value is the rigid scissor, the second and third are the stretching for the conduction and valence respectively. The optical absorption spectrum is obtained in a range of energies given by &amp;lt;code&amp;gt;BEnRange&amp;lt;/code&amp;gt; and the number of frequencies in the interval is &amp;lt;code&amp;gt;BEnSteps&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For the last variable you will be using a predefined scissor operator. If you want to know how to compute a scissor operator you can go and follow the GW tutorial here [[GW tutorial. Convergence and approximations (BN)]]. &lt;br /&gt;
&lt;br /&gt;
The dictionary of convergence in this case is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#list of variables to optimize the BSE&lt;br /&gt;
        conv = { &#039;BSEEhEny&#039;: [[[1,10],[1,10],[1,12],[1,14]],&#039;eV&#039;],&lt;br /&gt;
                 &#039;BSENGBlk&#039;: [[0,0,1,2], &#039;Ry&#039;],&lt;br /&gt;
                 &#039;BSENGexx&#039;: [[10,10,15,20],&#039;Ry&#039;]}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All these variables do not change the dielectric screening, so optionally you can calculate it once (using the previous section to determine converged parameters) and put the database in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder to make the calculations faster. Otherwise the dielectric screening will be computed for each run (in the case of this tutorial, this is still quite fast). This is a slightly advanced use of &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;, so it is better to leave till you are more familiar with the code and its flow. &lt;br /&gt;
&lt;br /&gt;
To run the convergence calculations for the BSE Hamiltonian write:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python bse_conv_bn.py -r -b&amp;lt;/source&amp;gt;&lt;br /&gt;
Once the calculations are done you can plot the optical absorption spectra:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ python bse_conv_bn.py -p -b&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bse-hbn-conv-1.png|x750px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Again, we invite you to change the values in the dictionary to check if the calculation would converge better using larger or smaller parameters.&lt;br /&gt;
&lt;br /&gt;
=== Coulomb truncation convergence ===&lt;br /&gt;
&lt;br /&gt;
Here we will check how the dielectric screening changes with vacuum spacing between layers and including a coulomb truncation technique. For that we define a loop where we do a self-consistent ground state calculation, non self-consistent calculation, create the databases and run a &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; BSE calculation for different vacuum spacings.&lt;br /&gt;
&lt;br /&gt;
To analyze the data we will plot the dielectric screening and check how the different values of the screening change the absorption spectra.&lt;br /&gt;
In the folder &amp;lt;code&amp;gt;tutorials/bn/&amp;lt;/code&amp;gt; you find the python script &amp;lt;code&amp;gt;bse_cutoff.py&amp;lt;/code&amp;gt;. This script takes some time to be executed, you can run both variants without the cutoff and with the cutoff &amp;lt;code&amp;gt;-c&amp;lt;/code&amp;gt; simultaneously to save time. You can run this script with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_cutoff.py -r -t4    # without coulomb cutoff&lt;br /&gt;
python bse_cutoff.py -r -c -t4 # with coulomb cutoff&amp;lt;/source&amp;gt;&lt;br /&gt;
where &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; specifies the number of MPI threads to use. The main loop changes the &amp;lt;code&amp;gt;layer_separation&amp;lt;/code&amp;gt; variable using values from a list in the header of the file. In the script you can find how the functions &amp;lt;code&amp;gt;scf&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ncf&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;database&amp;lt;/code&amp;gt; are defined.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Plot the dielectric function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In a similar way as what was done before we can now plot the dielectric function for different layer separations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;yambopy plotem1s bse_cutoff/*/*     # without coulomb cutoff  &lt;br /&gt;
yambopy plotem1s bse_cutoff_cut/*/* # with coulomb cutoff&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bn em1s cutoff cut.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bn em1s cutoff.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In these figures it is clear that the long-range part of the coulomb interaction (q=0 in reciprocal space) is truncated, i. e. it is forced to go to zero.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Plot the absorption&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can also plot how the absorption spectra changes with the cutoff using:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_cutoff.py -p&lt;br /&gt;
python bse_cutoff.py -p -c&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Bn bse cutoff.png|bn bse cutoff]]&lt;br /&gt;
&lt;br /&gt;
[[File:Bn bse cutoff cut.png|bn bse cutoff cut]]&lt;br /&gt;
&lt;br /&gt;
As you can see, the spectra is still changing with the vaccum spacing, you should increase the vacuum until convergence. For that you can add larger values to the &amp;lt;code&amp;gt;layer_separations&amp;lt;/code&amp;gt; list and run the calculations and analysis again.&lt;br /&gt;
&lt;br /&gt;
=== Excitonic wavefunctions ===&lt;br /&gt;
&lt;br /&gt;
In this example we show how to use the &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt; to plot the excitonic wavefunctions that result from a BSE calculation. The script we will use this time is: &amp;lt;code&amp;gt;bse_bn.py&amp;lt;/code&amp;gt;. Be aware the parameters specified for the calculation are not high enough to obtain a converged result. To run the BSE calculation do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_bn.py -r&amp;lt;/source&amp;gt;&lt;br /&gt;
Afterwards you can run a basic analysis of the excitonic states and store the wavefunctions of the ones that are more optically active and plot their wavefunctions in reciprocal space. Plots in real space are also possible using yambopy (by calling ypp). In the analysis code you have:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#get the absorption spectra&lt;br /&gt;
#&#039;yambo&#039; : was the jobstring &#039;-J&#039; used when running yambo&lt;br /&gt;
#&#039;bse&#039;   : folder where the job was run&lt;br /&gt;
a = YamboBSEAbsorptionSpectra(&#039;yambo&#039;,path=&#039;bse&#039;)&lt;br /&gt;
&lt;br /&gt;
# Here we choose which excitons to read&lt;br /&gt;
# min_intensity : choose the excitons that have at least this intensity&lt;br /&gt;
# max_energy    : choose excitons with energy lower than this&lt;br /&gt;
# Degen_Step    : take only excitons that have energies more different than Degen_Step&lt;br /&gt;
excitons = a.get_excitons(min_intensity=0.001,max_energy=7,Degen_Step=0.01)&lt;br /&gt;
&lt;br /&gt;
# read the wavefunctions&lt;br /&gt;
# Cells=[13,13,1]   #number of cell repetitions&lt;br /&gt;
# Hole=[0,0,6+.5]   #position of the hole in cartesian coordinates (Bohr units)&lt;br /&gt;
# FFTGvecs=10       #number of FFT vecs to use, larger makes the&lt;br /&gt;
#                   #image smoother, but takes more time to plot&lt;br /&gt;
a.get_wavefunctions(Degen_Step=0.01,repx=range(-1,2),repy=range(-1,2),repz=range(1),&lt;br /&gt;
                    Cells=[13,13,1],Hole=[0,0,6+.5], FFTGvecs=10,wf=True)&lt;br /&gt;
&lt;br /&gt;
a.write_json()&amp;lt;/source&amp;gt;&lt;br /&gt;
The class &amp;lt;code&amp;gt;YamboBSEAbsorptionSpectra()&amp;lt;/code&amp;gt; reads the absorption spectra obtained with explicit diagonalization of the BSE matrix. &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; is the &amp;lt;code&amp;gt;job_string&amp;lt;/code&amp;gt; identifier used when running yambo, &amp;lt;code&amp;gt;bse&amp;lt;/code&amp;gt; is the name of the folder where the job was run. The function &amp;lt;code&amp;gt;get_excitons()&amp;lt;/code&amp;gt; runs &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; to obtain the exitonic states and their intensities. The function &amp;lt;code&amp;gt;get_wavefunctions()&amp;lt;/code&amp;gt; also calls &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; and reads the reciprocal (and optionally real space) space wavefunctions and finally we store all the data in a &amp;lt;code&amp;gt;json&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
This file can then be easily plotted with another python script. To run this part of the code you can do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_bn.py -a  #this will generate absorptionspectra.json&lt;br /&gt;
yambopy plotexcitons absorptionspectra.json #this will plot it&amp;lt;/source&amp;gt;&lt;br /&gt;
You can tune the parameters &amp;lt;code&amp;gt;min_intensity&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;max_energy&amp;lt;/code&amp;gt; and obtain more or less excitons. &amp;lt;code&amp;gt;Degen_Step&amp;lt;/code&amp;gt; is used to not consider excitons that are degenerate in energy. The reason is that when representing the excitonic wavefunction, degenerate states should be represented together. This value should in general be very small in order to not combine excitons that have energies close to each other but are not exactly degenerate. You should then obtain plots similar (these ones were generated on a 30x30 k-point grid) to the figures presented here:&lt;br /&gt;
&lt;br /&gt;
[[File:Absorption bn.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
[[File:Excitons bn.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
Again, be aware that this figures serve only to show the kind of representation that can be obtained with &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt;. Further convergence tests need to be performed to obtain accurate results, but that is left to the user. You are invited to re-run the nscf loop with more k-points and represent the resulting wavefunctions.&lt;br /&gt;
&lt;br /&gt;
You can now visualize these wavefunctions in real space using our online tool: [http://henriquemiranda.github.io/excitonwebsite/ http://henriquemiranda.github.io/excitonwebsite/]&lt;br /&gt;
&lt;br /&gt;
For that, go to the website, and in the &amp;lt;code&amp;gt;Excitons&amp;lt;/code&amp;gt; section select &amp;lt;code&amp;gt;absorptionspectra.json&amp;lt;/code&amp;gt; file using the &amp;lt;code&amp;gt;Custom File&amp;lt;/code&amp;gt;. You should see on the right part the absorption spectra and on the left the representation of the wavefunction in real space. Alternatively you can vizualize the individually generated &amp;lt;code&amp;gt;.xsf&amp;lt;/code&amp;gt; files using xcrysden.&lt;br /&gt;
&lt;br /&gt;
=== Parallel static screening ===&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show how you can split the calculation of the dielectric function in different jobs using &amp;lt;code&amp;gt;yambopy&amp;lt;/code&amp;gt;. The dielectric function can then be used to calculate the excitonic states using the BSE.&lt;br /&gt;
&lt;br /&gt;
The idea is that in certain clusters it is advantageous to split the jobs as much as possible. The dielectric function is calculated for different momentum transfer (q-points) over the brillouin zone. Each calculation is independent and can run at the same time. Using the &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; parallelization you can separate the dielectric function calculation among many cpus using the variable &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;X_all_q_CPU&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;X_all_q_ROLEs&amp;lt;/code&amp;gt;. The issue is that you still need to make a big reservation and in some cases there is load imbalance (some nodes end up waiting for others). Splitting in smaller jobs can help your jobs to get ahead in the queue and avoid the load imbalance. If there are many free nodes you might end up running all the q-points at the same time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The idea is quite simple:&#039;&#039;&#039; you create an individual input file for each q-point, submit each job separately, collect the results and do the final BSE step (this method should also apply for a GW calculation).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. Parallel Dielectric function&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To run the dielectric function in parallel do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_par_bn.py -r -t2&amp;lt;/source&amp;gt;&lt;br /&gt;
Here we tell &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; to calculate the dielectric function. We read the number of q-points the system has and generate one input file per q-point. Next we tell &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; to calculate the first q-point. &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; will calculate the dipoles and the dielectric function at the first q-point. Once the calculation is done we copy the dipoles to the SAVE directory. After that we run each q-point calculation as a separate job. Here the user can decide to submit one job per q-point on a cluster or use the python &amp;lt;code&amp;gt;multiprocessing&amp;lt;/code&amp;gt; module to submit the jobs in parallel. In this example we use the second option.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;from yambopy import *&lt;br /&gt;
import os&lt;br /&gt;
import multiprocessing&lt;br /&gt;
&lt;br /&gt;
yambo = &amp;quot;yambo&amp;quot;;&lt;br /&gt;
folder = &amp;quot;bse_par&amp;quot;;&lt;br /&gt;
nthreads = 2 #create two simultaneous jobs&lt;br /&gt;
&lt;br /&gt;
#create the yambo input file&lt;br /&gt;
y = YamboIn(&#039;yambo -r -b -o b -V all&#039;,folder=folder)&lt;br /&gt;
&lt;br /&gt;
y[&#039;FFTGvecs&#039;] = [30,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;NGsBlkXs&#039;] = [1,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;BndsRnXs&#039;] = [[1,30],&#039;&#039;]&lt;br /&gt;
y.write(&#039;%s/yambo_run.in&#039;%folder)&lt;br /&gt;
&lt;br /&gt;
#get the number of q-points&lt;br /&gt;
startk,endk = map(int,y[&#039;QpntsRXs&#039;][0])&lt;br /&gt;
&lt;br /&gt;
#prepare the q-points input files&lt;br /&gt;
jobs = []&lt;br /&gt;
for nk in xrange(1,endk+1):&lt;br /&gt;
    y[&#039;QpntsRXs&#039;] = [[nk,nk],&#039;&#039;]&lt;br /&gt;
    y.write(&#039;%s/yambo_q%d.in&#039;%(folder,nk))&lt;br /&gt;
    if nk != 1:&lt;br /&gt;
        jobs.append(&#039;cd %s; %s -F yambo_q%d.in -J yambo_q%d -C yambo_q%d 2&amp;amp;gt; log%d&#039;%(folder,yambo,nk,nk,nk,nk))&lt;br /&gt;
&lt;br /&gt;
#calculate first q-point and dipoles&lt;br /&gt;
os.system(&#039;cd %s; %s -F yambo_q1.in -J yambo_q1 -C yambo_q1&#039;%(folder,yambo))&lt;br /&gt;
#copy dipoles to save&lt;br /&gt;
os.system(&#039;cp %s/yambo_q1/ndb.dip* %s/SAVE&#039;%(folder,folder))&lt;br /&gt;
&lt;br /&gt;
p = multiprocessing.Pool(nthreads)&lt;br /&gt;
p.map(run_job, jobs)&amp;lt;/source&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;3. BSE&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the dielectric function is calculated, it is time to collect the data in one folder and do the last step of the calculation: generate the BSE Hamiltonian, diagonalize it and calculate the absorption.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#gather all the files&lt;br /&gt;
if not os.path.isdir(&#039;%s/yambo&#039;%folder):&lt;br /&gt;
    os.mkdir(&#039;%s/yambo&#039;%folder)&lt;br /&gt;
os.system(&#039;cp %s/yambo_q1/ndb.em* %s/yambo&#039;%(folder,folder))&lt;br /&gt;
os.system(&#039;cp %s/*/ndb.em*_fragment* %s/yambo&#039;%(folder,folder))&lt;br /&gt;
&lt;br /&gt;
y = YamboIn(&#039;yambo -r -b -o b -k sex -y d -V all&#039;,folder=folder)&lt;br /&gt;
y[&#039;FFTGvecs&#039;] = [30,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;NGsBlkXs&#039;] = [1,&#039;Ry&#039;]&lt;br /&gt;
y[&#039;BndsRnXs&#039;] = [[1,30],&#039;&#039;]&lt;br /&gt;
y[&#039;BSEBands&#039;] = [[3,6],&#039;&#039;]&lt;br /&gt;
y[&#039;BEnSteps&#039;] = [500,&#039;&#039;]&lt;br /&gt;
y[&#039;BEnRange&#039;] = [[0.0,10.0],&#039;eV&#039;]&lt;br /&gt;
y[&#039;KfnQP_E&#039;]  = [2.91355133,1.0,1.0] #some scissor shift&lt;br /&gt;
y.arguments.append(&#039;WRbsWF&#039;)&lt;br /&gt;
y.write(&#039;%s/yambo_run.in&#039;%folder)&lt;br /&gt;
&lt;br /&gt;
print(&#039;running yambo&#039;)&lt;br /&gt;
os.system(&#039;cd %s; %s -F yambo_run.in -J yambo&#039;%(folder,yambo))&amp;lt;/source&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;3. Collect and plot the results&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can then plot the data as before:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;python bse_par_bn.py -p&amp;lt;/source&amp;gt;&lt;br /&gt;
This will execute the following code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;#collect the data&lt;br /&gt;
pack_files_in_folder(&#039;bse_par&#039;)&lt;br /&gt;
&lt;br /&gt;
#plot the results using yambo analyser&lt;br /&gt;
y = YamboAnalyser()&lt;br /&gt;
print y&lt;br /&gt;
y.plot_bse([&#039;eps&#039;,&#039;diago&#039;])&amp;lt;/source&amp;gt;&lt;br /&gt;
You should obtain a plot like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Bethe Salpeter in BN.png|Yambo tutorial image]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-hbn-conv-2.png&amp;diff=3393</id>
		<title>File:Bse-hbn-conv-2.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-hbn-conv-2.png&amp;diff=3393"/>
		<updated>2020-01-20T16:21:38Z</updated>

		<summary type="html">&lt;p&gt;Pedro: User created page with UploadWizard&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=={{int:filedesc}}==&lt;br /&gt;
{{Information&lt;br /&gt;
|description={{en|1=Yambo tutorial image}}&lt;br /&gt;
|date=2020-01-20&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Pedro|Pedro]]&lt;br /&gt;
|permission=&lt;br /&gt;
|other versions=&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=={{int:license-header}}==&lt;br /&gt;
{{self|cc-by-sa-4.0}}&lt;br /&gt;
&lt;br /&gt;
This file was uploaded with the UploadWizard extension.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uploaded with UploadWizard]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-hbn-conv-1.png&amp;diff=3392</id>
		<title>File:Bse-hbn-conv-1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-hbn-conv-1.png&amp;diff=3392"/>
		<updated>2020-01-20T16:21:38Z</updated>

		<summary type="html">&lt;p&gt;Pedro: User created page with UploadWizard&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=={{int:filedesc}}==&lt;br /&gt;
{{Information&lt;br /&gt;
|description={{en|1=Yambo tutorial image}}&lt;br /&gt;
|date=2020-01-20&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Pedro|Pedro]]&lt;br /&gt;
|permission=&lt;br /&gt;
|other versions=&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=={{int:license-header}}==&lt;br /&gt;
{{self|cc-by-sa-4.0}}&lt;br /&gt;
&lt;br /&gt;
This file was uploaded with the UploadWizard extension.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uploaded with UploadWizard]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-bndsrnxs-conv.png&amp;diff=3328</id>
		<title>File:Bse-bndsrnxs-conv.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-bndsrnxs-conv.png&amp;diff=3328"/>
		<updated>2020-01-20T10:43:47Z</updated>

		<summary type="html">&lt;p&gt;Pedro: User created page with UploadWizard&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=={{int:filedesc}}==&lt;br /&gt;
{{Information&lt;br /&gt;
|description={{en|1=Yambo tutorial image, congervence of the BSE optical spectrum for hBN with the BndsRnXs variable.}}&lt;br /&gt;
|date=2020-01-20&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Pedro|Pedro]]&lt;br /&gt;
|permission=&lt;br /&gt;
|other versions=&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=={{int:license-header}}==&lt;br /&gt;
{{self|cc-by-sa-4.0}}&lt;br /&gt;
&lt;br /&gt;
This file was uploaded with the UploadWizard extension.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uploaded with UploadWizard]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-ngsblkxs-conv.png&amp;diff=3327</id>
		<title>File:Bse-ngsblkxs-conv.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-ngsblkxs-conv.png&amp;diff=3327"/>
		<updated>2020-01-20T10:43:47Z</updated>

		<summary type="html">&lt;p&gt;Pedro: User created page with UploadWizard&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=={{int:filedesc}}==&lt;br /&gt;
{{Information&lt;br /&gt;
|description={{en|1=Yambo tutorial image, congervence of the BSE optical spectrum for hBN with the NGsBlkXs variable.}}&lt;br /&gt;
|date=2020-01-20&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Pedro|Pedro]]&lt;br /&gt;
|permission=&lt;br /&gt;
|other versions=&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=={{int:license-header}}==&lt;br /&gt;
{{self|cc-by-sa-4.0}}&lt;br /&gt;
&lt;br /&gt;
This file was uploaded with the UploadWizard extension.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uploaded with UploadWizard]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-fft-conv.png&amp;diff=3326</id>
		<title>File:Bse-fft-conv.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Bse-fft-conv.png&amp;diff=3326"/>
		<updated>2020-01-20T10:43:47Z</updated>

		<summary type="html">&lt;p&gt;Pedro: User created page with UploadWizard&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=={{int:filedesc}}==&lt;br /&gt;
{{Information&lt;br /&gt;
|description={{en|1=Yambo tutorial image, congervence of the BSE optical spectrum for hBN with the FFTGvecs variable.}}&lt;br /&gt;
|date=2020-01-20&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Pedro|Pedro]]&lt;br /&gt;
|permission=&lt;br /&gt;
|other versions=&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=={{int:license-header}}==&lt;br /&gt;
{{self|cc-by-sa-4.0}}&lt;br /&gt;
&lt;br /&gt;
This file was uploaded with the UploadWizard extension.&lt;br /&gt;
&lt;br /&gt;
[[Category:Uploaded with UploadWizard]]&lt;/div&gt;</summary>
		<author><name>Pedro</name></author>
	</entry>
</feed>