<?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=Maurizia</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=Maurizia"/>
	<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Special:Contributions/Maurizia"/>
	<updated>2026-05-17T17:05:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=5654</id>
		<title>Hartree Fock</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=5654"/>
		<updated>2022-04-03T17:14:34Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prerequisites ==&lt;br /&gt;
[[File:Yambo-handbook-v4.1.2-p-9.png|thumb|Cheatsheet on HF|150px]]&lt;br /&gt;
&amp;lt;!-- * Complete the [[Generating the Yambo databases|Generating the Yambo databases]] tutorial --&amp;gt;&lt;br /&gt;
* You must first complete the &amp;quot;How to use Yambo&amp;quot; modules (&#039;&#039;[[Input_file_generation_and_command_line_options|input file generation and command_line_options]], [[Initialization]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for bulk hBN &lt;br /&gt;
* The &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;
== Background ==&lt;br /&gt;
The exchange part contribution of the self-energy for a generic state (nk) in reciprocal space reads:&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
It is important to note that in this way we are adding the HF contribution in a perturbative way to previously calculated DFT energies:&lt;br /&gt;
&lt;br /&gt;
[[File:Ehf.png|x20px|caption]]  &lt;br /&gt;
&lt;br /&gt;
and hence they will differ from a standard self-consistent HF calculation.&lt;br /&gt;
&lt;br /&gt;
== Input file generation ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by building up an input file for a HF calculation. 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 -x&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -x -F hf.in&lt;br /&gt;
&lt;br /&gt;
Looking inside the input file you will find:&lt;br /&gt;
&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 3187        RL    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL    # [XC] XCpotential RL components&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
   1| 14|  1|100|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
The variable  [[Variables#EXXRLvcs|EXXRLvcs]]  governs the number of G vectors to be summed in the expression of the exchange self-energy reported above.&lt;br /&gt;
The variable [[Variables#VXCRLvcs|VXCRLvcs]]  set the number of G vectors used in the evaluation of the density for the &amp;lt;Vxc&amp;gt; matrix element. A large number is needed in order to have a precise cancellation with the ground state calculation, in particular when GGA potentials are used. A good practice is to leave it at the maximum number (default). In case it would be needed to reduce (e.g. for memory reason), the accuracy can be checked by comparing the E_xc value printed in Yambo report and QE output file.&lt;br /&gt;
The [[Variables#QPkrange|QPkrange]]  name list it is a generalized index needed to select the first and last kpoints and bands we want to calculate the QP correction. &lt;br /&gt;
In general, we are interested in the gap of the system or in the band structure across the Fermi Energy. Let&#039;s start by editing the &#039;&#039;hf.in&#039;&#039; file by selecting the last occupied and first unoccupied bands These are the bands 8 and 9 as reported in the r_setup file.   &lt;br /&gt;
So we change the [[Variables#QPkrange|QPkrange]] variable in:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    1| 14|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
and run calculations to converge the expression above. In the expression of the Exchange Self Energy, we have a summation over bands, an integral over the Brillouin Zone and a Sum over the G vectors. Looking at the occupation factor we realize that occupied states only enters in the expression, so we do not need to worry about the bands as Yambo will include all the occupied bands by default. In order to check convergence of the G vectors in the summation in the Σx expression, we will perform different calculation varying the kinetic energy cutoff governing the number of G vectors entering in the sum. Let&#039;s start by setting in &#039;&#039;hf.in&#039;&#039;:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]= 10 Ry&lt;br /&gt;
&lt;br /&gt;
== Calculation and analysis of output ==&lt;br /&gt;
Let&#039;s now run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F hf.in -J 3D&lt;br /&gt;
&lt;br /&gt;
The result can be found int the output &#039;&#039;o-3D.hf&#039;&#039; file and in the &#039;&#039;r-3D_HF_and_locXC&#039;&#039; file. Looking inside the output file we have:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #  K-point          Band       Eo           Ehf          DFT        HF&lt;br /&gt;
 #&lt;br /&gt;
     1.00000      8.00000     -1.29642     -4.79324    -18.03344    -21.53026&lt;br /&gt;
     1.00000      9.00000      4.83239     9.755507    -9.592554    -4.669446&lt;br /&gt;
     2.00000      8.00000     -1.33551     -4.80994    -18.07476    -21.54919&lt;br /&gt;
     2.00000      9.00000      7.56742     13.43122    -11.55012    -5.68633&lt;br /&gt;
 ........&lt;br /&gt;
 &lt;br /&gt;
Looking at the definition of the HF energy, the third column is the DFT energy (KS eigenvalue), Ehf is the HF energy, and column 4 and 5 report the different contribution to be subtracted Vx (DFT) and added Σx (HF) to the unperturbed DFT eigenvalue.  From these data we can calculate the  HF gap: you can recognize that the direct gap is found at k-point number 7,  being 4.29 eV at  DFT level and 11.95 eV in  HF approximation. This information can be also easily found in the &lt;br /&gt;
report file &#039;&#039;r-3D_HF_and_locXC&#039;&#039; searching for Direct Gaps: &lt;br /&gt;
&lt;br /&gt;
Before the HF computation:  &lt;br /&gt;
&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;
&lt;br /&gt;
&lt;br /&gt;
... after the HF computation:&lt;br /&gt;
&lt;br /&gt;
 [05.01] HF occupations report&lt;br /&gt;
  =============================&lt;br /&gt;
&lt;br /&gt;
  [Hartree-Fock] Direct Gap                         :  11.94549 [eV]&lt;br /&gt;
  [Hartree-Fock] Direct Gap localized at k-point    :   7&lt;br /&gt;
  [Hartree-Fock] Indirect Gap                       :  11.28767 [eV]&lt;br /&gt;
  [Hartree-Fock] Indirect Gap between k-points      :  14   7&lt;br /&gt;
&lt;br /&gt;
or simply by typing:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;irect Gap&amp;quot; r-3D_HF_and_locXC&lt;br /&gt;
&lt;br /&gt;
and the gap value before and after the HF correction is shown:&lt;br /&gt;
  [X] Direct Gap                                    :  4.289853 [eV]&lt;br /&gt;
  [X] Direct Gap localized at k-point               :   7&lt;br /&gt;
  [Hartree-Fock] Direct Gap                         :  11.94549 [eV]&lt;br /&gt;
  [Hartree-Fock] Direct Gap localized at k-point    :   7&lt;br /&gt;
  [Hartree-Fock] Indirect Gap                       :  11.28767 [eV]&lt;br /&gt;
  [Hartree-Fock] Indirect Gap between kpts          :  14   7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the report file, the first value indicates the maximum (direct) gap while the second one is the minimum (indirect) energy gap between the same bands.&lt;br /&gt;
&lt;br /&gt;
In the following, in order to converge the direct gap, we will focus the K point where the direct band is found. Inspecting the &#039;&#039;r_setup&#039;&#039; file, or any other report file it can be recognized that the direct minimum gap is found at the K-point number 7  (M point): this can be seen by searching the DFT &amp;quot;Direct Gap&amp;quot; and looking at the eigenvalues reported for each k point. Note that the zero energy is fixed at the top of the valence band, K point number 14 (H point). &lt;br /&gt;
So we can restrict the convergence calculations to the occupied and empty bands at point M, by modifying the input file as:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    7| 7|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Even if for this case the calculations are not at all expensive, reducing the calculations to few bands when performing convergence test allows to save memory and time. &lt;br /&gt;
&lt;br /&gt;
Now we can run different calculations changing the value of [[Variables#EXXRLvcs|EXXRLvcs]], let&#039;s say to 10,20,30 and 40 Ry. &lt;br /&gt;
Build four different input files differing only for the [[Variables#EXXRLvcs|EXXRLvcs]] values and naming them hf_10Ry.in, hf_20Ry.in, etc.&lt;br /&gt;
 &lt;br /&gt;
 $ cp hf.in hf_10Ry.in&lt;br /&gt;
 $ yambo -F hf_10Ry.in -J 3D&lt;br /&gt;
 $ cp hf.in hf_20Ry.in       &#039;&#039;and edit file, changing EXXRLvcs to 20 Ry&#039;&#039;&lt;br /&gt;
 $ yambo -F hf_20Ry.in -J 3D&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Once the calculations are terminated, collect the results found in the output, for instance, putting in a file named hf.dat the following data:&lt;br /&gt;
Cutoff Energy, Number of G vector in the Sum,  HF energy for the occupied state (Ehf for the state 8), HF energy for the unoccupied state (Ehf for the state 9).&lt;br /&gt;
You can use the &#039;&#039;grep&#039;&#039; command to extract these data from the output e.g by typing.&lt;br /&gt;
&lt;br /&gt;
 grep &amp;quot;^ *7 *8&amp;quot; o-3D.hf_*&lt;br /&gt;
and&lt;br /&gt;
 grep &amp;quot;^ *7 *9&amp;quot; o-3D.hf_*&lt;br /&gt;
&lt;br /&gt;
and looking at the column corresponding to Ehf value (column 4).&lt;br /&gt;
For the number of G vectors corresponding to the cutoff energy cutoff in input search  &#039;&#039;Exchange RL vectors&#039;&#039; in the report files. Note that it is not possible anymore to extract directly the HF gap from the report file as we did above, as in this case, we did not include all the BZ in the calculation.&lt;br /&gt;
Now it possible to plot the energy gap in function of the energy cutoff or number of Gvectors:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 1:($4-$3)  w lp t &amp;quot;HF gap vs Energy cutoff&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 2:($4-$3)  w lp t &amp;quot;HF gap vs Number of G vector&amp;quot;&lt;br /&gt;
&lt;br /&gt;
or you can plot the gap in function of both quantities using the [[gnuplot_scripts|hf.gnu]] gnuplot script:&lt;br /&gt;
&lt;br /&gt;
[[File:Hf_plot1.png|none|600px|caption]]&lt;br /&gt;
&lt;br /&gt;
and you can see that at 40Ry the energy gap is very close to convergence. Plotting the occupied and unoccupied bands separately you can recognize that for this system the unoccupied band does converge much faster. &lt;br /&gt;
&lt;br /&gt;
The last important convergence test deals with the accuracy of the integral over the Brillouin zone in the expression of the Exchange Self-Energy, which translates into K point convergence. &lt;br /&gt;
In order to test the K point sampling, you should:&lt;br /&gt;
# perform a new non-scf calculation with a bigger k point grid, &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. &lt;br /&gt;
&lt;br /&gt;
For now, however, you can skip this convergence test and continue the main tutorial (click back on your browser).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=5653</id>
		<title>Hartree Fock</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=5653"/>
		<updated>2022-04-03T17:09:46Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prerequisites ==&lt;br /&gt;
[[File:Yambo-handbook-v4.1.2-p-9.png|thumb|Cheatsheet on HF|150px]]&lt;br /&gt;
&amp;lt;!-- * Complete the [[Generating the Yambo databases|Generating the Yambo databases]] tutorial --&amp;gt;&lt;br /&gt;
* You must first complete the &amp;quot;How to use Yambo&amp;quot; modules (&#039;&#039;[[Input_file_generation_and_command_line_options|input file generation and command_line_options]], [[Initialization]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for bulk hBN &lt;br /&gt;
* The &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;
== Background ==&lt;br /&gt;
The exchange part contribution of the self-energy for a generic state (nk) in reciprocal space reads:&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
It is important to note that in this way we are adding the HF contribution in a perturbative way to previously calculated DFT energies:&lt;br /&gt;
&lt;br /&gt;
[[File:Ehf.png|x20px|caption]]  &lt;br /&gt;
&lt;br /&gt;
and hence they will differ from a standard self-consistent HF calculation.&lt;br /&gt;
&lt;br /&gt;
== Input file generation ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by building up an input file for a HF calculation. 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 -x&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -x -F hf.in&lt;br /&gt;
&lt;br /&gt;
Looking inside the input file you will find:&lt;br /&gt;
&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 3187        RL    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL    # [XC] XCpotential RL components&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
   1| 14|  1|100|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
The variable  [[Variables#EXXRLvcs|EXXRLvcs]]  governs the number of G vectors to be summed in the expression of the exchange self-energy reported above.&lt;br /&gt;
The variable [[Variables#VXCRLvcs|VXCRLvcs]]  set the number of G vectors used in the evaluation of the density for the &amp;lt;Vxc&amp;gt; matrix element. A large number is needed in order to have a precise cancellation with the ground state calculation, in particular when GGA potentials are used. A good practice is to leave it at the maximum number (default). In case it would be needed to reduce (e.g. for memory reason), the accuracy can be checked by comparing the E_xc value printed in Yambo report and QE output file.&lt;br /&gt;
The [[Variables#QPkrange|QPkrange]]  name list it is a generalized index needed to select the first and last kpoints and bands we want to calculate the QP correction. &lt;br /&gt;
In general, we are interested in the gap of the system or in the band structure across the Fermi Energy. Let&#039;s start by editing the &#039;&#039;hf.in&#039;&#039; file by selecting the last occupied and first unoccupied bands These are the bands 8 and 9 as reported in the r_setup file.   &lt;br /&gt;
So we change the [[Variables#QPkrange|QPkrange]] variable in:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    1| 14|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
and run calculations to converge the expression above. In the expression of the Exchange Self Energy, we have a summation over bands, an integral over the Brillouin Zone and a Sum over the G vectors. Looking at the occupation factor we realize that occupied states only enters in the expression, so we do not need to worry about the bands as Yambo will include all the occupied bands by default. In order to check convergence of the G vectors in the summation in the Σx expression, we will perform different calculation varying the kinetic energy cutoff governing the number of G vectors entering in the sum. Let&#039;s start by setting in &#039;&#039;hf.in&#039;&#039;:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]= 10 Ry&lt;br /&gt;
&lt;br /&gt;
== Calculation and analysis of output ==&lt;br /&gt;
Let&#039;s now run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F hf.in -J 3D&lt;br /&gt;
&lt;br /&gt;
The result can be found int the output &#039;&#039;o-3D.hf&#039;&#039; file and in the &#039;&#039;r-3D_HF_and_locXC&#039;&#039; file. Looking inside the output file we have:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #  K-point          Band       Eo           Ehf          DFT        HF&lt;br /&gt;
 #&lt;br /&gt;
     1.00000      8.00000     -1.29642     -4.79324    -18.03344    -21.53026&lt;br /&gt;
     1.00000      9.00000      4.83239     9.755507    -9.592554    -4.669446&lt;br /&gt;
     2.00000      8.00000     -1.33551     -4.80994    -18.07476    -21.54919&lt;br /&gt;
     2.00000      9.00000      7.56742     13.43122    -11.55012    -5.68633&lt;br /&gt;
 ........&lt;br /&gt;
 &lt;br /&gt;
Looking at the definition of the HF energy, the third column is the DFT energy (KS eigenvalue), Ehf is the HF energy, and column 4 and 5 report the different contribution to be subtracted Vx (DFT) and added Σx (HF) to the unperturbed DFT eigenvalue.  From these data we can calculate the  HF gap: you can recognize that the direct gap is found at k-point number 7,  being 4.29 eV at  DFT level and 11.95 eV in  HF approximation. This information can be also easily found in the &lt;br /&gt;
report file &#039;&#039;r-3D_HF_and_locXC&#039;&#039; searching for Direct Gaps: &lt;br /&gt;
&lt;br /&gt;
Before the HF computation:  &lt;br /&gt;
&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;
&lt;br /&gt;
&lt;br /&gt;
... after the HF computation:&lt;br /&gt;
&lt;br /&gt;
 [05.01] HF occupations report&lt;br /&gt;
  =============================&lt;br /&gt;
&lt;br /&gt;
  [Hartree-Fock] Direct Gap                         :  11.94549 [eV]&lt;br /&gt;
  [Hartree-Fock] Direct Gap localized at k-point    :   7&lt;br /&gt;
  [Hartree-Fock] Indirect Gap                       :  11.28767 [eV]&lt;br /&gt;
  [Hartree-Fock] Indirect Gap between k-points      :  14   7&lt;br /&gt;
&lt;br /&gt;
or simply by typing:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;irect Gap&amp;quot; r-3D_HF_and_locXC&lt;br /&gt;
&lt;br /&gt;
and the gap value before and after the HF correction is shown:&lt;br /&gt;
  [X] Direct Gap                                    :  4.289853 [eV]&lt;br /&gt;
  [X] Direct Gap localized at k-point               :   7&lt;br /&gt;
  [Hartree-Fock] Direct Gap                         :  11.94549 [eV]&lt;br /&gt;
  [Hartree-Fock] Direct Gap localized at k-point    :   7&lt;br /&gt;
  [Hartree-Fock] Indirect Gap                       :  11.28767 [eV]&lt;br /&gt;
  [Hartree-Fock] Indirect Gap between kpts          :  14   7&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the report file, the first value indicates the maximum (direct) gap while the second one is the minimum (indirect) energy gap between the same bands.&lt;br /&gt;
&lt;br /&gt;
In the following, in order to converge the direct gap, we will focus the K point where the direct band is found. Inspecting the &#039;&#039;r_setup&#039;&#039; file, or any other report file it can be recognized that the direct minimum gap is found at the K-point number 7  (M point): this can be seen by searching the DFT &amp;quot;Direct Gap&amp;quot; and looking at the eigenvalues reported for each k point. Note that the zero energy is fixed at the top of the valence band, K point number 14 (H point). &lt;br /&gt;
So we can restrict the convergence calculations to the occupied and empty bands at point M, by modifying the input file as:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    7| 7|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Even if for this case the calculations are not at all expensive, reducing the calculations to few bands when performing convergence test allows to save memory and time. &lt;br /&gt;
&lt;br /&gt;
Now we can run different calculations changing the value of [[Variables#EXXRLvcs|EXXRLvcs]], let&#039;s say to 10,20,30 and 40 Ry. &lt;br /&gt;
Build four different input files differing only for the [[Variables#EXXRLvcs|EXXRLvcs]] values and naming them hf_10Ry.in, hf_20Ry.in, etc.&lt;br /&gt;
 &lt;br /&gt;
 $ cp hf.in hf_10Ry.in&lt;br /&gt;
 $ yambo -F hf_10Ry.in -J 3D&lt;br /&gt;
 $ cp hf.in hf_20Ry.in       &#039;&#039;and edit file, changing EXXRLvcs to 20Ry&#039;&#039;&lt;br /&gt;
 $ yambo -F hf_20Ry.in -J 3D&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Once the calculations are terminated, collect the results found in the output, for instance, putting in a file named hf.dat the following data:&lt;br /&gt;
Cutoff Energy, Number of G vector in the Sum,  HF energy for the occupied state (Ehf for the state 8), HF energy for the unoccupied state (Ehf for the state 9).&lt;br /&gt;
You can use the &#039;&#039;grep&#039;&#039; command to extract these data from the output e.g by typing.&lt;br /&gt;
&lt;br /&gt;
 grep &amp;quot;^ *7 *8&amp;quot; o-3D.hf_*&lt;br /&gt;
and&lt;br /&gt;
 grep &amp;quot;^ *7 *9&amp;quot; o-3D.hf_*&lt;br /&gt;
&lt;br /&gt;
and looking at the column corresponding to Ehf value (column 4).&lt;br /&gt;
For the number of G vectors corresponding to the cutoff energy cutoff in input search  &#039;&#039;Exchange RL vectors&#039;&#039; in the report files. Note that it is not possible anymore to extract directly the HF gap from the report file as we did above, as in this case, we did not include all the BZ in the calculation.&lt;br /&gt;
Now it possible to plot the energy gap in function of the energy cutoff or number of Gvectors:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 1:($4-$3)  w lp t &amp;quot;HF gap vs Energy cutoff&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 2:($4-$3)  w lp t &amp;quot;HF gap vs Number of G vector&amp;quot;&lt;br /&gt;
&lt;br /&gt;
or you can plot the gap in function of both quantities using the [[gnuplot_scripts|hf.gnu]] gnuplot script:&lt;br /&gt;
&lt;br /&gt;
[[File:Hf_plot1.png|none|600px|caption]]&lt;br /&gt;
&lt;br /&gt;
and you can see that at 40Ry the energy gap is very close to convergence. Plotting the occupied and unoccupied bands separately you can recognize that for this system the unoccupied band does converge much faster. &lt;br /&gt;
&lt;br /&gt;
The last important convergence test deals with the accuracy of the integral over the Brillouin zone in the expression of the Exchange Self-Energy, which translates into K point convergence. &lt;br /&gt;
In order to test the K point sampling, you should:&lt;br /&gt;
# perform a new non-scf calculation with a bigger k point grid, &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. &lt;br /&gt;
&lt;br /&gt;
For now, however, you can skip this convergence test and continue the main tutorial (click back on your browser).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=5652</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=5652"/>
		<updated>2022-04-03T16:36:35Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Step 1: The Exchange Self Energy or HF quasi-particle correction */&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;
 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>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4864</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=4864"/>
		<updated>2021-04-07T14:24:26Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Step 3: Interpolating Band Structures */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 &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 -x -p p -g 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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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.521152           2.375027&lt;br /&gt;
         7                  9                 3.877976           2.351568          -2.284813&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;
&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;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4858</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=4858"/>
		<updated>2021-04-07T13:41:37Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Step 3: Interpolating Band Structures */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g 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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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.521152           2.375027&lt;br /&gt;
         7                  9                 3.877976           2.351568          -2.284813&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 strcuture 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4810</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=4810"/>
		<updated>2021-04-06T12:44:30Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Converging Screening Parameters */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4809</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=4809"/>
		<updated>2021-04-06T12:43:49Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Converging Screening Parameters */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4808</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=4808"/>
		<updated>2021-04-06T12:42:52Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Converging Screening Parameters */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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;
! $ cat o-10b* | grep &amp;quot;8.000&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;
! $ cat o-10b* | grep &amp;quot;9.000&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4781</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=4781"/>
		<updated>2021-04-06T09:24:27Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Converging Screening Parameters */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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;
 $ cat o-10b* | grep &amp;quot;8.000&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;9.000&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4780</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=4780"/>
		<updated>2021-04-06T09:22:03Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Convergence tests for a quasi particle calculation */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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 (indeed later you will learn how to use the 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;
 $ cat o-10b* | grep &amp;quot;8.000&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;9.000&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4753</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=4753"/>
		<updated>2021-04-06T08:32:30Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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;
--&amp;gt;&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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4752</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=4752"/>
		<updated>2021-04-06T08:24:39Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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; which is always the first step you have to perform for any simulation using the Yambo code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or if you wish you can learn (see below) 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;
--&amp;gt;&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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4751</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=4751"/>
		<updated>2021-04-06T08:20:47Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 the yambo tutorials (for hBN bulk in this case)  and go directly to the [Initialization of Yambo databases]  which is always the first step you have to perform for any simulation using the Yambo code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or if you wish you can learn (see below) 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;
--&amp;gt;&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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4750</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=4750"/>
		<updated>2021-04-06T08:19:16Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 the yambo tutorials (for hBN bulk in this case)  and go directly to the initialiation step [[Initialization step]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Or if you wish you can learn (see below) 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;
--&amp;gt;&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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4749</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=4749"/>
		<updated>2021-04-06T08:17:45Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Conversion to Yambo format */&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;
* 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;
&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 the yambo tutorials (for hBN bulk in this case)  or, if you wish you can learn (see below) 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;
--&amp;gt;&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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4748</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=4748"/>
		<updated>2021-04-06T08:14:00Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 the yambo tutorials (for hBN bulk in this case)  or, if you wish you can learn (see below) 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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4747</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=4747"/>
		<updated>2021-04-06T08:07:42Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 will 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 the yambo tutorials for hBN or, if you wish you can learn (see below) how to start from the DFT simulations doing an scf and nscf calculation, entering in &#039;&#039;&#039;PWSCF&#039;&#039;&#039; folder. In this way you will learn how to 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;
&amp;lt;!--&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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4746</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=4746"/>
		<updated>2021-04-06T08:00:08Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 will 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; directory where you can find the &#039;&#039;&#039;SAVE&#039;&#039;&#039; directory needed to start the yambo tutorials for hBN or do the DFT scf and nscf simulations entering in &#039;&#039;&#039;PWSCF&#039;&#039;&#039; directory and learn how to create the &#039;&#039;&#039;SAVE&#039;&#039;&#039; starting from files produced by pw.x (see below)&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;
&amp;lt;!--&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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4745</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=4745"/>
		<updated>2021-04-06T07:56:22Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 will 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;
==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;
&amp;lt;!--&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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4744</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=4744"/>
		<updated>2021-04-06T07:49:34Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Download the Files */&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;
* 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;
&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 will 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;
 $ hBN 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;
==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;
&amp;lt;!--&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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4743</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=4743"/>
		<updated>2021-04-06T07:37:27Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Input file generation */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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-point 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 (indeed later you will learn how to use the 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;
 $ cat o-10b* | grep &amp;quot;8.000&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;9.000&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4742</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=4742"/>
		<updated>2021-04-06T07:31:23Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Input file generation */&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 &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&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 see two ways to take into account the dynamical effects. First, we will see how to set the 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;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &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 &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 -x -p p -g n -F gw_ppa.in&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;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|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;
 [[Variables#NGsBlkXp|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;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|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;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate 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         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7.000000   8.000000  -0.411876  -0.567723   2.322443&lt;br /&gt;
  7.000000   9.000000   3.877976   2.413773  -2.232241&lt;br /&gt;
&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;
 [07.02] QP properties and I/O&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;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&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-point 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 (indeed later you will learn how to use the 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;
 $ cat o-10b* | grep &amp;quot;8.000&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;9.000&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 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1: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 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($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 &#039;&#039;gw_ppa_30b_3Ry.in&#039;&#039; 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 &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;, &#039;&#039;gw_ppa_Gbnd20.in&#039;&#039; 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 8.00 o-Gbnd*  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep 9.00 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 &#039;&#039;Gbnd_conv.dat&#039;&#039; containing: the number of Gbnd, 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;NN&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;
 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 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 strcuture 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 look this new 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;
&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: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Download&amp;diff=4741</id>
		<title>Download</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Download&amp;diff=4741"/>
		<updated>2021-04-06T07:29:45Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Getting the latest snapshot with git */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Get in touch with Yambo on git (optional) ==&lt;br /&gt;
The Yambo source is hosted on the [https://github.com/yambo-code Git-Hub] hosting service. &amp;lt;br&amp;gt;&lt;br /&gt;
Full access to the git repository or tar-balls are available. &lt;br /&gt;
No registration or password is required.   &amp;lt;br&amp;gt;&lt;br /&gt;
However We warmly invite all Yambo users to register on Github and, after that:&lt;br /&gt;
* if you like the project, go to the [https://github.com/yambo-code/yambo Yambo repository] and push the star button.&lt;br /&gt;
* if you would like to receive updates push the watch button.&lt;br /&gt;
* if you wish, send your github username to the yambo email address and we will add you to the Users group of the yambo project.&lt;br /&gt;
&lt;br /&gt;
Also if you need any further help regarding the access to the Yambo download page please send us an e-mail.&lt;br /&gt;
email: yambo at DOMAIN. DOMAIN=yambo-code.org&lt;br /&gt;
&lt;br /&gt;
== Direct download (for impatient) ==&lt;br /&gt;
Tar-balls are available on the github download page:&lt;br /&gt;
* [https://github.com/yambo-code/yambo/wiki/Releases-%28tar.gz-format%29 Browse all releases (tar.gz format)] &lt;br /&gt;
* [https://github.com/yambo-code/yambo/wiki/Releases-%28zip-format%29 Browse all releases (zip format)] &lt;br /&gt;
Please choose your preferred release.&lt;br /&gt;
&lt;br /&gt;
== Getting the latest snapshot with git ==&lt;br /&gt;
To obtain the latest source you need to have &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; installed.&lt;br /&gt;
[https://git-scm.com/ Git] is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for software development.&lt;br /&gt;
&lt;br /&gt;
To obtain the last GPL source, you simply need to do:&lt;br /&gt;
&lt;br /&gt;
   git clone https://github.com/yambo-code/yambo.git yambo&lt;br /&gt;
&lt;br /&gt;
Please notice that doing so you will download the whole yambo repository, thus included all previous releases.&lt;br /&gt;
To see the list of releases just do &lt;br /&gt;
&lt;br /&gt;
   git branch -a&lt;br /&gt;
&lt;br /&gt;
and you will see &lt;br /&gt;
&lt;br /&gt;
* 5.0&lt;br /&gt;
&lt;br /&gt;
if you want to switch to a previous version i.e 4.1 do&lt;br /&gt;
&lt;br /&gt;
   git checkout 4.1&lt;br /&gt;
&lt;br /&gt;
to switch to a specific version (X.Y) among the ones listed after the command &amp;quot;git branch -a&amp;quot; (X.Y=4.1 in the example).&lt;br /&gt;
For production we suggest to always checkout a specific branch and not to stay in the master which maybe less stable. The branch corresponding to the version X.Y is always kept at the last patch-level. However if you need to checkout a specific patch-level you can do&lt;br /&gt;
 &lt;br /&gt;
   git tag&lt;br /&gt;
   git checkout 4.1.2&lt;br /&gt;
&lt;br /&gt;
to switch to a specific release (X.Y.Z) among the ones listed after the command &amp;quot;git tag&amp;quot; (X.Y.Z=4.1.2 in the example).&lt;br /&gt;
&lt;br /&gt;
== Getting the latest snapshot with subversion (obsolete) ==&lt;br /&gt;
If you are more familiar with subversion you can also download the whole repository in svn form.&lt;br /&gt;
Github offers the feature to automatically convert the git repo during the download. However remember that the repository in svn like form will be much bigger (~300 MB) that in git form (16 MB). Thus it is better to directly specify which branch you would like to download in that case:&lt;br /&gt;
&amp;lt;pre&amp;gt;svn checkout https://github.com/yambo-code/yambo.git/branches/4.1 yambo-4.1&amp;lt;/pre&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;pre&amp;gt;svn checkout https://github.com/yambo-code/yambo.git/tags/4.1.2 yambo-4.1.2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting a dedicated branch inside the gpl repository (experimental) ==&lt;br /&gt;
Yambo is a GPL code mantained by a small team of researchers. If you would like to help us coding new features or simply you would like to modify the code for your needs, we advise to follow the online tutorial [http://www.yambo-code.org/tutorials/developing_yambo/index.php Developing yambo]. Together with this tutorial we can also give you write permission inside the GPL repository. Thus, in case you are interested, please contact the yambo team and we will be glad to set up a specific branch for your needs.&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=4740</id>
		<title>Hartree Fock</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=4740"/>
		<updated>2021-04-06T07:09:26Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Calculation and analysis of output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prerequisites ==&lt;br /&gt;
[[File:Yambo-handbook-v4.1.2-p-9.png|thumb|Cheatsheet on HF|150px]]&lt;br /&gt;
&amp;lt;!-- * Complete the [[Generating the Yambo databases|Generating the Yambo databases]] tutorial --&amp;gt;&lt;br /&gt;
* You must first complete the &amp;quot;How to use Yambo&amp;quot; modules (&#039;&#039;[[Input_file_generation_and_command_line_options|input file generation and command_line_options]], [[Initialization]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for bulk hBN &lt;br /&gt;
* The &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;
== Background ==&lt;br /&gt;
The exchange part contribution of the self-energy for a generic state (nk) in reciprocal space reads:&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
It is important to note that in this way we are adding the HF contribution in a perturbative way to previously calculated DFT energies:&lt;br /&gt;
&lt;br /&gt;
[[File:Ehf.png|x20px|caption]]  &lt;br /&gt;
&lt;br /&gt;
and hence they will differ from a standard self-consistent HF calculation.&lt;br /&gt;
&lt;br /&gt;
== Input file generation ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by building up an input file for a HF calculation. 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 -x&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -x -F hf.in&lt;br /&gt;
&lt;br /&gt;
Looking inside the input file you will find:&lt;br /&gt;
&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 3187        RL    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL    # [XC] XCpotential RL components&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
   1| 14|  1|100|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
The variable  [[Variables#EXXRLvcs|EXXRLvcs]]  governs the number of G vectors to be summed in the expression of the exchange self-energy reported above.&lt;br /&gt;
The variable [[Variables#VXCRLvcs|VXCRLvcs]]  set the number of G vectors used in the evaluation of the density for the &amp;lt;Vxc&amp;gt; matrix element. A large number is needed in order to have a precise cancellation with the ground state calculation, in particular when GGA potentials are used. A good practice is to leave it at the maximum number (default). In case it would be needed to reduce (e.g. for memory reason), the accuracy can be checked by comparing the E_xc value printed in Yambo report and QE output file.&lt;br /&gt;
The [[Variables#QPkrange|QPkrange]]  name list it is a generalized index needed to select the first and last kpoints and bands we want to calculate the QP correction. &lt;br /&gt;
In general, we are interested in the gap of the system or in the band structure across the Fermi Energy. Let&#039;s start by editing the &#039;&#039;hf.in&#039;&#039; file by selecting the last occupied and first unoccupied bands These are the bands 8 and 9 as reported in the r_setup file.   &lt;br /&gt;
So we change the [[Variables#QPkrange|QPkrange]] variable in:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    1| 14|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
and run calculations to converge the expression above. In the expression of the Exchange Self Energy, we have a summation over bands, an integral over the Brillouin Zone and a Sum over the G vectors. Looking at the occupation factor we realize that occupied states only enters in the expression, so we do not need to worry about the bands as Yambo will include all the occupied bands by default. In order to check convergence of the G vectors in the summation in the Σx expression, we will perform different calculation varying the kinetic energy cutoff governing the number of G vectors entering in the sum. Let&#039;s start by setting in &#039;&#039;hf.in&#039;&#039;:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]= 10 Ry&lt;br /&gt;
&lt;br /&gt;
== Calculation and analysis of output ==&lt;br /&gt;
Let&#039;s now run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F hf.in -J 3D&lt;br /&gt;
&lt;br /&gt;
The result can be found int the output &#039;&#039;o-3D.hf&#039;&#039; file and in the &#039;&#039;r-3D_HF_and_locXC&#039;&#039; file. Looking inside the output file we have:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #  K-point          Band       Eo           Ehf          DFT        HF&lt;br /&gt;
 #&lt;br /&gt;
     1.00000      8.00000     -1.29642     -4.79324    -18.03344    -21.53026&lt;br /&gt;
     1.00000      9.00000      4.83239     9.755507    -9.592554    -4.669446&lt;br /&gt;
     2.00000      8.00000     -1.33551     -4.80994    -18.07476    -21.54919&lt;br /&gt;
     2.00000      9.00000      7.56742     13.43122    -11.55012    -5.68633&lt;br /&gt;
 ........&lt;br /&gt;
 &lt;br /&gt;
Looking at the definition of the HF energy, the third column is the DFT energy (KS eigenvalue), Ehf is the HF energy, and column 4 and 5 report the different contribution to be subtracted Vx (DFT) and added Σx (HF) to the unperturbed DFT eigenvalue.  From these data we can calculate the  HF gap: you can recognize that the direct gap is found at k-point number 7,  being 4.29 eV at  DFT level and 11.95 eV in  HF approximation. This information can be also easily found in the &lt;br /&gt;
report file &#039;&#039;r-3D_HF_and_locXC&#039;&#039; searching for Direct Gaps: &lt;br /&gt;
&lt;br /&gt;
Before the HF computation:  &lt;br /&gt;
&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;
&lt;br /&gt;
&lt;br /&gt;
... after the HF computation:&lt;br /&gt;
&lt;br /&gt;
 [05.01] HF occupations report&lt;br /&gt;
  =============================&lt;br /&gt;
&lt;br /&gt;
  [Hartree-Fock] Direct Gap                         :  11.94549 [eV]&lt;br /&gt;
  [Hartree-Fock] Direct Gap localized at k-point    :   7&lt;br /&gt;
  [Hartree-Fock] Indirect Gap                       :  11.28767 [eV]&lt;br /&gt;
  [Hartree-Fock] Indirect Gap between k-points      :  14   7&lt;br /&gt;
&lt;br /&gt;
or simply by typing:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;Direct Gap&amp;quot; r-3D_HF_and_locXC&lt;br /&gt;
&lt;br /&gt;
and the gap value before and after the HF correction is shown:&lt;br /&gt;
  [X] Direct Gap                                    :  4.289853 [eV]&lt;br /&gt;
  [X] Direct Gap localized at k-point               :   7&lt;br /&gt;
  [Hartree-Fock] Direct Gap                         :  11.94549 [eV]&lt;br /&gt;
  [Hartree-Fock] Direct Gap localized at k-point    :   7&lt;br /&gt;
&lt;br /&gt;
In the report file, the first value indicates the minimum gap while the second one is the maximum energy gap between the same bands.&lt;br /&gt;
&lt;br /&gt;
In the following, in order to converge the direct gap, we will focus the K point where the direct band is found. Inspecting the &#039;&#039;r_setup&#039;&#039; file, or any other report file it can be recognized that the direct minimum gap is found at the K-point number 7  (M point): this can be seen by searching the DFT &amp;quot;Direct Gap&amp;quot; and looking at the eigenvalues reported for each k point. Note that the zero energy is fixed at the top of the valence band, K point number 14 (H point). &lt;br /&gt;
So we can restrict the convergence calculations to the occupied and empty bands at point M, by modifying the input file as:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    7| 7|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Even if for this case the calculations are not at all expensive, reducing the calculations to few bands when performing convergence test allows to save memory and time. &lt;br /&gt;
&lt;br /&gt;
Now we can run different calculations changing the value of [[Variables#EXXRLvcs|EXXRLvcs]], let&#039;s say to 10,20,30 and 40 Ry. &lt;br /&gt;
Build four different input files differing only for the [[Variables#EXXRLvcs|EXXRLvcs]] values and naming them hf_10Ry.in, hf_20Ry.in, etc.&lt;br /&gt;
 &lt;br /&gt;
 $ cp hf.in hf_10Ry.in&lt;br /&gt;
 $ yambo -F hf_10Ry.in -J 3D&lt;br /&gt;
 $ cp hf.in hf_20Ry.in       &#039;&#039;and edit file, changing EXXRLvcs to 20Ry&#039;&#039;&lt;br /&gt;
 $ yambo -F hf_20Ry.in -J 3D&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Once the calculations are terminated, collect the results found in the output, for instance, putting in a file named hf.dat the following data:&lt;br /&gt;
Cutoff Energy, Number of G vector in the Sum,  HF energy for the occupied state (Ehf for the state 8), HF energy for the unoccupied state (Ehf for the state 9).&lt;br /&gt;
You can use the &#039;&#039;grep&#039;&#039; command to extract these data from the output e.g by typing.&lt;br /&gt;
&lt;br /&gt;
 grep 8.000 o-3D.hf_*&lt;br /&gt;
and&lt;br /&gt;
 grep 9.000 o-3D.hf_*&lt;br /&gt;
&lt;br /&gt;
and looking at the column corresponding to Ehf value (column 4).&lt;br /&gt;
For the number of G vectors corresponding to the cutoff energy cutoff in input search  &#039;&#039;Exchange RL vectors&#039;&#039; in the report files. Note that it is not possible anymore to extract directly the HF gap from the report file as we did above, as in this case, we did not include all the BZ in the calculation.&lt;br /&gt;
Now it possible to plot the energy gap in function of the energy cutoff or number of Gvectors:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 1:($4-$3)  w lp t &amp;quot;HF gap vs Energy cutoff&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 2:($4-$3)  w lp t &amp;quot;HF gap vs Number of G vector&amp;quot;&lt;br /&gt;
&lt;br /&gt;
or you can plot the gap in function of both quantities using the [[gnuplot_scripts|hf.gnu]] gnuplot script:&lt;br /&gt;
&lt;br /&gt;
[[File:Hf_plot1.png|none|600px|caption]]&lt;br /&gt;
&lt;br /&gt;
and you can see that at 40Ry the energy gap is very close to convergence. Plotting the occupied and unoccupied bands separately you can recognize that for this system the unoccupied band does converge much faster. &lt;br /&gt;
&lt;br /&gt;
The last important convergence test deals with the accuracy of the integral over the Brillouin zone in the expression of the Exchange Self-Energy, which translates into K point convergence. &lt;br /&gt;
In order to test the K point sampling, you should:&lt;br /&gt;
# perform a new non-scf calculation with a bigger k point grid, &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. &lt;br /&gt;
&lt;br /&gt;
For now, however, you can skip this convergence test and continue the tutorial at &lt;br /&gt;
[[How to obtain the quasi-particle band structure of a bulk material: h-BN|How to obtain the quasiparticle band structure of a bulk material]]&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: [[How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN|GW]] &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]] --&amp;gt; [[Hartree_Fock]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: Back to [[How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN|GW]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=4739</id>
		<title>Hartree Fock</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Hartree_Fock&amp;diff=4739"/>
		<updated>2021-04-06T06:56:41Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Input file generation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prerequisites ==&lt;br /&gt;
[[File:Yambo-handbook-v4.1.2-p-9.png|thumb|Cheatsheet on HF|150px]]&lt;br /&gt;
&amp;lt;!-- * Complete the [[Generating the Yambo databases|Generating the Yambo databases]] tutorial --&amp;gt;&lt;br /&gt;
* You must first complete the &amp;quot;How to use Yambo&amp;quot; modules (&#039;&#039;[[Input_file_generation_and_command_line_options|input file generation and command_line_options]], [[Initialization]]&#039;&#039;)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for bulk hBN &lt;br /&gt;
* The &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;
== Background ==&lt;br /&gt;
The exchange part contribution of the self-energy for a generic state (nk) in reciprocal space reads:&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
It is important to note that in this way we are adding the HF contribution in a perturbative way to previously calculated DFT energies:&lt;br /&gt;
&lt;br /&gt;
[[File:Ehf.png|x20px|caption]]  &lt;br /&gt;
&lt;br /&gt;
and hence they will differ from a standard self-consistent HF calculation.&lt;br /&gt;
&lt;br /&gt;
== Input file generation ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by building up an input file for a HF calculation. 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 -x&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo        &#039;&#039;(Initialization)&#039;&#039;&lt;br /&gt;
 $ yambo -x -F hf.in&lt;br /&gt;
&lt;br /&gt;
Looking inside the input file you will find:&lt;br /&gt;
&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 3187        RL    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL    # [XC] XCpotential RL components&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
   1| 14|  1|100|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
The variable  [[Variables#EXXRLvcs|EXXRLvcs]]  governs the number of G vectors to be summed in the expression of the exchange self-energy reported above.&lt;br /&gt;
The variable [[Variables#VXCRLvcs|VXCRLvcs]]  set the number of G vectors used in the evaluation of the density for the &amp;lt;Vxc&amp;gt; matrix element. A large number is needed in order to have a precise cancellation with the ground state calculation, in particular when GGA potentials are used. A good practice is to leave it at the maximum number (default). In case it would be needed to reduce (e.g. for memory reason), the accuracy can be checked by comparing the E_xc value printed in Yambo report and QE output file.&lt;br /&gt;
The [[Variables#QPkrange|QPkrange]]  name list it is a generalized index needed to select the first and last kpoints and bands we want to calculate the QP correction. &lt;br /&gt;
In general, we are interested in the gap of the system or in the band structure across the Fermi Energy. Let&#039;s start by editing the &#039;&#039;hf.in&#039;&#039; file by selecting the last occupied and first unoccupied bands These are the bands 8 and 9 as reported in the r_setup file.   &lt;br /&gt;
So we change the [[Variables#QPkrange|QPkrange]] variable in:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    1| 14|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
and run calculations to converge the expression above. In the expression of the Exchange Self Energy, we have a summation over bands, an integral over the Brillouin Zone and a Sum over the G vectors. Looking at the occupation factor we realize that occupied states only enters in the expression, so we do not need to worry about the bands as Yambo will include all the occupied bands by default. In order to check convergence of the G vectors in the summation in the Σx expression, we will perform different calculation varying the kinetic energy cutoff governing the number of G vectors entering in the sum. Let&#039;s start by setting in &#039;&#039;hf.in&#039;&#039;:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]= 10 Ry&lt;br /&gt;
&lt;br /&gt;
== Calculation and analysis of output ==&lt;br /&gt;
Let&#039;s now run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F hf.in -J 3D&lt;br /&gt;
&lt;br /&gt;
The result can be found int the output &#039;&#039;o-3D.hf&#039;&#039; file and in the &#039;&#039;r-3D_HF_and_locXC&#039;&#039; file. Looking inside the output file we have:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #  K-point          Band       Eo           Ehf          DFT        HF&lt;br /&gt;
 #&lt;br /&gt;
     1.00000      8.00000     -1.29642     -4.79324    -18.03344    -21.53026&lt;br /&gt;
     1.00000      9.00000      4.83239     9.755507    -9.592554    -4.669446&lt;br /&gt;
     2.00000      8.00000     -1.33551     -4.80994    -18.07476    -21.54919&lt;br /&gt;
     2.00000      9.00000      7.56742     13.43122    -11.55012    -5.68633&lt;br /&gt;
 ........&lt;br /&gt;
 &lt;br /&gt;
Looking at the definition of the HF energy, the third column is the DFT energy (KS eigenvalue), Ehf is the HF energy, and column 4 and 5 report the different contribution to be subtracted Vx (DFT) and added Σx (HF) to the unperturbed DFT eigenvalue.  From these data we can calculate the  HF gap: you can recognize that the direct gap is found at k-point number 7,  being 4.29 eV at  DFT level and 11.95 eV in  HF approximation. This information can be also easily found in the &lt;br /&gt;
report file &#039;&#039;r-3D_HF_and_locXC&#039;&#039; searching for Direct Gaps: &lt;br /&gt;
&lt;br /&gt;
Before the HF computation:  &lt;br /&gt;
&lt;br /&gt;
 States summary         : Full        Metallic    Empty&lt;br /&gt;
                           0001-0008               0009-0100&lt;br /&gt;
  Indirect Gaps      [ev]: 3.877976  7.279063&lt;br /&gt;
  Direct Gaps        [ev]: 4.28985  11.35417 &lt;br /&gt;
&lt;br /&gt;
... after the HF computation:&lt;br /&gt;
&lt;br /&gt;
 [05.01] HF occupations report&lt;br /&gt;
  =============================&lt;br /&gt;
&lt;br /&gt;
  States summary         : Full        Metallic    Empty&lt;br /&gt;
                           0001-0008               0009-0100&lt;br /&gt;
  Indirect Gaps      [ev]: 11.28776  16.09201  &lt;br /&gt;
  Direct Gaps        [ev]: 11.94547  21.59526&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
or simply by typing:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;Direct Gaps&amp;quot; r-3D_HF_and_locXC&lt;br /&gt;
&lt;br /&gt;
and the gap value before and after the HF correction is shown:&lt;br /&gt;
 Direct Gaps        [ev]:  4.28985  11.35417&lt;br /&gt;
 Direct Gaps        [ev]: 11.94547  21.59526 &lt;br /&gt;
&lt;br /&gt;
In the report file, the first value indicates the minimum gap while the second one is the maximum energy gap between the same bands.&lt;br /&gt;
&lt;br /&gt;
In the following, in order to converge the direct gap, we will focus the K point where the direct band is found. Inspecting the &#039;&#039;r_setup&#039;&#039; file, or any other report file it can be recognized that the direct minimum gap is found at the K-point number 7  (M point): this can be seen by searching the DFT &amp;quot;Direct Gap&amp;quot; and looking at the eigenvalues reported for each k point. Note that the zero energy is fixed at the top of the valence band, K point number 14 (H point). &lt;br /&gt;
So we can restrict the convergence calculations to the occupied and empty bands at point M, by modifying the input file as:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
    7| 7|  8| 9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Even if for this case the calculations are not at all expensive, reducing the calculations to few bands when performing convergence test allows to save memory and time. &lt;br /&gt;
&lt;br /&gt;
Now we can run different calculations changing the value of [[Variables#EXXRLvcs|EXXRLvcs]], let&#039;s say to 10,20,30 and 40 Ry. &lt;br /&gt;
Build four different input files differing only for the [[Variables#EXXRLvcs|EXXRLvcs]] values and naming them hf_10Ry.in, hf_20Ry.in, etc.&lt;br /&gt;
 &lt;br /&gt;
 $ cp hf.in hf_10Ry.in&lt;br /&gt;
 $ yambo -F hf_10Ry.in -J 3D&lt;br /&gt;
 $ cp hf.in hf_20Ry.in       &#039;&#039;and edit file, changing EXXRLvcs to 20Ry&#039;&#039;&lt;br /&gt;
 $ yambo -F hf_20Ry.in -J 3D&lt;br /&gt;
 .....&lt;br /&gt;
&lt;br /&gt;
Once the calculations are terminated, collect the results found in the output, for instance, putting in a file named hf.dat the following data:&lt;br /&gt;
Cutoff Energy, Number of G vector in the Sum,  HF energy for the occupied state (Ehf for the state 8), HF energy for the unoccupied state (Ehf for the state 9).&lt;br /&gt;
You can use the &#039;&#039;grep&#039;&#039; command to extract these data from the output e.g by typing.&lt;br /&gt;
&lt;br /&gt;
 grep 8.000 o-3D.hf_*&lt;br /&gt;
and&lt;br /&gt;
 grep 9.000 o-3D.hf_*&lt;br /&gt;
&lt;br /&gt;
and looking at the column corresponding to Ehf value (column 4).&lt;br /&gt;
For the number of G vectors corresponding to the cutoff energy cutoff in input search  &#039;&#039;Exchange RL vectors&#039;&#039; in the report files. Note that it is not possible anymore to extract directly the HF gap from the report file as we did above, as in this case, we did not include all the BZ in the calculation.&lt;br /&gt;
Now it possible to plot the energy gap in function of the energy cutoff or number of Gvectors:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 1:($4-$3)  w lp t &amp;quot;HF gap vs Energy cutoff&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;hf.dat&amp;quot; u 2:($4-$3)  w lp t &amp;quot;HF gap vs Number of G vector&amp;quot;&lt;br /&gt;
&lt;br /&gt;
or you can plot the gap in function of both quantities using the [[gnuplot_scripts|hf.gnu]] gnuplot script:&lt;br /&gt;
&lt;br /&gt;
[[File:Hf_plot1.png|none|600px|caption]]&lt;br /&gt;
&lt;br /&gt;
and you can see that at 40Ry the energy gap is very close to convergence. Plotting the occupied and unoccupied bands separately you can recognize that for this system the unoccupied band does converge much faster. &lt;br /&gt;
&lt;br /&gt;
The last important convergence test deals with the accuracy of the integral over the Brillouin zone in the expression of the Exchange Self-Energy, which translates into K point convergence. &lt;br /&gt;
In order to test the K point sampling, you should:&lt;br /&gt;
# perform a new non-scf calculation with a bigger k point grid, &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. &lt;br /&gt;
&lt;br /&gt;
For now, however, you can skip this convergence test and continue the tutorial at &lt;br /&gt;
[[How to obtain the quasi-particle band structure of a bulk material: h-BN|How to obtain the quasiparticle band structure of a bulk material]]&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: [[How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN|GW]] &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]] --&amp;gt; [[Hartree_Fock]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: Back to [[How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN|GW]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4666</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=4666"/>
		<updated>2021-04-02T13:05:04Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Verbosity */&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;
* 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;
&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 will 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;
&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;
==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;
&amp;lt;!--&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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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|  1|100|&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 -J 1Ry -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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=4652</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=4652"/>
		<updated>2021-04-02T11:31:52Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Allowed options */&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;
* 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;
&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 will 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;
&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;
==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;
&amp;lt;!--&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;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Conversion to Yambo format ===&lt;br /&gt;
The PWscf &#039;&#039;bBN.save&#039;&#039; output is converted 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;
&lt;br /&gt;
==Initialization of Yambo databases==&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &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;
&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;
  [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;
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;
  [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;
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;
&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;
&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 &#039;&#039;&#039;lowercase&#039;&#039;&#039; options. &lt;br /&gt;
&lt;br /&gt;
====Allowed options====&lt;br /&gt;
To see the list of runlevels and options, run &amp;lt;code&amp;gt;yambo -h&amp;lt;/code&amp;gt; or better,&lt;br /&gt;
 $ yambo -h&lt;br /&gt;
 This is yambo 4.4.0 rev.148&lt;br /&gt;
 A shiny pot of fun and happiness [C.D.Hogan] &lt;br /&gt;
 -h		:Short Help&lt;br /&gt;
 -H		:Long Help&lt;br /&gt;
 -J &amp;lt;opt&amp;gt;	:Job string identifier&lt;br /&gt;
 -V &amp;lt;opt&amp;gt;	:Input file verbosity[opt=RL,kpt,sc,qp,io,gen,resp,all,par]&lt;br /&gt;
 -F &amp;lt;opt&amp;gt;	:Input file&lt;br /&gt;
 -I &amp;lt;opt&amp;gt;	:Core I/O directory&lt;br /&gt;
 -O &amp;lt;opt&amp;gt;	:Additional I/O directory&lt;br /&gt;
 -C &amp;lt;opt&amp;gt;	:Communications I/O directory&lt;br /&gt;
 -D		:DataBases properties&lt;br /&gt;
 -W &amp;lt;opt&amp;gt;	:Wall Time limitation (1d2h30m format)&lt;br /&gt;
 -Q		:Don&#039;t launch the text editor&lt;br /&gt;
 -E &amp;lt;opt&amp;gt;	:Environment Parallel Variables file&lt;br /&gt;
 -M		:Switch-off MPI support (serial run)&lt;br /&gt;
 -N		:Switch-off OpenMP support (single thread run)&lt;br /&gt;
 -i		:Initialization&lt;br /&gt;
 -o &amp;lt;opt&amp;gt;	:Optics [opt=(c)hi is (G)-space / (b)se is (eh)-space ]&lt;br /&gt;
 -k &amp;lt;opt&amp;gt;	:Kernel [opt=hartree/alda/lrc/hf/sex](hf/sex only eh-space; lrc only G-space)&lt;br /&gt;
 -y &amp;lt;opt&amp;gt;	:BSE solver [opt=h/d/s/(p/f)i](h)aydock/(d)iagonalization/(i)nversion&lt;br /&gt;
 -r		:Coulomb potential&lt;br /&gt;
 -x		:Hartree-Fock Self-energy and local XC&lt;br /&gt;
 -d		:Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 -b		:Static Inverse Dielectric Matrix&lt;br /&gt;
 -p &amp;lt;opt&amp;gt;	:GW approximations [opt=(p)PA/(c)HOSEX]&lt;br /&gt;
 -g &amp;lt;opt&amp;gt;	:Dyson Equation solver[opt=(n)ewton/(s)ecant/(g)reen]&lt;br /&gt;
 -l		:GoWo Quasiparticle lifetimes&lt;br /&gt;
 -a		:ACFDT Total Energy&lt;br /&gt;
 -s		:ScaLapacK test&lt;br /&gt;
&lt;br /&gt;
Any time you launch Yambo with a lowercase option, Yambo will generate the appropriate input file (default name: &#039;&#039;yambo.in&#039;&#039;) and launch the &amp;lt;code&amp;gt;vi&amp;lt;/code&amp;gt; editor. &lt;br /&gt;
&lt;br /&gt;
Editor choice can be changed at configure; 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 -x -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;
====Combining options====&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 -o c -k 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 -x -g n -p p        &#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;
===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 -x&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|  1|100|&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;
===Uppercase options===&lt;br /&gt;
Uppercase 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;
====Allowed options====&lt;br /&gt;
To see the list of options, again do:&lt;br /&gt;
 $ yambo -H&lt;br /&gt;
 Tool: yambo 4.1.2 rev.14024&lt;br /&gt;
 Description: A shiny pot of fun and happiness [C.D.Hogan] &lt;br /&gt;
 -J &amp;lt;opt&amp;gt;	:Job string identifier&lt;br /&gt;
 -V &amp;lt;opt&amp;gt;	:Input file verbosity&lt;br /&gt;
                 [opt=RL,kpt,sc,qp,io,gen,resp,all,par]&lt;br /&gt;
 -F &amp;lt;opt&amp;gt;	:Input file&lt;br /&gt;
 -I &amp;lt;opt&amp;gt;	:Core I/O directory&lt;br /&gt;
 -O &amp;lt;opt&amp;gt;	:Additional I/O directory&lt;br /&gt;
 -C &amp;lt;opt&amp;gt;	:Communications I/O directory&lt;br /&gt;
 -D		:DataBases properties&lt;br /&gt;
 -W &amp;lt;opt&amp;gt;	:Wall Time limitation (1d2h30m format)&lt;br /&gt;
 -Q		:Don&#039;t launch the text editor&lt;br /&gt;
 -M		:Switch-off MPI support (serial run)&lt;br /&gt;
 -N		:Switch-off OpenMP support (single thread run)&lt;br /&gt;
 [Lower case options]&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 -x    &#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;
===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 -o 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 -o 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 -J 1Ry -V RL -x        &#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           &#039;&#039;Run the code&#039;&#039;&lt;br /&gt;
 $ ls&lt;br /&gt;
 yambo.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;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_solver:_diagonalization&amp;diff=3736</id>
		<title>Bethe-Salpeter solver: diagonalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_solver:_diagonalization&amp;diff=3736"/>
		<updated>2020-01-29T14:12:44Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this module you learn how to obtain an optical absorption spectra within the Bethe-Salpeter equation (BSE) framework by diagonalizing a previously calculated Bethe-Salpeter (BS) kernel.&lt;br /&gt;
 &lt;br /&gt;
==Prerequisites==&lt;br /&gt;
[[File:Yambo-handbook-v4.1.2-p-15.png|thumb|Cheatsheet on BSS diagonalization|150px]]&lt;br /&gt;
* You must first complete the [[Static screening]] and [[Bethe-Salpeter kernel]] modules&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for 3D hBN&lt;br /&gt;
* The &amp;lt;code&amp;gt;3D_QP_BSE&amp;lt;/code&amp;gt; directory (provided) which contains the database with the GW corrections (create one directory with this name and put the ndb.QP file produced yesterday there)&lt;br /&gt;
* The &amp;lt;code&amp;gt;3D_BSE&amp;lt;/code&amp;gt; directory containing the databases from the [[Static screening]] and [[Bethe-Salpeter kernel]] modules&lt;br /&gt;
* The &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;
==Background==&lt;br /&gt;
The macroscopic dielectric function (from which the absorption and EEL spectra can be computed) is obtained from the eigenvalues &#039;&#039;E&#039;&#039;&amp;lt;sub&amp;gt;&amp;amp;lambda;&amp;lt;/sub&amp;gt; (excitonic energies) and eigenvectors A&amp;lt;sup&amp;gt;&amp;amp;lambda;&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;&#039;&#039;cv&#039;&#039;&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt; (exciton composition in terms of electron-hole pairs) of the two-particle Hamiltonian:&lt;br /&gt;
&lt;br /&gt;
[[File:BSE1-Eq4.png|none|x50px]]&lt;br /&gt;
&lt;br /&gt;
To get the two-particle Hamiltonian eigensolutions you need to diagonalize the two-particle Hamiltonian (non spin-polarized case):&lt;br /&gt;
&lt;br /&gt;
[[File:BSE1-Eq1.png|none|x50px]]&lt;br /&gt;
&lt;br /&gt;
for which the &#039;&#039;2V - W&#039;&#039; part was evaluated in the [[Bethe-Salpeter kernel]] module.&lt;br /&gt;
&lt;br /&gt;
The difference of quasiparticle energies &#039;&#039;&amp;amp;Delta;&amp;amp;epsilon;&amp;lt;sub&amp;gt;cv&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;= &amp;amp;epsilon;&amp;lt;sub&amp;gt;c&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt; - &amp;amp;epsilon;&amp;lt;sub&amp;gt;v&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is added to the matrix just before the solver. &lt;br /&gt;
There are two possible choices:&lt;br /&gt;
* the Kohn-Sham energies (calculated at DFT level) are corrected through a Scissor and the renormalization of the conduction and valence bandwidth (linearly with respect to the conduction band minimum and the valence band maximum respectively):&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&amp;amp;Delta;&amp;amp;epsilon;&amp;lt;sub&amp;gt;cv&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;= M&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;(&amp;amp;epsilon;&amp;lt;sub&amp;gt;c&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;KS&amp;lt;/sup&amp;gt; - CBM) - M&amp;lt;sub&amp;gt;v&amp;lt;/sub&amp;gt;(&amp;amp;epsilon;&amp;lt;sub&amp;gt;v&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;KS&amp;lt;/sup&amp;gt; - VBM) + Scissor&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
* the quasiparticle energies calculated at [[How to obtain the quasi-particle band structure of a bulk material: h-BN|GW level]] are used. Missing energies are computed by interpolation.&lt;br /&gt;
&lt;br /&gt;
==Choosing the input parameters==&lt;br /&gt;
&lt;br /&gt;
Invoke yambo with the &amp;quot;-y d&amp;quot; option in the command line:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F 03_3D_BSE_diago_solver.in -y d -V qp -J 3D_BSE&lt;br /&gt;
&lt;br /&gt;
The input is open in the editor. The input variable to be changed are &lt;br /&gt;
 % [[Variables#BEnRange|BEnRange]]&lt;br /&gt;
   2.00000 | 8.00000 | eV    &lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 200      &lt;br /&gt;
 &lt;br /&gt;
which define 200 evenly spaced points between 2 and 8 eV at which the spectrum is calculated (&amp;amp;omega; in the equation for the macroscopic dielectric function),&lt;br /&gt;
  &lt;br /&gt;
 % [[Variables#BDmRange|BDmRange]]&lt;br /&gt;
   0.10000 |  0.10000 | eV    &lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
which defines the spectral broadening (Lorentzian model), &lt;br /&gt;
&lt;br /&gt;
 % [[Variables#BLongDir|BLongDir]]&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 | &lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
which defines the direction of the perturbing electric field (in this case the in-plane direction).&lt;br /&gt;
&lt;br /&gt;
Another parameter to modify is&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]] &lt;br /&gt;
  1.440000 | 1.000000 | 1.000000 |&lt;br /&gt;
 %&lt;br /&gt;
This gives the quasiparticle corrections to the Kohn-Sham eigenvalues and  is deduced either from experiment or previous [[How to obtain the quasi-particle band structure of a bulk material: h-BN|GW calculations]]. &lt;br /&gt;
With reference to the equation in the Background, the format is&lt;br /&gt;
  &#039;&#039;Scissor&#039;&#039; | &#039;&#039;M&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;&#039;&#039; | &#039;&#039;M&amp;lt;sub&amp;gt;v&amp;lt;/sub&amp;gt;&#039;&#039; |&lt;br /&gt;
The alternative of directly input corrections calculated from a previous GW calculation is shown in the next section.&lt;br /&gt;
&lt;br /&gt;
==Bethe-Salpeter solver runlevel== &lt;br /&gt;
 $ yambo -F 03_3D_BSE_diago_solver.in -J 3D_BSE  &lt;br /&gt;
In the log (either in standard output or in l-3d_BSE_optics_bse_bsk_bss), after various setup/loading, the BSE is diagonalized using the linked linear algebra libraries: &lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] BSE solver(s)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06.01] Diagonalization solver&lt;br /&gt;
 &amp;lt;01s&amp;gt; BSK diagonalize |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; EPS   residuals |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; BSK     epsilon |########################################| [100%] --(E) --(X)&lt;br /&gt;
The report r-3d_BSE_optics_bse_bsk_bss contains information relative to this runlevel in section 6:&lt;br /&gt;
&lt;br /&gt;
 [06] BSE solver(s)&lt;br /&gt;
 ==================&lt;br /&gt;
&lt;br /&gt;
Take some time to inspect the log and the report to check the consistency with the input variables. This run produces a new database in the 3D_BSE directory&lt;br /&gt;
 3D_BSE/ndb.BS_diago_Q01&lt;br /&gt;
So if you need the spectrum on a different energy range, direction, with a different broadening or on more points the diagonalization is not repeated, just the spectrum is recalculated.&lt;br /&gt;
    &lt;br /&gt;
This run produces as well human readable files (o-*). Specifically o-3D_BSE.eps_q1_diago_bse contains the real and imaginary part of the macroscopic dielectric function &lt;br /&gt;
  &lt;br /&gt;
 $ less o-3D_BSE.eps_q1_diago_bse &lt;br /&gt;
 ...&lt;br /&gt;
 #&lt;br /&gt;
 #  E/ev[1]    EPS-Im[2]  EPS-Re[3]  EPSo-Im[4] EPSo-Re[5]&lt;br /&gt;
 #&lt;br /&gt;
   2.00000    0.16162    5.83681    0.04959    4.14127&lt;br /&gt;
   2.03015    0.16787    5.88612    0.05090    4.15638&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
which is in the format &lt;br /&gt;
 Energy in eV | Imaginary part BSE | Real part BSE |Imaginary part IPA | Real part IPA |  &lt;br /&gt;
&lt;br /&gt;
where real and imaginary parts refer to the macroscopic dielectric function. The imaginary part is related to the optical absorption. The latter (column 2) can be plotted versus the photon energy (column 1) and compared with the independent particle approximation (IPA, column 4), e.g.: &lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 plot &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:2 w l t &#039;BSE&#039;, &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:4 w l  t &#039;IPA&#039;&lt;br /&gt;
&lt;br /&gt;
[[file:03_bse_diago.png |none|600px]]&lt;br /&gt;
The addition of the kernel has the effect to red-shift the spectrum onset and to redistribute the oscillator strengths. Note that the convergence with respect to k-points smooths out the low energy peaks in the IPA (which are an artifact of poor convergence with k-points producing an artificial confinement) to give the shoulder corresponding to the van Hove singularity in the band structure. On the other hand the low energy peak in the BSE is genuine and it is the signature of a bound exciton.&lt;br /&gt;
&lt;br /&gt;
==Reading the QP corrections from a previous &#039;&#039;GW&#039;&#039; calculation==&lt;br /&gt;
In the above calculation we have used a simple scissor operator to correct the Kohn-Sam DFT energies. In this part we see how we can instead take the corrections from a previous Yambo Gw calculation.&lt;br /&gt;
We create and edit the input:&lt;br /&gt;
 $yambo -F 03_3D_QP_BSE.in -y d -V qp -J 3D_BSE&lt;br /&gt;
We set all parameters as in the previous calculation, except for the part regarding the QP correction:&lt;br /&gt;
  [[Variables#KfnQPdb|KfnQPdb]]= &amp;quot;E &amp;lt; 3D_QP_BSE/ndb.QP&amp;quot;              # [EXTQP BSK BSS] Database&lt;br /&gt;
  [[Variables#KfnQP_N|KfnQP_N]]= 1                   # [EXTQP BSK BSS] Interpolation neighbours&lt;br /&gt;
  % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
   0.000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
Instead of setting the values for the scissor, we give the path to a database (3D_QP_BSE/ndb.QP) which contains the QP corrections. This has been created by running a GW calculation as in the [[How to obtain the quasi-particle band structure of a bulk material: h-BN |GW tutorial]].&lt;br /&gt;
Run Yambo:&lt;br /&gt;
 $ yambo -F 03_3D_QP_BSE.in -J &amp;quot;3D_QP_BSE,3D_BSE&amp;quot;&lt;br /&gt;
This produces the following log in the standard output. Note Section 4 (regarding external QP corrections to the kernel):&lt;br /&gt;
 &amp;lt;01s&amp;gt; [04.01] External QP corrections (K)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [QP@K] E&amp;lt;3D_QP_BSE/ndb.QP[ PPA XG:39 Xb:1   40 Scb:1   40]&lt;br /&gt;
 &amp;lt;01s&amp;gt; [QP] Kpts covered exactly  [o/o]: 100.0000&lt;br /&gt;
This tells you that the file was found, read correctly and that the &#039;&#039;&#039;k&#039;&#039;&#039; points found in the file matched the ones you are using for the current calculation (otherwise interpolation would be needed).&lt;br /&gt;
It is crucial to check that the file has been read, since if not Yambo gives a warning but continues the calculation (with no QP corrections at all!).&lt;br /&gt;
As in the previous calculation the final results of the calculation are the files with the spectral functions. Let&#039;s compare the results for the optical absorption spectrum with those obtained previously with a simple scissor:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 plot &#039;o-3D_QP_BSE.eps_q1_diago_bse&#039; u 1:2 w l t &#039;Explicit QP&#039;, &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:2 w l t &#039;Scissor&#039; &lt;br /&gt;
[[File:03 bse diago qp.png|none|600px]]&lt;br /&gt;
It is clear that this makes a difference in the peak distribution and intensity. Note that beside a simple shift you can renormalise as well the bandwidth of the valence and conduction bands in KfnQP_E (respectively the third and second value). You can try as an exercise to set up a new calculation using e.g. 1.440000 | 1.200000 | 0.900000 | for KfnQP_E.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
From this tutorial you&#039;ve learned:&lt;br /&gt;
* How to compute the optical spectrum by using the diagonal solver within the Bethe-Salpeter equation framework&lt;br /&gt;
* Two alternative ways to provide QP energies (explicitly or via a scissor). &lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* Previous module: [[Bethe-Salpeter kernel]]&lt;br /&gt;
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: Lanczos-Haydock | Lanczos-Haydock]] &lt;br /&gt;
* Back to [[Calculating optical spectra including excitonic effects: a step-by-step guide]] tutorial&lt;br /&gt;
* [[Tutorials|Back to tutorials menu]]&lt;br /&gt;
* [[Modules|Back to technical modules menu]]&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_solver:_diagonalization&amp;diff=3735</id>
		<title>Bethe-Salpeter solver: diagonalization</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bethe-Salpeter_solver:_diagonalization&amp;diff=3735"/>
		<updated>2020-01-29T14:12:07Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Prerequisites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this module you learn how to obtain an optical absorption spectra within the Bethe-Salpeter equation (BSE) framework by diagonalizing a previously calculated Bethe-Salpeter (BS) kernel.&lt;br /&gt;
 &lt;br /&gt;
==Prerequisites==&lt;br /&gt;
[[File:Yambo-handbook-v4.1.2-p-15.png|thumb|Cheatsheet on BSS diagonalization|150px]]&lt;br /&gt;
* You must first complete the [[Static screening]] and [[Bethe-Salpeter kernel]] modules&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for 3D hBN&lt;br /&gt;
* The &amp;lt;code&amp;gt;3D_QP_BSE&amp;lt;/code&amp;gt; directory (provided) which contains the database with the GW corrections (create one directory with this name and put the ndb.QP file produced yesterady there)&lt;br /&gt;
* The &amp;lt;code&amp;gt;3D_BSE&amp;lt;/code&amp;gt; directory containing the databases from the [[Static screening]] and [[Bethe-Salpeter kernel]] modules&lt;br /&gt;
* The &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;
==Background==&lt;br /&gt;
The macroscopic dielectric function (from which the absorption and EEL spectra can be computed) is obtained from the eigenvalues &#039;&#039;E&#039;&#039;&amp;lt;sub&amp;gt;&amp;amp;lambda;&amp;lt;/sub&amp;gt; (excitonic energies) and eigenvectors A&amp;lt;sup&amp;gt;&amp;amp;lambda;&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;&#039;&#039;cv&#039;&#039;&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt; (exciton composition in terms of electron-hole pairs) of the two-particle Hamiltonian:&lt;br /&gt;
&lt;br /&gt;
[[File:BSE1-Eq4.png|none|x50px]]&lt;br /&gt;
&lt;br /&gt;
To get the two-particle Hamiltonian eigensolutions you need to diagonalize the two-particle Hamiltonian (non spin-polarized case):&lt;br /&gt;
&lt;br /&gt;
[[File:BSE1-Eq1.png|none|x50px]]&lt;br /&gt;
&lt;br /&gt;
for which the &#039;&#039;2V - W&#039;&#039; part was evaluated in the [[Bethe-Salpeter kernel]] module.&lt;br /&gt;
&lt;br /&gt;
The difference of quasiparticle energies &#039;&#039;&amp;amp;Delta;&amp;amp;epsilon;&amp;lt;sub&amp;gt;cv&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;= &amp;amp;epsilon;&amp;lt;sub&amp;gt;c&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt; - &amp;amp;epsilon;&amp;lt;sub&amp;gt;v&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is added to the matrix just before the solver. &lt;br /&gt;
There are two possible choices:&lt;br /&gt;
* the Kohn-Sham energies (calculated at DFT level) are corrected through a Scissor and the renormalization of the conduction and valence bandwidth (linearly with respect to the conduction band minimum and the valence band maximum respectively):&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&amp;amp;Delta;&amp;amp;epsilon;&amp;lt;sub&amp;gt;cv&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;= M&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;(&amp;amp;epsilon;&amp;lt;sub&amp;gt;c&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;KS&amp;lt;/sup&amp;gt; - CBM) - M&amp;lt;sub&amp;gt;v&amp;lt;/sub&amp;gt;(&amp;amp;epsilon;&amp;lt;sub&amp;gt;v&#039;&#039;&#039;k&#039;&#039;&#039;&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;KS&amp;lt;/sup&amp;gt; - VBM) + Scissor&#039;&#039;  &lt;br /&gt;
&lt;br /&gt;
* the quasiparticle energies calculated at [[How to obtain the quasi-particle band structure of a bulk material: h-BN|GW level]] are used. Missing energies are computed by interpolation.&lt;br /&gt;
&lt;br /&gt;
==Choosing the input parameters==&lt;br /&gt;
&lt;br /&gt;
Invoke yambo with the &amp;quot;-y d&amp;quot; option in the command line:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F 03_3D_BSE_diago_solver.in -y d -V qp -J 3D_BSE&lt;br /&gt;
&lt;br /&gt;
The input is open in the editor. The input variable to be changed are &lt;br /&gt;
 % [[Variables#BEnRange|BEnRange]]&lt;br /&gt;
   2.00000 | 8.00000 | eV    &lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 200      &lt;br /&gt;
 &lt;br /&gt;
which define 200 evenly spaced points between 2 and 8 eV at which the spectrum is calculated (&amp;amp;omega; in the equation for the macroscopic dielectric function),&lt;br /&gt;
  &lt;br /&gt;
 % [[Variables#BDmRange|BDmRange]]&lt;br /&gt;
   0.10000 |  0.10000 | eV    &lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
which defines the spectral broadening (Lorentzian model), &lt;br /&gt;
&lt;br /&gt;
 % [[Variables#BLongDir|BLongDir]]&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 | &lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
which defines the direction of the perturbing electric field (in this case the in-plane direction).&lt;br /&gt;
&lt;br /&gt;
Another parameter to modify is&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]] &lt;br /&gt;
  1.440000 | 1.000000 | 1.000000 |&lt;br /&gt;
 %&lt;br /&gt;
This gives the quasiparticle corrections to the Kohn-Sham eigenvalues and  is deduced either from experiment or previous [[How to obtain the quasi-particle band structure of a bulk material: h-BN|GW calculations]]. &lt;br /&gt;
With reference to the equation in the Background, the format is&lt;br /&gt;
  &#039;&#039;Scissor&#039;&#039; | &#039;&#039;M&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;&#039;&#039; | &#039;&#039;M&amp;lt;sub&amp;gt;v&amp;lt;/sub&amp;gt;&#039;&#039; |&lt;br /&gt;
The alternative of directly input corrections calculated from a previous GW calculation is shown in the next section.&lt;br /&gt;
&lt;br /&gt;
==Bethe-Salpeter solver runlevel== &lt;br /&gt;
 $ yambo -F 03_3D_BSE_diago_solver.in -J 3D_BSE  &lt;br /&gt;
In the log (either in standard output or in l-3d_BSE_optics_bse_bsk_bss), after various setup/loading, the BSE is diagonalized using the linked linear algebra libraries: &lt;br /&gt;
 &amp;lt;01s&amp;gt; [06] BSE solver(s)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [LA] SERIAL linear algebra&lt;br /&gt;
 &amp;lt;01s&amp;gt; [06.01] Diagonalization solver&lt;br /&gt;
 &amp;lt;01s&amp;gt; BSK diagonalize |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; EPS   residuals |########################################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;01s&amp;gt; BSK     epsilon |########################################| [100%] --(E) --(X)&lt;br /&gt;
The report r-3d_BSE_optics_bse_bsk_bss contains information relative to this runlevel in section 6:&lt;br /&gt;
&lt;br /&gt;
 [06] BSE solver(s)&lt;br /&gt;
 ==================&lt;br /&gt;
&lt;br /&gt;
Take some time to inspect the log and the report to check the consistency with the input variables. This run produces a new database in the 3D_BSE directory&lt;br /&gt;
 3D_BSE/ndb.BS_diago_Q01&lt;br /&gt;
So if you need the spectrum on a different energy range, direction, with a different broadening or on more points the diagonalization is not repeated, just the spectrum is recalculated.&lt;br /&gt;
    &lt;br /&gt;
This run produces as well human readable files (o-*). Specifically o-3D_BSE.eps_q1_diago_bse contains the real and imaginary part of the macroscopic dielectric function &lt;br /&gt;
  &lt;br /&gt;
 $ less o-3D_BSE.eps_q1_diago_bse &lt;br /&gt;
 ...&lt;br /&gt;
 #&lt;br /&gt;
 #  E/ev[1]    EPS-Im[2]  EPS-Re[3]  EPSo-Im[4] EPSo-Re[5]&lt;br /&gt;
 #&lt;br /&gt;
   2.00000    0.16162    5.83681    0.04959    4.14127&lt;br /&gt;
   2.03015    0.16787    5.88612    0.05090    4.15638&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
which is in the format &lt;br /&gt;
 Energy in eV | Imaginary part BSE | Real part BSE |Imaginary part IPA | Real part IPA |  &lt;br /&gt;
&lt;br /&gt;
where real and imaginary parts refer to the macroscopic dielectric function. The imaginary part is related to the optical absorption. The latter (column 2) can be plotted versus the photon energy (column 1) and compared with the independent particle approximation (IPA, column 4), e.g.: &lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 plot &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:2 w l t &#039;BSE&#039;, &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:4 w l  t &#039;IPA&#039;&lt;br /&gt;
&lt;br /&gt;
[[file:03_bse_diago.png |none|600px]]&lt;br /&gt;
The addition of the kernel has the effect to red-shift the spectrum onset and to redistribute the oscillator strengths. Note that the convergence with respect to k-points smooths out the low energy peaks in the IPA (which are an artifact of poor convergence with k-points producing an artificial confinement) to give the shoulder corresponding to the van Hove singularity in the band structure. On the other hand the low energy peak in the BSE is genuine and it is the signature of a bound exciton.&lt;br /&gt;
&lt;br /&gt;
==Reading the QP corrections from a previous &#039;&#039;GW&#039;&#039; calculation==&lt;br /&gt;
In the above calculation we have used a simple scissor operator to correct the Kohn-Sam DFT energies. In this part we see how we can instead take the corrections from a previous Yambo Gw calculation.&lt;br /&gt;
We create and edit the input:&lt;br /&gt;
 $yambo -F 03_3D_QP_BSE.in -y d -V qp -J 3D_BSE&lt;br /&gt;
We set all parameters as in the previous calculation, except for the part regarding the QP correction:&lt;br /&gt;
  [[Variables#KfnQPdb|KfnQPdb]]= &amp;quot;E &amp;lt; 3D_QP_BSE/ndb.QP&amp;quot;              # [EXTQP BSK BSS] Database&lt;br /&gt;
  [[Variables#KfnQP_N|KfnQP_N]]= 1                   # [EXTQP BSK BSS] Interpolation neighbours&lt;br /&gt;
  % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
   0.000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
Instead of setting the values for the scissor, we give the path to a database (3D_QP_BSE/ndb.QP) which contains the QP corrections. This has been created by running a GW calculation as in the [[How to obtain the quasi-particle band structure of a bulk material: h-BN |GW tutorial]].&lt;br /&gt;
Run Yambo:&lt;br /&gt;
 $ yambo -F 03_3D_QP_BSE.in -J &amp;quot;3D_QP_BSE,3D_BSE&amp;quot;&lt;br /&gt;
This produces the following log in the standard output. Note Section 4 (regarding external QP corrections to the kernel):&lt;br /&gt;
 &amp;lt;01s&amp;gt; [04.01] External QP corrections (K)&lt;br /&gt;
 &amp;lt;01s&amp;gt; [QP@K] E&amp;lt;3D_QP_BSE/ndb.QP[ PPA XG:39 Xb:1   40 Scb:1   40]&lt;br /&gt;
 &amp;lt;01s&amp;gt; [QP] Kpts covered exactly  [o/o]: 100.0000&lt;br /&gt;
This tells you that the file was found, read correctly and that the &#039;&#039;&#039;k&#039;&#039;&#039; points found in the file matched the ones you are using for the current calculation (otherwise interpolation would be needed).&lt;br /&gt;
It is crucial to check that the file has been read, since if not Yambo gives a warning but continues the calculation (with no QP corrections at all!).&lt;br /&gt;
As in the previous calculation the final results of the calculation are the files with the spectral functions. Let&#039;s compare the results for the optical absorption spectrum with those obtained previously with a simple scissor:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 plot &#039;o-3D_QP_BSE.eps_q1_diago_bse&#039; u 1:2 w l t &#039;Explicit QP&#039;, &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:2 w l t &#039;Scissor&#039; &lt;br /&gt;
[[File:03 bse diago qp.png|none|600px]]&lt;br /&gt;
It is clear that this makes a difference in the peak distribution and intensity. Note that beside a simple shift you can renormalise as well the bandwidth of the valence and conduction bands in KfnQP_E (respectively the third and second value). You can try as an exercise to set up a new calculation using e.g. 1.440000 | 1.200000 | 0.900000 | for KfnQP_E.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
From this tutorial you&#039;ve learned:&lt;br /&gt;
* How to compute the optical spectrum by using the diagonal solver within the Bethe-Salpeter equation framework&lt;br /&gt;
* Two alternative ways to provide QP energies (explicitly or via a scissor). &lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* Previous module: [[Bethe-Salpeter kernel]]&lt;br /&gt;
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: Lanczos-Haydock | Lanczos-Haydock]] &lt;br /&gt;
* Back to [[Calculating optical spectra including excitonic effects: a step-by-step guide]] tutorial&lt;br /&gt;
* [[Tutorials|Back to tutorials menu]]&lt;br /&gt;
* [[Modules|Back to technical modules menu]]&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3411</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3411"/>
		<updated>2020-01-21T04:57:23Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Use the truncated coulomb potential in a BSE calculation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where   L is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizabilities with and withou cutoff:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.012/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.012/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two GW spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
&lt;br /&gt;
Also note that, for the case without cutoff, to plot the imaginary part of the polarizability, the Imaginary part of the macroscopic dieletric function has been multiplied by the appropriate prefactor. &lt;br /&gt;
&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Alpha2D.gif&amp;diff=3410</id>
		<title>File:Alpha2D.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Alpha2D.gif&amp;diff=3410"/>
		<updated>2020-01-21T04:56:06Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: Maurizia uploaded a new version of File:Alpha2D.gif&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:Maurizia|Maurizia]]&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>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3409</id>
		<title>How to analyse excitons</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3409"/>
		<updated>2020-01-21T04:54:16Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Plot the exciton spatial distribution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn (for a 2D-hBN)  how to:&lt;br /&gt;
* analyze a BSE optical spectrum in terms of excitonic eigenvectors and eigenvalues&lt;br /&gt;
* look at the spatial distribution of the exciton&lt;br /&gt;
 &lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&#039;&#039;&#039;Previous modules&#039;&#039;&#039;&lt;br /&gt;
* You must have completed the [[How to treat low dimensional systems]] tutorial&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp &amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;xcrysden&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot or xmgrace&amp;lt;/code&amp;gt; executable&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== YAMBO calculations ==&lt;br /&gt;
If you have completed the tutorials of 2D hBN you should have all the databases required to do this tutorial in your &amp;lt;code&amp;gt;YAMBO_TUTORIALS/hBN-2D/SAVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2D_WR_WC&amp;lt;/code&amp;gt; (databases generated with RIM and cutoff) directories&lt;br /&gt;
&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ndb.gops ndb.kindx ns.db1  ns.kb_pp_pwscf_fragment_1 ....&lt;br /&gt;
 $ ls ./2D_WR_WC&lt;br /&gt;
 ndb.BS_Q1_CPU_0	ndb.cutoff	ndb.dip_iR_and_P_fragment_1	ndb.pp_fragment_1 ...&lt;br /&gt;
&lt;br /&gt;
==Sort the excitonic eigenvalues==&lt;br /&gt;
&lt;br /&gt;
 $ ypp -J 2D_WR_WC -e s 1&lt;br /&gt;
&lt;br /&gt;
We are sorting the excitons for the qindex = 1 (optical limit q=0).&lt;br /&gt;
The new generated file &#039;&#039;o-2D_WR_WC.exc_qpt1_E_sorted &#039;&#039; (&#039;&#039;o-2D_WR_WC.exc_qpt1_I_sorted &#039;&#039;) reports &lt;br /&gt;
the energies of the excitons and their Dipole Oscillator Strengths sorted by energy  (Index).&lt;br /&gt;
[[File:strengh.png|none|x120px|]]&lt;br /&gt;
Open the first file and look inside. The first exciton is at 4.83 eV and the second one has the highest strenght (normalized to 1)&lt;br /&gt;
&lt;br /&gt;
Or you can make a plot&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
gnuplot&amp;gt; set style line 2 lc rgb &#039;black&#039; pt 7   # circle&lt;br /&gt;
gnuplot&amp;gt; plot &#039;o-2D_WR_WC.exc_qpt1_E_sorted&#039;  with points ls 2 title &#039;Strenghts&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:strenght.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
Attention the convergence of these results with different k-points grids is mandatory!&lt;br /&gt;
&lt;br /&gt;
== Calculate the exciton oscillator strenght and amplitude ==&lt;br /&gt;
&lt;br /&gt;
We can now analyze the excitons in terms of single-particle states, to do that create the appropriate input &lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC -e a 1 &lt;br /&gt;
&lt;br /&gt;
Suppose you wish to analyze the first 5 excitons then change this line as:&lt;br /&gt;
 States= &amp;quot;1 - 5&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
 $ls  o*exc*at*&lt;br /&gt;
 o-2D_WR_WC.exc_qpt1_amplitude_at_1 o-2D_WR_WC.exc_qpt1_weights_at_1 ...&lt;br /&gt;
 &lt;br /&gt;
For an exciton  &amp;lt;math&amp;gt;|\lambda&amp;gt;&amp;lt;/math&amp;gt; , &#039;&#039;o-2D_WR_WC.exc_qpt1_weights_at_*&#039;&#039; report the Weights&lt;br /&gt;
[[File:Weights.png|none|x60px|]]&lt;br /&gt;
and &#039;&#039;o-2D_WR_WC.exc_qpt1_amplitude_**&#039;&#039; report the amplitudes &lt;br /&gt;
[[File:Ampl.png|none|x70px|]]&lt;br /&gt;
&lt;br /&gt;
Open the file  &#039;&#039;o-2D_WR_WC.exc_weights_at_1&#039;&#039; &lt;br /&gt;
 #  Band_V     Band_C     K  ibz     Symm.      Weight     Energy&lt;br /&gt;
 #&lt;br /&gt;
  4.000000   5.000000   7.000000   2.000000   0.922095   4.401093&lt;br /&gt;
  4.000000   5.000000   7.000000   1.000000   0.922086   4.401093&lt;br /&gt;
 The first exciton is  essentially done of only single particle transitions from VBM to CBM at K (last k-point of the grid).&lt;br /&gt;
&lt;br /&gt;
[[File:Amplitude_plot.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plot the exciton spatial distribution ==&lt;br /&gt;
&lt;br /&gt;
To see the spatial character of the exciton YPP writes the exciton spatial distribution, in other words the probability to find the electron somewhere in the space when the hole is fixed in a give position.&lt;br /&gt;
Different output formats can be selected and 1D,2D,3D plots done.&lt;br /&gt;
Create the input and change the size of the cell where to see the exciton.&lt;br /&gt;
Note that  If the k-grid of the BSE simulation is a NxNx1  the exciton has an induced fictitious periodicity every Nx Nx1 Cell  of the simulation.&lt;br /&gt;
For hBN-2D this is not a problem because the exciton is strongly localized but in other systems with  more delocalized excitons to look at the real exciton size it is necessary to use &lt;br /&gt;
very large k-grids in the BSE&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC  -e w  1&lt;br /&gt;
&lt;br /&gt;
 excitons                     # [R] Excitons&lt;br /&gt;
 wavefunction                 # [R] Wavefunction&lt;br /&gt;
 Format= &amp;quot;x&amp;quot;                  # Output format [(c)ube/(g)nuplot/(x)crysden]&lt;br /&gt;
 Direction= &amp;quot;12&amp;quot;               # [rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 States= &amp;quot;1 - 1&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
 Degen_Step=   0.0100   eV    # Maximum energy separation of two degenerate states&lt;br /&gt;
 % Cells&lt;br /&gt;
  5 | 5 | 1 |                             # Number of cell repetitions in each direction (odd or 1)&lt;br /&gt;
 %&lt;br /&gt;
 % Hole&lt;br /&gt;
 2.4     | 1.400     | 0.00     |        # [cc] Hole position in unit cell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC &lt;br /&gt;
&lt;br /&gt;
 $ xcrysden --xsf o-2D_WR_WC.exc_2d_1.xsf&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BN2D.png|none|400px|]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Or alternatively &lt;br /&gt;
 $ xcrysden --sushi&lt;br /&gt;
 [[File:SUSHI.JPG|none|400px|]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3408</id>
		<title>How to analyse excitons</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3408"/>
		<updated>2020-01-20T19:36:23Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Calculate the exciton oscillator strenght and amplitude */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn (for a 2D-hBN)  how to:&lt;br /&gt;
* analyze a BSE optical spectrum in terms of excitonic eigenvectors and eigenvalues&lt;br /&gt;
* look at the spatial distribution of the exciton&lt;br /&gt;
 &lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&#039;&#039;&#039;Previous modules&#039;&#039;&#039;&lt;br /&gt;
* You must have completed the [[How to treat low dimensional systems]] tutorial&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp &amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;xcrysden&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot or xmgrace&amp;lt;/code&amp;gt; executable&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== YAMBO calculations ==&lt;br /&gt;
If you have completed the tutorials of 2D hBN you should have all the databases required to do this tutorial in your &amp;lt;code&amp;gt;YAMBO_TUTORIALS/hBN-2D/SAVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2D_WR_WC&amp;lt;/code&amp;gt; (databases generated with RIM and cutoff) directories&lt;br /&gt;
&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ndb.gops ndb.kindx ns.db1  ns.kb_pp_pwscf_fragment_1 ....&lt;br /&gt;
 $ ls ./2D_WR_WC&lt;br /&gt;
 ndb.BS_Q1_CPU_0	ndb.cutoff	ndb.dip_iR_and_P_fragment_1	ndb.pp_fragment_1 ...&lt;br /&gt;
&lt;br /&gt;
==Sort the excitonic eigenvalues==&lt;br /&gt;
&lt;br /&gt;
 $ ypp -J 2D_WR_WC -e s 1&lt;br /&gt;
&lt;br /&gt;
We are sorting the excitons for the qindex = 1 (optical limit q=0).&lt;br /&gt;
The new generated file &#039;&#039;o-2D_WR_WC.exc_qpt1_E_sorted &#039;&#039; (&#039;&#039;o-2D_WR_WC.exc_qpt1_I_sorted &#039;&#039;) reports &lt;br /&gt;
the energies of the excitons and their Dipole Oscillator Strengths sorted by energy  (Index).&lt;br /&gt;
[[File:strengh.png|none|x120px|]]&lt;br /&gt;
Open the first file and look inside. The first exciton is at 4.83 eV and the second one has the highest strenght (normalized to 1)&lt;br /&gt;
&lt;br /&gt;
Or you can make a plot&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
gnuplot&amp;gt; set style line 2 lc rgb &#039;black&#039; pt 7   # circle&lt;br /&gt;
gnuplot&amp;gt; plot &#039;o-2D_WR_WC.exc_qpt1_E_sorted&#039;  with points ls 2 title &#039;Strenghts&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:strenght.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
Attention the convergence of these results with different k-points grids is mandatory!&lt;br /&gt;
&lt;br /&gt;
== Calculate the exciton oscillator strenght and amplitude ==&lt;br /&gt;
&lt;br /&gt;
We can now analyze the excitons in terms of single-particle states, to do that create the appropriate input &lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC -e a 1 &lt;br /&gt;
&lt;br /&gt;
Suppose you wish to analyze the first 5 excitons then change this line as:&lt;br /&gt;
 States= &amp;quot;1 - 5&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
 $ls  o*exc*at*&lt;br /&gt;
 o-2D_WR_WC.exc_qpt1_amplitude_at_1 o-2D_WR_WC.exc_qpt1_weights_at_1 ...&lt;br /&gt;
 &lt;br /&gt;
For an exciton  &amp;lt;math&amp;gt;|\lambda&amp;gt;&amp;lt;/math&amp;gt; , &#039;&#039;o-2D_WR_WC.exc_qpt1_weights_at_*&#039;&#039; report the Weights&lt;br /&gt;
[[File:Weights.png|none|x60px|]]&lt;br /&gt;
and &#039;&#039;o-2D_WR_WC.exc_qpt1_amplitude_**&#039;&#039; report the amplitudes &lt;br /&gt;
[[File:Ampl.png|none|x70px|]]&lt;br /&gt;
&lt;br /&gt;
Open the file  &#039;&#039;o-2D_WR_WC.exc_weights_at_1&#039;&#039; &lt;br /&gt;
 #  Band_V     Band_C     K  ibz     Symm.      Weight     Energy&lt;br /&gt;
 #&lt;br /&gt;
  4.000000   5.000000   7.000000   2.000000   0.922095   4.401093&lt;br /&gt;
  4.000000   5.000000   7.000000   1.000000   0.922086   4.401093&lt;br /&gt;
 The first exciton is  essentially done of only single particle transitions from VBM to CBM at K (last k-point of the grid).&lt;br /&gt;
&lt;br /&gt;
[[File:Amplitude_plot.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plot the exciton spatial distribution ==&lt;br /&gt;
&lt;br /&gt;
To see the spatial character of the exciton YPP writes the exciton spatial distribution, in other words the probability to find the electron somewhere in the space when the hole is fixed in a give position.&lt;br /&gt;
Different output formats can be selected and 1D,2D,3D plots done.&lt;br /&gt;
Create the input and change the size of the cell where to see the exciton.&lt;br /&gt;
Note that  If the k-grid of the BSE simulation is a NxNx1  the exciton has an induced fictitious periodicity every Nx Nx1 Cell  of the simulation.&lt;br /&gt;
For hBN-2D this is not a problem because the exciton is strongly localized but in other systems with  more delocalized excitons to look at the real exciton size it is necessary to use &lt;br /&gt;
very large k-grids in the BSE&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC  -e w &lt;br /&gt;
&lt;br /&gt;
 excitons                     # [R] Excitons&lt;br /&gt;
 wavefunction                 # [R] Wavefunction&lt;br /&gt;
 Format= &amp;quot;x&amp;quot;                  # Output format [(c)ube/(g)nuplot/(x)crysden]&lt;br /&gt;
 Direction= &amp;quot;12&amp;quot;               # [rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 States= &amp;quot;1 - 1&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
 Degen_Step=   0.0100   eV    # Maximum energy separation of two degenerate states&lt;br /&gt;
 % Cells&lt;br /&gt;
  5 | 5 | 1 |                             # Number of cell repetitions in each direction (odd or 1)&lt;br /&gt;
 %&lt;br /&gt;
 % Hole&lt;br /&gt;
 2.4     | 1.400     | 0.00     |        # [cc] Hole position in unit cell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC &lt;br /&gt;
&lt;br /&gt;
 $ xcrysden --xsf o-2D_WR_WC.exc_2d_1.xsf&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BN2D.png|none|400px|]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Or alternatively &lt;br /&gt;
 $ xcrysden --sushi&lt;br /&gt;
 [[File:SUSHI.JPG|none|400px|]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3407</id>
		<title>How to analyse excitons</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3407"/>
		<updated>2020-01-20T19:33:58Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Calculate the exciton oscillator strenght and amplitude */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn (for a 2D-hBN)  how to:&lt;br /&gt;
* analyze a BSE optical spectrum in terms of excitonic eigenvectors and eigenvalues&lt;br /&gt;
* look at the spatial distribution of the exciton&lt;br /&gt;
 &lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&#039;&#039;&#039;Previous modules&#039;&#039;&#039;&lt;br /&gt;
* You must have completed the [[How to treat low dimensional systems]] tutorial&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp &amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;xcrysden&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot or xmgrace&amp;lt;/code&amp;gt; executable&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== YAMBO calculations ==&lt;br /&gt;
If you have completed the tutorials of 2D hBN you should have all the databases required to do this tutorial in your &amp;lt;code&amp;gt;YAMBO_TUTORIALS/hBN-2D/SAVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2D_WR_WC&amp;lt;/code&amp;gt; (databases generated with RIM and cutoff) directories&lt;br /&gt;
&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ndb.gops ndb.kindx ns.db1  ns.kb_pp_pwscf_fragment_1 ....&lt;br /&gt;
 $ ls ./2D_WR_WC&lt;br /&gt;
 ndb.BS_Q1_CPU_0	ndb.cutoff	ndb.dip_iR_and_P_fragment_1	ndb.pp_fragment_1 ...&lt;br /&gt;
&lt;br /&gt;
==Sort the excitonic eigenvalues==&lt;br /&gt;
&lt;br /&gt;
 $ ypp -J 2D_WR_WC -e s 1&lt;br /&gt;
&lt;br /&gt;
We are sorting the excitons for the qindex = 1 (optical limit q=0).&lt;br /&gt;
The new generated file &#039;&#039;o-2D_WR_WC.exc_qpt1_E_sorted &#039;&#039; (&#039;&#039;o-2D_WR_WC.exc_qpt1_I_sorted &#039;&#039;) reports &lt;br /&gt;
the energies of the excitons and their Dipole Oscillator Strengths sorted by energy  (Index).&lt;br /&gt;
[[File:strengh.png|none|x120px|]]&lt;br /&gt;
Open the first file and look inside. The first exciton is at 4.83 eV and the second one has the highest strenght (normalized to 1)&lt;br /&gt;
&lt;br /&gt;
Or you can make a plot&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
gnuplot&amp;gt; set style line 2 lc rgb &#039;black&#039; pt 7   # circle&lt;br /&gt;
gnuplot&amp;gt; plot &#039;o-2D_WR_WC.exc_qpt1_E_sorted&#039;  with points ls 2 title &#039;Strenghts&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:strenght.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
Attention the convergence of these results with different k-points grids is mandatory!&lt;br /&gt;
&lt;br /&gt;
== Calculate the exciton oscillator strenght and amplitude ==&lt;br /&gt;
&lt;br /&gt;
We can now analyze the excitons in terms of single-particle states, to do that create the appropriate input &lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC -e a 1 &lt;br /&gt;
&lt;br /&gt;
Suppose you wish to analyze the first 5 excitons then change this line as:&lt;br /&gt;
 States= &amp;quot;1 - 5&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
 $ls  o*exc*at*&lt;br /&gt;
 o-2D_WR_WC.exc_amplitude_at_1 o-2D_WR_WC.exc_weights_at_1 ...&lt;br /&gt;
 &lt;br /&gt;
For an exciton  &amp;lt;math&amp;gt;|\lambda&amp;gt;&amp;lt;/math&amp;gt; , &#039;&#039;o-2D_WR_WC.exc_weights_at_*&#039;&#039; report the Weights&lt;br /&gt;
[[File:Weights.png|none|x60px|]]&lt;br /&gt;
and &#039;&#039;o-2D_WR_WC.exc_amplitudes_at_*&#039;&#039; report the amplitudes &lt;br /&gt;
[[File:Ampl.png|none|x70px|]]&lt;br /&gt;
&lt;br /&gt;
Open the file  &#039;&#039;o-2D_WR_WC.exc_weights_at_1&#039;&#039; &lt;br /&gt;
 #  Band_V     Band_C     K  ibz     Symm.      Weight     Energy&lt;br /&gt;
 #&lt;br /&gt;
  4.000000   5.000000   7.000000   2.000000   0.922095   4.401093&lt;br /&gt;
  4.000000   5.000000   7.000000   1.000000   0.922086   4.401093&lt;br /&gt;
 The first exciton is  essentially done of only single particle transitions from VBM to CBM at K (last k-point of the grid).&lt;br /&gt;
&lt;br /&gt;
[[File:Amplitude_plot.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plot the exciton spatial distribution ==&lt;br /&gt;
&lt;br /&gt;
To see the spatial character of the exciton YPP writes the exciton spatial distribution, in other words the probability to find the electron somewhere in the space when the hole is fixed in a give position.&lt;br /&gt;
Different output formats can be selected and 1D,2D,3D plots done.&lt;br /&gt;
Create the input and change the size of the cell where to see the exciton.&lt;br /&gt;
Note that  If the k-grid of the BSE simulation is a NxNx1  the exciton has an induced fictitious periodicity every Nx Nx1 Cell  of the simulation.&lt;br /&gt;
For hBN-2D this is not a problem because the exciton is strongly localized but in other systems with  more delocalized excitons to look at the real exciton size it is necessary to use &lt;br /&gt;
very large k-grids in the BSE&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC  -e w &lt;br /&gt;
&lt;br /&gt;
 excitons                     # [R] Excitons&lt;br /&gt;
 wavefunction                 # [R] Wavefunction&lt;br /&gt;
 Format= &amp;quot;x&amp;quot;                  # Output format [(c)ube/(g)nuplot/(x)crysden]&lt;br /&gt;
 Direction= &amp;quot;12&amp;quot;               # [rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 States= &amp;quot;1 - 1&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
 Degen_Step=   0.0100   eV    # Maximum energy separation of two degenerate states&lt;br /&gt;
 % Cells&lt;br /&gt;
  5 | 5 | 1 |                             # Number of cell repetitions in each direction (odd or 1)&lt;br /&gt;
 %&lt;br /&gt;
 % Hole&lt;br /&gt;
 2.4     | 1.400     | 0.00     |        # [cc] Hole position in unit cell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC &lt;br /&gt;
&lt;br /&gt;
 $ xcrysden --xsf o-2D_WR_WC.exc_2d_1.xsf&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BN2D.png|none|400px|]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Or alternatively &lt;br /&gt;
 $ xcrysden --sushi&lt;br /&gt;
 [[File:SUSHI.JPG|none|400px|]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3406</id>
		<title>How to analyse excitons</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3406"/>
		<updated>2020-01-20T19:32:09Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Calculate the exciton oscillator strenght and amplitude */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn (for a 2D-hBN)  how to:&lt;br /&gt;
* analyze a BSE optical spectrum in terms of excitonic eigenvectors and eigenvalues&lt;br /&gt;
* look at the spatial distribution of the exciton&lt;br /&gt;
 &lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&#039;&#039;&#039;Previous modules&#039;&#039;&#039;&lt;br /&gt;
* You must have completed the [[How to treat low dimensional systems]] tutorial&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp &amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;xcrysden&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot or xmgrace&amp;lt;/code&amp;gt; executable&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== YAMBO calculations ==&lt;br /&gt;
If you have completed the tutorials of 2D hBN you should have all the databases required to do this tutorial in your &amp;lt;code&amp;gt;YAMBO_TUTORIALS/hBN-2D/SAVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2D_WR_WC&amp;lt;/code&amp;gt; (databases generated with RIM and cutoff) directories&lt;br /&gt;
&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ndb.gops ndb.kindx ns.db1  ns.kb_pp_pwscf_fragment_1 ....&lt;br /&gt;
 $ ls ./2D_WR_WC&lt;br /&gt;
 ndb.BS_Q1_CPU_0	ndb.cutoff	ndb.dip_iR_and_P_fragment_1	ndb.pp_fragment_1 ...&lt;br /&gt;
&lt;br /&gt;
==Sort the excitonic eigenvalues==&lt;br /&gt;
&lt;br /&gt;
 $ ypp -J 2D_WR_WC -e s 1&lt;br /&gt;
&lt;br /&gt;
We are sorting the excitons for the qindex = 1 (optical limit q=0).&lt;br /&gt;
The new generated file &#039;&#039;o-2D_WR_WC.exc_qpt1_E_sorted &#039;&#039; (&#039;&#039;o-2D_WR_WC.exc_qpt1_I_sorted &#039;&#039;) reports &lt;br /&gt;
the energies of the excitons and their Dipole Oscillator Strengths sorted by energy  (Index).&lt;br /&gt;
[[File:strengh.png|none|x120px|]]&lt;br /&gt;
Open the first file and look inside. The first exciton is at 4.83 eV and the second one has the highest strenght (normalized to 1)&lt;br /&gt;
&lt;br /&gt;
Or you can make a plot&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
gnuplot&amp;gt; set style line 2 lc rgb &#039;black&#039; pt 7   # circle&lt;br /&gt;
gnuplot&amp;gt; plot &#039;o-2D_WR_WC.exc_qpt1_E_sorted&#039;  with points ls 2 title &#039;Strenghts&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:strenght.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
Attention the convergence of these results with different k-points grids is mandatory!&lt;br /&gt;
&lt;br /&gt;
== Calculate the exciton oscillator strenght and amplitude ==&lt;br /&gt;
&lt;br /&gt;
We can now analyze the excitons in terms of single-particle states, to do that create the appropriate input &lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC -e a 1 &lt;br /&gt;
&lt;br /&gt;
Suppose you wish to analyze the first 5 excitons then change this line as:&lt;br /&gt;
 States= &amp;quot;1 - 5&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
 $ls ls o*exc*at*&lt;br /&gt;
 o-2D_WR_WC.exc_amplitude_at_1 o-2D_WR_WC.exc_weights_at_1 ...&lt;br /&gt;
 &lt;br /&gt;
For an exciton  &amp;lt;math&amp;gt;|\lambda&amp;gt;&amp;lt;/math&amp;gt; , &#039;&#039;o-2D_WR_WC.exc_weights_at_*&#039;&#039; report the Weights&lt;br /&gt;
[[File:Weights.png|none|x60px|]]&lt;br /&gt;
and &#039;&#039;o-2D_WR_WC.exc_amplitudes_at_*&#039;&#039; report the amplitudes &lt;br /&gt;
[[File:Ampl.png|none|x70px|]]&lt;br /&gt;
&lt;br /&gt;
Open the file  &#039;&#039;o-2D_WR_WC.exc_weights_at_1&#039;&#039; &lt;br /&gt;
 #  Band_V     Band_C     K  ibz     Symm.      Weight     Energy&lt;br /&gt;
 #&lt;br /&gt;
  4.000000   5.000000   7.000000   2.000000   0.922095   4.401093&lt;br /&gt;
  4.000000   5.000000   7.000000   1.000000   0.922086   4.401093&lt;br /&gt;
 The first exciton is  essentially done of only single particle transitions from VBM to CBM at K (last k-point of the grid).&lt;br /&gt;
&lt;br /&gt;
[[File:Amplitude_plot.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plot the exciton spatial distribution ==&lt;br /&gt;
&lt;br /&gt;
To see the spatial character of the exciton YPP writes the exciton spatial distribution, in other words the probability to find the electron somewhere in the space when the hole is fixed in a give position.&lt;br /&gt;
Different output formats can be selected and 1D,2D,3D plots done.&lt;br /&gt;
Create the input and change the size of the cell where to see the exciton.&lt;br /&gt;
Note that  If the k-grid of the BSE simulation is a NxNx1  the exciton has an induced fictitious periodicity every Nx Nx1 Cell  of the simulation.&lt;br /&gt;
For hBN-2D this is not a problem because the exciton is strongly localized but in other systems with  more delocalized excitons to look at the real exciton size it is necessary to use &lt;br /&gt;
very large k-grids in the BSE&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC  -e w &lt;br /&gt;
&lt;br /&gt;
 excitons                     # [R] Excitons&lt;br /&gt;
 wavefunction                 # [R] Wavefunction&lt;br /&gt;
 Format= &amp;quot;x&amp;quot;                  # Output format [(c)ube/(g)nuplot/(x)crysden]&lt;br /&gt;
 Direction= &amp;quot;12&amp;quot;               # [rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 States= &amp;quot;1 - 1&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
 Degen_Step=   0.0100   eV    # Maximum energy separation of two degenerate states&lt;br /&gt;
 % Cells&lt;br /&gt;
  5 | 5 | 1 |                             # Number of cell repetitions in each direction (odd or 1)&lt;br /&gt;
 %&lt;br /&gt;
 % Hole&lt;br /&gt;
 2.4     | 1.400     | 0.00     |        # [cc] Hole position in unit cell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC &lt;br /&gt;
&lt;br /&gt;
 $ xcrysden --xsf o-2D_WR_WC.exc_2d_1.xsf&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BN2D.png|none|400px|]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Or alternatively &lt;br /&gt;
 $ xcrysden --sushi&lt;br /&gt;
 [[File:SUSHI.JPG|none|400px|]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Strenght.png&amp;diff=3405</id>
		<title>File:Strenght.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Strenght.png&amp;diff=3405"/>
		<updated>2020-01-20T19:21:31Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: 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:Maurizia|Maurizia]]&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>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3404</id>
		<title>How to analyse excitons</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3404"/>
		<updated>2020-01-20T19:17:58Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Sort the excitonic eigenvalues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn (for a 2D-hBN)  how to:&lt;br /&gt;
* analyze a BSE optical spectrum in terms of excitonic eigenvectors and eigenvalues&lt;br /&gt;
* look at the spatial distribution of the exciton&lt;br /&gt;
 &lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&#039;&#039;&#039;Previous modules&#039;&#039;&#039;&lt;br /&gt;
* You must have completed the [[How to treat low dimensional systems]] tutorial&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp &amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;xcrysden&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot or xmgrace&amp;lt;/code&amp;gt; executable&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== YAMBO calculations ==&lt;br /&gt;
If you have completed the tutorials of 2D hBN you should have all the databases required to do this tutorial in your &amp;lt;code&amp;gt;YAMBO_TUTORIALS/hBN-2D/SAVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2D_WR_WC&amp;lt;/code&amp;gt; (databases generated with RIM and cutoff) directories&lt;br /&gt;
&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ndb.gops ndb.kindx ns.db1  ns.kb_pp_pwscf_fragment_1 ....&lt;br /&gt;
 $ ls ./2D_WR_WC&lt;br /&gt;
 ndb.BS_Q1_CPU_0	ndb.cutoff	ndb.dip_iR_and_P_fragment_1	ndb.pp_fragment_1 ...&lt;br /&gt;
&lt;br /&gt;
==Sort the excitonic eigenvalues==&lt;br /&gt;
&lt;br /&gt;
 $ ypp -J 2D_WR_WC -e s 1&lt;br /&gt;
&lt;br /&gt;
We are sorting the excitons for the qindex = 1 (optical limit q=0).&lt;br /&gt;
The new generated file &#039;&#039;o-2D_WR_WC.exc_qpt1_E_sorted &#039;&#039; (&#039;&#039;o-2D_WR_WC.exc_qpt1_I_sorted &#039;&#039;) reports &lt;br /&gt;
the energies of the excitons and their Dipole Oscillator Strengths sorted by energy  (Index).&lt;br /&gt;
[[File:strengh.png|none|x120px|]]&lt;br /&gt;
Open the first file and look inside. The first exciton is at 4.83 eV and the second one has the highest strenght (normalized to 1)&lt;br /&gt;
&lt;br /&gt;
Or you can make a plot&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
gnuplot&amp;gt; set style line 2 lc rgb &#039;black&#039; pt 7   # circle&lt;br /&gt;
gnuplot&amp;gt; plot &#039;o-2D_WR_WC.exc_qpt1_E_sorted&#039;  with points ls 2 title &#039;Strenghts&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:strenght.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
Attention the convergence of these results with different k-points grids is mandatory!&lt;br /&gt;
&lt;br /&gt;
== Calculate the exciton oscillator strenght and amplitude ==&lt;br /&gt;
&lt;br /&gt;
We can now analyze the excitons in terms of single-particle states, to do that create the appropriate input &lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC -e a&lt;br /&gt;
&lt;br /&gt;
Suppose you wish to analyze the first 5 excitons then change this line as:&lt;br /&gt;
 States= &amp;quot;1 - 5&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
 $ls ls o*exc*at*&lt;br /&gt;
 o-2D_WR_WC.exc_amplitude_at_1 o-2D_WR_WC.exc_weights_at_1 ...&lt;br /&gt;
 &lt;br /&gt;
For an exciton  &amp;lt;math&amp;gt;|\lambda&amp;gt;&amp;lt;/math&amp;gt; , &#039;&#039;o-2D_WR_WC.exc_weights_at_*&#039;&#039; report the Weights&lt;br /&gt;
[[File:Weights.png|none|x60px|]]&lt;br /&gt;
and &#039;&#039;o-2D_WR_WC.exc_amplitudes_at_*&#039;&#039; report the amplitudes &lt;br /&gt;
[[File:Ampl.png|none|x70px|]]&lt;br /&gt;
&lt;br /&gt;
Open the file  &#039;&#039;o-2D_WR_WC.exc_weights_at_1&#039;&#039; &lt;br /&gt;
 #  Band_V     Band_C     K  ibz     Symm.      Weight     Energy&lt;br /&gt;
 #&lt;br /&gt;
  4.000000   5.000000   7.000000   2.000000   0.922095   4.401093&lt;br /&gt;
  4.000000   5.000000   7.000000   1.000000   0.922086   4.401093&lt;br /&gt;
 The first exciton is  essentially done of only single particle transitions from VBM to CBM at K (last k-point of the grid).&lt;br /&gt;
&lt;br /&gt;
[[File:Amplitude_plot.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plot the exciton spatial distribution ==&lt;br /&gt;
&lt;br /&gt;
To see the spatial character of the exciton YPP writes the exciton spatial distribution, in other words the probability to find the electron somewhere in the space when the hole is fixed in a give position.&lt;br /&gt;
Different output formats can be selected and 1D,2D,3D plots done.&lt;br /&gt;
Create the input and change the size of the cell where to see the exciton.&lt;br /&gt;
Note that  If the k-grid of the BSE simulation is a NxNx1  the exciton has an induced fictitious periodicity every Nx Nx1 Cell  of the simulation.&lt;br /&gt;
For hBN-2D this is not a problem because the exciton is strongly localized but in other systems with  more delocalized excitons to look at the real exciton size it is necessary to use &lt;br /&gt;
very large k-grids in the BSE&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC  -e w &lt;br /&gt;
&lt;br /&gt;
 excitons                     # [R] Excitons&lt;br /&gt;
 wavefunction                 # [R] Wavefunction&lt;br /&gt;
 Format= &amp;quot;x&amp;quot;                  # Output format [(c)ube/(g)nuplot/(x)crysden]&lt;br /&gt;
 Direction= &amp;quot;12&amp;quot;               # [rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 States= &amp;quot;1 - 1&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
 Degen_Step=   0.0100   eV    # Maximum energy separation of two degenerate states&lt;br /&gt;
 % Cells&lt;br /&gt;
  5 | 5 | 1 |                             # Number of cell repetitions in each direction (odd or 1)&lt;br /&gt;
 %&lt;br /&gt;
 % Hole&lt;br /&gt;
 2.4     | 1.400     | 0.00     |        # [cc] Hole position in unit cell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC &lt;br /&gt;
&lt;br /&gt;
 $ xcrysden --xsf o-2D_WR_WC.exc_2d_1.xsf&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BN2D.png|none|400px|]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Or alternatively &lt;br /&gt;
 $ xcrysden --sushi&lt;br /&gt;
 [[File:SUSHI.JPG|none|400px|]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3403</id>
		<title>How to analyse excitons</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_analyse_excitons&amp;diff=3403"/>
		<updated>2020-01-20T18:48:18Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Sort the excitonic eigenvalues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn (for a 2D-hBN)  how to:&lt;br /&gt;
* analyze a BSE optical spectrum in terms of excitonic eigenvectors and eigenvalues&lt;br /&gt;
* look at the spatial distribution of the exciton&lt;br /&gt;
 &lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&#039;&#039;&#039;Previous modules&#039;&#039;&#039;&lt;br /&gt;
* You must have completed the [[How to treat low dimensional systems]] tutorial&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp &amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;xcrysden&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot or xmgrace&amp;lt;/code&amp;gt; executable&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== YAMBO calculations ==&lt;br /&gt;
If you have completed the tutorials of 2D hBN you should have all the databases required to do this tutorial in your &amp;lt;code&amp;gt;YAMBO_TUTORIALS/hBN-2D/SAVE&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;2D_WR_WC&amp;lt;/code&amp;gt; (databases generated with RIM and cutoff) directories&lt;br /&gt;
&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ndb.gops ndb.kindx ns.db1  ns.kb_pp_pwscf_fragment_1 ....&lt;br /&gt;
 $ ls ./2D_WR_WC&lt;br /&gt;
 ndb.BS_Q1_CPU_0	ndb.cutoff	ndb.dip_iR_and_P_fragment_1	ndb.pp_fragment_1 ...&lt;br /&gt;
&lt;br /&gt;
==Sort the excitonic eigenvalues==&lt;br /&gt;
&lt;br /&gt;
 $ ypp -J 2D_WR_WC -e s 1&lt;br /&gt;
&lt;br /&gt;
We are sorting the excitons for the qindex = 1 (optical limit q=0).&lt;br /&gt;
The new generated file &#039;&#039;o-2D_WR_WC.exc_qpt1_E_sorted &#039;&#039; (&#039;&#039;o-2D_WR_WC.exc_qpt1_I_sorted &#039;&#039;) reports &lt;br /&gt;
the energies of the excitons and their Dipole Oscillator Strengths sorted by energy  (Index).&lt;br /&gt;
[[File:strengh.png|none|x120px|]]&lt;br /&gt;
Open the first file and look inside. The first exciton is at 4.83 eV and the second one has the highest strenght (normalized to 1)&lt;br /&gt;
&lt;br /&gt;
Or you can make a plot&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;quot;o-2D_WR_WC.exc_qpt1_E sorted &amp;quot; u 1:2 title &#039;Strenght2D&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:strenght.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
Attention the convergence of these results with different k-points grids is mandatory!&lt;br /&gt;
&lt;br /&gt;
== Calculate the exciton oscillator strenght and amplitude ==&lt;br /&gt;
&lt;br /&gt;
We can now analyze the excitons in terms of single-particle states, to do that create the appropriate input &lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC -e a&lt;br /&gt;
&lt;br /&gt;
Suppose you wish to analyze the first 5 excitons then change this line as:&lt;br /&gt;
 States= &amp;quot;1 - 5&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
&lt;br /&gt;
 $ ypp -F ypp_AMPL.in -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
 $ls ls o*exc*at*&lt;br /&gt;
 o-2D_WR_WC.exc_amplitude_at_1 o-2D_WR_WC.exc_weights_at_1 ...&lt;br /&gt;
 &lt;br /&gt;
For an exciton  &amp;lt;math&amp;gt;|\lambda&amp;gt;&amp;lt;/math&amp;gt; , &#039;&#039;o-2D_WR_WC.exc_weights_at_*&#039;&#039; report the Weights&lt;br /&gt;
[[File:Weights.png|none|x60px|]]&lt;br /&gt;
and &#039;&#039;o-2D_WR_WC.exc_amplitudes_at_*&#039;&#039; report the amplitudes &lt;br /&gt;
[[File:Ampl.png|none|x70px|]]&lt;br /&gt;
&lt;br /&gt;
Open the file  &#039;&#039;o-2D_WR_WC.exc_weights_at_1&#039;&#039; &lt;br /&gt;
 #  Band_V     Band_C     K  ibz     Symm.      Weight     Energy&lt;br /&gt;
 #&lt;br /&gt;
  4.000000   5.000000   7.000000   2.000000   0.922095   4.401093&lt;br /&gt;
  4.000000   5.000000   7.000000   1.000000   0.922086   4.401093&lt;br /&gt;
 The first exciton is  essentially done of only single particle transitions from VBM to CBM at K (last k-point of the grid).&lt;br /&gt;
&lt;br /&gt;
[[File:Amplitude_plot.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
== Plot the exciton spatial distribution ==&lt;br /&gt;
&lt;br /&gt;
To see the spatial character of the exciton YPP writes the exciton spatial distribution, in other words the probability to find the electron somewhere in the space when the hole is fixed in a give position.&lt;br /&gt;
Different output formats can be selected and 1D,2D,3D plots done.&lt;br /&gt;
Create the input and change the size of the cell where to see the exciton.&lt;br /&gt;
Note that  If the k-grid of the BSE simulation is a NxNx1  the exciton has an induced fictitious periodicity every Nx Nx1 Cell  of the simulation.&lt;br /&gt;
For hBN-2D this is not a problem because the exciton is strongly localized but in other systems with  more delocalized excitons to look at the real exciton size it is necessary to use &lt;br /&gt;
very large k-grids in the BSE&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC  -e w &lt;br /&gt;
&lt;br /&gt;
 excitons                     # [R] Excitons&lt;br /&gt;
 wavefunction                 # [R] Wavefunction&lt;br /&gt;
 Format= &amp;quot;x&amp;quot;                  # Output format [(c)ube/(g)nuplot/(x)crysden]&lt;br /&gt;
 Direction= &amp;quot;12&amp;quot;               # [rlu] [1/2/3] for 1d or [12/13/23] for 2d [123] for 3D&lt;br /&gt;
 FFTGvecs=  3951        RL    # [FFT] Plane-waves&lt;br /&gt;
 States= &amp;quot;1 - 1&amp;quot;              # Index of the BS state(s)&lt;br /&gt;
 Degen_Step=   0.0100   eV    # Maximum energy separation of two degenerate states&lt;br /&gt;
 % Cells&lt;br /&gt;
  5 | 5 | 1 |                             # Number of cell repetitions in each direction (odd or 1)&lt;br /&gt;
 %&lt;br /&gt;
 % Hole&lt;br /&gt;
 2.4     | 1.400     | 0.00     |        # [cc] Hole position in unit cell&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Close the input and run ypp&lt;br /&gt;
 $ ypp -F ypp_WF.in -J 2D_WR_WC &lt;br /&gt;
&lt;br /&gt;
 $ xcrysden --xsf o-2D_WR_WC.exc_2d_1.xsf&lt;br /&gt;
&lt;br /&gt;
[[File:exc_BN2D.png|none|400px|]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Or alternatively &lt;br /&gt;
 $ xcrysden --sushi&lt;br /&gt;
 [[File:SUSHI.JPG|none|400px|]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:BSE_2D_cutnocut.png&amp;diff=3402</id>
		<title>File:BSE 2D cutnocut.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:BSE_2D_cutnocut.png&amp;diff=3402"/>
		<updated>2020-01-20T18:37:31Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: Maurizia uploaded a new version of File:BSE 2D cutnocut.png&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:Maurizia|Maurizia]]&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>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:BSE_2D_cutnocut.png&amp;diff=3401</id>
		<title>File:BSE 2D cutnocut.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:BSE_2D_cutnocut.png&amp;diff=3401"/>
		<updated>2020-01-20T18:16:05Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: 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:Maurizia|Maurizia]]&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>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3400</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3400"/>
		<updated>2020-01-20T18:14:33Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizabilities with and withou cutoff:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.012/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.012/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two GW spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
&lt;br /&gt;
Also note that, for the case without cutoff, to plot the imaginary part of the polarizability, the Imaginary part of the macroscopic dieletric function has been multiplied by the appropriate prefactor. &lt;br /&gt;
&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3387</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3387"/>
		<updated>2020-01-20T15:54:51Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizabilities with and withou cutoff:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.012/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.012/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut_new2.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two GW spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
&lt;br /&gt;
Also note that, for the case without cutoff, to plot the imaginary part of the polarizability, the Imaginary part of the macroscopic dieletric function has been multiplied by the appropriate prefactor. &lt;br /&gt;
&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3383</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3383"/>
		<updated>2020-01-20T15:49:29Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizabilities with and withou cutoff:&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.012/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.012/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut_new2.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3377</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3377"/>
		<updated>2020-01-20T15:37:38Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizability :&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.01/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.01/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut_new2.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Alpha2D.gif&amp;diff=3375</id>
		<title>File:Alpha2D.gif</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Alpha2D.gif&amp;diff=3375"/>
		<updated>2020-01-20T15:35:15Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: Maurizia uploaded a new version of File:Alpha2D.gif&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:Maurizia|Maurizia]]&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>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3373</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3373"/>
		<updated>2020-01-20T15:31:59Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizability :&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.01/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.01/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut_new1.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3372</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3372"/>
		<updated>2020-01-20T15:29:21Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizability :&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.01/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.01/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut_new.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3368</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3368"/>
		<updated>2020-01-20T15:26:06Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Use the truncated coulomb potential in a BSE calculation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part &lt;br /&gt;
of the dielectric function  using the file &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You realize immediately that the real part of the macroscopic dielectric function is almost 1, while the imaginary part is almost zero.  &lt;br /&gt;
Indeed when the use of the cutoff in the coulomb potential is activated you are simulating a real isolated sheet in vacuum and so you are obtaining almost the dielectric function of vacuum!&lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file  which contains the macroscopic polarizability (called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;)&lt;br /&gt;
which is a well defined quantity strictly related to optical conductivity or absorbance. &lt;br /&gt;
&lt;br /&gt;
For a 2D system has the dimension of a length and it is defined as :&lt;br /&gt;
&lt;br /&gt;
 [[File:alpha2D.gif|none|x80px|]]  where [[File:Lz.gif|none|x80px|]] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizability :&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.01/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.01/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3364</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3364"/>
		<updated>2020-01-20T15:06:52Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Use the truncated coulomb potential in a BSE calculation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot the real and Imaginary part&#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;&lt;br /&gt;
You realize immediately when the use of the cutoff in the coulomb potential is activated, the real part is almost 1, while the imaginary part is almost zero, being essentially the dieletric function of vacuum. &lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;  which contains the macroscopic polarizability&lt;br /&gt;
defined for a 2D system (with non-periodic direction along z) as :&lt;br /&gt;
&lt;br /&gt;
 [File:alpha2D.gif|none|x80px|]  where [File:Lz.gif|none|x80px|] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizability :&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.01/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.01/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3359</id>
		<title>How to treat low dimensional systems</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=How_to_treat_low_dimensional_systems&amp;diff=3359"/>
		<updated>2020-01-20T15:02:02Z</updated>

		<summary type="html">&lt;p&gt;Maurizia: /* Use the truncated coulomb potential in a BSE calculation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to treat low-dimensional material.&lt;br /&gt;
A small k-sampling is used to reduce the computational cost/time. &lt;br /&gt;
Later on you can repeat this tutorial but using denser k-grids to check the convergence.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisites ==&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;ypp&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;
* Have Completed the [[First steps: a walk through from DFT to optical properties]] tutorial&lt;br /&gt;
&lt;br /&gt;
==Avoid numerical divergences using the Random Integration Method (RIM)==&lt;br /&gt;
In DFT runs of low-dimensional materials low dimensional k-grids are generally used. (i.e. NxNx1 for a 2D sheet perpendicular to the z direction)&lt;br /&gt;
This can create numerical problems in the convergence of the many-body (MB) results due to the divergence at small q of the coulomb potential, &lt;br /&gt;
which appears in all the main equations.&lt;br /&gt;
To eliminate this problem YAMBO uses the so-called Random Integration Method &lt;br /&gt;
which means to use a Monte Carlo Integration with Random Q-points whose number &#039;&#039;[[Variables#RandQpts|RandQpts]]&#039;&#039; will be given in input.&lt;br /&gt;
For example the exchange self-energy matrix element which is:&lt;br /&gt;
[[File:sigmax.png|none|x50px|]]  &lt;br /&gt;
assuming that the integrand is a smooth function of momenta the integral can be approximated as &lt;br /&gt;
[[File:rim0.png|none|x50px|]]&lt;br /&gt;
where the small Brillouin Zones (sBZ) relative to a given q-point are the Brillouin Zones of the momenta vectors lattice. &lt;br /&gt;
They are chosen in such a way to cover the whole BZ. &lt;br /&gt;
In the RIM run-level yambo calculates the integrals of the symmetrized Coulomb potential &lt;br /&gt;
[[File:rim1.png|none|x50px|]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So we are ready to start the tutorial&lt;br /&gt;
First go in the proper directory and have a look if all the required databases are there&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN-2D/YAMBO&lt;br /&gt;
 $ ls ./SAVE&lt;br /&gt;
 ns.db1 ns.wf ns.kb_pp_pwscf ...&lt;br /&gt;
 $ yambo          &#039;&#039;(initialization, if you haven&#039;t already done so)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create the input to generate the &amp;lt;code&amp;gt;ndb.RIM&amp;lt;/code&amp;gt; database &lt;br /&gt;
 $ yambo -F yambo_WR.in -r &lt;br /&gt;
and change the following variables&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
N.B &#039;&#039;RandGvec=100&#039;&#039; means to use the RIM for the first 100 G-components of the coulomb potential &lt;br /&gt;
(Suggestion : later you can check convergence of the HF gap changing these two values)&lt;br /&gt;
Close input and Run yambo&lt;br /&gt;
 $ yambo -F yambo_WR.in -J 2D_WR&lt;br /&gt;
At the end you find a new database &#039;&#039;ndb.RIM&#039;&#039; and a new report file &#039;&#039;r-2D_WR_rim_cut &#039;&#039;. Open it and look inside&lt;br /&gt;
&lt;br /&gt;
 Gamma point sphere radius         [au]:  0.08028&lt;br /&gt;
  Points outside the sphere             :  799246&lt;br /&gt;
  [Int_sBZ(q=0) 1/q^2]*(Vol_sBZ)^(-1/3) = 7.665674&lt;br /&gt;
                                 should be &amp;lt; 7.795600&lt;br /&gt;
  [WR./2D_WR//ndb.RIM]--------------------------------------&lt;br /&gt;
   Brillouin Zone Q/K grids (IBZ/BZ):   7   36    7   36&lt;br /&gt;
   Coulombian RL components        : 111&lt;br /&gt;
   Coulombian diagonal components  :yes&lt;br /&gt;
   RIM random points               : 1000000&lt;br /&gt;
   RIM  RL volume             [a.u.]: 0.390293&lt;br /&gt;
   Real RL volume             [a.u.]: 0.390112&lt;br /&gt;
   Eps^-1 reference component       :0&lt;br /&gt;
   Eps^-1 components                : 0.00      0.00      0.00&lt;br /&gt;
   RIM anysotropy factor            : 0.000000&lt;br /&gt;
  - S/N 005962 -------------------------- v.04.01.02 r.00120 -&lt;br /&gt;
&lt;br /&gt;
  Summary of Coulomb integrals for non-metallic bands |Q|[au] RIM/Bare:&lt;br /&gt;
&lt;br /&gt;
  Q [1]:0.1000E-40.9833 * Q [2]: 0.256404 1.094818&lt;br /&gt;
  Q [5]: 0.444104 1.032268 * Q [3]: 0.512807 1.024055&lt;br /&gt;
  Q [6]: 0.678380 1.013997 * Q [4]: 0.769211 1.010774&lt;br /&gt;
  Q [7]: 0.888208 1.008393&lt;br /&gt;
&lt;br /&gt;
The RIM and Real RL Volumes are quite similar so one million random q-points seems a reasonable number, &lt;br /&gt;
but again you are invited, later on, to check the convergence of one of the main observables (i.e. HF gap, GW gap, absorption..) changing this number.&lt;br /&gt;
&lt;br /&gt;
Close the report file and perform a calculation of the exchange self-energy to estimate the HF gap (very fast calculation) using the RIM.&lt;br /&gt;
Generate the input &lt;br /&gt;
 $  yambo -F yambo_HF_WR.in -J 2D_WR -r -x &lt;br /&gt;
In order to calculate the HF gap only for the last k-point (which is the high-simmetry point K)  change the last line as&lt;br /&gt;
Note also that 4 (5) is the highest occupied (lowest unoccupied) band.&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 7|  7|  4|  5|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_HF_WR.in -J 2D_WR&lt;br /&gt;
At the end you will find the report file &#039;&#039;r-2D_WR_HF_and_locXC_rim_cut&#039;&#039; and the output file &#039;&#039;o-2D_WR.hf&#039;&#039;. Open them and have a look&lt;br /&gt;
In the output file &#039;&#039;o-2D_WR.hf&#039;&#039;   you will see&lt;br /&gt;
#    K-point      Band         Eo           Ehf          DFT          HF&lt;br /&gt;
#&lt;br /&gt;
     7.00000      4.00000      0.00000     -3.25329    -16.21953    -19.47282&lt;br /&gt;
     7.00000      5.00000      4.40109      9.67551    -11.10755     -5.83314&lt;br /&gt;
&lt;br /&gt;
The HF gap is 12.92 eV obtained subtracting the 2 values in the fourth column &lt;br /&gt;
Now you can do a similar HF calculation without generating and reading the RIM database&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in  -x&lt;br /&gt;
change the variables &#039;&#039;QPkrange&#039;&#039; as before, close the input and run yambo&lt;br /&gt;
  $ yambo -F yambo_HF_NR.in -J 2D_NR&lt;br /&gt;
&lt;br /&gt;
 in this case the HF gap in the file &#039;&#039;o-2D_NR.hf&#039;&#039; results to be 12.69 eV. &lt;br /&gt;
&lt;br /&gt;
Indeed the presence of the numerical instability,  discussed before, is evident only using denser k-grids with respect to the one  used in this Tutorial (6x6x1)&lt;br /&gt;
Suggestion: later you can generate other SAVE  directories with  denser k-grids  and check the HF gap.&lt;br /&gt;
The results of the  HF gap calculated with different k-grids without (noRIM) and with Random Integration  Method (RIM) to show up the problem are reported:&lt;br /&gt;
&lt;br /&gt;
               noRIM        RIM&lt;br /&gt;
&lt;br /&gt;
    6x6x1    12.69eV    12.92eV&lt;br /&gt;
 12x12x1     12.80eV    12.92eV&lt;br /&gt;
 15x15x1     12.96eV    12.93eV&lt;br /&gt;
 45x45x1     15.52eV    12.96eV&lt;br /&gt;
&lt;br /&gt;
So the &#039;&#039;&#039;home message&#039;&#039;&#039; is : use always the RIM in MB simulations of low-dimensional materials.&lt;br /&gt;
&lt;br /&gt;
==Generate a truncated coulomb potential  ==&lt;br /&gt;
To simulate an isolated nano-material a convergence with cell vacuum size is in principle required, like in the DFT runs.&lt;br /&gt;
The use of a truncated Coulomb potential allows to achieve faster convergence  eliminating the interaction between the repeated  images&lt;br /&gt;
along the non-periodic direction (see i.e. C. A. Rozzi et al Phys. Rev. B 73, 205119)&lt;br /&gt;
In this tutorial we learn how to generate a box-like cutoff for a 2D system with the non-periodic direction along z.&lt;br /&gt;
&lt;br /&gt;
In YAMBO you can use :&lt;br /&gt;
* spherical   cutoff (for 0D systems)  &lt;br /&gt;
* cylindrical cutoff (for 1D systems) &lt;br /&gt;
* box-like    cutoff (for 0D, 1D and 2D systems)&lt;br /&gt;
&lt;br /&gt;
The Coulomb potential with a box-like cutoff is defined as &lt;br /&gt;
[[File:Vc1.png|none|x80px|]]&lt;br /&gt;
where S is a box-shaped region of the space having sides Lx,Ly and Lz, where they can also assume infinite values (untruncated interaction along desired directions). &lt;br /&gt;
&lt;br /&gt;
Then the FT component is &lt;br /&gt;
[[File:Vc2.png|none|x60px|]] where [[File:Vc3.png|none|x60px|]]&lt;br /&gt;
For a 2D-system with non period direction along z-axis we have&lt;br /&gt;
[[File:Vc4.png|none|x60px|]]&lt;br /&gt;
&lt;br /&gt;
Important remarks:&lt;br /&gt;
* the Random Integration Method (RIM) is required to perform the Q-space integration&lt;br /&gt;
* for sufficiently large supercells  a choose L_i slightly smaller than the cell size in the i-direction ensures to avoid interaction between replicas&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Create the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F yambo_WR_WC.in   -r &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the RIM Variables as before and  activate the &#039;&#039;cutoff&#039;&#039;  generation&lt;br /&gt;
 [[Variables#RandQpts|RandQpts]] = 1000000   # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 [[Variables#RandGvec|RandGvec]] = 100  RL   # [RIM] Coulomb interaction RS components &lt;br /&gt;
 [[Variables#CUTGeo|CUTGeo]] = &amp;quot;box z&amp;quot; # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.00     | 0.00     | 32.0    |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Close the input file  and run yambo:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F  yambo_WR_WC.in  -J 2D_WR_WC&lt;br /&gt;
&lt;br /&gt;
in the directory 2D_WR_WC you will find a new database &amp;lt;code&amp;gt; ndb.cutoff &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;-PPA calculation==&lt;br /&gt;
&lt;br /&gt;
Generate the input reading the databases in the &#039;&#039;2D_WR_WC&#039;&#039; directory &lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_G0W0.in -p p -g n -r -k hartree -V qp&lt;br /&gt;
 In the input  change the following variables&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]] = 4  Ry    # [Xp] Response block size &lt;br /&gt;
 [[Variables#QPkrange|QPkrange]]                    # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  4| 5|&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
 $ yambo -F yambo_G0W0.in -J 2D_WR_WC&lt;br /&gt;
At the end you will find a new report file &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;, open it and have a look.&lt;br /&gt;
You will find also a new output file &#039;&#039;o-2D_WR_WC.qp&#039;&#039;. If you open yoi will find that now the G&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;W&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt; gap is &lt;br /&gt;
4.40 eV (PBE) + 3.70 eV (G0W0 correction) = 8.10 eV &lt;br /&gt;
Indeed as you have learned in the previous tutorials the correlation part of the self-energy strongly reduces the HF gap.&lt;br /&gt;
Moreover you should note that the QP correction is larger that one found in the h-BN bulk. Why?&lt;br /&gt;
&lt;br /&gt;
==Use the truncated coulomb potential in a BSE calculation==&lt;br /&gt;
Generate the input for the BSE calculation:&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in -r -o b -p p -y d -k sex -V all&lt;br /&gt;
Some remarks: the largest verbosity is used &amp;lt;code&amp;gt;-V all &amp;lt;/code&amp;gt; and a long input file is generated;  with the option &amp;lt;code&amp;gt;  -p p &amp;lt;/code&amp;gt;  the static part of the screening matrix is read from the &amp;lt;code&amp;gt;ndb.pp&amp;lt;/code&amp;gt; databases&lt;br /&gt;
Change the number of G-vectors in the correlation part of the kernel   as:  &lt;br /&gt;
 [[Variables#BSENGBlk|BSENGBlk]]= 4 Ry    # [BSK] Screened interaction block size&lt;br /&gt;
use the simple rigid scissor to open the correct the KS energies &lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 3.70000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
Set the number of bands to:&lt;br /&gt;
 % [[Variables#BSEBands|BSEBands]]&lt;br /&gt;
  2 |  6 |                 # [BSK] Bands range&lt;br /&gt;
This choice means to include in the BSE only three occupied and 2 unoccupied bands. &lt;br /&gt;
Increase the number of energy steps&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 500                # [BSS] Energy steps&lt;br /&gt;
To do the next Tutorial  we need to write the excitonic WFs, so uncomment the following line&lt;br /&gt;
 #[[Variables#WRbsWF|WRbsWF]]                      # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR_WC -F yambo_BSE.in &lt;br /&gt;
Look at the report file &#039;&#039;r-2D_WR_WC_optics_bse_bsk_bss_em1d_ppa_rim_cut&#039;&#039; and plot &#039;&#039;o-2D_WR_WC.eps_q1_diago_bse&#039;&#039;.&lt;br /&gt;
You realize immediately that the real part is almost 1, while the imaginary part is almost zero, being essentially the dieletric function of vacuum. &lt;br /&gt;
&lt;br /&gt;
For this reason yambo produces another file called here &#039;o-2D_WR_WC.alpha_q1_diago_bse&#039;  which contains the macroscopic polarizability&lt;br /&gt;
defined for a 2D system (with non-periodic direction along z) as :&lt;br /&gt;
&lt;br /&gt;
 [File:alpha2D.gif|none|x80px|]  where [File:Lz.gif|none|x80px|] is the size of the cell in the non-periodic direction (z in this case)&lt;br /&gt;
&lt;br /&gt;
== Analyze the differences with corresponding GW and BSE calculations without the use of a truncated coulomb potential==&lt;br /&gt;
&lt;br /&gt;
Open the input file yambo_G0W0.in and set back &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
Close the input and run yambo&lt;br /&gt;
&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_G0W0.in &lt;br /&gt;
You will find a new report &#039;&#039;r-2D_WR_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;. &lt;br /&gt;
You are invited to see the difference with the previous one &#039;&#039;r-2D_WR_WC_em1d_ppa_HF_and_locXC_gw0_rim_cut&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also a new output file &#039;&#039;o-2D_WR.qp&#039;&#039; is present. Open and check the QP correction at the last k-point.  This time&lt;br /&gt;
a value of 2.83 eV instead of 3.70 eV is obtained. Are you able to explain this result?&lt;br /&gt;
&lt;br /&gt;
Now redoo the BSE calculation but without reading the cutoff database and applying the QP correction just obtained without using the cutoff. &lt;br /&gt;
 &lt;br /&gt;
To do that,  open the yambo_BSE.in  and put &amp;lt;code&amp;gt;CUTGeo= &amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;    &lt;br /&gt;
and set the QP correction of 2.83 eV, just obtained without uisng the cutoff.&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]]&lt;br /&gt;
 2.830000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
&lt;br /&gt;
Close the input file and run yambo&lt;br /&gt;
 $ yambo -J 2D_WR -F yambo_BSE.in&lt;br /&gt;
Plot the imaginary part of the GW and BSE polarizability :&lt;br /&gt;
&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 $ gnuplot&amp;gt; set ylabel &#039;alpha&#039;&lt;br /&gt;
 $ gnuplot&amp;gt; plot &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($4*33.01/4/pi) w l title &#039;GW without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:4 w l title &#039; GW with cutoff&#039; , &#039;o-2D_WR.eps_q1_diago_bse&#039; u 1:($2*33.01/4/pi) w l title &#039;BSE without cutoff&#039; ,&#039;o-2D_WR_WC.alpha_q1_diago_bse&#039; u 1:2 w l title &#039;BSE with cutoff&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:BSE_2D_cutnocut.png|none|600px|]]&lt;br /&gt;
&lt;br /&gt;
You can note that the energy of the peaks in the two G0W0 spectra (with and without cutoff) are quite different:&lt;br /&gt;
you find the first peak around 7 eV without cutoff  and around 8 eV with cutoff. &lt;br /&gt;
Instead the two GW+BSE spectra, without and with cutoff, are much more similar. Are you able to explain why?&lt;br /&gt;
Remarks: The convergence in k-space can be done separately for GW and BSE&lt;br /&gt;
calculations, because generally more k-points are needed to converge the excitonic with respect to the quasi-particle properties.&lt;br /&gt;
&lt;br /&gt;
N.B. If you will use the same inputs created in this tutorial remember to set up the cutoff variable &#039;&#039;CUTGeo= &amp;quot;box z&amp;quot;&#039;&#039; to use again the truncated coulomb potential in the GW and BSE calculations&lt;br /&gt;
&lt;br /&gt;
Literature on two-dimensional h-BN: L. Wirtz et al Phys Rev Lett 96 126104 (2006), F. Rasmussen et al Phys Rev. B 94 155406 (2016),N. Berseneva et al Phys. Rev. B 87 035404 (2013).&lt;/div&gt;</summary>
		<author><name>Maurizia</name></author>
	</entry>
</feed>