<?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=Aferretti</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=Aferretti"/>
	<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Special:Contributions/Aferretti"/>
	<updated>2026-07-01T17:30:29Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4890</id>
		<title>CECAM VIRTUAL 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4890"/>
		<updated>2021-04-09T07:22:46Z</updated>

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

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

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

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

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

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

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

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

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

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

		<summary type="html">&lt;p&gt;Aferretti: /* Converging the sum over states in the correlation self-energy */&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 $3+$4}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $3+$4}&#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;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 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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4845</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=4845"/>
		<updated>2021-04-07T08:26:04Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Converging the sum over states in the correlation self-energy */&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 $3+$4}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $3+$4}&#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;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 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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4844</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=4844"/>
		<updated>2021-04-07T08:13:02Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Step 5: Eigenvalue only self-consistent evGW0 and evGW */&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 &#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 &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $3+$4}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $3+$4}&#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;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 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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4843</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=4843"/>
		<updated>2021-04-07T07:58:50Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Converging the sum over states in the correlation self-energy */&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 &#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 &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $3+$4}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;^ *7 *8&amp;quot; o-Gbnd*  | awk &#039;{print $3+$4}&#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;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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4842</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=4842"/>
		<updated>2021-04-07T07:54:52Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* 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;
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 &#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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4841</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=4841"/>
		<updated>2021-04-07T07:54:17Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* 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;
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 data sets unto 40 bands&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 &#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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4840</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=4840"/>
		<updated>2021-04-07T07:44:15Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Understanding the output */&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 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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4839</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=4839"/>
		<updated>2021-04-07T07:43:35Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Understanding the output */&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;
 &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;
&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 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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4838</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=4838"/>
		<updated>2021-04-07T07:43:06Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Understanding the output */&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;
 &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;
&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 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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4837</id>
		<title>Bash scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4837"/>
		<updated>2021-04-07T07:40:35Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* parse_qps.sh  (parse QP energies) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Hexagonal-BN tutorial =&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_1.sh   (GW ecut_X and nbnd_X convergence input fles) ===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #  &lt;br /&gt;
 # NGsBlkXp and BndsRnXp convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40&#039;&lt;br /&gt;
 blocks=&#039;1 2 3 4 5&#039;&lt;br /&gt;
 #&lt;br /&gt;
 for i in ${bands} ; do&lt;br /&gt;
 for j in ${blocks}; do&lt;br /&gt;
     sed  -e &amp;quot;s/1 | 10/1 | $i/g&amp;quot;  gw_ppa.in  &amp;gt; tmp$i&lt;br /&gt;
     sed  -e &amp;quot;s/NGsBlkXp= 1/ NGsBlkXp= $j/g&amp;quot;  tmp$i &amp;gt; gw_ppa_$i&#039;b_&#039;$j&#039;Ry.in&#039;&lt;br /&gt;
     rm tmp*&lt;br /&gt;
 done&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===parse_qps.sh  (parse QP energies)===&lt;br /&gt;
&lt;br /&gt;
 #! /bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # parse QP energies from output files calculated with BndsRnXp bands &lt;br /&gt;
 # and put them in files ordered by NGsBlkXp&lt;br /&gt;
 #&lt;br /&gt;
 label=10b&lt;br /&gt;
 fileout=10b.dat &lt;br /&gt;
 #&lt;br /&gt;
 file_list=`ls  o-${label}_* `&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;# ecut  NumG  QP1  QP2&amp;quot; &amp;gt; $fileout&lt;br /&gt;
 for file in $file_list; do&lt;br /&gt;
    #&lt;br /&gt;
    ecut=` grep &amp;quot;NGsBlkXp&amp;quot; $file | awk &#039;{print $4}&#039; `&lt;br /&gt;
    numG=` grep &amp;quot;used&amp;quot; $file |awk &#039;{print $5}&#039;`&lt;br /&gt;
    qp1=` cat $file | grep &amp;quot;^ *7 *8&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    qp2=` cat $file | grep &amp;quot;^ *7 *9&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    #&lt;br /&gt;
    echo $ecut $numG $qp1 $qp2 &amp;gt;&amp;gt; $fileout&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_2.sh  (GW Gbnd convergence input files) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #&lt;br /&gt;
 # Gbnd convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40 50 60 70 80&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/1 | 40/1 | $i/g&amp;quot;  gw_ppa_30b_3Ry.in  &amp;gt;  gw_ppa_Gbnd$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_3.sh  (Real axis convergence input files)===&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 bands=&#039;10 50 100 150 200 250&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/ETStpsXd= 100/ETStpsXd=$i/g&amp;quot;  gw_ff.in  &amp;gt;  gw_ff$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
= Silicon Tutorial =&lt;br /&gt;
&lt;br /&gt;
=== parse_gap.sh  (to parse the gap corrections) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 if [ ! -f GAMMA/References/$1 ]&lt;br /&gt;
 then&lt;br /&gt;
     echo &amp;quot;File not found&amp;quot;&lt;br /&gt;
     exit&lt;br /&gt;
 fi&lt;br /&gt;
 rm -f $2&lt;br /&gt;
 kpts=&#039;GAMMA 2x2x2 4x4x4 6x6x6 8x8x8&#039;&lt;br /&gt;
 NK=(1 8 64 216 512)&lt;br /&gt;
 j=0&lt;br /&gt;
 for i in ${kpts}&lt;br /&gt;
  do&lt;br /&gt;
    VBMo=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    VBM=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    CBMo=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    CBM=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in &lt;br /&gt;
     *-01HF*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $5-$3 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
     *-Cohsex*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $4+$5 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
    esac&lt;br /&gt;
    j=`expr $j + 1`&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
= Hydrogen chain tutorial =&lt;br /&gt;
&lt;br /&gt;
=== launch_xcrysden.sh ===&lt;br /&gt;
&lt;br /&gt;
 #! /bin/sh&lt;br /&gt;
 #&lt;br /&gt;
 if [ $# != 1 ] ; then&lt;br /&gt;
  echo $0 &amp;quot;o- file&amp;quot;&lt;br /&gt;
  exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 twoD=`echo $1 |grep &#039;2d&#039;`&lt;br /&gt;
 threeD=`echo $1 |grep &#039;3d&#039;`&lt;br /&gt;
 if test -n &amp;quot;$twoD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts2D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi &lt;br /&gt;
 if test -n &amp;quot;$threeD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts/3D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
* [[Tutorials|Back to tutorials menu]]&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4836</id>
		<title>Bash scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4836"/>
		<updated>2021-04-07T07:37:58Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Silicon Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Hexagonal-BN tutorial =&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_1.sh   (GW ecut_X and nbnd_X convergence input fles) ===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #  &lt;br /&gt;
 # NGsBlkXp and BndsRnXp convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40&#039;&lt;br /&gt;
 blocks=&#039;1 2 3 4 5&#039;&lt;br /&gt;
 #&lt;br /&gt;
 for i in ${bands} ; do&lt;br /&gt;
 for j in ${blocks}; do&lt;br /&gt;
     sed  -e &amp;quot;s/1 | 10/1 | $i/g&amp;quot;  gw_ppa.in  &amp;gt; tmp$i&lt;br /&gt;
     sed  -e &amp;quot;s/NGsBlkXp= 1/ NGsBlkXp= $j/g&amp;quot;  tmp$i &amp;gt; gw_ppa_$i&#039;b_&#039;$j&#039;Ry.in&#039;&lt;br /&gt;
     rm tmp*&lt;br /&gt;
 done&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===parse_qps.sh  (parse QP energies)===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash -x&lt;br /&gt;
 #&lt;br /&gt;
 # parse QP energies from output files calculated with BndsRnXp bands &lt;br /&gt;
 # and put them in files ordered by NGsBlkXp&lt;br /&gt;
 #&lt;br /&gt;
 label=10b&lt;br /&gt;
 fileout=10b.dat &lt;br /&gt;
 #&lt;br /&gt;
 file_list=`ls  o-${label}_* `&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;# ecut  NumG  QP1  QP2&amp;quot; &amp;gt; $fileout&lt;br /&gt;
 for file in $file_list; do&lt;br /&gt;
    #&lt;br /&gt;
    ecut=` grep &amp;quot;NGsBlkXp&amp;quot; $file | awk &#039;{print $4}&#039; `&lt;br /&gt;
    numG=` grep &amp;quot;used&amp;quot; $file |awk &#039;{print $5}&#039;`&lt;br /&gt;
    qp1=` cat $file | grep &amp;quot;^ *7 *8&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    qp2=` cat $file | grep &amp;quot;^ *7 *9&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    #&lt;br /&gt;
    echo $ecut $numG $qp1 $qp2 &amp;gt;&amp;gt; $fileout&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_2.sh  (GW Gbnd convergence input files) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #&lt;br /&gt;
 # Gbnd convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40 50 60 70 80&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/1 | 40/1 | $i/g&amp;quot;  gw_ppa_30b_3Ry.in  &amp;gt;  gw_ppa_Gbnd$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_3.sh  (Real axis convergence input files)===&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 bands=&#039;10 50 100 150 200 250&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/ETStpsXd= 100/ETStpsXd=$i/g&amp;quot;  gw_ff.in  &amp;gt;  gw_ff$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
= Silicon Tutorial =&lt;br /&gt;
&lt;br /&gt;
=== parse_gap.sh  (to parse the gap corrections) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 if [ ! -f GAMMA/References/$1 ]&lt;br /&gt;
 then&lt;br /&gt;
     echo &amp;quot;File not found&amp;quot;&lt;br /&gt;
     exit&lt;br /&gt;
 fi&lt;br /&gt;
 rm -f $2&lt;br /&gt;
 kpts=&#039;GAMMA 2x2x2 4x4x4 6x6x6 8x8x8&#039;&lt;br /&gt;
 NK=(1 8 64 216 512)&lt;br /&gt;
 j=0&lt;br /&gt;
 for i in ${kpts}&lt;br /&gt;
  do&lt;br /&gt;
    VBMo=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    VBM=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    CBMo=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    CBM=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in &lt;br /&gt;
     *-01HF*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $5-$3 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
     *-Cohsex*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $4+$5 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
    esac&lt;br /&gt;
    j=`expr $j + 1`&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
= Hydrogen chain tutorial =&lt;br /&gt;
&lt;br /&gt;
=== launch_xcrysden.sh ===&lt;br /&gt;
&lt;br /&gt;
 #! /bin/sh&lt;br /&gt;
 #&lt;br /&gt;
 if [ $# != 1 ] ; then&lt;br /&gt;
  echo $0 &amp;quot;o- file&amp;quot;&lt;br /&gt;
  exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 twoD=`echo $1 |grep &#039;2d&#039;`&lt;br /&gt;
 threeD=`echo $1 |grep &#039;3d&#039;`&lt;br /&gt;
 if test -n &amp;quot;$twoD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts2D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi &lt;br /&gt;
 if test -n &amp;quot;$threeD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts/3D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
* [[Tutorials|Back to tutorials menu]]&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4835</id>
		<title>Bash scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4835"/>
		<updated>2021-04-07T07:37:21Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Hexagonal-BN tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Hexagonal-BN tutorial =&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_1.sh   (GW ecut_X and nbnd_X convergence input fles) ===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #  &lt;br /&gt;
 # NGsBlkXp and BndsRnXp convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40&#039;&lt;br /&gt;
 blocks=&#039;1 2 3 4 5&#039;&lt;br /&gt;
 #&lt;br /&gt;
 for i in ${bands} ; do&lt;br /&gt;
 for j in ${blocks}; do&lt;br /&gt;
     sed  -e &amp;quot;s/1 | 10/1 | $i/g&amp;quot;  gw_ppa.in  &amp;gt; tmp$i&lt;br /&gt;
     sed  -e &amp;quot;s/NGsBlkXp= 1/ NGsBlkXp= $j/g&amp;quot;  tmp$i &amp;gt; gw_ppa_$i&#039;b_&#039;$j&#039;Ry.in&#039;&lt;br /&gt;
     rm tmp*&lt;br /&gt;
 done&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===parse_qps.sh  (parse QP energies)===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash -x&lt;br /&gt;
 #&lt;br /&gt;
 # parse QP energies from output files calculated with BndsRnXp bands &lt;br /&gt;
 # and put them in files ordered by NGsBlkXp&lt;br /&gt;
 #&lt;br /&gt;
 label=10b&lt;br /&gt;
 fileout=10b.dat &lt;br /&gt;
 #&lt;br /&gt;
 file_list=`ls  o-${label}_* `&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;# ecut  NumG  QP1  QP2&amp;quot; &amp;gt; $fileout&lt;br /&gt;
 for file in $file_list; do&lt;br /&gt;
    #&lt;br /&gt;
    ecut=` grep &amp;quot;NGsBlkXp&amp;quot; $file | awk &#039;{print $4}&#039; `&lt;br /&gt;
    numG=` grep &amp;quot;used&amp;quot; $file |awk &#039;{print $5}&#039;`&lt;br /&gt;
    qp1=` cat $file | grep &amp;quot;^ *7 *8&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    qp2=` cat $file | grep &amp;quot;^ *7 *9&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    #&lt;br /&gt;
    echo $ecut $numG $qp1 $qp2 &amp;gt;&amp;gt; $fileout&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_2.sh  (GW Gbnd convergence input files) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #&lt;br /&gt;
 # Gbnd convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40 50 60 70 80&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/1 | 40/1 | $i/g&amp;quot;  gw_ppa_30b_3Ry.in  &amp;gt;  gw_ppa_Gbnd$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_3.sh  (Real axis convergence input files)===&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 bands=&#039;10 50 100 150 200 250&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/ETStpsXd= 100/ETStpsXd=$i/g&amp;quot;  gw_ff.in  &amp;gt;  gw_ff$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
= Silicon Tutorial =&lt;br /&gt;
&lt;br /&gt;
=== parse_gap.sh (shell script to parse the gap corrections) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 if [ ! -f GAMMA/References/$1 ]&lt;br /&gt;
 then&lt;br /&gt;
     echo &amp;quot;File not found&amp;quot;&lt;br /&gt;
     exit&lt;br /&gt;
 fi&lt;br /&gt;
 rm -f $2&lt;br /&gt;
 kpts=&#039;GAMMA 2x2x2 4x4x4 6x6x6 8x8x8&#039;&lt;br /&gt;
 NK=(1 8 64 216 512)&lt;br /&gt;
 j=0&lt;br /&gt;
 for i in ${kpts}&lt;br /&gt;
  do&lt;br /&gt;
    VBMo=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    VBM=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    CBMo=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    CBM=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in &lt;br /&gt;
     *-01HF*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $5-$3 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
     *-Cohsex*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $4+$5 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
    esac&lt;br /&gt;
    j=`expr $j + 1`&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
= Hydrogen chain tutorial =&lt;br /&gt;
&lt;br /&gt;
=== launch_xcrysden.sh ===&lt;br /&gt;
&lt;br /&gt;
 #! /bin/sh&lt;br /&gt;
 #&lt;br /&gt;
 if [ $# != 1 ] ; then&lt;br /&gt;
  echo $0 &amp;quot;o- file&amp;quot;&lt;br /&gt;
  exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 twoD=`echo $1 |grep &#039;2d&#039;`&lt;br /&gt;
 threeD=`echo $1 |grep &#039;3d&#039;`&lt;br /&gt;
 if test -n &amp;quot;$twoD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts2D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi &lt;br /&gt;
 if test -n &amp;quot;$threeD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts/3D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
* [[Tutorials|Back to tutorials menu]]&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4834</id>
		<title>Bash scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Bash_scripts&amp;diff=4834"/>
		<updated>2021-04-07T07:33:30Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Hexagonal-BN tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Hexagonal-BN tutorial =&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_1.sh===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #  &lt;br /&gt;
 # NGsBlkXp and BndsRnXp convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40&#039;&lt;br /&gt;
 blocks=&#039;1 2 3 4 5&#039;&lt;br /&gt;
 #&lt;br /&gt;
 for i in ${bands} ; do&lt;br /&gt;
 for j in ${blocks}; do&lt;br /&gt;
     sed  -e &amp;quot;s/1 | 10/1 | $i/g&amp;quot;  gw_ppa.in  &amp;gt; tmp$i&lt;br /&gt;
     sed  -e &amp;quot;s/NGsBlkXp= 1/ NGsBlkXp= $j/g&amp;quot;  tmp$i &amp;gt; gw_ppa_$i&#039;b_&#039;$j&#039;Ry.in&#039;&lt;br /&gt;
     rm tmp*&lt;br /&gt;
 done&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
===parse_qps.sh ===&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash -x&lt;br /&gt;
 #&lt;br /&gt;
 # parse QP energies from output files calculated with BndsRnXp bands and put them in files ordered by NGsBlkXp)&lt;br /&gt;
 #&lt;br /&gt;
 label=10b&lt;br /&gt;
 fileout=10b.dat &lt;br /&gt;
 #&lt;br /&gt;
 file_list=`ls  o-${label}_* `&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;# ecut  NumG  QP1  QP2&amp;quot; &amp;gt; $fileout&lt;br /&gt;
 for file in $file_list; do&lt;br /&gt;
    #&lt;br /&gt;
    ecut=` grep &amp;quot;NGsBlkXp&amp;quot; $file | awk &#039;{print $4}&#039; `&lt;br /&gt;
    numG=` grep &amp;quot;used&amp;quot; $file |awk &#039;{print $5}&#039;`&lt;br /&gt;
    qp1=` cat $file | grep &amp;quot;^ *7 *8&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    qp2=` cat $file | grep &amp;quot;^ *7 *9&amp;quot; |  awk &#039;{print $3+$4}&#039; `&lt;br /&gt;
    #&lt;br /&gt;
    echo $ecut $numG $qp1 $qp2 &amp;gt;&amp;gt; $fileout&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_2.sh===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 #&lt;br /&gt;
 # Gbnd convergence input files&lt;br /&gt;
 #&lt;br /&gt;
 bands=&#039;10 20 30 40 50 60 70 80&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/1 | 40/1 | $i/g&amp;quot;  gw_ppa_30b_3Ry.in  &amp;gt;  gw_ppa_Gbnd$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===generate_inputs_3.sh (Real axis convergence input files)===&lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 bands=&#039;10 50 100 150 200 250&#039;&lt;br /&gt;
 for i in ${bands}&lt;br /&gt;
 do&lt;br /&gt;
   sed  -e &amp;quot;s/ETStpsXd= 100/ETStpsXd=$i/g&amp;quot;  gw_ff.in  &amp;gt;  gw_ff$i&#039;.in&#039;&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
= Silicon Tutorial =&lt;br /&gt;
&lt;br /&gt;
=== parse_gap.sh (shell script to parse the gap corrections) ===&lt;br /&gt;
 &lt;br /&gt;
 #!/bin/bash &lt;br /&gt;
 if [ ! -f GAMMA/References/$1 ]&lt;br /&gt;
 then&lt;br /&gt;
     echo &amp;quot;File not found&amp;quot;&lt;br /&gt;
     exit&lt;br /&gt;
 fi&lt;br /&gt;
 rm -f $2&lt;br /&gt;
 kpts=&#039;GAMMA 2x2x2 4x4x4 6x6x6 8x8x8&#039;&lt;br /&gt;
 NK=(1 8 64 216 512)&lt;br /&gt;
 j=0&lt;br /&gt;
 for i in ${kpts}&lt;br /&gt;
  do&lt;br /&gt;
    VBMo=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    VBM=`grep &amp;quot; 1.000&amp;quot; $i/References/$1 | grep &amp;quot; 4.0000&amp;quot; | grep &amp;quot; 0.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    CBMo=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $3}&#039;`&lt;br /&gt;
    CBM=`grep &amp;quot; 2.576&amp;quot; $i/References/$1 | grep &amp;quot; 5.000&amp;quot; | awk &#039;{print $4}&#039;`&lt;br /&gt;
    case &amp;quot;$1&amp;quot; in &lt;br /&gt;
     *-01HF*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $5-$3 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
     *-Cohsex*)&lt;br /&gt;
       echo  ${NK[$j]} $VBMo $VBM $CBMo $CBM | awk &#039;{print $1 &amp;quot; &amp;quot; $4+$5 }&#039; &amp;gt;&amp;gt;  &amp;quot;$2&amp;quot;&lt;br /&gt;
       ;;&lt;br /&gt;
    esac&lt;br /&gt;
    j=`expr $j + 1`&lt;br /&gt;
  done&lt;br /&gt;
&lt;br /&gt;
= Hydrogen chain tutorial =&lt;br /&gt;
&lt;br /&gt;
=== launch_xcrysden.sh ===&lt;br /&gt;
&lt;br /&gt;
 #! /bin/sh&lt;br /&gt;
 #&lt;br /&gt;
 if [ $# != 1 ] ; then&lt;br /&gt;
  echo $0 &amp;quot;o- file&amp;quot;&lt;br /&gt;
  exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 twoD=`echo $1 |grep &#039;2d&#039;`&lt;br /&gt;
 threeD=`echo $1 |grep &#039;3d&#039;`&lt;br /&gt;
 if test -n &amp;quot;$twoD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts2D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi &lt;br /&gt;
 if test -n &amp;quot;$threeD&amp;quot;  ; then&lt;br /&gt;
  cp $1 file.xsf&lt;br /&gt;
  xcrysden -s ../Xcrysden_scripts/3D.xcrysden&lt;br /&gt;
  rm -f file.xsf&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
* [[Tutorials|Back to tutorials menu]]&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4831</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=4831"/>
		<updated>2021-04-07T07:13:10Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* 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;
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;
 &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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4828</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=4828"/>
		<updated>2021-04-06T17:50:35Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Understanding the output */&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;
 &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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Yambo_Virtual_Machine&amp;diff=4827</id>
		<title>Yambo Virtual Machine</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Yambo_Virtual_Machine&amp;diff=4827"/>
		<updated>2021-04-06T17:29:27Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Updating the Yambo tutorial files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;VirtualBox&#039;&#039;&#039; is a software to run a (&#039;virtualized&#039;) operating system as a client of a host operating system. The host operating system is what you boot your computer into. The client operating system (called a &#039;virtual machine&#039;, or a &#039;software appliance&#039;)  has been prepared by us specifically for this School. &lt;br /&gt;
The &#039;&#039;&#039;Yambo Quantum Mobile&#039;&#039;&#039; VM is entirely based on the &#039;&#039;&#039;Quantum Mobile&#039;&#039;&#039; developed by the [https://people.epfl.ch/nicola.marzari/?lang=en EPFL group of Nicola Marzari] and supported by the [http://nccr-marvel.ch/ MARVEL NCCR] and the [http://max-centre.eu/ MaX H2020 Centre of Excellence].&lt;br /&gt;
&lt;br /&gt;
== Download and Install VirtualBox Software ==&lt;br /&gt;
&lt;br /&gt;
Go to [https://www.virtualbox.org Virtualbox Home] and click on the big button to download the latest Version, select your host system on the next page and start the download of the package.&lt;br /&gt;
&lt;br /&gt;
* For Windows users the download provides an `.exe` file that can be started by double-clicking on its icon&lt;br /&gt;
* For Mac users the download provides a disk image `.dmg` file that also can be  started by double-clicking&lt;br /&gt;
* For Linux users more choices are available,  depending on distribution. There is also the option to use a repository for Debian-based Linux distributions.&lt;br /&gt;
&lt;br /&gt;
This should be all. If something goes wrong, try to reboot your host and try to re-install on the freshly booted machine. (In the past, it was often found (at least on MacOSX) that upgrades of VirtualBox do not work when having run VirtualBox clients before.)&lt;br /&gt;
&lt;br /&gt;
== Download the Yambo Quantum Mobile image==&lt;br /&gt;
&lt;br /&gt;
Download the virtual machine image clicking on the following link&lt;br /&gt;
&lt;br /&gt;
[[File:yambo_VM.png|link=http://www.yambo-code.org/educational/VirtualMachine/YAMBO_Quantum_Mobile.ova]]&lt;br /&gt;
&lt;br /&gt;
Note that this image has a large size of 4 GBytes. Don&#039;t attempt to download it from a poor wireless connection. Having downloaded the VM Image, it needs to be &#039;&#039;&#039;imported&#039;&#039;&#039; into VirtualBox.&lt;br /&gt;
&lt;br /&gt;
== Install the Yambo Quantum Mobile VM ==&lt;br /&gt;
&lt;br /&gt;
* Find where VirtualBox is installed on your PC. To find it open a terminal and &lt;br /&gt;
 &amp;gt; which virtualbox&lt;br /&gt;
 /usr/bin/virtualbox&lt;br /&gt;
 &amp;gt; /usr/bin/virtualbo&lt;br /&gt;
* Goto Menu Item &amp;quot;File&amp;quot;, then &amp;quot;Import Appliance&amp;quot; (File-&amp;gt;Import Appliance)&lt;br /&gt;
* In the topmost field, type in the name of the downloaded Appliance File or search for it via the finder that opens when clicking the button to the right.&lt;br /&gt;
&lt;br /&gt;
[[File:QM1.png|400px|Screenshot before Import]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM2.png|400px|Screenshot Image selection]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM3.png|400px|Screenshot during Import]]&lt;br /&gt;
&lt;br /&gt;
* Proceed until the virtual machine has been successfully created.&lt;br /&gt;
&lt;br /&gt;
== Starting the Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
After import, the VirtualBox window looks roughly so:&lt;br /&gt;
&lt;br /&gt;
[[File:QM4.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
* Double-Click on the Virtual Machine Icon of the VirtualBox program.&lt;br /&gt;
* Within a few seconds, the window of the virtual machine will open and eventually you will see the graphical window of a running VM, into which you are automatically logged in as user `max`.&lt;br /&gt;
&lt;br /&gt;
[[File:QM5.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
== Updating the Yambo tutorial files ==&lt;br /&gt;
&lt;br /&gt;
Now, that the Yambo VM is running, open a terminal window (black icon with &#039;&amp;gt;&#039; on the left) and &lt;br /&gt;
&lt;br /&gt;
* read the &#039;&#039;RELEASE_NOTES.txt&#039;&#039; that are on your Desktop.&lt;br /&gt;
* update the Yambo tutorial files&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; cd YAMBO_TUTORIALS&lt;br /&gt;
 &amp;gt; git pull&lt;br /&gt;
 &amp;gt; ./setup.pl -install&lt;br /&gt;
&lt;br /&gt;
Now you are ready to do your tutorials.&lt;br /&gt;
&lt;br /&gt;
== Reducing the size of the VM image ==&lt;br /&gt;
Open a terminal in the VM and type&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero | pv | sudo dd of=/bigemptyfile bs=4096k&lt;br /&gt;
 sudo rm -rf /bigemptyfile&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4826</id>
		<title>CECAM VIRTUAL 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4826"/>
		<updated>2021-04-06T16:55:26Z</updated>

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

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

		<summary type="html">&lt;p&gt;Aferretti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;VirtualBox&#039;&#039;&#039; is a software to run a (&#039;virtualized&#039;) operating system as a client of a host operating system. The host operating system is what you boot your computer into. The client operating system (called a &#039;virtual machine&#039;, or a &#039;software appliance&#039;)  has been prepared by us specifically for this School. &lt;br /&gt;
The &#039;&#039;&#039;Yambo Quantum Mobile&#039;&#039;&#039; VM is entirely based on the &#039;&#039;&#039;Quantum Mobile&#039;&#039;&#039; developed by the [https://people.epfl.ch/nicola.marzari/?lang=en EPFL group of Nicola Marzari] and supported by the [http://nccr-marvel.ch/ MARVEL NCCR] and the [http://max-centre.eu/ MaX H2020 Centre of Excellence].&lt;br /&gt;
&lt;br /&gt;
== Download and Install VirtualBox Software ==&lt;br /&gt;
&lt;br /&gt;
Go to [https://www.virtualbox.org Virtualbox Home] and click on the big button to download the latest Version, select your host system on the next page and start the download of the package.&lt;br /&gt;
&lt;br /&gt;
* For Windows users the download provides an `.exe` file that can be started by double-clicking on its icon&lt;br /&gt;
* For Mac users the download provides a disk image `.dmg` file that also can be  started by double-clicking&lt;br /&gt;
* For Linux users more choices are available,  depending on distribution. There is also the option to use a repository for Debian-based Linux distributions.&lt;br /&gt;
&lt;br /&gt;
This should be all. If something goes wrong, try to reboot your host and try to re-install on the freshly booted machine. (In the past, it was often found (at least on MacOSX) that upgrades of VirtualBox do not work when having run VirtualBox clients before.)&lt;br /&gt;
&lt;br /&gt;
== Download the Yambo Quantum Mobile image==&lt;br /&gt;
&lt;br /&gt;
Download the virtual machine image clicking on the following link&lt;br /&gt;
&lt;br /&gt;
[[File:yambo_VM.png|link=http://www.yambo-code.org/educational/VirtualMachine/YAMBO_Quantum_Mobile.ova]]&lt;br /&gt;
&lt;br /&gt;
Note that this image has a large size of 4 GBytes. Don&#039;t attempt to download it from a poor wireless connection. Having downloaded the VM Image, it needs to be &#039;&#039;&#039;imported&#039;&#039;&#039; into VirtualBox.&lt;br /&gt;
&lt;br /&gt;
== Install the Yambo Quantum Mobile VM ==&lt;br /&gt;
&lt;br /&gt;
* Find where VirtualBox is installed on your PC. To find it open a terminal and &lt;br /&gt;
 &amp;gt; which virtualbox&lt;br /&gt;
 /usr/bin/virtualbox&lt;br /&gt;
 &amp;gt; /usr/bin/virtualbo&lt;br /&gt;
* Goto Menu Item &amp;quot;File&amp;quot;, then &amp;quot;Import Appliance&amp;quot; (File-&amp;gt;Import Appliance)&lt;br /&gt;
* In the topmost field, type in the name of the downloaded Appliance File or search for it via the finder that opens when clicking the button to the right.&lt;br /&gt;
&lt;br /&gt;
[[File:QM1.png|400px|Screenshot before Import]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM2.png|400px|Screenshot Image selection]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM3.png|400px|Screenshot during Import]]&lt;br /&gt;
&lt;br /&gt;
* Proceed until the virtual machine has been successfully created.&lt;br /&gt;
&lt;br /&gt;
== Starting the Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
After import, the VirtualBox window looks roughly so:&lt;br /&gt;
&lt;br /&gt;
[[File:QM4.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
* Double-Click on the Virtual Machine Icon of the VirtualBox program.&lt;br /&gt;
* Within a few seconds, the window of the virtual machine will open and eventually you will see the graphical window of a running VM, into which you are automatically logged in as user `max`.&lt;br /&gt;
&lt;br /&gt;
[[File:QM5.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
== Updating the Yambo tutorial files ==&lt;br /&gt;
&lt;br /&gt;
Now that the Yambo VM is running open a terminal window (black icon with &#039;&amp;gt;&#039; on the left) and &lt;br /&gt;
&lt;br /&gt;
* read the &#039;&#039;RELEASE_NOTES.txt&#039;&#039; that are on your Desktop.&lt;br /&gt;
* update the Yambo tutorial files&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; cd YAMBO_TUTORIALS&lt;br /&gt;
 &amp;gt; git pull&lt;br /&gt;
 &amp;gt; ./setup.pl -install&lt;br /&gt;
&lt;br /&gt;
Now you are ready to do your tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reducing the size of the VM image ==&lt;br /&gt;
Open a terminal in the VM and type&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero | pv | sudo dd of=/bigemptyfile bs=4096k&lt;br /&gt;
 sudo rm -rf /bigemptyfile&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Yambo_Virtual_Machine&amp;diff=4823</id>
		<title>Yambo Virtual Machine</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Yambo_Virtual_Machine&amp;diff=4823"/>
		<updated>2021-04-06T16:33:29Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;VirtualBox is a software to run a (&#039;virtualized&#039;) operating system as a client of a host operating system. The host operating system is what you boot your computer into. The client operating system (called a &#039;virtual machine&#039;, or a &#039;software appliance&#039;)  has been prepared by us specifically for this School. &lt;br /&gt;
The Yambo Quantum Mobile VM is entirely based on the &#039;&#039;&#039;Quantum Mobile&#039;&#039;&#039; developed by the [https://people.epfl.ch/nicola.marzari/?lang=en EPFL group of Nicola Marzari] and supported by the [http://nccr-marvel.ch/ MARVEL NCCR] and the [http://max-centre.eu/ MaX H2020 Centre of Excellence].&lt;br /&gt;
&lt;br /&gt;
== Download and Install VirtualBox Software ==&lt;br /&gt;
&lt;br /&gt;
Go to [https://www.virtualbox.org Virtualbox Home] and click on the big button to download the latest Version, select your host system on the next page and start the download of the package.&lt;br /&gt;
&lt;br /&gt;
* For Windows users the download provides an `.exe` file that can be started by double-clicking on its icon&lt;br /&gt;
* For Mac users the download provides a disk image `.dmg` file that also can be  started by double-clicking&lt;br /&gt;
* For Linux users more choices are available,  depending on distribution. There is also the option to use a repository for Debian-based Linux distributions.&lt;br /&gt;
&lt;br /&gt;
This should be all. If something goes wrong, try to reboot your host and try to re-install on the freshly booted machine. (In the past, it was often found (at least on MacOSX) that upgrades of VirtualBox do not work when having run VirtualBox clients before.)&lt;br /&gt;
&lt;br /&gt;
== Download the Yambo Quantum Mobile image==&lt;br /&gt;
&lt;br /&gt;
Download the virtual machine image clicking on the following link&lt;br /&gt;
&lt;br /&gt;
[[File:yambo_VM.png|link=http://www.yambo-code.org/educational/VirtualMachine/YAMBO_Quantum_Mobile.ova]]&lt;br /&gt;
&lt;br /&gt;
Note that this image has a large size of 4 GBytes. Don&#039;t attempt to download it from a poor wireless connection. Having downloaded the VM Image, it needs to be &#039;&#039;&#039;imported&#039;&#039;&#039; into VirtualBox.&lt;br /&gt;
&lt;br /&gt;
== Install the Yambo Quantum Mobile VM ==&lt;br /&gt;
&lt;br /&gt;
* Find where VirtualBox is installed on your PC. To find it open a terminal and &lt;br /&gt;
 &amp;gt; which virtualbox&lt;br /&gt;
 /usr/bin/virtualbox&lt;br /&gt;
 &amp;gt; /usr/bin/virtualbo&lt;br /&gt;
* Goto Menu Item &amp;quot;File&amp;quot;, then &amp;quot;Import Appliance&amp;quot; (File-&amp;gt;Import Appliance)&lt;br /&gt;
* In the topmost field, type in the name of the downloaded Appliance File or search for it via the finder that opens when clicking the button to the right.&lt;br /&gt;
&lt;br /&gt;
[[File:QM1.png|400px|Screenshot before Import]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM2.png|400px|Screenshot Image selection]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM3.png|400px|Screenshot during Import]]&lt;br /&gt;
&lt;br /&gt;
* Proceed until the virtual machine has been successfully created.&lt;br /&gt;
&lt;br /&gt;
== Starting the Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
After import, the VirtualBox window looks roughly so:&lt;br /&gt;
&lt;br /&gt;
[[File:QM4.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
* Double-Click on the Virtual Machine Icon of the VirtualBox program.&lt;br /&gt;
* Within a few seconds, the window of the virtual machine will open and eventually you will see the graphical window of a running VM, into which you are automatically logged in as user `max`.&lt;br /&gt;
&lt;br /&gt;
[[File:QM5.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
== Updating the Yambo tutorial files ==&lt;br /&gt;
&lt;br /&gt;
Now that the Yambo VM is running open a terminal window (black icon with &#039;&amp;gt;&#039; on the left) and &lt;br /&gt;
&lt;br /&gt;
* read the &#039;&#039;RELEASE_NOTES.txt&#039;&#039; that are on your Desktop.&lt;br /&gt;
* update the Yambo tutorial files&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; cd YAMBO_TUTORIALS&lt;br /&gt;
 &amp;gt; git pull&lt;br /&gt;
 &amp;gt; ./setup.pl -install&lt;br /&gt;
&lt;br /&gt;
Now you are ready to do your tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reducing the size of the VM image ==&lt;br /&gt;
Open a terminal in the VM and type&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero | pv | sudo dd of=/bigemptyfile bs=4096k&lt;br /&gt;
 sudo rm -rf /bigemptyfile&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Yambo_Virtual_Machine&amp;diff=4822</id>
		<title>Yambo Virtual Machine</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Yambo_Virtual_Machine&amp;diff=4822"/>
		<updated>2021-04-06T16:32:59Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;VirtualBox is a software to run a (&#039;virtualized&#039;) operating system as a client of a host operating system. The host operating system is what you boot your computer into. The client operating system (called a &#039;virtual machine&#039;, or a &#039;software appliance&#039;)  has been prepared by us specifically for this School. &lt;br /&gt;
The Yambo Quantum Mobile VM is entirely based on the &#039;&#039;&#039;Quantum Mobile&#039;&#039;&#039; developed by the [https://people.epfl.ch/nicola.marzari/?lang=en EPFL group of Nicola Marzari] and supported by the [http://nccr-marvel.ch/ MARVEL NCCR] and the [http://max-centre.eu/ MaX H2020 Centre of Excellence].&lt;br /&gt;
&lt;br /&gt;
== Download and Install VirtualBox Software ==&lt;br /&gt;
&lt;br /&gt;
Go to [https://www.virtualbox.org Virtualbox Home] and click on the big button to download the latest Version, select your host system on the next page and start the download of the package.&lt;br /&gt;
&lt;br /&gt;
* For Windows users the download provides an `.exe` file that can be started by double-clicking on its icon&lt;br /&gt;
* For Mac users the download provides a disk image `.dmg` file that also can be  started by double-clicking&lt;br /&gt;
* For Linux users more choices are available,  depending on distribution. There is also the option to use a repository for Debian-based Linux distributions.&lt;br /&gt;
&lt;br /&gt;
This should be all. If something goes wrong, try to reboot your host and try to re-install on the freshly booted machine. (In the past, it was often found (at least on MacOSX) that upgrades of VirtualBox do not work when having run VirtualBox clients before.)&lt;br /&gt;
&lt;br /&gt;
== Download the Yambo Quantum Mobile ==&lt;br /&gt;
&lt;br /&gt;
Download the virtual machine image clicking on the following link&lt;br /&gt;
&lt;br /&gt;
[[File:yambo_VM.png|link=http://www.yambo-code.org/educational/VirtualMachine/YAMBO_Quantum_Mobile.ova]]&lt;br /&gt;
&lt;br /&gt;
Note that this image has a large size of 4 GBytes. Don&#039;t attempt to download it from a poor wireless connection. Having downloaded the VM Image, it needs to be &#039;&#039;&#039;imported&#039;&#039;&#039; into VirtualBox.&lt;br /&gt;
&lt;br /&gt;
== Install the Yambo Quantum Mobile VM ==&lt;br /&gt;
&lt;br /&gt;
* Find where VirtualBox is installed on your PC. To find it open a terminal and &lt;br /&gt;
 &amp;gt; which virtualbox&lt;br /&gt;
 /usr/bin/virtualbox&lt;br /&gt;
 &amp;gt; /usr/bin/virtualbo&lt;br /&gt;
* Goto Menu Item &amp;quot;File&amp;quot;, then &amp;quot;Import Appliance&amp;quot; (File-&amp;gt;Import Appliance)&lt;br /&gt;
* In the topmost field, type in the name of the downloaded Appliance File or search for it via the finder that opens when clicking the button to the right.&lt;br /&gt;
&lt;br /&gt;
[[File:QM1.png|400px|Screenshot before Import]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM2.png|400px|Screenshot Image selection]]&lt;br /&gt;
&lt;br /&gt;
[[File:QM3.png|400px|Screenshot during Import]]&lt;br /&gt;
&lt;br /&gt;
* Proceed until the virtual machine has been successfully created.&lt;br /&gt;
&lt;br /&gt;
== Starting the Virtual Machine ==&lt;br /&gt;
&lt;br /&gt;
After import, the VirtualBox window looks roughly so:&lt;br /&gt;
&lt;br /&gt;
[[File:QM4.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
* Double-Click on the Virtual Machine Icon of the VirtualBox program.&lt;br /&gt;
* Within a few seconds, the window of the virtual machine will open and eventually you will see the graphical window of a running VM, into which you are automatically logged in as user `max`.&lt;br /&gt;
&lt;br /&gt;
[[File:QM5.png|400px|irtualBox Window after Import]]&lt;br /&gt;
&lt;br /&gt;
== Updating the Yambo tutorial files ==&lt;br /&gt;
&lt;br /&gt;
Now that the Yambo VM is running open a terminal window (black icon with &#039;&amp;gt;&#039; on the left) and &lt;br /&gt;
&lt;br /&gt;
* read the &#039;&#039;RELEASE_NOTES.txt&#039;&#039; that are on your Desktop.&lt;br /&gt;
* update the Yambo tutorial files&lt;br /&gt;
&lt;br /&gt;
 &amp;gt; cd YAMBO_TUTORIALS&lt;br /&gt;
 &amp;gt; git pull&lt;br /&gt;
 &amp;gt; ./setup.pl -install&lt;br /&gt;
&lt;br /&gt;
Now you are ready to do your tutorials.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reducing the size of the VM image ==&lt;br /&gt;
Open a terminal in the VM and type&lt;br /&gt;
&lt;br /&gt;
 sudo dd if=/dev/zero | pv | sudo dd of=/bigemptyfile bs=4096k&lt;br /&gt;
 sudo rm -rf /bigemptyfile&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4821</id>
		<title>CECAM VIRTUAL 2021</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=CECAM_VIRTUAL_2021&amp;diff=4821"/>
		<updated>2021-04-06T16:29:13Z</updated>

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

		<summary type="html">&lt;p&gt;Aferretti: /* 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;
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         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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4818</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=4818"/>
		<updated>2021-04-06T16:05:24Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* 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 &#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;
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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_hBN_Yambo_Virtual_2021_version&amp;diff=4817</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=4817"/>
		<updated>2021-04-06T16:04:45Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* 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 &#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 includes also the calculation of the exchange self-energy&lt;br /&gt;
(simply, it 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;
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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3722</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3722"/>
		<updated>2020-01-28T16:17:37Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* MPI vs OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following. In the following we stopped increasing the number of threads up to 8 because of the&lt;br /&gt;
specific architecture used in the runs (a dual socket machine with 8 cores/socket).&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
 # ncores         MPI     threads         dip          Xo          X       io_X       io_WF       Sgm_x        Sgm_c  WALL_TIME&lt;br /&gt;
       16           2           8     3.6816s   386.0552s    0.0856s    0.0268s     0.2163s    18.9077s    530.0875s     15m43s&lt;br /&gt;
       16           4           4     0.9950s    82.5070s    0.1098s    0.0299s     0.2051s     3.0837s    122.6565s     03m32s&lt;br /&gt;
       16           8           2     0.8524s    72.6708s    0.0986s    0.0293s     0.2282s     3.0379s     88.1589s     02m48s&lt;br /&gt;
       16          16           1     0.7653s    68.2550s    0.1048s    0.0309s     0.2463s     2.9211s     72.6220s     02m27s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. Nevertheless, note that the relative performance of the different parallel configurations&lt;br /&gt;
may strongly depend on the actual machine you are running on.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
The &amp;lt;b&amp;gt;total memory usage&amp;lt;/b&amp;gt; is also very critical since the GW method may have a large memory footprint.&lt;br /&gt;
If you have compiled yambo with the flag &amp;lt;code&amp;gt;--enable-memory-profile&amp;lt;/code&amp;gt;, the memory usage is tracked and the maximum allocated mem&lt;br /&gt;
is printed in the report file, and can be extracted typing:&lt;br /&gt;
 $ grep &amp;quot;Max memory used&amp;quot;  &amp;lt;report_file&amp;gt;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In general yambo can distribute memory when using MPI parallelism (though the actual amount depends on the distribution of MPI tasks across MPI levels). &lt;br /&gt;
Nevertheless, some memory replication is still present. In general, within the node OpenMP helps in easing the memory usage. Therefore, in cases where the node memori is &lt;br /&gt;
tight, one may consider changing some MPI tasks for OpenMP threads within the node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
* with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3721</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3721"/>
		<updated>2020-01-28T16:17:05Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* MPI vs OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following. In the following we stopped increasing the number of threads up to 8 because of the&lt;br /&gt;
specific architecture used in the runs (a dual socket machine with 8 cores/socket).&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
 # ncores         MPI     threads         dip          Xo          X       io_X       io_WF       Sgm_x        Sgm_c  WALL_TIME&lt;br /&gt;
       16           2           8     3.6816s   386.0552s    0.0856s    0.0268s     0.2163s    18.9077s    530.0875s     15m43s&lt;br /&gt;
       16           4           4     0.9950s    82.5070s    0.1098s    0.0299s     0.2051s     3.0837s    122.6565s     03m32s&lt;br /&gt;
       16           8           2     0.8524s    72.6708s    0.0986s    0.0293s     0.2282s     3.0379s     88.1589s     02m48s&lt;br /&gt;
       16          16           1     0.7653s    68.2550s    0.1048s    0.0309s     0.2463s     2.9211s     72.6220s     02m27s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. Nevertheless, note that the relative performance of the different parallel configurations&lt;br /&gt;
may strongly depend on the actual machine you are running on.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
The &amp;lt;b&amp;gt;total memory usage&amp;lt;/b&amp;gt; is also very critical since the GW method may have a large memory footprint.&lt;br /&gt;
If you have compiled yambo with the flag &amp;lt;code&amp;gt;--enable-memory-profile&amp;lt;/code&amp;gt;, the memory usage is tracked and the maximum allocated mem&lt;br /&gt;
is printed in the report file, and can be extracted typing:&lt;br /&gt;
 $ grep &amp;quot;Max memory used&amp;quot;  &amp;lt;report_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In general yambo can distribute memory when using MPI parallelism (though the actual amount depends on the distribution of MPI tasks across MPI levels). &lt;br /&gt;
Nevertheless, some memory replication is still present. In general, within the node OpenMP helps in easing the memory usage. Therefore, in cases where the node memori is &lt;br /&gt;
tight, one may consider changing some MPI tasks for OpenMP threads within the node.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
* with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3718</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3718"/>
		<updated>2020-01-28T15:59:45Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* MPI vs OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following. In the following we stopped increasing the number of threads up to 8 because of the&lt;br /&gt;
specific architecture used in the runs (a dual socket machine with 8 cores/socket).&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
 # ncores         MPI     threads         dip          Xo          X       io_X       io_WF       Sgm_x        Sgm_c  WALL_TIME&lt;br /&gt;
       16           2           8     3.6816s   386.0552s    0.0856s    0.0268s     0.2163s    18.9077s    530.0875s     15m43s&lt;br /&gt;
       16           4           4     0.9950s    82.5070s    0.1098s    0.0299s     0.2051s     3.0837s    122.6565s     03m32s&lt;br /&gt;
       16           8           2     0.8524s    72.6708s    0.0986s    0.0293s     0.2282s     3.0379s     88.1589s     02m48s&lt;br /&gt;
       16          16           1     0.7653s    68.2550s    0.1048s    0.0309s     0.2463s     2.9211s     72.6220s     02m27s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. Nevertheless, note that the relative performance of the different parallel configurations&lt;br /&gt;
may strongly depend on the actual machine you are running on.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
The total memory usage is also very critical since the GW method may have a large memory footprint.&lt;br /&gt;
If you have compiled yambo with the flag &amp;lt;code&amp;gt;--enable-memory-profile&amp;lt;/code&amp;gt;, the memory usage is tracked and the maximum allocated mem&lt;br /&gt;
is printed in the report file, and can be extracted typing:&lt;br /&gt;
 $ grep &amp;quot;Max memory used&amp;quot;  &amp;lt;report_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
* with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3717</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3717"/>
		<updated>2020-01-28T15:58:40Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* MPI vs OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following. In the following we stopped increasing the number of threads up to 8 because of the&lt;br /&gt;
specific architecture used in the runs (a dual socket machine with 8 cores/socket).&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
 # ncores         MPI     threads         dip          Xo          X       io_X       io_WF       Sgm_x        Sgm_c  WALL_TIME&lt;br /&gt;
       16           2           8     3.6816s   386.0552s    0.0856s    0.0268s     0.2163s    18.9077s    530.0875s     15m43s&lt;br /&gt;
       16           4           4     0.9950s    82.5070s    0.1098s    0.0299s     0.2051s     3.0837s    122.6565s     03m32s&lt;br /&gt;
       16           8           2     0.8524s    72.6708s    0.0986s    0.0293s     0.2282s     3.0379s     88.1589s     02m48s&lt;br /&gt;
       16          16           1     0.7653s    68.2550s    0.1048s    0.0309s     0.2463s     2.9211s     72.6220s     02m27s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. Nevertheless, note that the relative performance of the different parallel configurations&lt;br /&gt;
may strongly depend on the actual machine you are running on.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
The total memory usage is also very critical since the GW method may have a large memory footprint.&lt;br /&gt;
If you have compiled yambo with the flag &amp;lt;code&amp;gt;--enable-memory-profile&amp;lt;/code&amp;gt;, the memory usage is tracked and the maximum allocated mem&lt;br /&gt;
is printed in the report file, and can be extracted typing:&lt;br /&gt;
 $ grep &amp;quot;Max memory used&amp;quot;  &amp;lt;report_file&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;--!&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
* with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3716</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3716"/>
		<updated>2020-01-28T15:18:52Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* MPI vs OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following. In the following we stopped increasing the number of threads up to 8 because of the&lt;br /&gt;
specific architecture used in the runs (a dual socket machine with 8 cores/socket).&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
 # ncores         MPI     threads         dip          Xo          X       io_X       io_WF       Sgm_x        Sgm_c  WALL_TIME&lt;br /&gt;
       16           2           8     3.6816s   386.0552s    0.0856s    0.0268s     0.2163s    18.9077s    530.0875s     15m43s&lt;br /&gt;
       16           4           4     0.9950s    82.5070s    0.1098s    0.0299s     0.2051s     3.0837s    122.6565s     03m32s&lt;br /&gt;
       16           8           2     0.8524s    72.6708s    0.0986s    0.0293s     0.2282s     3.0379s     88.1589s     02m48s&lt;br /&gt;
       16          16           1     0.7653s    68.2550s    0.1048s    0.0309s     0.2463s     2.9211s     72.6220s     02m27s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. Nevertheless, note that the relative performance of the different parallel configurations&lt;br /&gt;
may strongly depend on the actual machine you are running on.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3713</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3713"/>
		<updated>2020-01-28T14:44:36Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following. In the following we stopped increasing the number of threads up to 8 because of the&lt;br /&gt;
specific architecture used in the runs (a dual socket machine with 8 cores/socket).&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Scaling_MPI_corvina.jpg&amp;diff=3712</id>
		<title>File:Scaling MPI corvina.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Scaling_MPI_corvina.jpg&amp;diff=3712"/>
		<updated>2020-01-28T14:42:47Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: Aferretti uploaded a new version of File:Scaling MPI corvina.jpg&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=={{int:filedesc}}==&lt;br /&gt;
{{Information&lt;br /&gt;
|description={{en|1=Yambo tutorial image, MPI scaling, corvina}}&lt;br /&gt;
|date=2020-01-28&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Aferretti|Aferretti]]&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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3711</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3711"/>
		<updated>2020-01-28T14:35:54Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* MPI vs OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3710</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3710"/>
		<updated>2020-01-28T14:35:05Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following&lt;br /&gt;
&lt;br /&gt;
 # ncores   threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3709</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3709"/>
		<updated>2020-01-28T14:34:42Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure OpenMP scaling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce data similar to the following&lt;br /&gt;
&lt;br /&gt;
 # ncores    threads         dip          Xo           X         io_X       io_WF       Sgm_x         Sgm_c   WALL_TIME&lt;br /&gt;
       1          1     4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s      15m7.00s      29m29s&lt;br /&gt;
       2          2     3.1971s   549.1491s     0.2248s      0.0298s     0.2491s    17.6552s     584.3692s      19m17s&lt;br /&gt;
       4          4     2.9419s   358.5202s     0.1928s      0.0289s     0.2590s     9.2010s     421.2219s      13m15s&lt;br /&gt;
       8          8     2.7992s   344.3342s     0.2332s      0.0325s     0.2543s     5.4334s     362.6982s      11m58s&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3708</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3708"/>
		<updated>2020-01-28T14:25:52Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure MPI scaling with default parallelization scheme */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_MPI_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce a plot similar to the following&lt;br /&gt;
&lt;br /&gt;
[[File:scaling_omp_fermi.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=File:Scaling_MPI_corvina.jpg&amp;diff=3707</id>
		<title>File:Scaling MPI corvina.jpg</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=File:Scaling_MPI_corvina.jpg&amp;diff=3707"/>
		<updated>2020-01-28T14:24:22Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: 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, MPI scaling, corvina}}&lt;br /&gt;
|date=2020-01-28&lt;br /&gt;
|source={{own}}&lt;br /&gt;
|author=[[User:Aferretti|Aferretti]]&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>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3706</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3706"/>
		<updated>2020-01-28T14:23:17Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure MPI scaling with default parallelization scheme */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot produced on a local cluster equipped with two Intel(R) Xeon(R) Silver 4208 CPU @ 2.10GHz processors per node (16 physical cares/node).&lt;br /&gt;
[[File:scaling_mpi_corvina.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
- you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce a plot similar to the following&lt;br /&gt;
&lt;br /&gt;
[[File:scaling_omp_fermi.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3705</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3705"/>
		<updated>2020-01-28T14:19:07Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure MPI scaling with default parallelization scheme */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s    140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s     72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot performed on Fermi&lt;br /&gt;
[[File:scaling_mpi_fermi.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
- you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce a plot similar to the following&lt;br /&gt;
&lt;br /&gt;
[[File:scaling_omp_fermi.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3704</id>
		<title>GW parallel strategies</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_parallel_strategies&amp;diff=3704"/>
		<updated>2020-01-28T14:18:31Z</updated>

		<summary type="html">&lt;p&gt;Aferretti: /* Pure MPI scaling with default parallelization scheme */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;This modules contains very general discussions of the parallel environment of Yambo. &lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Still the actual run of the code is specific to the CECAM cluster. If you want to run it  just replace the parallel queue instructions with simple MPI commands. THIS PAGE NEEDS TO BE UPDATED&#039;&#039;&#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
In this tutorial we will see how to setup the variables governing the parallel execution of yambo in order to perform efficient calculations in terms of both cpu time and memory to solution. As a test case we will consider the hBN 2D material. Because of its reduced dimensionality, GW calculations turns out to be very delicate. Beside the usual convergence studies with respect to k-points and sums-over-bands, in low dimensional systems a sensible amount of vacuum is required in order to treat the system as isolated, translating into a large number of plane-waves. As for other tutorials, it is important to stress that this tutorial it is meant to illustrate the functionality of the key variables and to run in reasonable time, so it has not the purpose to reach the desired accuracy to reproduce experimental results. Moreover please also note that scaling performance illustrated below may be significantly dependent on the underlying parallel architecture. Nevertheless, general considerations are tentatively drawn in discussing the results.&lt;br /&gt;
&lt;br /&gt;
==Files and Tools==&lt;br /&gt;
Database and tools can be downloaded here:&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/parse_yambo.py parse_yambo.py].  &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/run.sh run.sh]. &#039;&#039;&#039;(broken link)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
and also&lt;br /&gt;
&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN.tar.gz hBN.tar.gz]&lt;br /&gt;
*[http://www.yambo-code.org/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Getting familiar with yambo in parallel ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start by copying the tutorial files in the cluster and unzip them in the folder you will run the tutorial.&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cp $path/hBN-2D-para.tar.gz ./&lt;br /&gt;
 $ tar -zxvf hBN-2D-para.tar.gz&lt;br /&gt;
 $ cd ./hBN-2D-para/YAMBO&lt;br /&gt;
Under the YAMBO folder, together with the SAVE folder, you will see the run.sh script&lt;br /&gt;
&lt;br /&gt;
 $ ls&lt;br /&gt;
 parse_qp.py parse_ytiming.py  SAVE&lt;br /&gt;
&lt;br /&gt;
First, run the initialization as usual.&lt;br /&gt;
Then you need to generate the input file for a GW run.&lt;br /&gt;
 $ yambo -g n -p p -F yambo_gw.in &lt;br /&gt;
After setting the variables in red, the new input file should look like the following:&lt;br /&gt;
 $ cat yambo_gw.in&lt;br /&gt;
&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 X_Threads=  0                # [OPENMP/X] Number of threads for response functions &lt;br /&gt;
 DIP_Threads=  0              # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_Threads=  0               # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 EXXRLvcs= 21817        RL    # [XX] Exchange RL components&lt;br /&gt;
 VXCRLvcs= 21817        RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
     1 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4            Ry&amp;lt;/span&amp;gt;    # [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 |  &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;300&amp;lt;/span&amp;gt; |               # [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;
   1| &amp;lt;span style=&amp;quot;color: red&amp;quot;&amp;gt;4| 1| 8&amp;lt;/span&amp;gt;|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Now you need to create a submission script. here below an example (run.sh) based on the SLURM scheduler. In the case of other schedulers, the header should be updated accordingly.&lt;br /&gt;
 $ cat run.sh&lt;br /&gt;
  &lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH -N 1&lt;br /&gt;
 #SBATCH -t 06:00:00 &lt;br /&gt;
 #SBATCH -J test&lt;br /&gt;
 #SBATCH --partition=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;queue name&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=1&lt;br /&gt;
 tasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=1&lt;br /&gt;
 ncpu=`echo $nodes $tasks_per_node | awk &#039;{print $1*$2}&#039;`&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;needed modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 module load &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;more modules&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 bindir=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&amp;lt;path to yambo bindir&amp;gt;&amp;lt;/span&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=$nthreads&lt;br /&gt;
 &lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&lt;br /&gt;
 jdir=run_${label}&lt;br /&gt;
 cdir=run_${label}.out&lt;br /&gt;
 &lt;br /&gt;
 filein0=yambo_gw.in&lt;br /&gt;
 filein=yambo_gw_${label}.in&lt;br /&gt;
 &lt;br /&gt;
 cp -f $filein0 $filein&lt;br /&gt;
 cat &amp;gt;&amp;gt; $filein &amp;lt;&amp;lt; EOF&lt;br /&gt;
 &lt;br /&gt;
 DIP_CPU= &amp;quot;1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;k c v&amp;quot;         # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=  0            # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0              # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 SE_CPU= &amp;quot; 1 $ncpu 1&amp;quot;       # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;         # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Running on $ncpu MPI, $nthreads OpenMP threads&amp;quot;&lt;br /&gt;
 mpirun -np $ncpu  $bindir/yambo -F $filein -J $jdir -C $cdir&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As soon as you are ready to submit the job.&lt;br /&gt;
&lt;br /&gt;
 $ sbatch run.sh&lt;br /&gt;
&lt;br /&gt;
Yambo calculates the GW-qp corrections running on 1 MPI process with a single thread.&lt;br /&gt;
As you can see, monitoring the log file produced by yambo, the run takes some time, although&lt;br /&gt;
we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
The status of the jobs can be monitored via:&lt;br /&gt;
 $ squeue  -u $USER        # to inspect the status of jobs &lt;br /&gt;
                           # (hint: make a unix alias, if you like)&lt;br /&gt;
 $ scancel  &amp;lt;jobid&amp;gt;        # to delete jobs in the queue&lt;br /&gt;
&lt;br /&gt;
== Pure MPI scaling with default parallelization scheme ==&lt;br /&gt;
&lt;br /&gt;
Meanwhile we can run the code in parallel. Let&#039;s use consider the case of a node having 16 cores (you can try to adapt the following discussion to the actual maximum number of&lt;br /&gt;
cores/node you have in your system). As a first run, we&#039;ll use 16 MPI tasks, still with a single thread.&lt;br /&gt;
To this end modify the run.sh script changing&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time the code should be much faster.&lt;br /&gt;
Once the run is over try to run the simulation also on 2, 4, 8 MPI tasks.&lt;br /&gt;
Each time, please remember to change both the number of tasks per node both in the header and in the &amp;lt;code&amp;gt;ntasks_per_node&amp;lt;/code&amp;gt; variable.  &lt;br /&gt;
Finally, you can try to produce a scaling plot.&lt;br /&gt;
&lt;br /&gt;
To analyze the data you can use the phyton script parse_ytiming.py run which is provided.&lt;br /&gt;
&lt;br /&gt;
You can use it running&lt;br /&gt;
 $ ./parse_ytiming.py run*/r-*&lt;br /&gt;
&lt;br /&gt;
You should obtain something like that (but with more columns)&lt;br /&gt;
 # ncores       dip          Xo           X         io_X       io_WF       Sgm_x        Sgm_c     (REDUX)   WALL_TIME&lt;br /&gt;
       1    4.7337s   13m39.00s     0.1500s      0.0241s     0.2487s    34.2143s     15m7.00s     0.0000s      29m29s&lt;br /&gt;
       4    1.6019s   218.7982s     0.0882s      0.0283s     0.2077s     9.3338s    242.4438s     0.0001s      07m54s&lt;br /&gt;
       8    1.0755s   127.3209s     0.0974s      0.0291s     0.2134s     5.4490s     140.7788s     0.6926s      04m38s&lt;br /&gt;
      12    0.7510s    89.1649s     0.1015s      0.0299s     0.2068s     4.2961s    109.1227s     0.0007s      03m26s&lt;br /&gt;
      16    0.7653s    68.2550s     0.1048s      0.0309s     0.2463s     2.9211s      72.6220s     0.2799s      02m27s&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Plot the execution time vs the number of MPI tasks&lt;br /&gt;
and check (do a log plot) how far you are from the ideal linear scaling.&lt;br /&gt;
Below a similar plot performed on Fermi&lt;br /&gt;
[[File:scaling_mpi_fermi.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- not all runlevels scale in in the same way &amp;lt;br&amp;gt;&lt;br /&gt;
- you should never overload the available number of cores&lt;br /&gt;
&lt;br /&gt;
== Pure OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Next step is instead to check the OpenMP scaling.&lt;br /&gt;
Set back&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
and now use&lt;br /&gt;
 ntasks_per_node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;16&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since we are already using 16 threads, we cannot also distribute among MPI tasks, i.e. ncpu will result equal to 1.&lt;br /&gt;
Try setting nthreads to 16, 8, 4 and 2 and again to plot the execution time vs the number of threads using the python script.&lt;br /&gt;
Again you should be able to produce a plot similar to the following&lt;br /&gt;
&lt;br /&gt;
[[File:scaling_omp_fermi.jpg|750px|center]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
* OpenMP usually shares the memory among threads, but not always &amp;lt;br&amp;gt;&lt;br /&gt;
* you should never overload the available number of cores &amp;lt;br&amp;gt;&lt;br /&gt;
* in principle, we could overload the cores setting more threads than the available total number of cores since a single core allows multi-thread operations&lt;br /&gt;
&lt;br /&gt;
== MPI vs OpenMP scaling ==&lt;br /&gt;
&lt;br /&gt;
Which is scaling better ? MPI or OpenMP?&lt;br /&gt;
How is the memory distributed?&lt;br /&gt;
&lt;br /&gt;
Now you can try running simulations with hybrid strategies.&lt;br /&gt;
Try for example setting:&lt;br /&gt;
&lt;br /&gt;
 #SBATCH --tasks-per-node=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ntasks_per_node= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8&amp;lt;/span&amp;gt;&lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can try to do scaling keeping the total number of threads per node (ntasks_per_node * nthreads) equal to 16.&lt;br /&gt;
Parsing the data we will obtain something similar to&lt;br /&gt;
&lt;br /&gt;
  # ncores         MPI     threads     Dipoles       Xo           X       Sgm_x       Sgm_c   WALL_TIME&lt;br /&gt;
      16           1          16       1.00s      38.00s       0.00s       2.00s      33.00s      01m25s&lt;br /&gt;
      16           2           8       2.00s      34.00s       0.00s       1.00s      16.00s      01m06s&lt;br /&gt;
      16           4           4       0.00s      34.00s       0.00s       1.00s      11.00s         56s&lt;br /&gt;
      16           8           2       0.00s      33.00s       0.00s       0.00s       9.00s         52s&lt;br /&gt;
      16          16           1       0.00s      35.00s       0.00s       0.00s       7.00s         54s&lt;br /&gt;
&lt;br /&gt;
As you can see here the total CPU time decreases more and more moving the parallelization from the OpenMP to the MPI level.&lt;br /&gt;
Sigma_c in particular scales better. However, the fastest run is not the one with 16 MPI task but the 8 2 configuration&lt;br /&gt;
since Xo is faster using a hybrid MPI-OpenMP scheme.&lt;br /&gt;
&lt;br /&gt;
However, CPU time is not the only parameter you need to check.&lt;br /&gt;
Also, the total memory usage is important&lt;br /&gt;
If you compare for example the two extreme cases (you can use)&lt;br /&gt;
 $ grep Gb run_MPI1_OMP*/l* | grep Alloc      (use this for the case with only one MPI proc)&lt;br /&gt;
 $ grep Gb run_MPI*_OMP*/LOG/l*_1 | grep Alloc  (use this for the case with more than one MPI proc)&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           1          16  &lt;br /&gt;
 &amp;lt;01s&amp;gt; [M  0.119 Gb] Alloc WF ( 0.112)&lt;br /&gt;
 &amp;lt;03s&amp;gt; [M  0.314 Gb] Alloc WF ( 0.306)&lt;br /&gt;
 &amp;lt;46s&amp;gt; [M  0.074 Gb] Alloc WF ( 0.056)&lt;br /&gt;
 &amp;lt;50s&amp;gt; [M  0.321 Gb] Alloc WF ( 0.306)&lt;br /&gt;
the numbers reported above refer to the total amount of memory use in the run.&lt;br /&gt;
&lt;br /&gt;
For the case&lt;br /&gt;
  # ncores         MPI     threads&lt;br /&gt;
      16           16          1&lt;br /&gt;
 &amp;lt;02s&amp;gt; P0001: [M  0.034 Gb] Alloc WF ( 0.026)&lt;br /&gt;
 &amp;lt;43s&amp;gt; P0001: [M  0.037 Gb] Alloc WF ( 0.019)&lt;br /&gt;
 &amp;lt;45s&amp;gt; P0001: [M  0.091 Gb] Alloc WF ( 0.076)&lt;br /&gt;
the numbers reported above refer to the total amount of memory per MPI task.&lt;br /&gt;
Multiplying by 16 you obtain an estimate of the total memory: 0.091*16=1.456 (0.076*16=1.216)&lt;br /&gt;
These last two numbers have to be compared with 0.321 (0.306)&lt;br /&gt;
As you can see yambo is distributing memory since the single MPI task uses less memory than&lt;br /&gt;
the total one needed (you can even compare with the serial case). However, it is not as efficient as&lt;br /&gt;
OpenMP in doing so.&lt;br /&gt;
&lt;br /&gt;
Using a hybrid scheme you may also consider running yambo on mode than one node.&lt;br /&gt;
To run on two nodes for example you need to set&lt;br /&gt;
 #SBATCH -N &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 nodes=&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2&amp;lt;/span&amp;gt;&lt;br /&gt;
accordingly you can now set &lt;br /&gt;
 nthreads= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4&amp;lt;/span&amp;gt;&lt;br /&gt;
This time you will use 32 cores with (16 per node) 4 OpenMP threads and 2*16/4=8 MPI tasks.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips:&#039;&#039;&#039; &amp;lt;br&amp;gt;&lt;br /&gt;
- in real life calculations running on n_cores &amp;gt; 100, it is a good idea to adopt a hybrid approach &amp;lt;br&amp;gt;&lt;br /&gt;
- with OpenMP, you cannot exit the single node, with MPI you can&lt;br /&gt;
&lt;br /&gt;
== Advanced: Comparing different parallelization schemes (optional) ==&lt;br /&gt;
&lt;br /&gt;
Up to now we used the default parallelization scheme.&lt;br /&gt;
Yambo also allows you to tune the parameters which controls the parallelization scheme.&lt;br /&gt;
To this end you can open again the job.sh script and modify the section where the yambo input &lt;br /&gt;
variables are set&lt;br /&gt;
&lt;br /&gt;
 X_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 1 $ncpu 1&amp;lt;/span&amp;gt;&amp;quot;      # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_ROLEs= &amp;quot;q g k c v&amp;quot;        # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 #X_nCPU_LinAlg_INV= $ncpu   # [PARALLEL] CPUs for Linear Algebra&lt;br /&gt;
 X_Threads=  0               # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 DIP_Threads=  0             # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 SE_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 1 $ncpu&amp;lt;/span&amp;gt;&amp;quot;         # [PARALLEL] CPUs for each role&lt;br /&gt;
 SE_ROLEs= &amp;quot;q qp b&amp;quot;          # [PARALLEL] CPUs roles (q,qp,b)&lt;br /&gt;
 SE_Threads=  0    &lt;br /&gt;
&lt;br /&gt;
In particular &amp;quot;X_CPU&amp;quot; sets how the MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
The possibilities are shown in the &amp;quot;X_ROLEs&amp;quot;. The same holds for &amp;quot;SE_CPU&amp;quot; and &amp;quot;SE_ROLEs&amp;quot; which control&lt;br /&gt;
how MPI Tasks are distributed in the calculation of the response function.&lt;br /&gt;
&lt;br /&gt;
Please try different parallelization schemes and check the performances of Yambo.&lt;br /&gt;
In doing so you should also change the jobname in the run.sh script&lt;br /&gt;
 label=MPI${ncpu}_OMP${nthreads}&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;_scheme1&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using the python script, you can then chenck how speed, memory and load balance between the CPUs are affected.&lt;br /&gt;
For more details see also the [[Using_Yambo_in_parallel|Parallel module]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tips: &amp;lt;br&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
* the product of the numbers entering each variable (i.e. X_CPU and SE_CPU) times the number of threads should always match the total number of cores (unless you want to overload the cores taking advantage of multi-threads) &amp;lt;br&amp;gt;&lt;br /&gt;
* using the X_Threads and SE_Threads variables you can think about setting different Hybrid schemes in between the screening and the self-energy runlevel.&lt;br /&gt;
* memory better scales if you parallelize on bands (c v b) &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on k-points performs similarly to parallelization on bands, but memory requires more memory &amp;lt;br&amp;gt;&lt;br /&gt;
* parallelization on q-points requires much less communication in between the MPI tasks. It maybe useful if you run on more than one node and the inter-node connection is slow&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; [[GW_parallel_strategies|GW Parallel]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: [[Pushing_convergence_in_parallel|GW Convergence]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Aferretti</name></author>
	</entry>
</feed>