<?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=Giacomo.sesti</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=Giacomo.sesti"/>
	<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Special:Contributions/Giacomo.sesti"/>
	<updated>2026-05-17T15:28:08Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Modena_2025&amp;diff=8788</id>
		<title>Modena 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Modena_2025&amp;diff=8788"/>
		<updated>2025-05-20T13:47:17Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* DAY 3 - Wednesday, 21 May */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A general description of the goal(s) of the school can be found on the [https://www.yambo-code.eu/2025/01/17/yambo-school-modena-2025/ Yambo main website]&lt;br /&gt;
&lt;br /&gt;
== Use CINECA computational resources ==&lt;br /&gt;
Yambo tutorials will be run on the Leonardo-DCGP partition. You can find info about Leonardo-DCGP [https://wiki.u-gov.it/confluence/display/SCAIUS/DCGP+Section here].&lt;br /&gt;
In order to access computational resources provided by CINECA you need your personal username and password that were sent you by the organizers.&lt;br /&gt;
&lt;br /&gt;
=== Connect to the cluster using ssh ===&lt;br /&gt;
&lt;br /&gt;
You can access Leonardo via &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; protocol in different ways.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using username and password &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use the following command replacing your username:&lt;br /&gt;
 ssh username@login.leonardo.cineca.it&lt;br /&gt;
&lt;br /&gt;
However, in this way you have to type your password each time you want to connect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using ssh key &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can setup a ssh key pair to avoid typing the password each time you want to connect to Leonardo. To do so, run the &amp;lt;code&amp;gt;ssh-keygen&amp;lt;/code&amp;gt; command to generate a private/public key pair:&lt;br /&gt;
 ssh-keygen -t rsa -b 4096 -f ~/.ssh/leonardo_rsa&lt;br /&gt;
 Generating public/private rsa key pair.&lt;br /&gt;
 Created directory &#039;/home/username/.ssh&#039;.&lt;br /&gt;
 Enter passphrase (empty for no passphrase): &lt;br /&gt;
 Enter same passphrase again: &lt;br /&gt;
 Your identification has been saved in /home/username/.ssh/leonardo_rsa&lt;br /&gt;
 Your public key has been saved in /home/username/.ssh/leonardo_rsa.pub&lt;br /&gt;
 The key fingerprint is:&lt;br /&gt;
 [...]&lt;br /&gt;
 The key&#039;s randomart image is:&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
Now you need to copy the &#039;&#039;&#039;public&#039;&#039;&#039; key to Leonardo. You can do that with the following command (for this step you need to type your password):&lt;br /&gt;
 ssh-copy-id -i ~/.ssh/leonardo_rsa username@login.leonardo.cineca.it&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Be aware that when running the &amp;lt;code&amp;gt;ssh-copy-id&amp;lt;/code&amp;gt; command, after typing &amp;quot;yes&amp;quot; at the prompt, you might see an error message like the one shown below. Don’t worry—just follow the instructions provided in this CINECA [https://wiki.u-gov.it/confluence/display/SCAIUS/FAQ#FAQ-Ikeepreceivingtheerrormessage%22WARNING:REMOTEHOSTIDENTIFICATIONHASCHANGED!%22evenifImodifyknown_hostfile guide to resolve the issue]. Once done, run the &amp;lt;code&amp;gt;ssh-copy-id&amp;lt;/code&amp;gt; command again.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
 /usr/bin/ssh-copy-id: &lt;br /&gt;
 ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&lt;br /&gt;
 ERROR: @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @&lt;br /&gt;
 ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&lt;br /&gt;
 ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
Once the public key has been copied, you can connect to Leonardo without having to type the password using the &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 ssh -i ~/.ssh/leonardo_rsa username@login.leonardo.cineca.it&lt;br /&gt;
&lt;br /&gt;
To simplify even more, you can paste the following lines in a file named &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; located inside the &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory adjusting the username:&lt;br /&gt;
 Host leonardo &lt;br /&gt;
  HostName login.leonardo.cineca.it&lt;br /&gt;
  User username&lt;br /&gt;
  IdentityFile ~/.ssh/leonardo_rsa&lt;br /&gt;
&lt;br /&gt;
With the &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; file setup you can connect simply with&lt;br /&gt;
 ssh leonardo&lt;br /&gt;
&lt;br /&gt;
=== General instructions to run tutorials ===&lt;br /&gt;
&lt;br /&gt;
Before proceeding, it is useful to know the different workspaces you have available on Leonardo, which can be accessed using environment variables. The main ones are:&lt;br /&gt;
* &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; directory associated to your username; &lt;br /&gt;
* &amp;lt;code&amp;gt;$WORK&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;work&amp;lt;/code&amp;gt; directory associated to the account where the computational resources dedicated to this school are allocated;&lt;br /&gt;
* &amp;lt;code&amp;gt;$SCRATCH&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;scratch&amp;lt;/code&amp;gt; directory associated to your username.&lt;br /&gt;
You can find more details about storage and FileSystems [https://wiki.u-gov.it/confluence/display/SCAIUS/4%3A+Data+storage+and+FileSystems here].&lt;br /&gt;
&lt;br /&gt;
Please don&#039;t forget to &#039;&#039;&#039;run all tutorials in your scratch directory&#039;&#039;&#039;:&lt;br /&gt;
 echo $SCRATCH&lt;br /&gt;
 /leonardo_scratch/large/userexternal/username&lt;br /&gt;
 cd $SCRATCH&lt;br /&gt;
&lt;br /&gt;
Computational resources on Leonardo are managed by the job scheduling system [https://slurm.schedmd.com/overview.html Slurm]. Most part of Yambo tutorials during this school can be run in serial, except some that need to be executed on multiple processors. Generally, Slurm batch jobs are submitted using a script, but the tutorials here are better understood if run interactively. The two procedures that we will use to submit interactive and non interactive jobs are explained below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Run a job using a batch script &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for the tutorials and examples that need to be run in parallel. In these cases you need to submit the job using a batch script &amp;lt;code&amp;gt;job.sh&amp;lt;/code&amp;gt;, whose generic structure is the following:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=JOB                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition= dcgp_usr_prod      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service &lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #          &lt;br /&gt;
 #SBATCH --nodes=&amp;lt;N&amp;gt;                     # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=&amp;lt;n&amp;gt;           # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --ntasks-per-socket=&amp;lt;n/2&amp;gt;       # Tasks invoked on each socket&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;c&amp;gt;             # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 mpirun -np ${SLURM_NTASKS} \&lt;br /&gt;
        yambo -F &amp;lt;input&amp;gt; -J &amp;lt;output&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that the instructions in the batch script must be compatible with the specific Leonardo-DCGP [https://wiki.u-gov.it/confluence/display/SCAIUS/DCGP+Section#DCGPSection-SLURMpartitions resources]. The complete list of Slurm options can be found [https://slurm.schedmd.com/sbatch.html here]. However you will find &#039;&#039;&#039;ready-to-use&#039;&#039;&#039; batch scripts in locations specified during the tutorials. &lt;br /&gt;
&lt;br /&gt;
To submit the job, use the &amp;lt;code&amp;gt;sbatch&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 sbatch job.sh&lt;br /&gt;
 Submitted batch job 15696508&lt;br /&gt;
&lt;br /&gt;
To check the job status, use the &amp;lt;code&amp;gt;squeue&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 squeue --me&lt;br /&gt;
            JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)&lt;br /&gt;
         15696508 dcgp_usr_   job.sh username  R       0:01      1 lrdn4135&lt;br /&gt;
&lt;br /&gt;
If you need to cancel your job, do:&lt;br /&gt;
 scancel &amp;lt;JOBID&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Open an interactive session &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for most of the tutorials, since the majority of these is meant to be run in serial (relatively to MPI parallelization) from the command line. Use the command below to open an interactive session of 4 hours:&lt;br /&gt;
 srun -A tra25_yambo -p dcgp_usr_prod --reservation=s_tra_yambo -N 1 -n 1 -c 4 -t 04:00:00 --gres=tmpfs:10g --pty /bin/bash&lt;br /&gt;
 srun: job 15694182 queued and waiting for resources&lt;br /&gt;
 srun: job 15694182 has been allocated resources&lt;br /&gt;
&lt;br /&gt;
We ask for 4 cpus-per-task (-c) because we can exploit OpenMP parallelization with the available resources.&lt;br /&gt;
&lt;br /&gt;
Then, you need to manually load &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; as in the batch script above:&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
&lt;br /&gt;
Finally, set the &amp;lt;code&amp;gt;OMP_NUM_THREADS&amp;lt;/code&amp;gt; environment variable to 4 using the appropriate Slurm environment variable:&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
&lt;br /&gt;
To close the interactive session when you have finished, log out of the compute node with the &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Plot results with gnuplot &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the tutorials you will often need to plot the results of the calculations. In order to do so on Leonardo, &#039;&#039;&#039;open a new terminal window&#039;&#039;&#039; and connect to Leonardo enabling X11 forwarding with the &amp;lt;code&amp;gt;-X&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 ssh -X leonardo&lt;br /&gt;
&lt;br /&gt;
Please note that &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; can be used in this way only from the login nodes:&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ cd &amp;lt;directory_with_data&amp;gt;&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 Terminal type is now &#039;...&#039;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Set up yambopy &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In order to run yambopy on Leonardo, you must first activate the python environment:&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 source /leonardo_work/tra25_yambo/env_yambopy/bin/activate&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Quick recap.&lt;br /&gt;
Before every tutorial, if you run on Leonardo, do the following steps&lt;br /&gt;
&lt;br /&gt;
 ssh leonardo&lt;br /&gt;
 cd $SCRATCH&lt;br /&gt;
 mkdir -p YAMBO_TUTORIALS &#039;&#039;&#039;#(Only if you didn&#039;t before)&#039;&#039;&#039;&lt;br /&gt;
 cd YAMBO_TUTORIALS&lt;br /&gt;
&lt;br /&gt;
Since the compute nodes are not connected to the external network, the tarballs must be downloaded before starting the interactive session.&lt;br /&gt;
Alternatively, once the interactive session has started, it is possible to access the tarballs by copying them from the following directories:&lt;br /&gt;
&lt;br /&gt;
 /leonardo_work/tra25_yambo/YAMBO_TUTORIALS&lt;br /&gt;
 /leonardo_work/tra25_yambo/YAMBOPY_TUTORIALS&lt;br /&gt;
&lt;br /&gt;
After that you can start the interactive session&lt;br /&gt;
&lt;br /&gt;
 srun -A tra25_yambo -p dcgp_usr_prod --reservation=s_tra_yambo -N 1 -n 1 -c 4 -t 04:00:00 --gres=tmpfs:10g --pty /bin/bash&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
set the environment variable for openMP &lt;br /&gt;
&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
&lt;br /&gt;
and load yambo or yambopy as explained above in the general instructions.&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 19 May === &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;16:15 - 18:30 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz&lt;br /&gt;
 $ ls&lt;br /&gt;
 hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
 $ ls&lt;br /&gt;
 &#039;&#039;&#039;hBN-2D&#039;&#039;&#039; &#039;&#039;&#039;hBN&#039;&#039;&#039; hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now that you have all the files, you may open the interactive job session with &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; as explained above and proceed with the tutorials.&lt;br /&gt;
&lt;br /&gt;
* [[First steps: walk through from DFT(standalone)|First steps: Initialization and more ]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 20 May ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:30 - 16:30 Linear response&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Next steps: RPA calculations (standalone)|Next steps: RPA calculations ]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;17:00 - 18:30 Introduction to Yambopy&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
At this point, you may learn about the python pre-postprocessing capabilities offered by yambopy, our python interface to yambo and QE. First of all, let&#039;s create a dedicated directory, download and extract the related files.&lt;br /&gt;
 &lt;br /&gt;
 $ cd $SCRATCH&lt;br /&gt;
 $ mkdir -p YAMBOPY_TUTORIALS&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS&lt;br /&gt;
 $ rsync -avzP /leonardo_work/tra25_yambo/YAMBOPY_TUTORIALS/yambopy_tutorial_Modena_2025.tar.gz .&lt;br /&gt;
 $ tar --strip-components=1 -xvzf yambopy_tutorial_Modena_2025.tar.gz&lt;br /&gt;
&lt;br /&gt;
Then, follow part 1 of the tutorial, which is related to DFT band structures, YAMBO initialization and linear response.&lt;br /&gt;
* [[Modena 2025 : Yambopy part 1]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 21 May ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:30 - 12:30 | 14:30 - 16:30 A tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get all the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/MoS2_2Dquasiparticle_tutorial_Modena2025.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
 $ tar -xvf MoS2_2Dquasiparticle_tutorial_Modena2025.tar.gz&lt;br /&gt;
 $ cd hBN&lt;br /&gt;
&lt;br /&gt;
Now you can start the first tutorial:&lt;br /&gt;
&lt;br /&gt;
* [[GW tutorial Rome 2023 | GW computations on practice: how to obtain the quasi-particle band structure of a bulk material ]]&lt;br /&gt;
&lt;br /&gt;
If you have gone through the first tutorial, pass now to the second one:&lt;br /&gt;
 &lt;br /&gt;
 $ cd $SCRATCH&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cd MoS2_2Dquasiparticle_tutorial_Modena2025&lt;br /&gt;
&lt;br /&gt;
* [[Quasi-particles of a 2D system | Quasi-particles of a 2D system ]]&lt;br /&gt;
&lt;br /&gt;
As for yambopy, the tutorial related to GW calculations is contained in the first section of Part 2&lt;br /&gt;
&lt;br /&gt;
* [[Modena 2025 : Yambopy part 2#GW calculations| Modena 2025 : Yambopy part 2 (GW calculations)]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;17:00 - 18:30 Bethe-Salpeter equation (BSE)&#039;&#039;&#039; Fulvio Paleari (CNR-Nano, Italy), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz # NOTE: YOU SHOULD ALREADY HAVE THIS FROM DAY 1&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-convergence-kpoints.tar.gz &lt;br /&gt;
 $ tar -xvf hBN-convergence-kpoints.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now, you may open the interactive job session with &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; and proceed with the following tutorials.&lt;br /&gt;
&lt;br /&gt;
* [[Calculating optical spectra including excitonic effects: a step-by-step guide|Perform a BSE calculation from beginning to end ]]&lt;br /&gt;
* [[How to analyse excitons - ICTP 2022 school|Analyse your results (exciton wavefunctions in real and reciprocal space, etc.) ]]&lt;br /&gt;
* [[BSE solvers overview|Solve the BSE eigenvalue problem with different numerical methods]]&lt;br /&gt;
* [[How to choose the input parameters|Choose the input parameters for a meaningful converged calculation]]&lt;br /&gt;
&lt;br /&gt;
Now, go into the yambopy tutorial directory to learn about python analysis tools for the BSE:&lt;br /&gt;
 $ cd $SCRATCH&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS/databases_yambopy&lt;br /&gt;
&lt;br /&gt;
* [[Modena 2025 : Yambopy part 2#Excitons| Modena 2025 : Yambopy part 2 (BSE calculations)]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, May 22 ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:30 - 16:00 Bethe-Salpeter (part 2)&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;16:30 - 17:30 Nonlinear response with the time dependent berry phase&#039;&#039;&#039; Myrta Gruning (Queen&#039;s University Belfast), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
For the tutorials we will use first the &amp;lt;code&amp;gt;hBN-2D-RT&amp;lt;/code&amp;gt; folder (k-sampling 10x10x1) and then the &amp;lt;code&amp;gt;hBN-2D&amp;lt;/code&amp;gt; folder (k-sampling 6x6x1)&lt;br /&gt;
You may already have them in the &amp;lt;code&amp;gt;YAMBO_TUTORIALS&amp;lt;/code&amp;gt; folder&lt;br /&gt;
 $ ls&lt;br /&gt;
 &#039;&#039;&#039;hBN-2D&#039;&#039;&#039; &#039;&#039;&#039;hBN-2D-RT&#039;&#039;&#039; hBN-2D.tar.gz  hBN-2D-RT.tar.gz&lt;br /&gt;
&lt;br /&gt;
If you need to download again the tutorial files, follow these steps (or see the above instructions):&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-RT.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D-RT.tar.gz&lt;br /&gt;
&lt;br /&gt;
* [[Prerequisites for Real Time propagation with Yambo (5.3)|Perform the setup for a real-time calculation]]&lt;br /&gt;
* [[Dielectric function from Bloch-states dynamics (5.3)|Dielectric function from Bloch-states dynamics]]&lt;br /&gt;
* [[Second-harmonic generation of 2D-hBN (5.3)|Second-harmonic generation of 2D-hBN]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 5 - Friday, 23 May ===&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 19 May ===&lt;br /&gt;
&lt;br /&gt;
* D. Varsano, [https://drive.google.com/file/d/1lbY6zF04WCcvZZhQy4TAIBca9wXHVmGG/view?usp=share_link Description and goal of the school].&lt;br /&gt;
* C. Franchini, [https://drive.google.com/file/d/1Z6GCjP4K1dM28ULsyYg2eckgUdYUSRph/view?usp=share_link First principles and data-driven correlated materials]&lt;br /&gt;
* F. Mohamed, [https://drive.google.com/file/d/1ITddkGTM12Gw5QxnZjAQpfZgYH0FvJL1/view?usp=share_link A tour on Density Functional Theory]&lt;br /&gt;
* E. Cannuccia, [https://drive.google.com/file/d/1mBTcPrnfoqwcA5wXE8gXQMO_qttClHAd/view?usp=share_link Electronic screening and linear response theory]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 20 May ===&lt;br /&gt;
&lt;br /&gt;
* A. Marini, [https://drive.google.com/file/d/1HTIPHkH2sBaVDLFwwS34T-fJ9x8FhVPq/view?usp=share_link Introduction to Many-Body Perturbation Theory]&lt;br /&gt;
* C. Cardoso, [https://drive.google.com/file/d/1SR9BtFKgz6Y1gaHSKF1s8xzb42D5C1Xg/view?usp=share_link Quasiparticles and the GW Approximation]&lt;br /&gt;
* A. Guandalini, [https://drive.google.com/file/d/1dgcdHMfA0b7jjyrCs4r9OrG6qpiu1v39/view?usp=share_link GW in practice: algorithms and approximations]&lt;br /&gt;
* G. Sesti, [https://drive.google.com/file/d/1te_85k9jgSymr3Av86rKOu0-tA-7sGWq/view?usp=sharing  GW advanced algorithms]&lt;br /&gt;
* M. Govoni, [https://drive.google.com/file/d/1XBa5RgmwKdYSy4mj_COXwbUQd3DPgRe4/view?usp=share_link GW without empty states and investigation of neutral excitations by embedding full configuration interaction in DFT+GW]&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 21 May ===&lt;br /&gt;
&lt;br /&gt;
* M. Palummo, [https://drive.google.com/file/d/1pQ491hqpETVLchL92QPy4f_jWqfMK5xf/view?usp=share_link Optical absorption and excitons via the Bethe-Salpeter Equation]&lt;br /&gt;
* D. Sangalli, Real-time simulations&lt;br /&gt;
* F. Paleari, Introduction to YamboPy (automation and post-processing)&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, 22 May ===&lt;br /&gt;
&lt;br /&gt;
* E. Luppi, An introduction to Non-linear spectroscopy&lt;br /&gt;
* M. Grüning, [https://drive.google.com/file/d/1bZF0f3AD-WL3M3vCtvrnA_1W94SKt-Gf/view?usp=sharing Non-linear spectroscopy in Yambo]&lt;br /&gt;
* F. Affinito, Frontiers in High-Performance Computing&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8787</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8787"/>
		<updated>2025-05-20T13:46:45Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial_Modena2025/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;  # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;    # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1    # [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                 # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:04:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile               # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod       # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI4_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like leonardo, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 4 cpus with 2 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Modena_2025&amp;diff=8786</id>
		<title>Modena 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Modena_2025&amp;diff=8786"/>
		<updated>2025-05-20T13:46:06Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* DAY 3 - Wednesday, 21 May */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A general description of the goal(s) of the school can be found on the [https://www.yambo-code.eu/2025/01/17/yambo-school-modena-2025/ Yambo main website]&lt;br /&gt;
&lt;br /&gt;
== Use CINECA computational resources ==&lt;br /&gt;
Yambo tutorials will be run on the Leonardo-DCGP partition. You can find info about Leonardo-DCGP [https://wiki.u-gov.it/confluence/display/SCAIUS/DCGP+Section here].&lt;br /&gt;
In order to access computational resources provided by CINECA you need your personal username and password that were sent you by the organizers.&lt;br /&gt;
&lt;br /&gt;
=== Connect to the cluster using ssh ===&lt;br /&gt;
&lt;br /&gt;
You can access Leonardo via &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; protocol in different ways.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using username and password &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use the following command replacing your username:&lt;br /&gt;
 ssh username@login.leonardo.cineca.it&lt;br /&gt;
&lt;br /&gt;
However, in this way you have to type your password each time you want to connect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using ssh key &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can setup a ssh key pair to avoid typing the password each time you want to connect to Leonardo. To do so, run the &amp;lt;code&amp;gt;ssh-keygen&amp;lt;/code&amp;gt; command to generate a private/public key pair:&lt;br /&gt;
 ssh-keygen -t rsa -b 4096 -f ~/.ssh/leonardo_rsa&lt;br /&gt;
 Generating public/private rsa key pair.&lt;br /&gt;
 Created directory &#039;/home/username/.ssh&#039;.&lt;br /&gt;
 Enter passphrase (empty for no passphrase): &lt;br /&gt;
 Enter same passphrase again: &lt;br /&gt;
 Your identification has been saved in /home/username/.ssh/leonardo_rsa&lt;br /&gt;
 Your public key has been saved in /home/username/.ssh/leonardo_rsa.pub&lt;br /&gt;
 The key fingerprint is:&lt;br /&gt;
 [...]&lt;br /&gt;
 The key&#039;s randomart image is:&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
Now you need to copy the &#039;&#039;&#039;public&#039;&#039;&#039; key to Leonardo. You can do that with the following command (for this step you need to type your password):&lt;br /&gt;
 ssh-copy-id -i ~/.ssh/leonardo_rsa username@login.leonardo.cineca.it&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Be aware that when running the &amp;lt;code&amp;gt;ssh-copy-id&amp;lt;/code&amp;gt; command, after typing &amp;quot;yes&amp;quot; at the prompt, you might see an error message like the one shown below. Don’t worry—just follow the instructions provided in this CINECA [https://wiki.u-gov.it/confluence/display/SCAIUS/FAQ#FAQ-Ikeepreceivingtheerrormessage%22WARNING:REMOTEHOSTIDENTIFICATIONHASCHANGED!%22evenifImodifyknown_hostfile guide to resolve the issue]. Once done, run the &amp;lt;code&amp;gt;ssh-copy-id&amp;lt;/code&amp;gt; command again.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
 /usr/bin/ssh-copy-id: &lt;br /&gt;
 ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&lt;br /&gt;
 ERROR: @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @&lt;br /&gt;
 ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&lt;br /&gt;
 ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
Once the public key has been copied, you can connect to Leonardo without having to type the password using the &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 ssh -i ~/.ssh/leonardo_rsa username@login.leonardo.cineca.it&lt;br /&gt;
&lt;br /&gt;
To simplify even more, you can paste the following lines in a file named &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; located inside the &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory adjusting the username:&lt;br /&gt;
 Host leonardo &lt;br /&gt;
  HostName login.leonardo.cineca.it&lt;br /&gt;
  User username&lt;br /&gt;
  IdentityFile ~/.ssh/leonardo_rsa&lt;br /&gt;
&lt;br /&gt;
With the &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; file setup you can connect simply with&lt;br /&gt;
 ssh leonardo&lt;br /&gt;
&lt;br /&gt;
=== General instructions to run tutorials ===&lt;br /&gt;
&lt;br /&gt;
Before proceeding, it is useful to know the different workspaces you have available on Leonardo, which can be accessed using environment variables. The main ones are:&lt;br /&gt;
* &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; directory associated to your username; &lt;br /&gt;
* &amp;lt;code&amp;gt;$WORK&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;work&amp;lt;/code&amp;gt; directory associated to the account where the computational resources dedicated to this school are allocated;&lt;br /&gt;
* &amp;lt;code&amp;gt;$SCRATCH&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;scratch&amp;lt;/code&amp;gt; directory associated to your username.&lt;br /&gt;
You can find more details about storage and FileSystems [https://wiki.u-gov.it/confluence/display/SCAIUS/4%3A+Data+storage+and+FileSystems here].&lt;br /&gt;
&lt;br /&gt;
Please don&#039;t forget to &#039;&#039;&#039;run all tutorials in your scratch directory&#039;&#039;&#039;:&lt;br /&gt;
 echo $SCRATCH&lt;br /&gt;
 /leonardo_scratch/large/userexternal/username&lt;br /&gt;
 cd $SCRATCH&lt;br /&gt;
&lt;br /&gt;
Computational resources on Leonardo are managed by the job scheduling system [https://slurm.schedmd.com/overview.html Slurm]. Most part of Yambo tutorials during this school can be run in serial, except some that need to be executed on multiple processors. Generally, Slurm batch jobs are submitted using a script, but the tutorials here are better understood if run interactively. The two procedures that we will use to submit interactive and non interactive jobs are explained below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Run a job using a batch script &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for the tutorials and examples that need to be run in parallel. In these cases you need to submit the job using a batch script &amp;lt;code&amp;gt;job.sh&amp;lt;/code&amp;gt;, whose generic structure is the following:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=JOB                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition= dcgp_usr_prod      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service &lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #          &lt;br /&gt;
 #SBATCH --nodes=&amp;lt;N&amp;gt;                     # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=&amp;lt;n&amp;gt;           # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --ntasks-per-socket=&amp;lt;n/2&amp;gt;       # Tasks invoked on each socket&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;c&amp;gt;             # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 mpirun -np ${SLURM_NTASKS} \&lt;br /&gt;
        yambo -F &amp;lt;input&amp;gt; -J &amp;lt;output&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note that the instructions in the batch script must be compatible with the specific Leonardo-DCGP [https://wiki.u-gov.it/confluence/display/SCAIUS/DCGP+Section#DCGPSection-SLURMpartitions resources]. The complete list of Slurm options can be found [https://slurm.schedmd.com/sbatch.html here]. However you will find &#039;&#039;&#039;ready-to-use&#039;&#039;&#039; batch scripts in locations specified during the tutorials. &lt;br /&gt;
&lt;br /&gt;
To submit the job, use the &amp;lt;code&amp;gt;sbatch&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 sbatch job.sh&lt;br /&gt;
 Submitted batch job 15696508&lt;br /&gt;
&lt;br /&gt;
To check the job status, use the &amp;lt;code&amp;gt;squeue&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 squeue --me&lt;br /&gt;
            JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)&lt;br /&gt;
         15696508 dcgp_usr_   job.sh username  R       0:01      1 lrdn4135&lt;br /&gt;
&lt;br /&gt;
If you need to cancel your job, do:&lt;br /&gt;
 scancel &amp;lt;JOBID&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Open an interactive session &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for most of the tutorials, since the majority of these is meant to be run in serial (relatively to MPI parallelization) from the command line. Use the command below to open an interactive session of 4 hours:&lt;br /&gt;
 srun -A tra25_yambo -p dcgp_usr_prod --reservation=s_tra_yambo -N 1 -n 1 -c 4 -t 04:00:00 --gres=tmpfs:10g --pty /bin/bash&lt;br /&gt;
 srun: job 15694182 queued and waiting for resources&lt;br /&gt;
 srun: job 15694182 has been allocated resources&lt;br /&gt;
&lt;br /&gt;
We ask for 4 cpus-per-task (-c) because we can exploit OpenMP parallelization with the available resources.&lt;br /&gt;
&lt;br /&gt;
Then, you need to manually load &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; as in the batch script above:&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
&lt;br /&gt;
Finally, set the &amp;lt;code&amp;gt;OMP_NUM_THREADS&amp;lt;/code&amp;gt; environment variable to 4 using the appropriate Slurm environment variable:&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
&lt;br /&gt;
To close the interactive session when you have finished, log out of the compute node with the &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Plot results with gnuplot &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the tutorials you will often need to plot the results of the calculations. In order to do so on Leonardo, &#039;&#039;&#039;open a new terminal window&#039;&#039;&#039; and connect to Leonardo enabling X11 forwarding with the &amp;lt;code&amp;gt;-X&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 ssh -X leonardo&lt;br /&gt;
&lt;br /&gt;
Please note that &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; can be used in this way only from the login nodes:&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ cd &amp;lt;directory_with_data&amp;gt;&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 Terminal type is now &#039;...&#039;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Set up yambopy &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In order to run yambopy on Leonardo, you must first activate the python environment:&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 source /leonardo_work/tra25_yambo/env_yambopy/bin/activate&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
Quick recap.&lt;br /&gt;
Before every tutorial, if you run on Leonardo, do the following steps&lt;br /&gt;
&lt;br /&gt;
 ssh leonardo&lt;br /&gt;
 cd $SCRATCH&lt;br /&gt;
 mkdir -p YAMBO_TUTORIALS &#039;&#039;&#039;#(Only if you didn&#039;t before)&#039;&#039;&#039;&lt;br /&gt;
 cd YAMBO_TUTORIALS&lt;br /&gt;
&lt;br /&gt;
Since the compute nodes are not connected to the external network, the tarballs must be downloaded before starting the interactive session.&lt;br /&gt;
Alternatively, once the interactive session has started, it is possible to access the tarballs by copying them from the following directories:&lt;br /&gt;
&lt;br /&gt;
 /leonardo_work/tra25_yambo/YAMBO_TUTORIALS&lt;br /&gt;
 /leonardo_work/tra25_yambo/YAMBOPY_TUTORIALS&lt;br /&gt;
&lt;br /&gt;
After that you can start the interactive session&lt;br /&gt;
&lt;br /&gt;
 srun -A tra25_yambo -p dcgp_usr_prod --reservation=s_tra_yambo -N 1 -n 1 -c 4 -t 04:00:00 --gres=tmpfs:10g --pty /bin/bash&lt;br /&gt;
 [...]&lt;br /&gt;
&lt;br /&gt;
set the environment variable for openMP &lt;br /&gt;
&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
&lt;br /&gt;
and load yambo or yambopy as explained above in the general instructions.&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 19 May === &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;16:15 - 18:30 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz&lt;br /&gt;
 $ ls&lt;br /&gt;
 hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
 $ ls&lt;br /&gt;
 &#039;&#039;&#039;hBN-2D&#039;&#039;&#039; &#039;&#039;&#039;hBN&#039;&#039;&#039; hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now that you have all the files, you may open the interactive job session with &amp;lt;code&amp;gt;srun&amp;lt;/code&amp;gt; as explained above and proceed with the tutorials.&lt;br /&gt;
&lt;br /&gt;
* [[First steps: walk through from DFT(standalone)|First steps: Initialization and more ]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 20 May ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:30 - 16:30 Linear response&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Next steps: RPA calculations (standalone)|Next steps: RPA calculations ]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;17:00 - 18:30 Introduction to Yambopy&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
At this point, you may learn about the python pre-postprocessing capabilities offered by yambopy, our python interface to yambo and QE. First of all, let&#039;s create a dedicated directory, download and extract the related files.&lt;br /&gt;
 &lt;br /&gt;
 $ cd $SCRATCH&lt;br /&gt;
 $ mkdir -p YAMBOPY_TUTORIALS&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS&lt;br /&gt;
 $ rsync -avzP /leonardo_work/tra25_yambo/YAMBOPY_TUTORIALS/yambopy_tutorial_Modena_2025.tar.gz .&lt;br /&gt;
 $ tar --strip-components=1 -xvzf yambopy_tutorial_Modena_2025.tar.gz&lt;br /&gt;
&lt;br /&gt;
Then, follow part 1 of the tutorial, which is related to DFT band structures, YAMBO initialization and linear response.&lt;br /&gt;
* [[Modena 2025 : Yambopy part 1]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 21 May ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;11:30 - 12:30 | 14:30 - 16:30 A tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get all the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/MoS2_2Dquasiparticle_tutorial_Modena2025.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
 $ tar -xvf MoS2_2Dquasiparticle_tutorial_Modena2025.tar.gz&lt;br /&gt;
 $ cd hBN&lt;br /&gt;
&lt;br /&gt;
Now you can start the first tutorial:&lt;br /&gt;
&lt;br /&gt;
* [[GW tutorial Rome 2023 | GW computations on practice: how to obtain the quasi-particle band structure of a bulk material ]]&lt;br /&gt;
&lt;br /&gt;
If you have gone through the first tutorial, pass now to the second one:&lt;br /&gt;
 &lt;br /&gt;
 $ cd $SCRATCH&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ cd MoS2_HPC_tutorial&lt;br /&gt;
&lt;br /&gt;
* [[Quasi-particles of a 2D system | Quasi-particles of a 2D system ]]&lt;br /&gt;
&lt;br /&gt;
As for yambopy, the tutorial related to GW calculations is contained in the first section of Part 2&lt;br /&gt;
&lt;br /&gt;
* [[Modena 2025 : Yambopy part 2#GW calculations| Modena 2025 : Yambopy part 2 (GW calculations)]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;17:00 - 18:30 Bethe-Salpeter equation (BSE)&#039;&#039;&#039; Fulvio Paleari (CNR-Nano, Italy), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz # NOTE: YOU SHOULD ALREADY HAVE THIS FROM DAY 1&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-convergence-kpoints.tar.gz &lt;br /&gt;
 $ tar -xvf hBN-convergence-kpoints.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now, you may open the interactive job session with &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; and proceed with the following tutorials.&lt;br /&gt;
&lt;br /&gt;
* [[Calculating optical spectra including excitonic effects: a step-by-step guide|Perform a BSE calculation from beginning to end ]]&lt;br /&gt;
* [[How to analyse excitons - ICTP 2022 school|Analyse your results (exciton wavefunctions in real and reciprocal space, etc.) ]]&lt;br /&gt;
* [[BSE solvers overview|Solve the BSE eigenvalue problem with different numerical methods]]&lt;br /&gt;
* [[How to choose the input parameters|Choose the input parameters for a meaningful converged calculation]]&lt;br /&gt;
&lt;br /&gt;
Now, go into the yambopy tutorial directory to learn about python analysis tools for the BSE:&lt;br /&gt;
 $ cd $SCRATCH&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS/databases_yambopy&lt;br /&gt;
&lt;br /&gt;
* [[Modena 2025 : Yambopy part 2#Excitons| Modena 2025 : Yambopy part 2 (BSE calculations)]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, May 22 ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:30 - 16:00 Bethe-Salpeter (part 2)&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;16:30 - 17:30 Nonlinear response with the time dependent berry phase&#039;&#039;&#039; Myrta Gruning (Queen&#039;s University Belfast), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
For the tutorials we will use first the &amp;lt;code&amp;gt;hBN-2D-RT&amp;lt;/code&amp;gt; folder (k-sampling 10x10x1) and then the &amp;lt;code&amp;gt;hBN-2D&amp;lt;/code&amp;gt; folder (k-sampling 6x6x1)&lt;br /&gt;
You may already have them in the &amp;lt;code&amp;gt;YAMBO_TUTORIALS&amp;lt;/code&amp;gt; folder&lt;br /&gt;
 $ ls&lt;br /&gt;
 &#039;&#039;&#039;hBN-2D&#039;&#039;&#039; &#039;&#039;&#039;hBN-2D-RT&#039;&#039;&#039; hBN-2D.tar.gz  hBN-2D-RT.tar.gz&lt;br /&gt;
&lt;br /&gt;
If you need to download again the tutorial files, follow these steps (or see the above instructions):&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-RT.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D-RT.tar.gz&lt;br /&gt;
&lt;br /&gt;
* [[Prerequisites for Real Time propagation with Yambo (5.3)|Perform the setup for a real-time calculation]]&lt;br /&gt;
* [[Dielectric function from Bloch-states dynamics (5.3)|Dielectric function from Bloch-states dynamics]]&lt;br /&gt;
* [[Second-harmonic generation of 2D-hBN (5.3)|Second-harmonic generation of 2D-hBN]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 5 - Friday, 23 May ===&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 19 May ===&lt;br /&gt;
&lt;br /&gt;
* D. Varsano, [https://drive.google.com/file/d/1lbY6zF04WCcvZZhQy4TAIBca9wXHVmGG/view?usp=share_link Description and goal of the school].&lt;br /&gt;
* C. Franchini, [https://drive.google.com/file/d/1Z6GCjP4K1dM28ULsyYg2eckgUdYUSRph/view?usp=share_link First principles and data-driven correlated materials]&lt;br /&gt;
* F. Mohamed, [https://drive.google.com/file/d/1ITddkGTM12Gw5QxnZjAQpfZgYH0FvJL1/view?usp=share_link A tour on Density Functional Theory]&lt;br /&gt;
* E. Cannuccia, [https://drive.google.com/file/d/1mBTcPrnfoqwcA5wXE8gXQMO_qttClHAd/view?usp=share_link Electronic screening and linear response theory]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 20 May ===&lt;br /&gt;
&lt;br /&gt;
* A. Marini, [https://drive.google.com/file/d/1HTIPHkH2sBaVDLFwwS34T-fJ9x8FhVPq/view?usp=share_link Introduction to Many-Body Perturbation Theory]&lt;br /&gt;
* C. Cardoso, [https://drive.google.com/file/d/1SR9BtFKgz6Y1gaHSKF1s8xzb42D5C1Xg/view?usp=share_link Quasiparticles and the GW Approximation]&lt;br /&gt;
* A. Guandalini, [https://drive.google.com/file/d/1dgcdHMfA0b7jjyrCs4r9OrG6qpiu1v39/view?usp=share_link GW in practice: algorithms and approximations]&lt;br /&gt;
* G. Sesti, [https://drive.google.com/file/d/1te_85k9jgSymr3Av86rKOu0-tA-7sGWq/view?usp=sharing  GW advanced algorithms]&lt;br /&gt;
* M. Govoni, [https://drive.google.com/file/d/1XBa5RgmwKdYSy4mj_COXwbUQd3DPgRe4/view?usp=share_link GW without empty states and investigation of neutral excitations by embedding full configuration interaction in DFT+GW]&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 21 May ===&lt;br /&gt;
&lt;br /&gt;
* M. Palummo, [https://drive.google.com/file/d/1pQ491hqpETVLchL92QPy4f_jWqfMK5xf/view?usp=share_link Optical absorption and excitons via the Bethe-Salpeter Equation]&lt;br /&gt;
* D. Sangalli, Real-time simulations&lt;br /&gt;
* F. Paleari, Introduction to YamboPy (automation and post-processing)&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, 22 May ===&lt;br /&gt;
&lt;br /&gt;
* E. Luppi, An introduction to Non-linear spectroscopy&lt;br /&gt;
* M. Grüning, [https://drive.google.com/file/d/1bZF0f3AD-WL3M3vCtvrnA_1W94SKt-Gf/view?usp=sharing Non-linear spectroscopy in Yambo]&lt;br /&gt;
* F. Affinito, Frontiers in High-Performance Computing&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8780</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8780"/>
		<updated>2025-05-19T21:50:54Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;  # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;    # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1    # [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                 # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:04:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile               # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod       # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI4_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like leonardo, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 4 cpus with 2 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8779</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8779"/>
		<updated>2025-05-19T21:49:56Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;  # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;    # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1    # [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                 # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:04:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile               # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod       # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI4_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like leonardo, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 2 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8778</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8778"/>
		<updated>2025-05-19T21:47:50Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;  # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;    # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1    # [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                 # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile               # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod       # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI4_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like leonardo, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 2 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8777</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8777"/>
		<updated>2025-05-19T21:47:11Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;  # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;    # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1    # [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                 # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile               # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod       # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI4_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like leonardo, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 2 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8776</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8776"/>
		<updated>2025-05-19T21:45:49Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;  # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;    # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1    # [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                 # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile               # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod       # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=NCPU          # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=NOMP            # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8775</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8775"/>
		<updated>2025-05-19T21:42:43Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=NCPU          # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=NOMP            # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8774</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8774"/>
		<updated>2025-05-19T21:41:35Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8773</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8773"/>
		<updated>2025-05-19T21:41:14Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra25_yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=rutile                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition=dcgp_usr_prod      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --gres=tmpfs:10g                # List of generic consumable resources&lt;br /&gt;
 #SBATCH --qos=normal                    # Quality of service&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school&lt;br /&gt;
 #&lt;br /&gt;
 #SBATCH --nodes=1                       # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=4             # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --cpus-per-task=1               # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load profile/candidate&lt;br /&gt;
 module use /leonardo/pub/userexternal/nspallan/spack-0.22.2-06/modules&lt;br /&gt;
 module load yambo/5.3.0--intel-oneapi-mpi--2021.12.1--oneapi--2024.1.0&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8772</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8772"/>
		<updated>2025-05-19T21:39:30Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8771</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8771"/>
		<updated>2025-05-19T21:38:30Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
!&lt;br /&gt;
!For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
#So now move to:&lt;br /&gt;
&lt;br /&gt;
# 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
#Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the #calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
# vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
# #!/bin/bash&lt;br /&gt;
# #SBATCH --nodes=1&lt;br /&gt;
# #SBATCH --ntasks-per-node=2&lt;br /&gt;
# #SBATCH --cpus-per-task=1&lt;br /&gt;
# #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
#each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still #the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not #using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
#In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific #compilation of the code.&lt;br /&gt;
&lt;br /&gt;
# module purge&lt;br /&gt;
# module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
# export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
#In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional #modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8770</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8770"/>
		<updated>2025-05-19T21:38:03Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
!&lt;br /&gt;
!For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
#So now move to:&lt;br /&gt;
&lt;br /&gt;
# 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
#Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the #calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
# vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
# #!/bin/bash&lt;br /&gt;
# #SBATCH --nodes=1&lt;br /&gt;
# #SBATCH --ntasks-per-node=2&lt;br /&gt;
# #SBATCH --cpus-per-task=1&lt;br /&gt;
# #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
#each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still #the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not #using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
#In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific #compilation of the code.&lt;br /&gt;
&lt;br /&gt;
# module purge&lt;br /&gt;
# module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
# export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
#In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional #modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8769</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8769"/>
		<updated>2025-05-19T21:35:40Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
!==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
!&lt;br /&gt;
!For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
#So now move to:&lt;br /&gt;
&lt;br /&gt;
# 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
#Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the #calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
# vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
# #!/bin/bash&lt;br /&gt;
# #SBATCH --nodes=1&lt;br /&gt;
# #SBATCH --ntasks-per-node=2&lt;br /&gt;
# #SBATCH --cpus-per-task=1&lt;br /&gt;
# #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
#each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still #the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not #using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
#In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific #compilation of the code.&lt;br /&gt;
&lt;br /&gt;
# module purge&lt;br /&gt;
# module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
# export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
#In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional #modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8768</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8768"/>
		<updated>2025-05-19T21:34:53Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
#==Step 3: Running on GPU== hidden no gpu partition in Yambo 2025 school&lt;br /&gt;
#&lt;br /&gt;
#For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
#So now move to:&lt;br /&gt;
&lt;br /&gt;
# 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
#Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the #calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
# vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
# #!/bin/bash&lt;br /&gt;
# #SBATCH --nodes=1&lt;br /&gt;
# #SBATCH --ntasks-per-node=2&lt;br /&gt;
# #SBATCH --cpus-per-task=1&lt;br /&gt;
# #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
#each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still #the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not #using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
#In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific #compilation of the code.&lt;br /&gt;
&lt;br /&gt;
# module purge&lt;br /&gt;
# module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
# export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
#In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional #modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8767</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8767"/>
		<updated>2025-05-19T21:33:39Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 3: Running on GPU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
#==Step 3: Running on GPU==&lt;br /&gt;
#&lt;br /&gt;
#For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Yambopy_tutorial:_band_structures&amp;diff=8687</id>
		<title>Yambopy tutorial: band structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Yambopy_tutorial:_band_structures&amp;diff=8687"/>
		<updated>2025-05-18T14:44:06Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This tutorial will show you how to visualise wave-function and band-structure related information, such as atomic, orbital and spin projections, following a DFT Quantum Espresso calculation using the &amp;quot;qepy&amp;quot; module of Yambopy. It also contains a section about Yambo and GW band structures.&lt;br /&gt;
&lt;br /&gt;
The full tutorial, including the Quantum espresso and Yambo databases that we will read, can be downloaded and extracted from the yambo website:&lt;br /&gt;
 wget https://media.yambo-code.eu/educational/tutorials/files/databases_qepy.tar.gz&lt;br /&gt;
 tar -xvzf databases_qepy.tar.gz&lt;br /&gt;
 cd databases_qepy&lt;br /&gt;
&lt;br /&gt;
==Tutorial 1. BN (semiconductor). Band structure==&lt;br /&gt;
&lt;br /&gt;
First enter in the folder &lt;br /&gt;
 cd databases_qepy/bn-semiconductor&lt;br /&gt;
and have a look to the &lt;br /&gt;
 vim plot-qe-bands.py&lt;br /&gt;
The qepy classes are useful both to execute Quantum Espresso and to analyze the results. Enter in the python environment, by typing &amp;lt;code&amp;gt;python&amp;lt;/code&amp;gt;, then the full qepy library is imported by simply doing:&lt;br /&gt;
&lt;br /&gt;
 from qepy import *&lt;br /&gt;
&lt;br /&gt;
===Plot Band structure===&lt;br /&gt;
&lt;br /&gt;
The qepy class &#039;&#039;&#039;PwXML&#039;&#039;&#039; reads the data file generated by Quantum Espresso and post-processes the data. The class is instanced by doing:&lt;br /&gt;
&lt;br /&gt;
 xml = PwXML(prefix=&#039;bn&#039;, path=&#039;bands&#039;)&lt;br /&gt;
&lt;br /&gt;
The variable prefix corresponds to the same variable of the QE input. The folder location is indicated by variable path. In order to plot the bands, we also define the k-points path (in crystal coordinates) using the function Path:&lt;br /&gt;
&lt;br /&gt;
 npoints = 50&lt;br /&gt;
 path_kpoints = Path([ [[0.0, 0.0, 0.0],&#039;$\Gamma$&#039;],&lt;br /&gt;
                       [[0.5, 0.0, 0.0],&#039;M&#039;],&lt;br /&gt;
                       [[1./3,1./3,0.0],&#039;K&#039;],&lt;br /&gt;
                       [[0.0, 0.0, 0.0],&#039;$\Gamma$&#039;]], [int(npoints*2),int(npoints),int(sqrt(5)*npoints)])&lt;br /&gt;
&lt;br /&gt;
It is worth to note that the path should coincide with the selected path for the QE band calculations.&lt;br /&gt;
&lt;br /&gt;
In order to show the plot we call the &#039;&#039;&#039;plot_eigen&#039;&#039;&#039; method of the &#039;&#039;&#039;PwXML&#039;&#039;&#039; class:&lt;br /&gt;
&lt;br /&gt;
 xml.plot_eigen(path_kpoints)&lt;br /&gt;
&lt;br /&gt;
This function will automatically plot the bands as shown below running the script:&lt;br /&gt;
&lt;br /&gt;
 python plot-qe-bands.py&lt;br /&gt;
&lt;br /&gt;
[[File:Bands BN 1.png| 400 px | center |Band structure of BN calculated at the level of DFT-LDA]]&lt;br /&gt;
&lt;br /&gt;
Alternatively, we can use the function &#039;&#039;&#039;plot_eigen_ax&#039;&#039;&#039;. This functions requires as input a matplotlib &#039;&#039;&#039;figure&#039;&#039;&#039; object with given axes, as you will see in the next example.&lt;br /&gt;
&lt;br /&gt;
===Plot atomic orbital projected Band structure===&lt;br /&gt;
&lt;br /&gt;
In addition to the band structure, useful information regarding the atomic orbital nature of the electronic wave functions can be displayed using the class &#039;&#039;&#039;ProjwfcXML&#039;&#039;&#039;. &lt;br /&gt;
In order to make quantum espresso calculate the relevant data, we need to use the QE executable &#039;&#039;&#039;projwfc.x&#039;&#039;&#039;, which will create the file &#039;&#039;&#039;atomic_proj.xml&#039;&#039;&#039;. This executable projects the Kohn-Sham wavefunctions onto orthogonalized atomic orbitals, among others functionalities. The orbital indexing  and ordering are explained in the input documentation of the projwfc.x function which you are invited to check (https://www.quantum-espresso.org/Doc/INPUT_PROJWFC.html#idm94). We can run &#039;&#039;&#039;projwf.x&#039;&#039;&#039; directly from the python script using the qepy class &#039;&#039;&#039;ProjwfcIn&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 proj = ProjwfcIn(prefix=&#039;bn&#039;)&lt;br /&gt;
 proj.run(folder=&#039;bands&#039;)&lt;br /&gt;
&lt;br /&gt;
Be aware that this can take a while in a large system with many k-points. As in the class &#039;&#039;&#039;PwXML&#039;&#039;&#039;, we then define the path_kpoints and also the selected atomic orbitals to project our bands. We have chosen to represent the projection weight onto the nitrogen (1) and boron (2) orbitals, which can be obtained with&lt;br /&gt;
&lt;br /&gt;
 # Automatic selection of the states&lt;br /&gt;
 atom_1 = band.get_states_helper(atom_query=[&#039;N&#039;])&lt;br /&gt;
 atom_2 = band.get_states_helper(atom_query=[&#039;B&#039;])&lt;br /&gt;
&lt;br /&gt;
The full list of orbitals is written in the file &#039;&#039;&#039;bands/prowfc.log&#039;&#039;&#039;. By inspecting it, you may also construct custom lists of states.&lt;br /&gt;
&lt;br /&gt;
We have also defined the figure box&lt;br /&gt;
&lt;br /&gt;
 import matplotlib.pyplot as plt&lt;br /&gt;
 fig = plt.figure(figsize=(5,7))&lt;br /&gt;
 ax  = fig.add_axes( [ 0.12, 0.10, 0.70, 0.80 ])&lt;br /&gt;
&lt;br /&gt;
The class &#039;&#039;&#039;ProjwfcXML&#039;&#039;&#039; then runs as in this example:&lt;br /&gt;
&lt;br /&gt;
 band = ProjwfcXML(prefix=&#039;bn&#039;,path=&#039;bands&#039;,qe_version=&#039;7.0&#039;)&lt;br /&gt;
 band.plot_eigen(ax,path_kpoints=path_kpoints,cmap=&#039;viridis&#039;,selected_orbitals=atom_1,selected_orbitals_2=atom_2)&lt;br /&gt;
&lt;br /&gt;
We can run now the file:&lt;br /&gt;
&lt;br /&gt;
 python plot-qe-orbitals.py&lt;br /&gt;
&lt;br /&gt;
[[File:Bands AOP BN 1.png| 400 px | center | Atomic orbital projected band structure of monolayer BN]]&lt;br /&gt;
&lt;br /&gt;
We have chosen the colormap &#039;viridis&#039; (variable cmap). You see that the colormap goes from maximum &#039;&#039;&#039;selected_orbitals&#039;&#039;&#039; content (in this case nitrogen) to the maximum &#039;&#039;&#039;selected_orbitals_2&#039;&#039;&#039; content (in this case boron). &lt;br /&gt;
The colormap can be represented in many ways and qepy does not include a particular function for this. An example is:&lt;br /&gt;
&lt;br /&gt;
 import matplotlib as mpl&lt;br /&gt;
 cmap=plt.get_cmap(&#039;viridis&#039;)&lt;br /&gt;
 bx  = fig.add_axes( [ 0.88, 0.10, 0.05, 0.80 ])&lt;br /&gt;
 norm = mpl.colors.Normalize(vmin=0.,vmax=1.)&lt;br /&gt;
 cb1 = mpl.colorbar.ColorbarBase(bx, cmap=cmap, norm=norm,orientation=&#039;vertical&#039;,ticks=[0,1])&lt;br /&gt;
 cb1.set_ticklabels([&#039;B&#039;, &#039;N&#039;])&lt;br /&gt;
&lt;br /&gt;
Suppose now that we have run the G0W0 calculation from the last tutorial, and we want to represent the atomic weights on top of the quasiparticle band structure instead of the Kohn-Sham one. However, we do not have the same kpoint grid between the G0W0 calculation and the quantum espresso &amp;quot;band&amp;quot; calculation along a path. We can then extract the parameters for a scissor operator (this is done below) and feed them to the &#039;&#039;&#039;ProjwfcXML&#039;&#039;&#039; class together with the number of valence bands. Try uncommenting the following lines in the tutorial script:&lt;br /&gt;
&lt;br /&gt;
 # Add scissor operator to the bands from a G0W0 calculation&lt;br /&gt;
 scissor= [1.8985195950522469, 1.0265240811345133, 1.051588659878575]&lt;br /&gt;
 n_val = 4&lt;br /&gt;
 band.add_scissor(n_val,scissor)&lt;br /&gt;
  &lt;br /&gt;
Finally, we can also plot the band orbital character with size variation instead of a color scale. In this case we have to pass only the variable selected_orbitals (see the next tutorial).&lt;br /&gt;
&lt;br /&gt;
==Tutorial 2. Iron. Ferromagnetic metallic material==&lt;br /&gt;
&lt;br /&gt;
In the case of spin-polarized calculations we can plot the spin up and down band structures. We have included in the tutorial a small workflow example to run quantum espresso calculations from scratch. This is done using the classes Tasks and Flows developed in yambopy. You can check the file flow-iron.py for an example. &lt;br /&gt;
Yambopy includes basic predefined workflows to run the common QE and Yambo calculations. In this case we are using the class &#039;&#039;&#039;PwBandsTasks&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
 python flow-iron.py&lt;br /&gt;
&lt;br /&gt;
In order to plot the spin-polarized bands. After doing all the calculations from scratch with the flows (flow-iron.py), we can make the band plot by running the script:&lt;br /&gt;
&lt;br /&gt;
 python plot-qe-bands.py&lt;br /&gt;
&lt;br /&gt;
The class PwXML automatically detects the spin polarized case (nspin=2 in the QE input file). The spin up channel is displayed with red and the spin down channel with blue. In the case of iron we have selected this k-point path:&lt;br /&gt;
&lt;br /&gt;
 npoints = 50&lt;br /&gt;
 path_kpoints = Path([ [[0.0, 0.0, 0.0 ],&#039;G&#039;],&lt;br /&gt;
                       [[0.0, 0.0, 1.0 ],&#039;H&#039;],&lt;br /&gt;
                       [[1./2,0.0,1./2.],&#039;N&#039;],&lt;br /&gt;
                       [[0.0, 0.0, 0.0 ],&#039;G&#039;],&lt;br /&gt;
                       [[1./2, 1./2, 1./2 ],&#039;P&#039;],&lt;br /&gt;
                       [[1./2,0.0,1./2. ],&#039;N&#039;]], [npoints,npoints,npoints,npoints,npoints])&lt;br /&gt;
&lt;br /&gt;
 xml = PwXML(prefix=&#039;pw&#039;,path=&#039;bands/t0&#039;)&lt;br /&gt;
 xml.plot_eigen(path_kpoints)&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 3-iron-bands.png| 600 px | center |Spin polarized band structure of iron calculated by DFT]]&lt;br /&gt;
&lt;br /&gt;
The analysis of the projected atomic orbitals is also implemented. In this case the results are more cumbersome because the projection is separated in spin up and down channels.&amp;lt;br&amp;gt; &lt;br /&gt;
Let us look first at the file &#039;&#039;&#039;plot-qe-orbitals-size&#039;&#039;&#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB: If you generated the quantum espresso databases using the flows instead of relying on the precomputed databases, you also need to rerun the quantum espresso executable projwfc.x to recompute the orbital projections. In this case, please uncomment the following lines in the script&#039;&#039;&#039; (plot-qe-orbitals-size.py) :&lt;br /&gt;
 #proj = ProjwfcIn(prefix=&#039;pw&#039;)&lt;br /&gt;
 #proj.run(folder=&#039;bands/t0&#039;)&lt;br /&gt;
&lt;br /&gt;
Now, we can use the dot size as a function of the weight of the orbitals&lt;br /&gt;
 # Automatic selection of the states&lt;br /&gt;
 s = band.get_states_helper(orbital_query=[&#039;s&#039;])&lt;br /&gt;
 p = band.get_states_helper(orbital_query=[&#039;p&#039;])&lt;br /&gt;
 d = band.get_states_helper(orbital_query=[&#039;d&#039;])&lt;br /&gt;
&lt;br /&gt;
and the plots are done with&lt;br /&gt;
 band = ProjwfcXML(prefix=&#039;pw&#039;,path=&#039;bands/t0&#039;,qe_version=&#039;7.0&#039;)&lt;br /&gt;
 band.plot_eigen(ax,path_kpoints=path_kpoints,&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;selected_orbitals=s,&amp;lt;/span&amp;gt;color=&#039;pink&#039;,color_2=&#039;black&#039;)&lt;br /&gt;
 band.plot_eigen(ax,path_kpoints=path_kpoints,&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;selected_orbitals=p,&amp;lt;/span&amp;gt;color=&#039;green&#039;,color_2=&#039;orange&#039;)&lt;br /&gt;
 band.plot_eigen(ax,path_kpoints=path_kpoints,&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;selected_orbitals=d,&amp;lt;/span&amp;gt;color=&#039;red&#039;,color_2=&#039;blue&#039;)&lt;br /&gt;
&lt;br /&gt;
As an example, we can select just the &#039;&#039;d&#039;&#039; orbitals by commenting the first two plots and then running the file:&lt;br /&gt;
&lt;br /&gt;
 plot-qe-orbitals-size.py&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 4-iron-bands-size-d-orbitals.png|400px|center|Iron band structure. Size is proportional to the weights of the projection on atomic d-orbitals. Red (blue) is up (down) spin polarization.]]&lt;br /&gt;
&lt;br /&gt;
From the plot is clear that &#039;&#039;d&#039;&#039; orbitals are mainly localized around the Fermi energy. The plot above is in red and blue, while the default choice in your script should be pink and black. You can experiment with the colors and other &#039;&#039;matplotlib&#039;&#039; plot options and also plot the other orbital types.&lt;br /&gt;
&lt;br /&gt;
Another option is to plot the orbital composition as a colormap running the file:&lt;br /&gt;
&lt;br /&gt;
 plot-qe-orbitals-colormap.py&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 5-iron-bands-colormap.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
Here we have added the p and d orbitals in the analysis:&lt;br /&gt;
&lt;br /&gt;
 p = band.get_states_helper(orbital_query=[&#039;p&#039;])&lt;br /&gt;
 d = band.get_states_helper(orbital_query=[&#039;d&#039;])&lt;br /&gt;
 band = ProjwfcXML(prefix=&#039;pw&#039;,path=&#039;bands/t0&#039;,qe_version=&#039;7.0&#039;)&lt;br /&gt;
 band.plot_eigen(ax,path_kpoints=path_kpoints,cmap=&#039;viridis&#039;,cmap2=&#039;rainbow&#039;,selected_orbitals=p,selected_orbitals_2=d)&lt;br /&gt;
&lt;br /&gt;
The colormap bar is added in the same way as in Tutorial 1 (see script), but this time we have a different colormap for each spin polarisation.&lt;br /&gt;
&lt;br /&gt;
==Tutorial 3: GW bands==&lt;br /&gt;
&lt;br /&gt;
Yambopy can be used either to run Yambo and QE calculations, or to analyse the results of QE and Yambo by dealing with their generated databases. This is done with a variety of classes included in the qepy (for QE) or yambopy (for Yambo) modules. &lt;br /&gt;
In the case of Yambo GW quasi-particle calculations, we can use the yambopy class &#039;&#039;&#039;YamboQPDB&#039;&#039;&#039; to read the database produced by the simulation.&lt;br /&gt;
Enter in the folder&lt;br /&gt;
 cd ../gw-bands&lt;br /&gt;
We can use this to find the scissor operator, plot the GW bands and to interpolate the GW bands on a smoother k-path. The example runs by typing:&lt;br /&gt;
&lt;br /&gt;
 python plot-qp.py&lt;br /&gt;
&lt;br /&gt;
See below for an explanation of the tutorial. As usual, we can import the qepy and yambopy libraries:&lt;br /&gt;
&lt;br /&gt;
  from qepy import *&lt;br /&gt;
  from yambopy import *&lt;br /&gt;
  import matplotlib.pyplot as plt&lt;br /&gt;
&lt;br /&gt;
We define the k-points path.&lt;br /&gt;
  npoints = 10&lt;br /&gt;
  path = Path([ [[  0.0,  0.0,  0.0],&#039;$\Gamma$&#039;],&lt;br /&gt;
                [[  0.5,  0.0,  0.0],&#039;M&#039;],&lt;br /&gt;
                [[1./3.,1./3.,  0.0],&#039;K&#039;],&lt;br /&gt;
                [[  0.0,  0.0,  0.0],&#039;$\Gamma$&#039;]], [int(npoints*2),int(npoints),int(sqrt(5)*npoints)] )&lt;br /&gt;
&lt;br /&gt;
Importantly, the number of points is a free choice. We can increase the variable npoints as we wish, it just means that the interpolation step will take more time. In order to analyse GW results we need to have the file related to the basic data of our Yambo calculation (&#039;&#039;&#039;SAVE/ns.db1&#039;&#039;&#039;) and the netcdf file with the quasi-particle results (&#039;&#039;&#039;ndb.QP&#039;&#039;&#039;). We load the data calling the respective classes:&lt;br /&gt;
&lt;br /&gt;
 # Read Lattice information from SAVE&lt;br /&gt;
 lat  = YamboSaveDB.from_db_file(folder=&#039;SAVE&#039;,filename=&#039;ns.db1&#039;)&lt;br /&gt;
 # Read QP database&lt;br /&gt;
 ydb  = YamboQPDB.from_db(filename=&#039;ndb.QP&#039;,folder=&#039;qp-gw&#039;)&lt;br /&gt;
(in the yambopy module, each class is specialised to read a specific Yambo database)&lt;br /&gt;
&lt;br /&gt;
The first option is to plot the energies and calculate the ideal Kohn-Sham to GW scissor operator. We need to select the index of the top valence band:&lt;br /&gt;
&lt;br /&gt;
 n_top_vb = 4&lt;br /&gt;
 ydb.plot_scissor_ax(ax,n_top_vb)&lt;br /&gt;
&lt;br /&gt;
Yambopy displays the fitting and also the data of the slope of each fitting. Notice that this is also a test if the GW calculations are running well. &#039;&#039;&#039;If the dependence is not linear you should double-check your results!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 6-slope-scissor.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
In this case the slope is:&lt;br /&gt;
&lt;br /&gt;
 valence bands:&lt;br /&gt;
 slope:     1.0515886598785766&lt;br /&gt;
 conduction bands:&lt;br /&gt;
 slope:     1.026524081134514&lt;br /&gt;
 scissor list (shift,c,v) [eV,adim,adim]: [1.8985204833551723, 1.026524081134514, 1.0515886598785766]&lt;br /&gt;
&lt;br /&gt;
In addition to the scissor operator, we can plot the GW (and DFT) band structure along the path. The first choice would be to plot the actual GW calculations, without interpolation, to check that the results are meaningful (or not). This plot is independent of the number of k-points (&#039;&#039;&#039;npoints&#039;&#039;&#039;) that we want to put in the interpolation. The class YamboQPDB finds the calculated points that belong to the path and plots them. Be aware that if we use coarse grids the class would not find any point and the function will not work.&lt;br /&gt;
&lt;br /&gt;
 ks_bs_0, qp_bs_0 = ydb.get_bs_path(lat,path)&lt;br /&gt;
 ks_bs_0.plot_ax(ax,legend=True,c_bands=&#039;r&#039;,label=&#039;KS&#039;)&lt;br /&gt;
 qp_bs_0.plot_ax(ax,legend=True,c_bands=&#039;b&#039;,label=&#039;QP-GW&#039;)&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 7-GW-band-structure-non-interpolated.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
The interpolation of the DFT and GW band structures looks similar:&lt;br /&gt;
&lt;br /&gt;
 ks_bs, qp_bs = ydb.interpolate(lat,path,what=&#039;QP+KS&#039;,lpratio=20)&lt;br /&gt;
 ks_bs.plot_ax(ax,legend=True,c_bands=&#039;r&#039;,label=&#039;KS&#039;)&lt;br /&gt;
 qp_bs.plot_ax(ax,legend=True,c_bands=&#039;b&#039;,label=&#039;QP-GW&#039;)&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;lpratio&#039;&#039;&#039; can be increased if the interpolation does not work as well as intended. The SKW interpolation scheme is the same on implemented in abipy.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 8-GW-band-structure-interpolated.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
Finally, we can compare the calculated GW eigenvalues with the interpolation.&lt;br /&gt;
&lt;br /&gt;
[[File:Figure 8-GW-band-structure-comparison.png|400px|center]]&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
* Back to [[Rome 2023#Tutorials]]&lt;br /&gt;
* Back to [[ICTP 2022#Tutorials]]&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8686</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8686"/>
		<updated>2025-05-18T14:35:53Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* RIM-W */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed? You should expect a GW gap of 2.806 eV. A large decrease compared to the value obtained when performing a RIM integration of only the bare Coulomb potential within the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8684</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8684"/>
		<updated>2025-05-18T14:29:31Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* RIM-W */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8683</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=8683"/>
		<updated>2025-05-18T14:28:02Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* RIM */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.116 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=8679</id>
		<title>First steps: walk through from DFT(standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=8679"/>
		<updated>2025-05-18T14:21:02Z</updated>

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

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

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

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Converging Screening Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.411876    -0.567723   2.322443&lt;br /&gt;
       7        9      3.877976     2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the current version of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for example in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;. Now, repeat this operation also in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
We can now perform once again the same calculations with the terminator activated&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08708      2.91254 &lt;br /&gt;
       7        9      3.877976     1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08715      2.93518 &lt;br /&gt;
       7        9      3.877976     1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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        6      -1.299712    -0.219100     3.788044&lt;br /&gt;
       1        7      -1.296430    -0.241496     3.788092&lt;br /&gt;
       1        8      -1.296420    -0.243115     3.785947&lt;br /&gt;
       1        9       4.832399     0.952386    -3.679259&lt;br /&gt;
       1        10      10.76416     2.09915     -4.38743&lt;br /&gt;
       1        11      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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8671</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8671"/>
		<updated>2025-05-18T13:45:48Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Converging Screening Parameters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.411876    -0.567723   2.322443&lt;br /&gt;
       7        9      3.877976     2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for example in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;. Now, repeat this operation also in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
We can now perform once again the same calculations with the terminator activated&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08708      2.91254 &lt;br /&gt;
       7        9      3.877976     1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08715      2.93518 &lt;br /&gt;
       7        9      3.877976     1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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        6      -1.299712    -0.219100     3.788044&lt;br /&gt;
       1        7      -1.296430    -0.241496     3.788092&lt;br /&gt;
       1        8      -1.296420    -0.243115     3.785947&lt;br /&gt;
       1        9       4.832399     0.952386    -3.679259&lt;br /&gt;
       1        10      10.76416     2.09915     -4.38743&lt;br /&gt;
       1        11      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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=8670</id>
		<title>Next steps: RPA calculations (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Next_steps:_RPA_calculations_(standalone)&amp;diff=8670"/>
		<updated>2025-05-18T13:42:23Z</updated>

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

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Understanding the output */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.411876    -0.567723   2.322443&lt;br /&gt;
       7        9      3.877976     2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for example in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;. Now, repeat this operation also in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
We can now perform once again the same calculations with the terminator activated&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08708      2.91254 &lt;br /&gt;
       7        9      3.877976     1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08715      2.93518 &lt;br /&gt;
       7        9      3.877976     1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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        6      -1.299712    -0.219100     3.788044&lt;br /&gt;
       1        7      -1.296430    -0.241496     3.788092&lt;br /&gt;
       1        8      -1.296420    -0.243115     3.785947&lt;br /&gt;
       1        9       4.832399     0.952386    -3.679259&lt;br /&gt;
       1        10      10.76416     2.09915     -4.38743&lt;br /&gt;
       1        11      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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8667</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8667"/>
		<updated>2025-05-18T13:35:19Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Secant Solver */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7     8       -0.411876  -0.567723   2.322443&lt;br /&gt;
  7     9        3.877976   2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for example in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;. Now, repeat this operation also in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
We can now perform once again the same calculations with the terminator activated&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08708      2.91254 &lt;br /&gt;
       7        9      3.877976     1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
       7        8     -0.41188     -0.08715      2.93518 &lt;br /&gt;
       7        9      3.877976     1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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        6      -1.299712    -0.219100     3.788044&lt;br /&gt;
       1        7      -1.296430    -0.241496     3.788092&lt;br /&gt;
       1        8      -1.296420    -0.243115     3.785947&lt;br /&gt;
       1        9       4.832399     0.952386    -3.679259&lt;br /&gt;
       1        10      10.76416     2.09915     -4.38743&lt;br /&gt;
       1        11      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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8666</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8666"/>
		<updated>2025-05-18T13:34:07Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 3: Interpolating Band Structures */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7     8       -0.411876  -0.567723   2.322443&lt;br /&gt;
  7     9        3.877976   2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for example in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;. Now, repeat this operation also in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
We can now perform once again the same calculations with the terminator activated&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8  -0.41188   -0.08708      2.91254 &lt;br /&gt;
   7   9   3.877976   1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8   -0.41188   -0.08715      2.93518 &lt;br /&gt;
   7   9   3.877976   1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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        6      -1.299712    -0.219100     3.788044&lt;br /&gt;
       1        7      -1.296430    -0.241496     3.788092&lt;br /&gt;
       1        8      -1.296420    -0.243115     3.785947&lt;br /&gt;
       1        9       4.832399     0.952386    -3.679259&lt;br /&gt;
       1        10      10.76416     2.09915     -4.38743&lt;br /&gt;
       1        11      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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8665</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8665"/>
		<updated>2025-05-18T13:31:18Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Accelerating the sum over states convergence in the correlation self-energy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7     8       -0.411876  -0.567723   2.322443&lt;br /&gt;
  7     9        3.877976   2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for example in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039;. Now, repeat this operation also in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
We can now perform once again the same calculations with the terminator activated&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8  -0.41188   -0.08708      2.91254 &lt;br /&gt;
   7   9   3.877976   1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8   -0.41188   -0.08715      2.93518 &lt;br /&gt;
   7   9   3.877976   1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8663</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8663"/>
		<updated>2025-05-18T13:29:32Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7     8       -0.411876  -0.567723   2.322443&lt;br /&gt;
  7     9        3.877976   2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. You can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
in the file &#039;&#039;gw_ppa_Gbnd10.in&#039;&#039; or simply you can modify by hand this line in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
Now we can repeat the same calculations &lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8  -0.41188   -0.08708      2.91254 &lt;br /&gt;
   7   9   3.877976   1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8   -0.41188   -0.08715      2.93518 &lt;br /&gt;
   7   9   3.877976   1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8662</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8662"/>
		<updated>2025-05-18T13:23:08Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7     8       -0.411876  -0.567723   2.322443&lt;br /&gt;
  7     9        3.877976   2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;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;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. We can activate it by adding the quasiparticle verbosity to the command line when generating the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -p p -g n -F gw_ppa_Gbnd10.in -V qp&lt;br /&gt;
&lt;br /&gt;
and you can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
or simply you can add by hand this line in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
Now we can repeat the same calculations &lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8  -0.41188   -0.08708      2.91254 &lt;br /&gt;
   7   9   3.877976   1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8   -0.41188   -0.08715      2.93518 &lt;br /&gt;
   7   9   3.877976   1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8661</id>
		<title>GW on h-BN (standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=GW_on_h-BN_(standalone)&amp;diff=8661"/>
		<updated>2025-05-18T13:21:31Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a modified version of the full tutorial on GW computations present on the Yambo wiki. Later, you can have a look at the extended version at [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will learn how to:&lt;br /&gt;
* Calculate quasi-particle corrections in the Hartree-Fock approximation &lt;br /&gt;
* Calculate quasi-particle corrections in the GW approximation &lt;br /&gt;
* Choose the input parameters for a meaningful converged calculation&lt;br /&gt;
* Plot a band structure including quasi-particle corrections&lt;br /&gt;
We will use bulk hBN as an example system. Before starting, you need to obtain the appropriate tarball. See instructions on the [[Tutorials|main tutorials page]]. &amp;lt;br&amp;gt;&lt;br /&gt;
We strongly recommend that you first complete the [[First steps: a walk through from DFT to optical properties]] tutorial.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- &#039;&#039;&#039;Prerequisites&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
At this stage, you should have already completed the following modules:&lt;br /&gt;
* [[Generating the Yambo databases|Generating the Yambo databases]]&lt;br /&gt;
* Step 2 Run [[Initialization]] tutorial&lt;br /&gt;
Now we can start to --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The aim of the present tutorial is to obtain quasiparticle correction to energy levels using many-body perturbation theory (MBPT). &amp;lt;br&amp;gt;&lt;br /&gt;
The general non-linear quasiparticle equation reads:&lt;br /&gt;
[[File:Eqp_1.png|none|x26px|caption]] &lt;br /&gt;
As a first step we want to evaluate the self energy Σ entering in the quasiparticle equation. In the GW approach the self-energy can be separated into two components: a static term called the exchange self-energy (Σx), and a dynamical term (energy dependent) called the correlation self-energy (Σc):&lt;br /&gt;
[[File:Sigma.png|none|x25px|caption]]&lt;br /&gt;
We will treat these two terms separately and demonstrate how to set the most important variables for calculating each term.&lt;br /&gt;
In practice we will compute  the quasi-particle corrections to the one particle Kohn-Sham eigenvalues obtained through a DFT calculation. &lt;br /&gt;
&lt;br /&gt;
The steps are the following:&lt;br /&gt;
&lt;br /&gt;
==Step 1: The Exchange Self Energy or HF quasi-particle correction==&lt;br /&gt;
&lt;br /&gt;
We start by evaluating the exchange Self-Energy and the corresponding Quasiparticle energies (Hartree-Fock energies). &lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; and then return to this tutorial &#039;&#039;How to obtain the quasiparticle band structure of a bulk material: h-BN&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Step 2: The Correlation Self-Energy and Quasiparticle Energies==&lt;br /&gt;
Once we have calculated the exchange part, we next turn our attention to the more demanding dynamical part. The correlation part of the self-energy in a plane wave representation reads:&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
In the expression for the correlation self energy, we have (1) a summation over bands, (2) an integral over the Brillouin Zone, and (3) a sum over the G vectors. In contrast with the case of Σx, the summation over bands extends over &#039;&#039;all&#039;&#039; bands (including the unoccupied ones), and so convergence tests are needed. Another important difference is that the Coulomb interaction is now screened so a fundamental ingredient is the evaluation of the dynamical dielectric matrix. The expression for the dielectric matrix, calculated at the RPA level and including local field effects, has been already treated in the [[Local fields|Local fields]] tutorial.&lt;br /&gt;
&lt;br /&gt;
In the following, we will see two ways to take into account the dynamical effects. First, we will see how to set the proper parameters to obtain a model dielectric function based on a widely used approximation, which models the energy dependence of each component of the dielectric matrix with a single pole function. &lt;br /&gt;
Secondly, we will see how to perform calculations by evaluating the dielectric matrix on a regular grid of frequencies. &lt;br /&gt;
&lt;br /&gt;
Once the correlation part of the self-energy is calculated, we will check the convergence of the different parameters with respect to some final quantity, such as the gap. &lt;br /&gt;
&lt;br /&gt;
After computing the frequency dependent self-energy, we will discover that in order to solve the quasiparticle equation we will need to know its value &#039;&#039;at the value of the quasiparticle itself&#039;&#039;. In the following, unless explicitly stated, we will solve the non-linear quasi-particle equation at first order, by expanding the self-energy around the Kohn-Sham eigenvalue. In this way the quasiparticle equation reads:&lt;br /&gt;
&lt;br /&gt;
[[File:Eqp_2.png|none|x26px|caption]] &lt;br /&gt;
&lt;br /&gt;
where the normalization factor Z is defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:z_fac.png|none|x40px|caption]] &lt;br /&gt;
&lt;br /&gt;
===The Plasmon Pole approximation===&lt;br /&gt;
As stated above, the basic idea of the plasmon-pole approximation is to approximate the frequency dependence of the dielectric matrix with a single pole function of the form:&lt;br /&gt;
[[File:ppa.png|none|x26px|caption]]&lt;br /&gt;
The two parameters R&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; and Ω&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; are obtained by a fit (for each component), after having calculated the RPA dielectric matrix at two given frequencies.&lt;br /&gt;
Yambo calculates the dielectric matrix in the static limit ( ω=0) and at a user defined frequency called the plasmon-pole frequency (ω=iωp). &lt;br /&gt;
Such an approximation has the big computational advantage of calculating the dielectric matrix for only two frequencies and leads to an analytical expression for the frequency integral of the correlation self-energy.&lt;br /&gt;
==== Input file generation ====&lt;br /&gt;
Let&#039;s start by building up the input file for a GW/PPA calculation, including the calculation of the exchange self-energy. From &amp;lt;code&amp;gt;yambo -H&amp;lt;/code&amp;gt; you should understand that the correct option is &amp;lt;code&amp;gt;yambo -x -p p -g n&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/hBN/YAMBO&lt;br /&gt;
 $ yambo -x -p p -g n -F gw_ppa.in&lt;br /&gt;
&lt;br /&gt;
Let&#039;s modify the input file in the following way: &lt;br /&gt;
&lt;br /&gt;
 HF_and_locXC                 # [R XX] Hartree-Fock Self-energy and Vxc&lt;br /&gt;
 ppa                          # [R Xp] Plasmon Pole Approximation&lt;br /&gt;
 gw0                          # [R GW] GoWo Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]] = 40         Ry    # [XX] Exchange RL components&lt;br /&gt;
 [[Variables#VXCRLvcs|VXCRLvcs]] = 3187        RL      # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;Hartree&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
   1 | 10 |                 # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXp|NGsBlkXp]]= 1000          mRy    # [Xp] Response block size&lt;br /&gt;
 % LongDrXp&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xp] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#PPAPntXp|PPAPntXp]] = 27.21138     eV    # [Xp] PPA imaginary energy&lt;br /&gt;
 %[[Variables#GbndRnge|GbndRnge]]&lt;br /&gt;
   1 | 40 |                 # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GDamping=  0.10000     eV    # [GW] G[W] damping&lt;br /&gt;
 dScStep=  0.10000      eV    # [GW] Energy step to evaluate Z factors&lt;br /&gt;
 DysSolver= &amp;quot;n&amp;quot;               # [GW] Dyson Equation solver (&amp;quot;n&amp;quot;,&amp;quot;s&amp;quot;,&amp;quot;g&amp;quot;)&lt;br /&gt;
 %[[Variables#QPkrange|QPkrange]]        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
  7|  7|  8|  9|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Brief explanation of some settings:&lt;br /&gt;
* Similar to the Hartree Fock study, we will concentrate on the convergence of the &#039;&#039;&#039;direct&#039;&#039;&#039; gap of the system. Hence we select the last occupied (8) and first unoccupied (9) bands for k-point number 7 in the &amp;lt;code&amp;gt;[[Variables#QPkrange|QPkrange]]&amp;lt;/code&amp;gt; variable. &lt;br /&gt;
* We also keep &amp;lt;code&amp;gt;[[Variables#EXXRLvcs|EXXRLvcs]]&amp;lt;/code&amp;gt; at its converged value of 40 Ry as obtained in the &#039;&#039;&#039;[[Hartree Fock]]&#039;&#039;&#039; tutorial.&lt;br /&gt;
* For the moment we keep fixed the plasmon pole energy &amp;lt;code&amp;gt;[[Variables#PPAPntXp|PPAPntXp]]&amp;lt;/code&amp;gt; at its default value (=1 Hartree).&lt;br /&gt;
* We keep fixed the direction of the electric field for the evaluation of the dielectric matrix to a non-specific value: &amp;lt;code&amp;gt;[[Variables#LongDrXp|LongDrXp]]&amp;lt;/code&amp;gt;=(1,1,1).&lt;br /&gt;
* Later we will study convergence with respect to &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt;; for now just set them to the values indicated.&lt;br /&gt;
&lt;br /&gt;
==== Understanding the output ====&lt;br /&gt;
Let&#039;s look at the typical Yambo output. Run Yambo with an appropriate &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt; flag:&lt;br /&gt;
   &lt;br /&gt;
 $ yambo -F gw_ppa.in -J 10b_1Ry&lt;br /&gt;
&lt;br /&gt;
In the standard output you can recognise the different steps of the calculations: calculation of the screening matrix (evaluation of the non interacting and interacting response), calculation of the exchange self-energy, and finally the calculation of the correlation self-energy and quasiparticle energies. Moreover information on memory usage and execution time are reported: &lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [05] Dynamic Dielectric Matrix (PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;08s&amp;gt; Xo@q[3] |########################################| [100%] 03s(E) 03s(X)&lt;br /&gt;
 &amp;lt;08s&amp;gt; X@q[3] |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [06] Bare local and non-local Exchange-Correlation&lt;br /&gt;
 &amp;lt;43s&amp;gt; EXS |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07] Dyson equation: Newton solver&lt;br /&gt;
 &amp;lt;43s&amp;gt; [07.01] G0W0 (W PPA)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; G0W0 (W PPA) |########################################| [100%] --(E) --(X)&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;45s&amp;gt; [07.02] QP properties and I/O&lt;br /&gt;
 &amp;lt;45s&amp;gt; [08] Game Over &amp;amp; Game summary&lt;br /&gt;
&lt;br /&gt;
Let&#039;s have a look at the report and output. The output file &#039;&#039;o-10b_1Ry.qp&#039;&#039; contains (for each band and k-point that we indicated in the input file) the values of the bare KS eigenvalue, its GW correction and the correlation part of the self energy:&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
  7     8       -0.411876  -0.567723   2.322443&lt;br /&gt;
  7     9        3.877976   2.413773  -2.232241&lt;br /&gt;
&lt;br /&gt;
In the header you can see the details of the calculations, for instance it reports that &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;=1 Ry corresponds to 5 Gvectors: &lt;br /&gt;
&lt;br /&gt;
 #  X G`s            [used]:  5&lt;br /&gt;
&lt;br /&gt;
Other information can be found in the report file &#039;&#039;r-10b_1Ry_em1d_ppa_HF_and_locXC_gw0&#039;&#039;, such as the renormalization factor defined above, the value of the &#039;&#039;exchange&#039;&#039; self-energy (non-local XC) and of the DFT exchange-correlation potential (local XC): &lt;br /&gt;
&lt;br /&gt;
 [07.02] QP properties and I/O&lt;br /&gt;
  =============================&lt;br /&gt;
  Legend (energies in eV):&lt;br /&gt;
  - B  : Band       - Eo  : bare energy&lt;br /&gt;
  - E  : QP energy  - Z   : Renormalization factor&lt;br /&gt;
  - So : Sc(Eo)     - S   : Sc(E)&lt;br /&gt;
  - dSp: Sc derivative precision&lt;br /&gt;
  - lXC: Starting Local XC (DFT)&lt;br /&gt;
  -nlXC: Starting non-Local XC (HF)&lt;br /&gt;
  QP [eV] @ K [7] (iku): 0.000000 -0.500000  0.000000&lt;br /&gt;
   B=8 Eo= -0.41 E= -0.98 E-Eo= -0.56 Re(Z)=0.81 Im(Z)=-.2368E-2 nlXC=-19.13 lXC=-16.11 So= 2.322&lt;br /&gt;
   B=9 Eo=  3.88 E=  6.29 E-Eo=  2.41 Re(Z)=0.83 Im(Z)=-.2016E-2 nlXC=-5.536 lXC=-10.67 So=-2.232&lt;br /&gt;
&lt;br /&gt;
Extended information can be also found in the output activating in the input the &amp;lt;code&amp;gt;[[Variables#ExtendOut|ExtendOut]]&amp;lt;/code&amp;gt; flag. This is an optional flag that can be activated by adding the &amp;lt;code&amp;gt;-V qp&amp;lt;/code&amp;gt; verbosity option when building the input file. The plasmon pole screening, exchange self-energy and the quasiparticle energies are also saved in databases so that they can be reused in further runs:&lt;br /&gt;
&lt;br /&gt;
 $ ls ./10b_1Ry&lt;br /&gt;
 ndb.pp ndb.pp_fragment_1 ... ndb.HF_and_locXC ndb.QP&lt;br /&gt;
&lt;br /&gt;
===Convergence tests for a quasi particle calculation===&lt;br /&gt;
&lt;br /&gt;
Now we can check the convergence of the different variables entering in the expression of the correlation part of the self energy.&amp;lt;br&amp;gt; &lt;br /&gt;
First, we focus on the parameter governing the &#039;&#039;screening matrix&#039;&#039; you have already seen in the [[RPA/IP]] section. In contrast to the calculation of the [[RPA/IP]] dielectric function, where you considered either the optical limit or a finite q response (EELS), here the dielectric matrix will be calculated for &#039;&#039;all&#039;&#039; q-points determined by the choice of k-point sampling.&lt;br /&gt;
 &lt;br /&gt;
The parameters that need to be converged can be understood by looking at expression of the dielectric matrix:&lt;br /&gt;
[[File:Yambo-CH5.png|none|x30px|Yambo tutorial image]]&lt;br /&gt;
where &#039;&#039;&amp;amp;chi;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&#039;&#039; is given by&lt;br /&gt;
[[File:Dyson_rpa.png|none|x40px|Yambo tutorial image]]&lt;br /&gt;
and  &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; is given by&lt;br /&gt;
[[File:ChiO.png|none|x45px|Yambo tutorial image]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; : The dimension of the microscopic inverse matrix, related to [[Local fields]]&lt;br /&gt;
* &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; : The sum on bands (c,v) in the independent particle &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Converging Screening Parameters====&lt;br /&gt;
Here we will check the convergence of the gap starting from the variables controlling the screening reported above: the bands employed to build the RPA response function &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and the number of blocks (G,G&#039;) of the dielectric matrix ε&amp;lt;sup&amp;gt;-1&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;G,G&#039;&amp;lt;/sub&amp;gt;  &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;. &lt;br /&gt;
In the next section we will study convergence with respect to the sum over states summation (sum over &#039;&#039;m&#039;&#039; in the Σ&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; expression); here let&#039;s fix &amp;lt;code&amp;gt;[[Variables#GbndRnge|GbndRnge]]&amp;lt;/code&amp;gt; to a reasonable value (40 Ry). &lt;br /&gt;
&lt;br /&gt;
Let&#039;s build a series of input files differing by the values of bands and block sizes in &amp;amp;chi;&amp;lt;sup&amp;gt;0&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;GG&#039;&amp;lt;/sub&amp;gt; considering &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in the range 10-50 (upper limit) and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt; in the range 1000 to 5000 mRy. 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;2000 mRy&#039;&#039;&#039;&lt;br /&gt;
while leaving the rest untouched. Repeat for 3000 mRy, 4000 mRy 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=1000,2000,3000,4000,5000 mRy.&lt;br /&gt;
&lt;br /&gt;
This is obviously quite tedious. However, you can automate both the input construction and code execution using bash or python scripts (indeed later you will learn how to use the the yambo-python [http://www.yambo-code.org/wiki/index.php?title=GW_tutorial._Convergence_and_approximations_(BN)]tool for this task). For now, you can use the simple [[bash_scripts|generate_inputs_1.sh]] bash script to generate the required input files (after copying the script you need to type &amp;lt;code&amp;gt;$ chmod +x name_of_the_script.sh &amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Finally launch the calculations:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_10b_1Ry.in -J 10b_1Ry&lt;br /&gt;
 $ yambo -F gw_ppa_10b_2Ry.in -J 10b_2Ry&lt;br /&gt;
 ...&lt;br /&gt;
 $ yambo -F gw_ppa_40b_5Ry.in -J 40b_5Ry&lt;br /&gt;
&lt;br /&gt;
Once the jobs are terminated we can collect the quasiparticle energies for fixed &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; in different files named e.g. &#039;&#039;10b.dat, 20b.dat&#039;&#039; etc. for plotting, by putting in separate columns: the energy cutoff; the size of the G blocks; the quasiparticle energy of the valence band; and that of the conduction band.&lt;br /&gt;
To do this e.g. for the &#039;&#039;10b.dat&#039;&#039; file you can type:&lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;8.000&amp;quot; |  awk &#039;{print $3+$4}&#039; &lt;br /&gt;
to parse the valence band quasiparticle energies  and &lt;br /&gt;
 $ cat o-10b* | grep &amp;quot;9.000&amp;quot; |  awk &#039;{print $3+$4}&#039; &lt;br /&gt;
for the conduction band; and put all the data in the &#039;&#039;10b.dat&#039;&#039; files. As there are many files to process you can use the [[bash_scripts|parse_qps.sh]] script to create the &#039;&#039;10b.dat&#039;&#039; file and edit the script changing the number of &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; for the other output files. &lt;br /&gt;
&lt;br /&gt;
Once we have collected all the quasiparticle values we can plot the gap, or the valence and conduction band energies separately, as a function of the block size or energy cutoff:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:3 w lp t &amp;quot; Valence BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:3 w lp t &amp;quot;Valence BndsRnXp=20&amp;quot;,.. &lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:4 w lp t &amp;quot; Conduction BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:4 w lp t &amp;quot;Conduction BndsRnXp=20&amp;quot;,..&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;10b.dat&amp;quot; u 1:($4-$3) w lp t &amp;quot; Gap BndsRnXp=10&amp;quot;, &amp;quot;20b.dat&amp;quot; u 1:($4-$3) w lp t &amp;quot;gap BndsRnXp=20&amp;quot;,..  &lt;br /&gt;
or both using e.g. the [[gnuplot_scripts|ppa_gap.gnu]] gnuplot script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=1 caption=&amp;quot;Quasiparticle energies with respect screening parameters&amp;quot;&amp;gt;&lt;br /&gt;
File:ppa2.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
File:ppa3.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#BndsRnXp|BndsRnXp]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[Variables#NGsBlkXp|NGsBlkXp]]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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;
Finally notice that in the last versions of Yambo (from 4.5 etc.) there is a terminator for the dielectric constant that accelerates convergence on the number of bands,&lt;br /&gt;
you can active it with the &amp;lt;code&amp;gt;-V resp&amp;lt;/code&amp;gt; verbosity and setting &amp;lt;code&amp;gt;XTermKind= &amp;quot;BG&amp;quot;&amp;lt;/code&amp;gt;. You can compare the converge of the dielectric constant with and without terminator,&lt;br /&gt;
similar to what happens for the self-energy, see next section.&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 $4+$5}&#039;&lt;br /&gt;
for the valence bands, and &lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; o-Gbnd*  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
for the conduction band.&lt;br /&gt;
&lt;br /&gt;
Collect the results in a text file &#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=1 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;
File:Gbnd_gap.png|Gap 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;
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;
====Accelerating the sum over states convergence in the correlation self-energy====&lt;br /&gt;
In general the convergence with respect the sum over states can be very cumbersome. Here we show how it can be mitigated by using &lt;br /&gt;
a technique developed by F. Bruneval and X. Gonze &amp;lt;ref name=&amp;quot;BG&amp;quot;&amp;gt; F. Bruneval and X. Gonze, Physical Review B 78, 085125  (2008 )&amp;lt;/ref&amp;gt;. The basic idea relies in replacing the eigenenergies of the states that are not treated explicitly by a common energy, and take into account all the states, which are not explicitly included in the calculation through the closure relation.&lt;br /&gt;
To apply this technique in Yambo we need to activate the optional terminator variable [[Variables#GTermKind|GTermKind]]. We can activate it by adding the quasiparticle verbosity to the command line when generating the input file:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -p p -g n -F gw_ppa_Gbnd10.in -V qp&lt;br /&gt;
&lt;br /&gt;
and you can edit the input file by setting:&lt;br /&gt;
 &lt;br /&gt;
 [[Variables#GTermKind|GTermKind]]= &amp;quot;BG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
or simply you can add by hand this line in all the other &#039;&#039;gw_ppa_GbndX.in&#039;&#039; input files.&lt;br /&gt;
Now we can repeat the same calculations &lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd10.in -J Gbnd10_term&lt;br /&gt;
 $ yambo -F gw_ppa_Gbnd20.in -J Gbnd20_term&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
and collect the new results:&lt;br /&gt;
&lt;br /&gt;
 $ grep &amp;quot;7 * 8&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039;&lt;br /&gt;
 $ grep &amp;quot;7 * 9&amp;quot; *term.qp  | awk &#039;{print $4+$5}&#039; &lt;br /&gt;
&lt;br /&gt;
in a new file called &#039;&#039;Gbnd_conv_terminator.dat&#039;&#039;. Now we can plot the same quantities as before by looking at the effect of having introduced the terminator. &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 t &amp;quot;Valence&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:2 w lp t &amp;quot;Valence with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:3 w lp t &amp;quot;Conduction with terminator&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;Gbnd_conv.dat&amp;quot; u 1:($3-$2)  w lp t &amp;quot;Gap&amp;quot;, &amp;quot;Gbnd_conv_terminator.dat&amp;quot; u 1:($3-$2) w lp t &amp;quot;Gap with terminator&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery mode=nolines widths=500px heights=500px perrow=3 caption=&amp;quot;Effect of the terminator in convergence of QP energies with respect sum over states&amp;quot;&amp;gt;&lt;br /&gt;
File:val_t.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique &amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:cond_t.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
File:gap_t.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt; with and without the terminator technique&amp;lt;ref name=&amp;quot;BG&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 accelerated in particular for the single quasiparticle states.&lt;br /&gt;
* From the plot above we can see that &amp;lt;code&amp;gt;[[Variables#GbndRange|GbndRange]]&amp;lt;/code&amp;gt;=40 is sufficient to have a converged gap&lt;br /&gt;
&lt;br /&gt;
===Beyond the plasmon pole approximation: a full frequency approach - real axis integration===&lt;br /&gt;
All the calculations performed up to now were based on the plasmon pole approximation (PPA). Now we remove this approximation by evaluating numerically the frequency integral in the expression of the correlation self-energy (Σc). To this aim we need to evaluate the screening for a number of frequencies in the interval depending on the electron-hole energy difference (energy difference between empty and occupied states) entering in the sum over states. &lt;br /&gt;
Let&#039;s build the input file for a full frequency calculation by simply typing:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff.in -g n -p r&lt;br /&gt;
&lt;br /&gt;
and we can set the variable studied up to now at their converged value:&lt;br /&gt;
&lt;br /&gt;
 %[[Variables#BndsRnXd|BndsRnXd]]&lt;br /&gt;
 1 | 30 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#NGsBlkXd|NGsBlkXd]]=3000 mRy&lt;br /&gt;
 %[[Variables#GbndRange|GbndRange]]&lt;br /&gt;
 1 | 40 |&lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#EXXRLvcs|EXXRLvcs]]=40000 mRy&lt;br /&gt;
 % [[Variables#LongDrXd|LongDrXd]] &lt;br /&gt;
 1.000000 | 1.000000 | 1.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&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;
and next vary in different files (name them &#039;&#039;gw_ff10.in&#039;&#039; etc.) the number of frequencies we evaluate for the screened coulomb potential. This is done by setting the values of [[Variables#ETStpsXd|ETStpsXd]]=10 , 50 , 100, 150, 200, 250. &lt;br /&gt;
You can also run the the [[bash_scripts|generate_inputs_3.sh]] bash script to generate the required input files.&lt;br /&gt;
&lt;br /&gt;
Next launch yambo:&lt;br /&gt;
 $ yambo -F gw_ff10.in -J ff10&lt;br /&gt;
 $ yambo -F gw_ff50.in -J ff50&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
Clearly as we are evaluating the screening for a large number of frequencies these calculations will be heavier than the case above where the calculation of the screening was done for only two frequencies  (zero and plasmon-pole). &lt;br /&gt;
As before, collect the valence and conduction bands as a function of the number of frequencies in a file called &#039;&#039;gw_ff.dat&#039;&#039; and plot the behaviour of the conduction and valence bands and the gap.&lt;br /&gt;
 &lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:2  w lp t &amp;quot;Valence&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:3  w lp t &amp;quot;Conduction&amp;quot;&lt;br /&gt;
 gnuplot&amp;gt; p &amp;quot;gw_ff.dat&amp;quot; u 1:($3-$2)  w lp 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=3 caption=&amp;quot;Real axis integration, convergences with respect the used number of frequencies&amp;quot;&amp;gt;&lt;br /&gt;
File:ff_v.png|Valence band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt;&lt;br /&gt;
File:ff_c.png|Conduction band energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
File:ff_g.png|Gap energy wrt &amp;lt;code&amp;gt;[[Variables#ETStpsXd|ETStpsXd]]&amp;lt;/code&amp;gt; &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see that:&lt;br /&gt;
&lt;br /&gt;
* Oscillations are still present, indicating that even more frequencies have to be considered. In general, a real-axis calculation is very demanding. &lt;br /&gt;
* The final result of the gap obtained up to now does not differ too much from the one obtained at the plasmon-pole level (~50 meV)&lt;br /&gt;
&lt;br /&gt;
As the real-axis calculation is computational demanding, in the last years it has been developed in Yambo an alternative method called Multipole approximation (MPA). The MPA can be seen as an extension of the PPA, where you take a finite number of poles instead of just one. It has been seen that even a small number of poles grants a MPA on par with a full real axis calculation. For your reference, at [[Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)|https://www.yambo-code.eu/wiki/index.php/Quasi-particles_and_Self-energy_within_the_Multipole_Approximation_(MPA)]] there is a tutorial on the MPA method. For now, however, let us pass over to the next section.&lt;br /&gt;
&lt;br /&gt;
===Secant Solver===&lt;br /&gt;
&lt;br /&gt;
The real axis integration permits also to go beyond the linear expansion to solve the quasi particle equation. &lt;br /&gt;
The QP equation is a non-linear equation whose solution must be found using a suitable numerical algorithm. &lt;br /&gt;
[[File:Eqp_sec.png|none|x22px|caption]] &lt;br /&gt;
The mostly used, based on the linearization of the self-energy operator is the Newton method that is the one we have used up to now. &lt;br /&gt;
Yambo can also perform a search of the QP energies using a non-linear iterative method based on the [https://en.wikipedia.org/wiki/Secant_method Secant iterative Method].&lt;br /&gt;
&lt;br /&gt;
In numerical analysis, the secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function &#039;&#039;f&#039;&#039;. The secant method can be thought of as a finite difference approximation of Newton&#039;s method. &lt;br /&gt;
The equation that defines the secant method is: &lt;br /&gt;
&lt;br /&gt;
[[File:secant_eq.png|none|x35px|caption]] &lt;br /&gt;
&lt;br /&gt;
The first two iterations of the secant method are shown in the following picture. The red curve shows the function f and the blue lines are the secants.&lt;br /&gt;
&lt;br /&gt;
[[File:Secant_method.png|center|250px|caption]] &lt;br /&gt;
&lt;br /&gt;
To see if there is any non-linear effect in the solution of the Dyson equation we compare the result of the calculation using the Newton solver as done before with the present case. &lt;br /&gt;
In order to use the secant method you need to edit one of the the previous &#039;&#039;gw_ffN.in&#039;&#039; files e.g. &#039;&#039;gw_ff100.in&#039;&#039; and substitute:&lt;br /&gt;
&lt;br /&gt;
 DysSolver= &amp;quot;g&amp;quot;&lt;br /&gt;
to &lt;br /&gt;
 DysSolver= &amp;quot;s&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Repeat the calculations in the same way as before:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F gw_ff100.in -J ff100&lt;br /&gt;
&lt;br /&gt;
Note than now the screening will &#039;&#039;not&#039;&#039; be calculated again as it has been stored in the &#039;&#039;ffN&#039;&#039; directories as can be seen in the report file:&lt;br /&gt;
&lt;br /&gt;
 [05] Dynamical Dielectric Matrix&lt;br /&gt;
 ================================&lt;br /&gt;
 [RD./ff10//ndb.em1d]----&lt;br /&gt;
 ...&lt;br /&gt;
 [RD./ff10//ndb.em1d_fragment_1]--------------&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Comparing the output files, e.g. for the case with 100 freqs:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp&#039;&#039;  &#039;&#039;&#039;Newton Solver:&#039;&#039;&#039;&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8  -0.41188   -0.08708      2.91254 &lt;br /&gt;
   7   9   3.877976   1.421968    -3.417357 &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;o-ff100.qp_01&#039;&#039; &#039;&#039;&#039;Secant Solver:&#039;&#039;&#039;&lt;br /&gt;
 #&lt;br /&gt;
 #  K-point    Band       Eo         E-Eo       Sc|Eo&lt;br /&gt;
 #&lt;br /&gt;
   7   8   -0.41188   -0.08715      2.93518 &lt;br /&gt;
   7   9   3.877976   1.401408    -3.731649 &lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
From the comparison, we see that the effect is of the order of 20 meV, of the same order of magnitude of the accuracy of the GW calculations.&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= 3000            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;
&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;BOLTZ&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_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;
&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=6947</id>
		<title>First steps: walk through from DFT(standalone)</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=First_steps:_walk_through_from_DFT(standalone)&amp;diff=6947"/>
		<updated>2023-05-24T15:25:26Z</updated>

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

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* RIM */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 4.109 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6929</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6929"/>
		<updated>2023-05-23T15:27:29Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* RIM */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6928</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6928"/>
		<updated>2023-05-23T15:24:03Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
 &lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
 &lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
 &lt;br /&gt;
 EOF&lt;br /&gt;
 &lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6927</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6927"/>
		<updated>2023-05-23T15:23:35Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, create the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --partition=m100_sys_test&lt;br /&gt;
 #SBATCH --qos=qos_test&lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo&lt;br /&gt;
 #SBATCH --time=0:30:00&lt;br /&gt;
 #SBATCH --account=tra23_Yambo&lt;br /&gt;
 #SBATCH --mem=230000MB&lt;br /&gt;
 #SBATCH --job-name=rutile&lt;br /&gt;
 #SBATCH --error=err.job-%j&lt;br /&gt;
 #SBATCH --output=out.job-%j&lt;br /&gt;
&lt;br /&gt;
 # load yambo and dependencies&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
 export OMP_NUM_THREADS=${SLURM_CPUS_PER_TASK}&lt;br /&gt;
&lt;br /&gt;
 # info&lt;br /&gt;
 ncpu=${SLURM_NTASKS}&lt;br /&gt;
 nthreads=${OMP_NUM_THREADS}&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;
 # Update input file&lt;br /&gt;
 filein0=gw.in         # Original file&lt;br /&gt;
 filein=gw_${label}.in # New file&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot; # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;   # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV=1    # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&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                # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 # run yambo&lt;br /&gt;
 mpirun -n $ncpu yambo -F $filein -J ${jdir} -C $cdir&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6926</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6926"/>
		<updated>2023-05-23T15:20:55Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* RIM */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6923</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6923"/>
		<updated>2023-05-23T10:36:39Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 3: Running on GPU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 20 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 2 MPI tasks, and using 1 thread.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6922</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6922"/>
		<updated>2023-05-23T10:35:51Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 3: Running on GPU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 20 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have still the total number of tasks equal to 8. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 8 MPI tasks, and using 4 threads.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6921</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6921"/>
		<updated>2023-05-23T10:30:35Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 3: Running on GPU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 20 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have &amp;lt;code&amp;gt;ntasks-per-node=2&amp;lt;/code&amp;gt;. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, even though we are we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 8 MPI tasks, and using 4 threads.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely CPU calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6920</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6920"/>
		<updated>2023-05-23T10:29:50Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 2: GW parallel strategies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 20 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done when using Yambo on clusters. So, now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_2Dquasiparticle_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;. You should see we compute a much larger number of quasi-particles:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
The [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have &amp;lt;code&amp;gt;ntasks-per-node=2&amp;lt;/code&amp;gt;. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, even though we are we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 8 MPI tasks, and using 4 threads.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely MPI calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Rome_2023&amp;diff=6919</id>
		<title>Rome 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Rome_2023&amp;diff=6919"/>
		<updated>2023-05-23T10:24:00Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* DAY 2 - Tuesday, 23 May */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A general description of the goal(s) of the school can be found on the [https://www.yambo-code.eu/2023/02/18/yambo-school-2023/ Yambo main website]&lt;br /&gt;
&lt;br /&gt;
== Use CINECA computational resources ==&lt;br /&gt;
Yambo tutorials will be run on the MARCONI100 (M100) accelerated cluster. You can find info about M100 [https://wiki.u-gov.it/confluence/display/SCAIUS/UG3.2%3A+MARCONI100+UserGuide#UG3.2:MARCONI100UserGuide here].&lt;br /&gt;
In order to access computational resources provided by CINECA you need your personal username and password that were sent you by the organizers.&lt;br /&gt;
&lt;br /&gt;
=== Connect to the cluster using ssh ===&lt;br /&gt;
&lt;br /&gt;
You can access M100 via &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; protocol in different ways.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using username and password &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use the following command replacing your username:&lt;br /&gt;
 $ ssh username@login.m100.cineca.it&lt;br /&gt;
&lt;br /&gt;
However, in this way you have to type your password each time you want to connect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using ssh key &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can setup a ssh key pair to avoid typing the password each time you want to connect to M100. To do so, go to your &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory (usually located in the &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; directory):&lt;br /&gt;
 $ cd $HOME/.ssh&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have this directory, you can create it with &amp;lt;code&amp;gt;mkdir $HOME/.ssh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Once you are in the &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory, run the &amp;lt;code&amp;gt;ssh-keygen&amp;lt;/code&amp;gt; command to generate a private/public key pair:&lt;br /&gt;
 $ ssh-keygen&lt;br /&gt;
 Generating public/private rsa key pair.&lt;br /&gt;
 Enter file in which to save the key: m100_id_rsa&lt;br /&gt;
 Enter passphrase (empty for no passphrase): &lt;br /&gt;
 Enter same passphrase again: &lt;br /&gt;
 Your identification has been saved in &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa&lt;br /&gt;
 Your public key has been saved in &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa.pub&lt;br /&gt;
 The key fingerprint is:&lt;br /&gt;
 &amp;lt;...&amp;gt;&lt;br /&gt;
 The key&#039;s randomart image is:&lt;br /&gt;
 &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to copy the &#039;&#039;&#039;public&#039;&#039;&#039; key to M100. You can do that with the following command (for this step you need to type your password):&lt;br /&gt;
 $ ssh-copy-id -i &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa.pub &amp;lt;username&amp;gt;@login.m100.cineca.it&lt;br /&gt;
&lt;br /&gt;
Once the public key has been copied, you can connect to M100 without having to type the password using the &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ ssh -i &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa username@login.m100.cineca.it&lt;br /&gt;
&lt;br /&gt;
To simplify even more, you can paste the following lines in a file named &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; located inside the &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory adjusting username and path:&lt;br /&gt;
 Host m100 &lt;br /&gt;
  HostName login.m100.cineca.it&lt;br /&gt;
  User username&lt;br /&gt;
  IdentityFile &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa&lt;br /&gt;
&lt;br /&gt;
With the &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; file setup you can connect simply with&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
&lt;br /&gt;
=== General instructions to run tutorials ===&lt;br /&gt;
&lt;br /&gt;
Before proceeding, it is useful to know the different workspaces you have available on M100, which can be accessed using environment variables. The main ones are:&lt;br /&gt;
* &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; directory associated to your username; &lt;br /&gt;
* &amp;lt;code&amp;gt;$WORK&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;work&amp;lt;/code&amp;gt; directory associated to the account where the computational resources dedicated to this school are allocated;&lt;br /&gt;
* &amp;lt;code&amp;gt;$CINECA_SCRATCH&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;scratch&amp;lt;/code&amp;gt; directory associated to your username.&lt;br /&gt;
You can find more details about storage and FileSystems [https://wiki.u-gov.it/confluence/display/SCAIUS/UG2.5%3A+Data+storage+and+FileSystems here].&lt;br /&gt;
&lt;br /&gt;
Please don&#039;t forget to &#039;&#039;&#039;run all tutorials in your scratch directory&#039;&#039;&#039;:&lt;br /&gt;
 $ echo $CINECA_SCRATCH&lt;br /&gt;
 /m100_scratch/userexternal/username&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
&lt;br /&gt;
Computational resources on M100 are managed by the job scheduling system [https://slurm.schedmd.com/overview.html Slurm]. Most part of Yambo tutorials during this school can be run in serial, except some that need to be executed on multiple processors. Generally, Slurm batch jobs are submitted using a script, but the tutorials here are better understood if run interactively. The two procedures that we will use to submit interactive and non interactive jobs are explained below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Run a job using a batch script &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
This procedure is suggested for the tutorials and examples that need to be run in parallel. In these cases you need to submit the job using a batch script &amp;lt;code&amp;gt;job.sh&amp;lt;/code&amp;gt;, whose generic structure is the following:&lt;br /&gt;
 $ more job.sh&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra23_Yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=JOB                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition= m100_sys_test      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --qos=qos_test                  # qos = quality of service &lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school &lt;br /&gt;
 #          &lt;br /&gt;
 #SBATCH --nodes=&amp;lt;N&amp;gt;                     # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=&amp;lt;nt&amp;gt;          # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --ntasks-per-socket=&amp;lt;nt/2&amp;gt;      # Tasks invoked on each socket&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;nc&amp;gt;            # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-mpi/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=&amp;lt;nc&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 mpirun --rank-by core -np ${SLURM_NTASKS} \&lt;br /&gt;
        yambo -F &amp;lt;input&amp;gt; -J &amp;lt;output&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for the tutorials and examples that need to be run in parallel. In these cases you need to submit the job using a batch script &amp;lt;code&amp;gt;job.sh&amp;lt;/code&amp;gt;. Please note that the instructions in the batch script must be compatible with the specific M100 [https://wiki.u-gov.it/confluence/display/SCAIUS/UG3.2%3A+MARCONI100+UserGuide#UG3.2:MARCONI100UserGuide-SystemArchitecture architecture] and [https://wiki.u-gov.it/confluence/display/SCAIUS/UG3.2%3A+MARCONI100+UserGuide#UG3.2:MARCONI100UserGuide-Accounting accounting] systems. The complete list of Slurm options can be found [https://slurm.schedmd.com/sbatch.html here]. However you will find &#039;&#039;&#039;ready-to-use&#039;&#039;&#039; batch scripts in locations specified during the tutorials. &lt;br /&gt;
&lt;br /&gt;
To submit the job, use the &amp;lt;code&amp;gt;sbatch&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 $ sbatch job.sh&lt;br /&gt;
 Submitted batch job &amp;lt;JOBID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the job status, use the &amp;lt;code&amp;gt;squeue&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 $ squeue -u &amp;lt;username&amp;gt;&lt;br /&gt;
              JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)&lt;br /&gt;
              &amp;lt;...&amp;gt;  m100_...      JOB username  R       0:01    &amp;lt;N&amp;gt; &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you need to cancel your job, do:&lt;br /&gt;
 $ scancel &amp;lt;JOBID&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Open an interactive session &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for most of the tutorials, since the majority of these is meant to be run in serial (relatively to MPI parallelization) from the command line. Use the command below to open an interactive session of 1 hour (complete documentation [https://slurm.schedmd.com/salloc.html here]):&lt;br /&gt;
 $ salloc -A tra23_Yambo -p m100_sys_test -q qos_test --reservation=s_tra_yambo --nodes=1 --ntasks-per-node=1 --cpus-per-task=4 -t 01:00:00&lt;br /&gt;
 salloc: Granted job allocation 10164647&lt;br /&gt;
 salloc: Waiting for resource configuration&lt;br /&gt;
 salloc: Nodes r256n01 are ready for job&lt;br /&gt;
&lt;br /&gt;
We ask for 4 cpus-per-task because we can exploit OpenMP parallelization with the available resources.&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;squeue&amp;lt;/code&amp;gt; you can see that there is now a job running:&lt;br /&gt;
 $ squeue -u username&lt;br /&gt;
              JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)&lt;br /&gt;
           10164647 m100_usr_ interact username  R       0:02      1 r256n01&lt;br /&gt;
&lt;br /&gt;
To run the tutorial, &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; into the node specified by the job allocation and &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to your scratch directory:&lt;br /&gt;
 username@&#039;&#039;&#039;login02&#039;&#039;&#039;$ ssh r256n01&lt;br /&gt;
 ...&lt;br /&gt;
 username@&#039;&#039;&#039;r256n01&#039;&#039;&#039;$ cd $CINECA_SCRATCH&lt;br /&gt;
&lt;br /&gt;
Then, you need to manually load &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; as in the batch script above. Please note that the serial version of the code is in a different directory and does not need &amp;lt;code&amp;gt;spectrum_mpi&amp;lt;/code&amp;gt;:&lt;br /&gt;
 $ module purge&lt;br /&gt;
 $ module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 $ export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
Finally, set the &amp;lt;code&amp;gt;OMP_NUM_THREADS&amp;lt;/code&amp;gt; environment variable to 4 (as in the &amp;lt;code&amp;gt;--cpus-per-task&amp;lt;/code&amp;gt; option):&lt;br /&gt;
 $ export OMP_NUM_THREADS=4&lt;br /&gt;
&lt;br /&gt;
To close the interactive session when you have finished, log out of the compute node with the &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; command, and then cancel the job:&lt;br /&gt;
 $ exit&lt;br /&gt;
 $ scancel &amp;lt;JOBID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Plot results with gnuplot &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the tutorials you will often need to plot the results of the calculations. In order to do so on M100, &#039;&#039;&#039;open a new terminal window&#039;&#039;&#039; and connect to M100 enabling X11 forwarding with the &amp;lt;code&amp;gt;-X&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ ssh -X m100&lt;br /&gt;
&lt;br /&gt;
Please note that &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; can be used in this way only from the login nodes:&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ cd &amp;lt;directory_with_data&amp;gt;&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 Terminal type is now &#039;...&#039;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Set up yambopy &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In order to run yambopy on m100, you must first setup the conda environment (to be done only once):&lt;br /&gt;
 $ cd&lt;br /&gt;
 $ module load anaconda/2020.11&lt;br /&gt;
 $ conda init bash&lt;br /&gt;
 $ source .bashrc&lt;br /&gt;
&lt;br /&gt;
After this, every time you want to use yambopy you need to load its module and environment:&lt;br /&gt;
 $ module load anaconda/2020.11&lt;br /&gt;
 $ conda activate /m100_work/tra23_Yambo/softwares/YAMBO/env_yambopy&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 22 May === &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;16:15 - 18:30 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN.tar.gz                         100%[================================================================&amp;gt;]  10.81M  52.6MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN-2D.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN-2D.tar.gz                      100%[================================================================&amp;gt;]   8.56M  46.7MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ ls&lt;br /&gt;
 hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
 $ ls&lt;br /&gt;
 &#039;&#039;&#039;hBN-2D&#039;&#039;&#039; &#039;&#039;&#039;hBN&#039;&#039;&#039; hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now that you have all the files, you may open the interactive job session with &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; as explained above and proceed with the tutorials.&lt;br /&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;
At this point, you may learn about the python pre-postprocessing capabilities offered by yambopy, our python interface to yambo and QE. First of all, let&#039;s create a dedicated directory, download and extract the related files.&lt;br /&gt;
 &lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ mkdir YAMBOPY_TUTORIALS&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/databases_yambopy.tar&lt;br /&gt;
 $ tar -xvf databases_yambopy.tar&lt;br /&gt;
 $ cd databases_yambopy&lt;br /&gt;
&lt;br /&gt;
Then, follow &#039;&#039;&#039;the first three sections&#039;&#039;&#039; of this link, which are related to initialization and linear response.&lt;br /&gt;
* [[Yambopy tutorial: Yambo databases|Reading databases with yambopy]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 23 May ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:00 - 16:30 A tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get all the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
&lt;br /&gt;
 ssh m100&lt;br /&gt;
 cd $CINECA_SCRATCH&lt;br /&gt;
 cd YAMBO_TUTORIALS&lt;br /&gt;
 wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
 wget https://media.yambo-code.eu/educational/tutorials/files/MoS2_2Dquasiparticle_tutorial.tar.gz&lt;br /&gt;
 tar -xvf hBN.tar.gz&lt;br /&gt;
 tar -xvf MoS2_2Dquasiparticle_tutorial.tar.gz&lt;br /&gt;
 cd hBN&lt;br /&gt;
&lt;br /&gt;
Now you can start the first tutorial:&lt;br /&gt;
&lt;br /&gt;
* [[GW tutorial Rome 2023 | GW computations on practice: how to obtain the quasi-particle band structure of a bulk material ]]&lt;br /&gt;
&lt;br /&gt;
If you have gone through the first tutorial, pass now to the second one:&lt;br /&gt;
 &lt;br /&gt;
 cd $CINECA_SCRATCH&lt;br /&gt;
 cd YAMBO_TUTORIALS&lt;br /&gt;
 cd MoS2_HPC_tutorial&lt;br /&gt;
&lt;br /&gt;
* [[Quasi-particles of a 2D system | Quasi-particles of a 2D system ]]&lt;br /&gt;
&lt;br /&gt;
To conclude, you can learn an other method to plot the band structure in Yambo&lt;br /&gt;
&lt;br /&gt;
* [[Yambopy tutorial: band structures| Yambopy tutorial: band structures]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 24 May ===&lt;br /&gt;
&#039;&#039;&#039;14:00 - 16:30 Bethe-Salpeter equation (BSE)&#039;&#039;&#039; Fulvio Paleari (CNR-Nano, Italy), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz # NOTE: YOU SHOULD ALREADY HAVE THIS FROM DAY 1&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN.tar.gz                         100%[================================================================&amp;gt;]  10.81M  52.6MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-convergence-kpoints.tar.gz &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN-convergence-kpoints.tar.gz’&lt;br /&gt;
&lt;br /&gt;
hBN-convergence-kpoints.tar.gz    100%[============================================================&amp;gt;] 226.10M  62.3MB/s    in 3.7s&lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ tar -xvf hBN-convergence-kpoints.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now, you may open the interactive job session with &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; and proceed with the following tutorials.&lt;br /&gt;
&lt;br /&gt;
* [[Calculating optical spectra including excitonic effects: a step-by-step guide|Perform a BSE calculation from beginning to end ]]&lt;br /&gt;
* [[How to analyse excitons - ICTP 2022 school|Analyse your results (exciton wavefunctions in real and reciprocal space, etc.) ]]&lt;br /&gt;
* [[BSE solvers overview|Solve the BSE eigenvalue problem with different numerical methods]]&lt;br /&gt;
* [[How to choose the input parameters|Choose the input parameters for a meaningful converged calculation]]&lt;br /&gt;
Now, go into the yambopy tutorial directory to learn about python analysis tools for the BSE:&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS/databases_yambopy&lt;br /&gt;
&lt;br /&gt;
* [[Yambopy_tutorial:_Yambo_databases#Exciton_intro_1:_read_and_sort_data|Visualization of excitonic properties with yambopy]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;17:00 - 18:30 Bethe-Salpeter equation in real time (TD-HSEX)&#039;&#039;&#039; Fulvio Paleari (CNR-Nano, Italy), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
The files needed for the following tutorials can be downloaded following these steps:&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-RT.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN-2D-RT.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN-2D-RT.tar.gz                         100%[================================================================&amp;gt;]  10.81M  52.6MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ tar -xvf hBN-2D-RT.tar.gz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[Introduction_to_Real_Time_propagation_in_Yambo#Time_Dependent_Equation_for_the_Reduced_One--Body_Density--Matrix|Read the introductive section to real-time propagation for the one-body density matrix]] (the part about time-dependent Schrödinger equation will be covered on DAY 4 and you can skip it for now)&lt;br /&gt;
* [[Prerequisites for Real Time propagation with Yambo|Perform the setup for a real-time calculation]]&lt;br /&gt;
* [[Linear response from real time simulations (density matrix only)|Calculate the linear response in real time]]&lt;br /&gt;
* [[Real time Bethe-Salpeter Equation (density matrix only)|Calculate the BSE in real time]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, May 25 ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:00 - 16:30 Real-time approach with the time dependent berry phase&#039;&#039;&#039; Myrta Gruning (Queen&#039;s University Belfast), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
* [[Linear response from Bloch-states dynamics]] (in preparation)&lt;br /&gt;
* [[Second-harmonic generation of 2D-hBN]] (in preparation)&lt;br /&gt;
&lt;br /&gt;
* [[Real time approach to non-linear response]] (additional tutorial)&lt;br /&gt;
* [[Correlation effects in the non-linear response]] (additional tutorial)&lt;br /&gt;
&lt;br /&gt;
=== DAY 5 - Friday, 26 May ===&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 22 May ===&lt;br /&gt;
&lt;br /&gt;
* D. Varsano, [https://media.yambo-code.eu/educational/Schools/ROME2023/scuola_intro.pdf Description and goal of the school].&lt;br /&gt;
* G. Stefanucci, [https://media.yambo-code.eu/educational/Schools/ROME2023/Stefanucci.pdf The Many-Body Problem: Key concepts of the Many-Body Perturbation Theory]&lt;br /&gt;
* M. Marsili, [https://media.yambo-code.eu/educational/Schools/ROME2023/marghe_linear_response.pdf Beyond the independent particle scheme: The linear response theory]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 23 May ===&lt;br /&gt;
&lt;br /&gt;
* E. Perfetto, [https://media.yambo-code.eu/educational/Schools/ROME2023/Talk_Perfetto.pdf An overview on non-equilibrium Green Functions]&lt;br /&gt;
* R. Frisenda, ARPES spectroscopy, an experimental overview&lt;br /&gt;
* A. Marini, The Quasi Particle concept and the GW method&lt;br /&gt;
* A. Guandalini, The GW method: approximations and algorithms&lt;br /&gt;
* D.A. Leon, C. Cardoso, Frequency dependence in GW: origin, modelling and practical implementations&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 24 May ===&lt;br /&gt;
&lt;br /&gt;
* A. Molina-Sánchez, Modelling excitons: from 2D materials to Pump and Probe experiments&lt;br /&gt;
* M. Palummo, The Bethe-Salpeter equation: derivations and main physical concepts&lt;br /&gt;
* F. Paleari, Real time approach to the Bethe-Salpeter equation&lt;br /&gt;
* D. Sangalli, TD-HSEX and real-time dynamics&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, 25 May ===&lt;br /&gt;
&lt;br /&gt;
* S. Mor, Time resolved spectroscopy: an  experimental overview&lt;br /&gt;
* M. Grüning, Nonlinear optics within Many-Body Perturbation Theory&lt;br /&gt;
* N. Tancogne-Dejean, Theory and simulation of High Harmonics Generation&lt;br /&gt;
* Y. Pavlyukh, Coherent electron-phonon dynamics within a time-linear GKBA scheme&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Rome_2023&amp;diff=6918</id>
		<title>Rome 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Rome_2023&amp;diff=6918"/>
		<updated>2023-05-23T10:23:24Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* DAY 2 - Tuesday, 23 May */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A general description of the goal(s) of the school can be found on the [https://www.yambo-code.eu/2023/02/18/yambo-school-2023/ Yambo main website]&lt;br /&gt;
&lt;br /&gt;
== Use CINECA computational resources ==&lt;br /&gt;
Yambo tutorials will be run on the MARCONI100 (M100) accelerated cluster. You can find info about M100 [https://wiki.u-gov.it/confluence/display/SCAIUS/UG3.2%3A+MARCONI100+UserGuide#UG3.2:MARCONI100UserGuide here].&lt;br /&gt;
In order to access computational resources provided by CINECA you need your personal username and password that were sent you by the organizers.&lt;br /&gt;
&lt;br /&gt;
=== Connect to the cluster using ssh ===&lt;br /&gt;
&lt;br /&gt;
You can access M100 via &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; protocol in different ways.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using username and password &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use the following command replacing your username:&lt;br /&gt;
 $ ssh username@login.m100.cineca.it&lt;br /&gt;
&lt;br /&gt;
However, in this way you have to type your password each time you want to connect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Connect using ssh key &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can setup a ssh key pair to avoid typing the password each time you want to connect to M100. To do so, go to your &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory (usually located in the &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; directory):&lt;br /&gt;
 $ cd $HOME/.ssh&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have this directory, you can create it with &amp;lt;code&amp;gt;mkdir $HOME/.ssh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Once you are in the &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory, run the &amp;lt;code&amp;gt;ssh-keygen&amp;lt;/code&amp;gt; command to generate a private/public key pair:&lt;br /&gt;
 $ ssh-keygen&lt;br /&gt;
 Generating public/private rsa key pair.&lt;br /&gt;
 Enter file in which to save the key: m100_id_rsa&lt;br /&gt;
 Enter passphrase (empty for no passphrase): &lt;br /&gt;
 Enter same passphrase again: &lt;br /&gt;
 Your identification has been saved in &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa&lt;br /&gt;
 Your public key has been saved in &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa.pub&lt;br /&gt;
 The key fingerprint is:&lt;br /&gt;
 &amp;lt;...&amp;gt;&lt;br /&gt;
 The key&#039;s randomart image is:&lt;br /&gt;
 &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you need to copy the &#039;&#039;&#039;public&#039;&#039;&#039; key to M100. You can do that with the following command (for this step you need to type your password):&lt;br /&gt;
 $ ssh-copy-id -i &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa.pub &amp;lt;username&amp;gt;@login.m100.cineca.it&lt;br /&gt;
&lt;br /&gt;
Once the public key has been copied, you can connect to M100 without having to type the password using the &amp;lt;code&amp;gt;-i&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ ssh -i &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa username@login.m100.cineca.it&lt;br /&gt;
&lt;br /&gt;
To simplify even more, you can paste the following lines in a file named &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; located inside the &amp;lt;code&amp;gt;.ssh&amp;lt;/code&amp;gt; directory adjusting username and path:&lt;br /&gt;
 Host m100 &lt;br /&gt;
  HostName login.m100.cineca.it&lt;br /&gt;
  User username&lt;br /&gt;
  IdentityFile &amp;lt;your_.ssh_dir&amp;gt;/m100_id_rsa&lt;br /&gt;
&lt;br /&gt;
With the &amp;lt;code&amp;gt;config&amp;lt;/code&amp;gt; file setup you can connect simply with&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
&lt;br /&gt;
=== General instructions to run tutorials ===&lt;br /&gt;
&lt;br /&gt;
Before proceeding, it is useful to know the different workspaces you have available on M100, which can be accessed using environment variables. The main ones are:&lt;br /&gt;
* &amp;lt;code&amp;gt;$HOME&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;home&amp;lt;/code&amp;gt; directory associated to your username; &lt;br /&gt;
* &amp;lt;code&amp;gt;$WORK&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;work&amp;lt;/code&amp;gt; directory associated to the account where the computational resources dedicated to this school are allocated;&lt;br /&gt;
* &amp;lt;code&amp;gt;$CINECA_SCRATCH&amp;lt;/code&amp;gt;: it&#039;s the &amp;lt;code&amp;gt;scratch&amp;lt;/code&amp;gt; directory associated to your username.&lt;br /&gt;
You can find more details about storage and FileSystems [https://wiki.u-gov.it/confluence/display/SCAIUS/UG2.5%3A+Data+storage+and+FileSystems here].&lt;br /&gt;
&lt;br /&gt;
Please don&#039;t forget to &#039;&#039;&#039;run all tutorials in your scratch directory&#039;&#039;&#039;:&lt;br /&gt;
 $ echo $CINECA_SCRATCH&lt;br /&gt;
 /m100_scratch/userexternal/username&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
&lt;br /&gt;
Computational resources on M100 are managed by the job scheduling system [https://slurm.schedmd.com/overview.html Slurm]. Most part of Yambo tutorials during this school can be run in serial, except some that need to be executed on multiple processors. Generally, Slurm batch jobs are submitted using a script, but the tutorials here are better understood if run interactively. The two procedures that we will use to submit interactive and non interactive jobs are explained below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Run a job using a batch script &#039;&#039;&#039;&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
This procedure is suggested for the tutorials and examples that need to be run in parallel. In these cases you need to submit the job using a batch script &amp;lt;code&amp;gt;job.sh&amp;lt;/code&amp;gt;, whose generic structure is the following:&lt;br /&gt;
 $ more job.sh&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --account=tra23_Yambo           # Charge resources used by this job to specified account&lt;br /&gt;
 #SBATCH --time=00:10:00                 # Set a limit on the total run time of the job allocation in hh:mm:ss&lt;br /&gt;
 #SBATCH --job-name=JOB                  # Specify a name for the job allocation&lt;br /&gt;
 #SBATCH --partition= m100_sys_test      # Request a specific partition for the resource allocation&lt;br /&gt;
 #SBATCH --qos=qos_test                  # qos = quality of service &lt;br /&gt;
 #SBATCH --reservation=s_tra_yambo       # Reservation specific to this school &lt;br /&gt;
 #          &lt;br /&gt;
 #SBATCH --nodes=&amp;lt;N&amp;gt;                     # Number of nodes to be allocated for the job&lt;br /&gt;
 #SBATCH --ntasks-per-node=&amp;lt;nt&amp;gt;          # Number of MPI tasks invoked per node&lt;br /&gt;
 #SBATCH --ntasks-per-socket=&amp;lt;nt/2&amp;gt;      # Tasks invoked on each socket&lt;br /&gt;
 #SBATCH --cpus-per-task=&amp;lt;nc&amp;gt;            # Number of OMP threads per task&lt;br /&gt;
 &lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary&lt;br /&gt;
 module load spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-mpi/bin:$PATH&lt;br /&gt;
 &lt;br /&gt;
 export OMP_NUM_THREADS=&amp;lt;nc&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 mpirun --rank-by core -np ${SLURM_NTASKS} \&lt;br /&gt;
        yambo -F &amp;lt;input&amp;gt; -J &amp;lt;output&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for the tutorials and examples that need to be run in parallel. In these cases you need to submit the job using a batch script &amp;lt;code&amp;gt;job.sh&amp;lt;/code&amp;gt;. Please note that the instructions in the batch script must be compatible with the specific M100 [https://wiki.u-gov.it/confluence/display/SCAIUS/UG3.2%3A+MARCONI100+UserGuide#UG3.2:MARCONI100UserGuide-SystemArchitecture architecture] and [https://wiki.u-gov.it/confluence/display/SCAIUS/UG3.2%3A+MARCONI100+UserGuide#UG3.2:MARCONI100UserGuide-Accounting accounting] systems. The complete list of Slurm options can be found [https://slurm.schedmd.com/sbatch.html here]. However you will find &#039;&#039;&#039;ready-to-use&#039;&#039;&#039; batch scripts in locations specified during the tutorials. &lt;br /&gt;
&lt;br /&gt;
To submit the job, use the &amp;lt;code&amp;gt;sbatch&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 $ sbatch job.sh&lt;br /&gt;
 Submitted batch job &amp;lt;JOBID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To check the job status, use the &amp;lt;code&amp;gt;squeue&amp;lt;/code&amp;gt; command:&lt;br /&gt;
 $ squeue -u &amp;lt;username&amp;gt;&lt;br /&gt;
              JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)&lt;br /&gt;
              &amp;lt;...&amp;gt;  m100_...      JOB username  R       0:01    &amp;lt;N&amp;gt; &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you need to cancel your job, do:&lt;br /&gt;
 $ scancel &amp;lt;JOBID&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Open an interactive session &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This procedure is suggested for most of the tutorials, since the majority of these is meant to be run in serial (relatively to MPI parallelization) from the command line. Use the command below to open an interactive session of 1 hour (complete documentation [https://slurm.schedmd.com/salloc.html here]):&lt;br /&gt;
 $ salloc -A tra23_Yambo -p m100_sys_test -q qos_test --reservation=s_tra_yambo --nodes=1 --ntasks-per-node=1 --cpus-per-task=4 -t 01:00:00&lt;br /&gt;
 salloc: Granted job allocation 10164647&lt;br /&gt;
 salloc: Waiting for resource configuration&lt;br /&gt;
 salloc: Nodes r256n01 are ready for job&lt;br /&gt;
&lt;br /&gt;
We ask for 4 cpus-per-task because we can exploit OpenMP parallelization with the available resources.&lt;br /&gt;
&lt;br /&gt;
With &amp;lt;code&amp;gt;squeue&amp;lt;/code&amp;gt; you can see that there is now a job running:&lt;br /&gt;
 $ squeue -u username&lt;br /&gt;
              JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)&lt;br /&gt;
           10164647 m100_usr_ interact username  R       0:02      1 r256n01&lt;br /&gt;
&lt;br /&gt;
To run the tutorial, &amp;lt;code&amp;gt;ssh&amp;lt;/code&amp;gt; into the node specified by the job allocation and &amp;lt;code&amp;gt;cd&amp;lt;/code&amp;gt; to your scratch directory:&lt;br /&gt;
 username@&#039;&#039;&#039;login02&#039;&#039;&#039;$ ssh r256n01&lt;br /&gt;
 ...&lt;br /&gt;
 username@&#039;&#039;&#039;r256n01&#039;&#039;&#039;$ cd $CINECA_SCRATCH&lt;br /&gt;
&lt;br /&gt;
Then, you need to manually load &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; as in the batch script above. Please note that the serial version of the code is in a different directory and does not need &amp;lt;code&amp;gt;spectrum_mpi&amp;lt;/code&amp;gt;:&lt;br /&gt;
 $ module purge&lt;br /&gt;
 $ module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 $ export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-cpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
Finally, set the &amp;lt;code&amp;gt;OMP_NUM_THREADS&amp;lt;/code&amp;gt; environment variable to 4 (as in the &amp;lt;code&amp;gt;--cpus-per-task&amp;lt;/code&amp;gt; option):&lt;br /&gt;
 $ export OMP_NUM_THREADS=4&lt;br /&gt;
&lt;br /&gt;
To close the interactive session when you have finished, log out of the compute node with the &amp;lt;code&amp;gt;exit&amp;lt;/code&amp;gt; command, and then cancel the job:&lt;br /&gt;
 $ exit&lt;br /&gt;
 $ scancel &amp;lt;JOBID&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Plot results with gnuplot &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
During the tutorials you will often need to plot the results of the calculations. In order to do so on M100, &#039;&#039;&#039;open a new terminal window&#039;&#039;&#039; and connect to M100 enabling X11 forwarding with the &amp;lt;code&amp;gt;-X&amp;lt;/code&amp;gt; option:&lt;br /&gt;
 $ ssh -X m100&lt;br /&gt;
&lt;br /&gt;
Please note that &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; can be used in this way only from the login nodes:&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ cd &amp;lt;directory_with_data&amp;gt;&lt;br /&gt;
 username@&#039;&#039;&#039;login01&#039;&#039;&#039;$ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 Terminal type is now &#039;...&#039;&lt;br /&gt;
 gnuplot&amp;gt; plot &amp;lt;...&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; - Set up yambopy &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In order to run yambopy on m100, you must first setup the conda environment (to be done only once):&lt;br /&gt;
 $ cd&lt;br /&gt;
 $ module load anaconda/2020.11&lt;br /&gt;
 $ conda init bash&lt;br /&gt;
 $ source .bashrc&lt;br /&gt;
&lt;br /&gt;
After this, every time you want to use yambopy you need to load its module and environment:&lt;br /&gt;
 $ module load anaconda/2020.11&lt;br /&gt;
 $ conda activate /m100_work/tra23_Yambo/softwares/YAMBO/env_yambopy&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 22 May === &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;16:15 - 18:30 From the DFT ground state to the complete setup of a Many Body calculation using Yambo&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN.tar.gz                         100%[================================================================&amp;gt;]  10.81M  52.6MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz&lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN-2D.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN-2D.tar.gz                      100%[================================================================&amp;gt;]   8.56M  46.7MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ ls&lt;br /&gt;
 hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
 $ tar -xvf hBN-2D.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
 $ ls&lt;br /&gt;
 &#039;&#039;&#039;hBN-2D&#039;&#039;&#039; &#039;&#039;&#039;hBN&#039;&#039;&#039; hBN-2D.tar.gz  hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now that you have all the files, you may open the interactive job session with &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; as explained above and proceed with the tutorials.&lt;br /&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;
At this point, you may learn about the python pre-postprocessing capabilities offered by yambopy, our python interface to yambo and QE. First of all, let&#039;s create a dedicated directory, download and extract the related files.&lt;br /&gt;
 &lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ mkdir YAMBOPY_TUTORIALS&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/databases_yambopy.tar&lt;br /&gt;
 $ tar -xvf databases_yambopy.tar&lt;br /&gt;
 $ cd databases_yambopy&lt;br /&gt;
&lt;br /&gt;
Then, follow &#039;&#039;&#039;the first three sections&#039;&#039;&#039; of this link, which are related to initialization and linear response.&lt;br /&gt;
* [[Yambopy tutorial: Yambo databases|Reading databases with yambopy]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 23 May ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:00 - 16:30 A tour through GW simulation in a complex material (from the blackboard to numerical computation: convergence, algorithms, parallel usage)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To get all the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
&lt;br /&gt;
 ssh m100&lt;br /&gt;
 cd $CINECA_SCRATCH&lt;br /&gt;
 cd YAMBO_TUTORIALS&lt;br /&gt;
 wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz&lt;br /&gt;
 wget https://media.yambo-code.eu/educational/tutorials/files/MoS2_2Dquasiparticle_tutorial.tar.gz&lt;br /&gt;
 tar -xvf hBN.tar.gz&lt;br /&gt;
 tar -xvf MoS2_HPC_tutorial.tar.gz&lt;br /&gt;
 cd hBN&lt;br /&gt;
&lt;br /&gt;
Now you can start the first tutorial:&lt;br /&gt;
&lt;br /&gt;
* [[GW tutorial Rome 2023 | GW computations on practice: how to obtain the quasi-particle band structure of a bulk material ]]&lt;br /&gt;
&lt;br /&gt;
If you have gone through the first tutorial, pass now to the second one:&lt;br /&gt;
 &lt;br /&gt;
 cd $CINECA_SCRATCH&lt;br /&gt;
 cd YAMBO_TUTORIALS&lt;br /&gt;
 cd MoS2_HPC_tutorial&lt;br /&gt;
&lt;br /&gt;
* [[Quasi-particles of a 2D system | Quasi-particles of a 2D system ]]&lt;br /&gt;
&lt;br /&gt;
To conclude, you can learn an other method to plot the band structure in Yambo&lt;br /&gt;
&lt;br /&gt;
* [[Yambopy tutorial: band structures| Yambopy tutorial: band structures]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 24 May ===&lt;br /&gt;
&#039;&#039;&#039;14:00 - 16:30 Bethe-Salpeter equation (BSE)&#039;&#039;&#039; Fulvio Paleari (CNR-Nano, Italy), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
To get the tutorial files needed for the following tutorials, follow these steps:&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz # NOTE: YOU SHOULD ALREADY HAVE THIS FROM DAY 1&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN.tar.gz                         100%[================================================================&amp;gt;]  10.81M  52.6MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-convergence-kpoints.tar.gz &lt;br /&gt;
&amp;lt;!-- &lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN-convergence-kpoints.tar.gz’&lt;br /&gt;
&lt;br /&gt;
hBN-convergence-kpoints.tar.gz    100%[============================================================&amp;gt;] 226.10M  62.3MB/s    in 3.7s&lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ tar -xvf hBN-convergence-kpoints.tar.gz&lt;br /&gt;
 $ tar -xvf hBN.tar.gz&lt;br /&gt;
&lt;br /&gt;
Now, you may open the interactive job session with &amp;lt;code&amp;gt;salloc&amp;lt;/code&amp;gt; and proceed with the following tutorials.&lt;br /&gt;
&lt;br /&gt;
* [[Calculating optical spectra including excitonic effects: a step-by-step guide|Perform a BSE calculation from beginning to end ]]&lt;br /&gt;
* [[How to analyse excitons - ICTP 2022 school|Analyse your results (exciton wavefunctions in real and reciprocal space, etc.) ]]&lt;br /&gt;
* [[BSE solvers overview|Solve the BSE eigenvalue problem with different numerical methods]]&lt;br /&gt;
* [[How to choose the input parameters|Choose the input parameters for a meaningful converged calculation]]&lt;br /&gt;
Now, go into the yambopy tutorial directory to learn about python analysis tools for the BSE:&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ cd YAMBOPY_TUTORIALS/databases_yambopy&lt;br /&gt;
&lt;br /&gt;
* [[Yambopy_tutorial:_Yambo_databases#Exciton_intro_1:_read_and_sort_data|Visualization of excitonic properties with yambopy]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;17:00 - 18:30 Bethe-Salpeter equation in real time (TD-HSEX)&#039;&#039;&#039; Fulvio Paleari (CNR-Nano, Italy), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
The files needed for the following tutorials can be downloaded following these steps:&lt;br /&gt;
 $ ssh m100&lt;br /&gt;
 $ cd $CINECA_SCRATCH&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ wget https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-RT.tar.gz&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
 ...&lt;br /&gt;
 Saving to: ‘hBN-2D-RT.tar.gz’&lt;br /&gt;
 &lt;br /&gt;
 hBN-2D-RT.tar.gz                         100%[================================================================&amp;gt;]  10.81M  52.6MB/s    in 0.2s    &lt;br /&gt;
 ...&lt;br /&gt;
--&amp;gt; &lt;br /&gt;
 $ tar -xvf hBN-2D-RT.tar.gz&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* [[Introduction_to_Real_Time_propagation_in_Yambo#Time_Dependent_Equation_for_the_Reduced_One--Body_Density--Matrix|Read the introductive section to real-time propagation for the one-body density matrix]] (the part about time-dependent Schrödinger equation will be covered on DAY 4 and you can skip it for now)&lt;br /&gt;
* [[Prerequisites for Real Time propagation with Yambo|Perform the setup for a real-time calculation]]&lt;br /&gt;
* [[Linear response from real time simulations (density matrix only)|Calculate the linear response in real time]]&lt;br /&gt;
* [[Real time Bethe-Salpeter Equation (density matrix only)|Calculate the BSE in real time]]&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, May 25 ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;14:00 - 16:30 Real-time approach with the time dependent berry phase&#039;&#039;&#039; Myrta Gruning (Queen&#039;s University Belfast), Davide Sangalli (CNR-ISM, Italy)&lt;br /&gt;
&lt;br /&gt;
* [[Linear response from Bloch-states dynamics]] (in preparation)&lt;br /&gt;
* [[Second-harmonic generation of 2D-hBN]] (in preparation)&lt;br /&gt;
&lt;br /&gt;
* [[Real time approach to non-linear response]] (additional tutorial)&lt;br /&gt;
* [[Correlation effects in the non-linear response]] (additional tutorial)&lt;br /&gt;
&lt;br /&gt;
=== DAY 5 - Friday, 26 May ===&lt;br /&gt;
&lt;br /&gt;
== Lectures ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== DAY 1 - Monday, 22 May ===&lt;br /&gt;
&lt;br /&gt;
* D. Varsano, [https://media.yambo-code.eu/educational/Schools/ROME2023/scuola_intro.pdf Description and goal of the school].&lt;br /&gt;
* G. Stefanucci, [https://media.yambo-code.eu/educational/Schools/ROME2023/Stefanucci.pdf The Many-Body Problem: Key concepts of the Many-Body Perturbation Theory]&lt;br /&gt;
* M. Marsili, [https://media.yambo-code.eu/educational/Schools/ROME2023/marghe_linear_response.pdf Beyond the independent particle scheme: The linear response theory]&lt;br /&gt;
&lt;br /&gt;
=== DAY 2 - Tuesday, 23 May ===&lt;br /&gt;
&lt;br /&gt;
* E. Perfetto, [https://media.yambo-code.eu/educational/Schools/ROME2023/Talk_Perfetto.pdf An overview on non-equilibrium Green Functions]&lt;br /&gt;
* R. Frisenda, ARPES spectroscopy, an experimental overview&lt;br /&gt;
* A. Marini, The Quasi Particle concept and the GW method&lt;br /&gt;
* A. Guandalini, The GW method: approximations and algorithms&lt;br /&gt;
* D.A. Leon, C. Cardoso, Frequency dependence in GW: origin, modelling and practical implementations&lt;br /&gt;
&lt;br /&gt;
=== DAY 3 - Wednesday, 24 May ===&lt;br /&gt;
&lt;br /&gt;
* A. Molina-Sánchez, Modelling excitons: from 2D materials to Pump and Probe experiments&lt;br /&gt;
* M. Palummo, The Bethe-Salpeter equation: derivations and main physical concepts&lt;br /&gt;
* F. Paleari, Real time approach to the Bethe-Salpeter equation&lt;br /&gt;
* D. Sangalli, TD-HSEX and real-time dynamics&lt;br /&gt;
&lt;br /&gt;
=== DAY 4 - Thursday, 25 May ===&lt;br /&gt;
&lt;br /&gt;
* S. Mor, Time resolved spectroscopy: an  experimental overview&lt;br /&gt;
* M. Grüning, Nonlinear optics within Many-Body Perturbation Theory&lt;br /&gt;
* N. Tancogne-Dejean, Theory and simulation of High Harmonics Generation&lt;br /&gt;
* Y. Pavlyukh, Coherent electron-phonon dynamics within a time-linear GKBA scheme&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Tutorials&amp;diff=6917</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Tutorials&amp;diff=6917"/>
		<updated>2023-05-23T10:22:46Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Files needed for stand-alone tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you are starting out with Yambo, or even an experienced user, we recommend that you complete the following tutorials before trying to use Yambo for your system.&lt;br /&gt;
&lt;br /&gt;
The tutorials are meant to give some introductory background to the key concepts behind Yambo. Practical topics such as convergence are also discussed. &lt;br /&gt;
Nonetheless, users are invited to first read and study the [[lectures|background material]] in order to get familiar with the fundamental physical quantities.&lt;br /&gt;
&lt;br /&gt;
Two kinds of tutorials are provided: &#039;&#039;&#039;stand-alone&#039;&#039;&#039; and &#039;&#039;&#039;modular&#039;&#039;&#039;. In addition you must have a working environment where both Yambo (and eventually QE) are installed.&lt;br /&gt;
&lt;br /&gt;
== Setting up Yambo (and eventually QE)  ==&lt;br /&gt;
To be able to follow the school you need a running version of the yambo/QE code.&lt;br /&gt;
&lt;br /&gt;
There are several different ways to prepare a working environment.&lt;br /&gt;
&lt;br /&gt;
=== Virtual Machine(s) ===&lt;br /&gt;
The easiest way is to access to a virtual machine which contains both (i) yambo/QE and (ii) the tutorials.&lt;br /&gt;
&lt;br /&gt;
You can do it in one of two ways:&lt;br /&gt;
* Virtual machine via [[ICTP cloud|ICTP cloud]] If the schools you are attending provided an ICTP virtual machine this is the preferred option. It works through internet connection inside a browser.&lt;br /&gt;
* Install the [[Yambo_Virtual_Machine|yambo virtual machine]] on your laptop / desktop. This requires Oracle virtual box. Pre-download of the Virtual machine. No internet connection needed.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
URL of the machine : https://ins45100.ictp.it/&lt;br /&gt;
READ-ONLY PASSWORD for TUTOR (ictptutor) access:&lt;br /&gt;
NairibiTutor&lt;br /&gt;
READ-WRITE password for PARTICIPANT&#039;s (ictpuser) access:&lt;br /&gt;
NairobiUser&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User installation  ===&lt;br /&gt;
You can also setup the yambo code on your on laptop / desktop using different methods.&lt;br /&gt;
&lt;br /&gt;
As far as the Yambo source is concerned you can:&lt;br /&gt;
* Install [[Yambo via Docker|Yambo via Docker]]&lt;br /&gt;
* [[download|Download]] and [[Installation|install]] yambo on your laptop / desktop (requires a linux machine).&lt;br /&gt;
* Install yambo on your laptop/desktop/cluster [https://github.com/nicspalla/my-repo via Spack].&lt;br /&gt;
* Install using  Anaconda.&lt;br /&gt;
&lt;br /&gt;
=== Yambo User Installation with Anaconda ===&lt;br /&gt;
It is possible to install Yambo (up to v5.0.4) and Quantum-ESPRESSO via conda-forge (a conda channel/repository):&lt;br /&gt;
To setup Anaconda, please start from installing [https://www.anaconda.com/products/distribution#Downloads Anaconda] or [https://docs.conda.io/en/latest/miniconda.html Miniconda].&lt;br /&gt;
&lt;br /&gt;
Then we suggest to create a conda environment and activate it:&lt;br /&gt;
 conda create --name yambopy -c conda-forge&lt;br /&gt;
 conda activate yambopy&lt;br /&gt;
Then you can install the prerequisites and the two codes:&lt;br /&gt;
 conda install numpy scipy netcdf4 matplotlib pyyaml lxml pandas&lt;br /&gt;
 conda install yambo &lt;br /&gt;
 conda install qe&lt;br /&gt;
&lt;br /&gt;
==Setting up Yambopy==&lt;br /&gt;
&lt;br /&gt;
===Quick installation===&lt;br /&gt;
&lt;br /&gt;
A quick way to start using Yambopy is described here.&lt;br /&gt;
&lt;br /&gt;
* Make sure that you are using Python 3 and that you have the following python packages: &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;scipy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;netCDF4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pyyaml&amp;lt;/code&amp;gt;. Optionally, you may want to have abipy [[https://abinit.github.io/abipy/index.html]] installed for band structure interpolations.&lt;br /&gt;
&lt;br /&gt;
* Go to a directory of your choice and clone yambopy from the git repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/yambo-code/yambopy.git&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to use git, you may download a tarball from the git repository instead.&lt;br /&gt;
&lt;br /&gt;
* Enter into the yambopy folder and install&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 sudo python setup.py install&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have administrative privileges (for example on a computing cluster), type instead&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 python setup.py install --user&lt;br /&gt;
&lt;br /&gt;
===Installing dependencies with Anaconda===&lt;br /&gt;
We suggest installing yambopy using Anaconda [[https://www.anaconda.com/products/distribution]] to manage the various python packages.&lt;br /&gt;
&lt;br /&gt;
In this case, you can follow these steps.&lt;br /&gt;
&lt;br /&gt;
First, install the required dependencies:&lt;br /&gt;
 conda install numpy scipy netcdf4 lxml pyyaml&lt;br /&gt;
&lt;br /&gt;
Then we create a conda environment based on python 3.6 (this is to ensure compatibility with abipy if we want to install it later on):&lt;br /&gt;
 conda create --name NAME_ENV python=3.6&lt;br /&gt;
Here choose &amp;lt;code&amp;gt;NAME_ENV&amp;lt;/code&amp;gt; as you want, e.g. &amp;lt;code&amp;gt;yenv&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Now, we install abipy and its dependency pymatgen using &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt;. Here make sure that you are using the &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; version provided by Anaconda and not your system version.&lt;br /&gt;
&lt;br /&gt;
 pip install pymatgen&lt;br /&gt;
 pip install abipy&lt;br /&gt;
&lt;br /&gt;
Finally, we are ready to install yambopy:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/yambo-code/yambopy.git &lt;br /&gt;
&lt;br /&gt;
(or download and extract tarball) and follow the steps outlined in the quick installation section.&lt;br /&gt;
&lt;br /&gt;
Now enter into the yambopy folder and install&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 sudo python setup.py install&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have administrative privileges (for example on a computing cluster), type instead&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 python setup.py install --user&lt;br /&gt;
&lt;br /&gt;
===Frequent issues===&lt;br /&gt;
When running the installation you may get a &amp;lt;code&amp;gt;SyntaxError&amp;lt;/code&amp;gt; related to utf-8 encoding or it may complain that module &amp;lt;code&amp;gt;setuptools&amp;lt;/code&amp;gt; is not installed even though it is. In this case, it means that the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command is not preserving the correct &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; for your python executable.&lt;br /&gt;
&lt;br /&gt;
Solve the problem by running the installation step as&lt;br /&gt;
&lt;br /&gt;
 sudo /your/path/to/python setup.py install&lt;br /&gt;
or&lt;br /&gt;
 sudo env PATH=$PATH python setup.py install&lt;br /&gt;
&lt;br /&gt;
This applies only to the installation step and not to subsequent yambopy use.&lt;br /&gt;
&lt;br /&gt;
== Tutorial files ==&lt;br /&gt;
The tutorial CORE databases can be obtained&lt;br /&gt;
&lt;br /&gt;
* from the [[Yambo_Virtual_Machine|Yambo Virtual Machine]] &lt;br /&gt;
* from the Yambo web-page&lt;br /&gt;
* from the Yambo GIT tutorial repository &lt;br /&gt;
&lt;br /&gt;
=== From the Yambo Virtual Machine (VM)  ===&lt;br /&gt;
If you are using the VM, a recent version of the tutorial files is provided.Follow these [[Yambo_Virtual_Machine#Updating_the_Yambo_tutorial_files| instructions]] to update the tutorial files to the most recent version.&lt;br /&gt;
&lt;br /&gt;
=== From the Yambo website ===&lt;br /&gt;
If you are using your own installation or the docker, the files needed to run the tutorials can be downloaded from the lists below. &lt;br /&gt;
&lt;br /&gt;
After downloading the tar.gz files just unpack them in &#039;&#039;&#039;the YAMBO_TUTORIALS&#039;&#039;&#039; folder. For example&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ mv hBN.tar.gz YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ tar -xvfz hBN.tar.gz&lt;br /&gt;
 $ ls YAMBO_TUTORIALS&lt;br /&gt;
   hBN&lt;br /&gt;
&lt;br /&gt;
====Files needed for modular tutorials====&lt;br /&gt;
All of the following should be downloaded prior to following the modular tutorials:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Tutorial !! File(s)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;4&amp;quot;| hBN || [https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz hBN.tar.gz] &lt;br /&gt;
|-&lt;br /&gt;
| [https://media.yambo-code.eu/educational/tutorials/files/hBN-convergence-kpoints.tar.gz hBN-convergence-kpoints.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz] &lt;br /&gt;
|-&lt;br /&gt;
| [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Files needed for stand-alone tutorials====&lt;br /&gt;
At the start of each tutorial you will be told which specific file needs to be downloaded:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Tutorial !! File(s)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;| Silicon || [https://media.yambo-code.eu/educational/tutorials/files/Silicon.tar.gz Silicon.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
|[https://media.yambo-code.eu/educational/tutorials/files/Silicon_Electron-Phonon.tar.gz Silicon_Electron-Phonon.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| LiF || [https://media.yambo-code.eu/educational/tutorials/files/LiF.tar.gz LiF.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| Aluminum || [https://media.yambo-code.eu/educational/tutorials/files/Aluminum.tar.gz Aluminum.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| GaSb || [https://media.yambo-code.eu/educational/tutorials/files/GaSb.tar.gz GaSb.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| AlAs || [https://media.yambo-code.eu/educational/tutorials/files/AlAs.tar.gz AlAs.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| Hydrogen_Chain || [https://media.yambo-code.eu/educational/tutorials/files/Hydrogen_Chain.tar.gz Hydrogen_Chain.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| MoS2 for HPC || [https://media.yambo-code.eu/educational/tutorials/files/MoS2_HPC_tutorial.tar.gz MoS2_HPC_tutorial.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| MoS2 for HPC shorter version || [https://media.yambo-code.eu/educational/tutorials/files/MoS2_2Dquasiparticle_tutorial.tar.gz MoS2_2Dquasiparticle_tutorial.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| Yambopy for QE || [https://media.yambo-code.eu/educational/tutorials/files/databases_qepy.tar databases_qepy]&lt;br /&gt;
|-&lt;br /&gt;
| Yambopy for YAMBO || [https://media.yambo-code.eu/educational/tutorials/files/databases_yambopy.tar databases_yambopy]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== From the Git Tutorial Repository (advanced users) ===&lt;br /&gt;
If you are using your own installation or the docker, the [https://github.com/yambo-code/tutorials tutorials repository] contains the updated tutorials CORE databases. To use it&lt;br /&gt;
 $ git clone https://github.com/yambo-code/tutorials.git YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ ./setup.pl -install&lt;br /&gt;
&lt;br /&gt;
== Stand-alone tutorials ==&lt;br /&gt;
These tutorials are self-contained and cover a variety of mixed topics, both physical and methodological. They are designed to be followed from start to finish in one page and do not require previous knowledge of yambo. Each tutorial requires download of a specific core database, and typically they cover a specific physical system (like bulk GaSb or a hydrogen chain). Ground state input files and pseudopotentials are provided. Output files are also provided for reference.&lt;br /&gt;
&lt;br /&gt;
These tutorials can be accessed directly from this page of from the side bar. They include different kind of subjects:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: These tutorials were prepared using previous version of the Yambo code: some command lines, variables, reports and outputs can be  slightly different from the last version of the code.  Scripts for parsing output cannot work anymore and should be edited to work with the new outputs. New command lines can be accessed typing &amp;lt;code&amp;gt;yambo -h &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Basic ===&lt;br /&gt;
* [[LiF|Linear Response in 3D. Excitons at work]]&lt;br /&gt;
* [[Silicon|GW convergence]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Si_Surface|Linear Response in 2D]]&lt;br /&gt;
* [[Si_wire|Linear Response in 1D]]&lt;br /&gt;
* [[H2|Linear Response in 0D]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
=== Post Processing ===&lt;br /&gt;
* [[Yambo Post Processing (ypp)]]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=First_steps_in_Yambopy First Steps in YamboPy]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=Yambopy_tutorial:_band_structures Yambopy tutorial: band structures]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=Yambopy_tutorial:_Yambo_databases Yambopy tutorial: Yambo databases]&lt;br /&gt;
&lt;br /&gt;
=== Advanced ===&lt;br /&gt;
* [[Hydrogen chain|TDDFT Failure and long range correlations]]&lt;br /&gt;
* [[Linear response from real time simulations]]&lt;br /&gt;
&lt;br /&gt;
==== GW and Quasi-particles ====&lt;br /&gt;
* [[Real_Axis_and_Lifetimes|Real Axis and Lifetimes]]&lt;br /&gt;
* [[Self-consistent GW on eigenvalues only]]&lt;br /&gt;
* [[GW tutorial on HPC]]&lt;br /&gt;
&lt;br /&gt;
==== Electron phonon coupling ====&lt;br /&gt;
* [[Electron Phonon Coupling|Electron Phonon Coupling]]&lt;br /&gt;
* [[Optical properties at finite temperature]]&lt;br /&gt;
* [[Phonon-assisted luminescence by finite atomic displacements]]&lt;br /&gt;
* [[Exciton-phonon coupling and luminescence]]&lt;br /&gt;
&lt;br /&gt;
==== Non linear response ====&lt;br /&gt;
* [http://www.attaccalite.com/lumen/linear_response.html Linear response using Dynamical Berry phase]&lt;br /&gt;
* [[Real time approach to non-linear response]]&lt;br /&gt;
* [[Correlation effects in the non-linear response]]&lt;br /&gt;
* [http://www.attaccalite.com/lumen/thg_in_silicon.html Third Harmonic Generation]&lt;br /&gt;
* [http://www.attaccalite.com/lumen/spin_orbit.html Spin-orbit coupling and non-linear response]&lt;br /&gt;
* [[Two-photon absorption]] &lt;br /&gt;
* [[Pump and Probe]]&lt;br /&gt;
* [[Parallelization for non-linear response calculations]]&lt;br /&gt;
&lt;br /&gt;
==== Developing Yambo ====&lt;br /&gt;
* [[How to create a new project in Yambo]]&lt;br /&gt;
* [[How to create a new ypp interface]]&lt;br /&gt;
* [[Some hints on github]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[SOC|Spin-Orbit Coupling MBPT]]&lt;br /&gt;
* [[Kerr|Kerr]]&lt;br /&gt;
* [[Real_Time|Real-Time]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- For each TUTORIAL (Solid_LiF, Solid_Al, ...) , therefore, you can download the ground state files (zip archive named TUTORIAL_ground_state.zip) and generate the Yambo databases from your own by running abinit/PWscf and a2y/p2y. In this case the Yambo input and reference files are contained in the zip file (TUTORIAL_reference_files.zip). Alternatively, if (and only if) you have compiled yambo with the NetCDF support you can directly download the zip files containing the Yambo core databases (TUTORIAL_NETCDF_databases_and_reference_files.zip). These are generated using the NetCDF interface in order to be readable in any platform.&lt;br /&gt;
After you have downloaded the tutorial zip files and unziped them you should have now a tutorial tree:&lt;br /&gt;
localhost:&amp;gt; ls &lt;br /&gt;
YAMBO_TUTORIALS/&lt;br /&gt;
localhost:&amp;gt; ls  YAMBO_TUTORIALS/&lt;br /&gt;
COPYING  Fantastic_Dimensions/  Hydrogen_Chain/  README  Solid_LiF/ Solid_Al/ SiH4/ ...&lt;br /&gt;
In each folder you will find an Abinit or Pwscf subfolder in case you have downloaded the ground state zip files and the YAMBO subfolder. The tutorials start by entering the YAMBO subfolder and followinf the informations provided in the tutorial documentation.  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modular tutorials ==&lt;br /&gt;
These tutorials are designed to provide a deeper understanding of specific yambo tasks and runlevels. They are designed to avoid repetition of common procedures and physical concepts. As such, they make use of the same physical systems: bulk hexagonal boron nitride &#039;&#039;hBN&#039;&#039; and a hBN sheet &#039;&#039;hBN-2D&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: These tutorials were prepared using previous version of the Yambo code: some command lines, variables, reports and outputs can be  slightly different from the last version of the code.  Scripts for parsing output cannot work anymore and should be edited to work with the new outputs. New command lines can be accessed typing &amp;lt;code&amp;gt;yambo -h &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Introduction====&lt;br /&gt;
* [[First steps: a walk through from DFT to optical properties]]&lt;br /&gt;
====Quasiparticles in the GW approximation====&lt;br /&gt;
* [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
====Using Yambo in Parallel====&lt;br /&gt;
This modules contains very general discussions of the parallel environment of Yambo. Still the actual run of the code is specific to the CECAM cluster. If you want to run these modules just replace the parallel queue instructions with simple MPI commands.&lt;br /&gt;
&lt;br /&gt;
* [[GW_parallel_strategies|Parallel GW (CECAM specific)]]: strategies for running Yambo in parallel&lt;br /&gt;
[[GW_parallel_strategies_CECAM]]&lt;br /&gt;
* [[Pushing_convergence_in_parallel|GW convergence (CECAM specific)]]: use Yambo in parallel to converge a GW calculation for a layer of hBN (hBN-2D)&lt;br /&gt;
&lt;br /&gt;
====Excitons and the Bethe-Salpeter Equation====&lt;br /&gt;
* [[How to obtain an optical spectrum|Calculating optical spectra including excitonic effects: a step-by-step guide]]&lt;br /&gt;
* [[How to choose the input parameters|Obtaining a converged optical spectrum]] &lt;br /&gt;
* [[How to treat low dimensional systems|Many-body effects in low-dimensional systems: numerical issues and remedies]] &lt;br /&gt;
* [[How to analyse excitons|Analysis of excitonic spectra in a 2D material]]&lt;br /&gt;
&amp;lt;!--* [[Two particle excitations]] (try to bypass this page) : Learn how to set up and run calculations to obtain and analyze an optical absorption spectrum of bulk and low dimension materials by using the Bethe-Salpeter equation--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Yambopy====&lt;br /&gt;
* [[First steps in Yambopy]]&lt;br /&gt;
* [[GW tutorial. Convergence and approximations (BN)]]&lt;br /&gt;
* [[Bethe-Salpeter equation tutorial. Optical absorption (BN)]]&lt;br /&gt;
* [[Yambopy tutorial: band structures | Database and plotting tutorial for quantum espresso: qepy]]&lt;br /&gt;
* [[Yambopy tutorial: Yambo databases | Database and plotting tutorial for yambo: yambopy ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Real-time simulations====&lt;br /&gt;
* [[Breaking of symmetries]]&lt;br /&gt;
* [[Independent-Particle Approximation Dynamics. Delta Pulse]]&lt;br /&gt;
* [[Post-processing. Optical Response]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
=== Modules ===&lt;br /&gt;
Alternatively, users can learn more about a specific runlevel or task by looking at the individual &#039;&#039;&#039;[[Modules|documentation modules]]&#039;&#039;&#039;. These provide a focus on the input parameters, run time behaviour, and underlying physics. Although they can be followed separately, non-experts are urged to follow them as part of the more structured tutorials given above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== &amp;lt;span id=&amp;quot;Schools&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;Schools ==&lt;br /&gt;
* [[ICTP2020]]&lt;br /&gt;
* [[CECAM VIRTUAL 2021]]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=ICTP_2022 ICTP2022]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Tutorials&amp;diff=6916</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Tutorials&amp;diff=6916"/>
		<updated>2023-05-23T10:22:24Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Files needed for stand-alone tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you are starting out with Yambo, or even an experienced user, we recommend that you complete the following tutorials before trying to use Yambo for your system.&lt;br /&gt;
&lt;br /&gt;
The tutorials are meant to give some introductory background to the key concepts behind Yambo. Practical topics such as convergence are also discussed. &lt;br /&gt;
Nonetheless, users are invited to first read and study the [[lectures|background material]] in order to get familiar with the fundamental physical quantities.&lt;br /&gt;
&lt;br /&gt;
Two kinds of tutorials are provided: &#039;&#039;&#039;stand-alone&#039;&#039;&#039; and &#039;&#039;&#039;modular&#039;&#039;&#039;. In addition you must have a working environment where both Yambo (and eventually QE) are installed.&lt;br /&gt;
&lt;br /&gt;
== Setting up Yambo (and eventually QE)  ==&lt;br /&gt;
To be able to follow the school you need a running version of the yambo/QE code.&lt;br /&gt;
&lt;br /&gt;
There are several different ways to prepare a working environment.&lt;br /&gt;
&lt;br /&gt;
=== Virtual Machine(s) ===&lt;br /&gt;
The easiest way is to access to a virtual machine which contains both (i) yambo/QE and (ii) the tutorials.&lt;br /&gt;
&lt;br /&gt;
You can do it in one of two ways:&lt;br /&gt;
* Virtual machine via [[ICTP cloud|ICTP cloud]] If the schools you are attending provided an ICTP virtual machine this is the preferred option. It works through internet connection inside a browser.&lt;br /&gt;
* Install the [[Yambo_Virtual_Machine|yambo virtual machine]] on your laptop / desktop. This requires Oracle virtual box. Pre-download of the Virtual machine. No internet connection needed.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
URL of the machine : https://ins45100.ictp.it/&lt;br /&gt;
READ-ONLY PASSWORD for TUTOR (ictptutor) access:&lt;br /&gt;
NairibiTutor&lt;br /&gt;
READ-WRITE password for PARTICIPANT&#039;s (ictpuser) access:&lt;br /&gt;
NairobiUser&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== User installation  ===&lt;br /&gt;
You can also setup the yambo code on your on laptop / desktop using different methods.&lt;br /&gt;
&lt;br /&gt;
As far as the Yambo source is concerned you can:&lt;br /&gt;
* Install [[Yambo via Docker|Yambo via Docker]]&lt;br /&gt;
* [[download|Download]] and [[Installation|install]] yambo on your laptop / desktop (requires a linux machine).&lt;br /&gt;
* Install yambo on your laptop/desktop/cluster [https://github.com/nicspalla/my-repo via Spack].&lt;br /&gt;
* Install using  Anaconda.&lt;br /&gt;
&lt;br /&gt;
=== Yambo User Installation with Anaconda ===&lt;br /&gt;
It is possible to install Yambo (up to v5.0.4) and Quantum-ESPRESSO via conda-forge (a conda channel/repository):&lt;br /&gt;
To setup Anaconda, please start from installing [https://www.anaconda.com/products/distribution#Downloads Anaconda] or [https://docs.conda.io/en/latest/miniconda.html Miniconda].&lt;br /&gt;
&lt;br /&gt;
Then we suggest to create a conda environment and activate it:&lt;br /&gt;
 conda create --name yambopy -c conda-forge&lt;br /&gt;
 conda activate yambopy&lt;br /&gt;
Then you can install the prerequisites and the two codes:&lt;br /&gt;
 conda install numpy scipy netcdf4 matplotlib pyyaml lxml pandas&lt;br /&gt;
 conda install yambo &lt;br /&gt;
 conda install qe&lt;br /&gt;
&lt;br /&gt;
==Setting up Yambopy==&lt;br /&gt;
&lt;br /&gt;
===Quick installation===&lt;br /&gt;
&lt;br /&gt;
A quick way to start using Yambopy is described here.&lt;br /&gt;
&lt;br /&gt;
* Make sure that you are using Python 3 and that you have the following python packages: &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;scipy&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;netCDF4&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;lxml&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pyyaml&amp;lt;/code&amp;gt;. Optionally, you may want to have abipy [[https://abinit.github.io/abipy/index.html]] installed for band structure interpolations.&lt;br /&gt;
&lt;br /&gt;
* Go to a directory of your choice and clone yambopy from the git repository&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/yambo-code/yambopy.git&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to use git, you may download a tarball from the git repository instead.&lt;br /&gt;
&lt;br /&gt;
* Enter into the yambopy folder and install&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 sudo python setup.py install&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have administrative privileges (for example on a computing cluster), type instead&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 python setup.py install --user&lt;br /&gt;
&lt;br /&gt;
===Installing dependencies with Anaconda===&lt;br /&gt;
We suggest installing yambopy using Anaconda [[https://www.anaconda.com/products/distribution]] to manage the various python packages.&lt;br /&gt;
&lt;br /&gt;
In this case, you can follow these steps.&lt;br /&gt;
&lt;br /&gt;
First, install the required dependencies:&lt;br /&gt;
 conda install numpy scipy netcdf4 lxml pyyaml&lt;br /&gt;
&lt;br /&gt;
Then we create a conda environment based on python 3.6 (this is to ensure compatibility with abipy if we want to install it later on):&lt;br /&gt;
 conda create --name NAME_ENV python=3.6&lt;br /&gt;
Here choose &amp;lt;code&amp;gt;NAME_ENV&amp;lt;/code&amp;gt; as you want, e.g. &amp;lt;code&amp;gt;yenv&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Now, we install abipy and its dependency pymatgen using &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt;. Here make sure that you are using the &amp;lt;code&amp;gt;pip&amp;lt;/code&amp;gt; version provided by Anaconda and not your system version.&lt;br /&gt;
&lt;br /&gt;
 pip install pymatgen&lt;br /&gt;
 pip install abipy&lt;br /&gt;
&lt;br /&gt;
Finally, we are ready to install yambopy:&lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/yambo-code/yambopy.git &lt;br /&gt;
&lt;br /&gt;
(or download and extract tarball) and follow the steps outlined in the quick installation section.&lt;br /&gt;
&lt;br /&gt;
Now enter into the yambopy folder and install&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 sudo python setup.py install&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have administrative privileges (for example on a computing cluster), type instead&lt;br /&gt;
&lt;br /&gt;
 cd yambopy&lt;br /&gt;
 python setup.py install --user&lt;br /&gt;
&lt;br /&gt;
===Frequent issues===&lt;br /&gt;
When running the installation you may get a &amp;lt;code&amp;gt;SyntaxError&amp;lt;/code&amp;gt; related to utf-8 encoding or it may complain that module &amp;lt;code&amp;gt;setuptools&amp;lt;/code&amp;gt; is not installed even though it is. In this case, it means that the &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; command is not preserving the correct &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; for your python executable.&lt;br /&gt;
&lt;br /&gt;
Solve the problem by running the installation step as&lt;br /&gt;
&lt;br /&gt;
 sudo /your/path/to/python setup.py install&lt;br /&gt;
or&lt;br /&gt;
 sudo env PATH=$PATH python setup.py install&lt;br /&gt;
&lt;br /&gt;
This applies only to the installation step and not to subsequent yambopy use.&lt;br /&gt;
&lt;br /&gt;
== Tutorial files ==&lt;br /&gt;
The tutorial CORE databases can be obtained&lt;br /&gt;
&lt;br /&gt;
* from the [[Yambo_Virtual_Machine|Yambo Virtual Machine]] &lt;br /&gt;
* from the Yambo web-page&lt;br /&gt;
* from the Yambo GIT tutorial repository &lt;br /&gt;
&lt;br /&gt;
=== From the Yambo Virtual Machine (VM)  ===&lt;br /&gt;
If you are using the VM, a recent version of the tutorial files is provided.Follow these [[Yambo_Virtual_Machine#Updating_the_Yambo_tutorial_files| instructions]] to update the tutorial files to the most recent version.&lt;br /&gt;
&lt;br /&gt;
=== From the Yambo website ===&lt;br /&gt;
If you are using your own installation or the docker, the files needed to run the tutorials can be downloaded from the lists below. &lt;br /&gt;
&lt;br /&gt;
After downloading the tar.gz files just unpack them in &#039;&#039;&#039;the YAMBO_TUTORIALS&#039;&#039;&#039; folder. For example&lt;br /&gt;
 $ mkdir YAMBO_TUTORIALS&lt;br /&gt;
 $ mv hBN.tar.gz YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ tar -xvfz hBN.tar.gz&lt;br /&gt;
 $ ls YAMBO_TUTORIALS&lt;br /&gt;
   hBN&lt;br /&gt;
&lt;br /&gt;
====Files needed for modular tutorials====&lt;br /&gt;
All of the following should be downloaded prior to following the modular tutorials:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Tutorial !! File(s)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;4&amp;quot;| hBN || [https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz hBN.tar.gz] &lt;br /&gt;
|-&lt;br /&gt;
| [https://media.yambo-code.eu/educational/tutorials/files/hBN-convergence-kpoints.tar.gz hBN-convergence-kpoints.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz hBN-2D.tar.gz] &lt;br /&gt;
|-&lt;br /&gt;
| [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-para.tar.gz hBN-2D-para.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
====Files needed for stand-alone tutorials====&lt;br /&gt;
At the start of each tutorial you will be told which specific file needs to be downloaded:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Tutorial !! File(s)&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot;| Silicon || [https://media.yambo-code.eu/educational/tutorials/files/Silicon.tar.gz Silicon.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
|[https://media.yambo-code.eu/educational/tutorials/files/Silicon_Electron-Phonon.tar.gz Silicon_Electron-Phonon.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| LiF || [https://media.yambo-code.eu/educational/tutorials/files/LiF.tar.gz LiF.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| Aluminum || [https://media.yambo-code.eu/educational/tutorials/files/Aluminum.tar.gz Aluminum.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| GaSb || [https://media.yambo-code.eu/educational/tutorials/files/GaSb.tar.gz GaSb.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| AlAs || [https://media.yambo-code.eu/educational/tutorials/files/AlAs.tar.gz AlAs.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| Hydrogen_Chain || [https://media.yambo-code.eu/educational/tutorials/files/Hydrogen_Chain.tar.gz Hydrogen_Chain.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| MoS2 for HPC || [https://media.yambo-code.eu/educational/tutorials/files/MoS2_HPC_tutorial.tar.gz MoS2_HPC_tutorial.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| MoS2 for HPC shorter version || [https://media.yambo-code.eu/educational/tutorials/files/MoS2_2Dquasiparticle_tutorial.tar.gz]&lt;br /&gt;
|-&lt;br /&gt;
| Yambopy for QE || [https://media.yambo-code.eu/educational/tutorials/files/databases_qepy.tar databases_qepy]&lt;br /&gt;
|-&lt;br /&gt;
| Yambopy for YAMBO || [https://media.yambo-code.eu/educational/tutorials/files/databases_yambopy.tar databases_yambopy]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== From the Git Tutorial Repository (advanced users) ===&lt;br /&gt;
If you are using your own installation or the docker, the [https://github.com/yambo-code/tutorials tutorials repository] contains the updated tutorials CORE databases. To use it&lt;br /&gt;
 $ git clone https://github.com/yambo-code/tutorials.git YAMBO_TUTORIALS&lt;br /&gt;
 $ cd YAMBO_TUTORIALS&lt;br /&gt;
 $ ./setup.pl -install&lt;br /&gt;
&lt;br /&gt;
== Stand-alone tutorials ==&lt;br /&gt;
These tutorials are self-contained and cover a variety of mixed topics, both physical and methodological. They are designed to be followed from start to finish in one page and do not require previous knowledge of yambo. Each tutorial requires download of a specific core database, and typically they cover a specific physical system (like bulk GaSb or a hydrogen chain). Ground state input files and pseudopotentials are provided. Output files are also provided for reference.&lt;br /&gt;
&lt;br /&gt;
These tutorials can be accessed directly from this page of from the side bar. They include different kind of subjects:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: These tutorials were prepared using previous version of the Yambo code: some command lines, variables, reports and outputs can be  slightly different from the last version of the code.  Scripts for parsing output cannot work anymore and should be edited to work with the new outputs. New command lines can be accessed typing &amp;lt;code&amp;gt;yambo -h &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Basic ===&lt;br /&gt;
* [[LiF|Linear Response in 3D. Excitons at work]]&lt;br /&gt;
* [[Silicon|GW convergence]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[Si_Surface|Linear Response in 2D]]&lt;br /&gt;
* [[Si_wire|Linear Response in 1D]]&lt;br /&gt;
* [[H2|Linear Response in 0D]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
=== Post Processing ===&lt;br /&gt;
* [[Yambo Post Processing (ypp)]]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=First_steps_in_Yambopy First Steps in YamboPy]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=Yambopy_tutorial:_band_structures Yambopy tutorial: band structures]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=Yambopy_tutorial:_Yambo_databases Yambopy tutorial: Yambo databases]&lt;br /&gt;
&lt;br /&gt;
=== Advanced ===&lt;br /&gt;
* [[Hydrogen chain|TDDFT Failure and long range correlations]]&lt;br /&gt;
* [[Linear response from real time simulations]]&lt;br /&gt;
&lt;br /&gt;
==== GW and Quasi-particles ====&lt;br /&gt;
* [[Real_Axis_and_Lifetimes|Real Axis and Lifetimes]]&lt;br /&gt;
* [[Self-consistent GW on eigenvalues only]]&lt;br /&gt;
* [[GW tutorial on HPC]]&lt;br /&gt;
&lt;br /&gt;
==== Electron phonon coupling ====&lt;br /&gt;
* [[Electron Phonon Coupling|Electron Phonon Coupling]]&lt;br /&gt;
* [[Optical properties at finite temperature]]&lt;br /&gt;
* [[Phonon-assisted luminescence by finite atomic displacements]]&lt;br /&gt;
* [[Exciton-phonon coupling and luminescence]]&lt;br /&gt;
&lt;br /&gt;
==== Non linear response ====&lt;br /&gt;
* [http://www.attaccalite.com/lumen/linear_response.html Linear response using Dynamical Berry phase]&lt;br /&gt;
* [[Real time approach to non-linear response]]&lt;br /&gt;
* [[Correlation effects in the non-linear response]]&lt;br /&gt;
* [http://www.attaccalite.com/lumen/thg_in_silicon.html Third Harmonic Generation]&lt;br /&gt;
* [http://www.attaccalite.com/lumen/spin_orbit.html Spin-orbit coupling and non-linear response]&lt;br /&gt;
* [[Two-photon absorption]] &lt;br /&gt;
* [[Pump and Probe]]&lt;br /&gt;
* [[Parallelization for non-linear response calculations]]&lt;br /&gt;
&lt;br /&gt;
==== Developing Yambo ====&lt;br /&gt;
* [[How to create a new project in Yambo]]&lt;br /&gt;
* [[How to create a new ypp interface]]&lt;br /&gt;
* [[Some hints on github]]&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
* [[SOC|Spin-Orbit Coupling MBPT]]&lt;br /&gt;
* [[Kerr|Kerr]]&lt;br /&gt;
* [[Real_Time|Real-Time]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- For each TUTORIAL (Solid_LiF, Solid_Al, ...) , therefore, you can download the ground state files (zip archive named TUTORIAL_ground_state.zip) and generate the Yambo databases from your own by running abinit/PWscf and a2y/p2y. In this case the Yambo input and reference files are contained in the zip file (TUTORIAL_reference_files.zip). Alternatively, if (and only if) you have compiled yambo with the NetCDF support you can directly download the zip files containing the Yambo core databases (TUTORIAL_NETCDF_databases_and_reference_files.zip). These are generated using the NetCDF interface in order to be readable in any platform.&lt;br /&gt;
After you have downloaded the tutorial zip files and unziped them you should have now a tutorial tree:&lt;br /&gt;
localhost:&amp;gt; ls &lt;br /&gt;
YAMBO_TUTORIALS/&lt;br /&gt;
localhost:&amp;gt; ls  YAMBO_TUTORIALS/&lt;br /&gt;
COPYING  Fantastic_Dimensions/  Hydrogen_Chain/  README  Solid_LiF/ Solid_Al/ SiH4/ ...&lt;br /&gt;
In each folder you will find an Abinit or Pwscf subfolder in case you have downloaded the ground state zip files and the YAMBO subfolder. The tutorials start by entering the YAMBO subfolder and followinf the informations provided in the tutorial documentation.  --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Modular tutorials ==&lt;br /&gt;
These tutorials are designed to provide a deeper understanding of specific yambo tasks and runlevels. They are designed to avoid repetition of common procedures and physical concepts. As such, they make use of the same physical systems: bulk hexagonal boron nitride &#039;&#039;hBN&#039;&#039; and a hBN sheet &#039;&#039;hBN-2D&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: These tutorials were prepared using previous version of the Yambo code: some command lines, variables, reports and outputs can be  slightly different from the last version of the code.  Scripts for parsing output cannot work anymore and should be edited to work with the new outputs. New command lines can be accessed typing &amp;lt;code&amp;gt;yambo -h &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Introduction====&lt;br /&gt;
* [[First steps: a walk through from DFT to optical properties]]&lt;br /&gt;
====Quasiparticles in the GW approximation====&lt;br /&gt;
* [[How to obtain the quasi-particle band structure of a bulk material: h-BN]]&lt;br /&gt;
====Using Yambo in Parallel====&lt;br /&gt;
This modules contains very general discussions of the parallel environment of Yambo. Still the actual run of the code is specific to the CECAM cluster. If you want to run these modules just replace the parallel queue instructions with simple MPI commands.&lt;br /&gt;
&lt;br /&gt;
* [[GW_parallel_strategies|Parallel GW (CECAM specific)]]: strategies for running Yambo in parallel&lt;br /&gt;
[[GW_parallel_strategies_CECAM]]&lt;br /&gt;
* [[Pushing_convergence_in_parallel|GW convergence (CECAM specific)]]: use Yambo in parallel to converge a GW calculation for a layer of hBN (hBN-2D)&lt;br /&gt;
&lt;br /&gt;
====Excitons and the Bethe-Salpeter Equation====&lt;br /&gt;
* [[How to obtain an optical spectrum|Calculating optical spectra including excitonic effects: a step-by-step guide]]&lt;br /&gt;
* [[How to choose the input parameters|Obtaining a converged optical spectrum]] &lt;br /&gt;
* [[How to treat low dimensional systems|Many-body effects in low-dimensional systems: numerical issues and remedies]] &lt;br /&gt;
* [[How to analyse excitons|Analysis of excitonic spectra in a 2D material]]&lt;br /&gt;
&amp;lt;!--* [[Two particle excitations]] (try to bypass this page) : Learn how to set up and run calculations to obtain and analyze an optical absorption spectrum of bulk and low dimension materials by using the Bethe-Salpeter equation--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Yambopy====&lt;br /&gt;
* [[First steps in Yambopy]]&lt;br /&gt;
* [[GW tutorial. Convergence and approximations (BN)]]&lt;br /&gt;
* [[Bethe-Salpeter equation tutorial. Optical absorption (BN)]]&lt;br /&gt;
* [[Yambopy tutorial: band structures | Database and plotting tutorial for quantum espresso: qepy]]&lt;br /&gt;
* [[Yambopy tutorial: Yambo databases | Database and plotting tutorial for yambo: yambopy ]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
====Real-time simulations====&lt;br /&gt;
* [[Breaking of symmetries]]&lt;br /&gt;
* [[Independent-Particle Approximation Dynamics. Delta Pulse]]&lt;br /&gt;
* [[Post-processing. Optical Response]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
=== Modules ===&lt;br /&gt;
Alternatively, users can learn more about a specific runlevel or task by looking at the individual &#039;&#039;&#039;[[Modules|documentation modules]]&#039;&#039;&#039;. These provide a focus on the input parameters, run time behaviour, and underlying physics. Although they can be followed separately, non-experts are urged to follow them as part of the more structured tutorials given above.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
== &amp;lt;span id=&amp;quot;Schools&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;Schools ==&lt;br /&gt;
* [[ICTP2020]]&lt;br /&gt;
* [[CECAM VIRTUAL 2021]]&lt;br /&gt;
* [https://www.yambo-code.org/wiki/index.php?title=ICTP_2022 ICTP2022]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6915</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6915"/>
		<updated>2023-05-23T10:20:46Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 20 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done on when using Yambo on clusters. So now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_HPC_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
Tthe [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, as we have seen, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have &amp;lt;code&amp;gt;ntasks-per-node=2&amp;lt;/code&amp;gt;. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, even though we are we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 8 MPI tasks, and using 4 threads.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely MPI calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
	<entry>
		<id>https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6914</id>
		<title>Quasi-particles of a 2D system</title>
		<link rel="alternate" type="text/html" href="https://wiki.yambo-code.eu/wiki/index.php?title=Quasi-particles_of_a_2D_system&amp;diff=6914"/>
		<updated>2023-05-23T10:20:18Z</updated>

		<summary type="html">&lt;p&gt;Giacomo.sesti: /* Step 1:  Speeding up the self-energy convergence */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:MoS2.png|thumb| MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt; monolayer (top and side views). Gray: Mo atoms, yellow: S atoms.]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial you will compute the quasiparticle corrections to the band structure of a free-standing single layer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;. Aim of the tutorial is to learn how to efficiently run a GW simulation in a 2D material based on:&lt;br /&gt;
*Acceleration techniques of GW, some of which specific for 2D systems&lt;br /&gt;
*Parallelization techniques&lt;br /&gt;
&lt;br /&gt;
In the end, you will obtain a quasiparticle band structure based on the simulations, the first step towards the reproduction of an ARPES spectrum. &lt;br /&gt;
Beware: we won’t use fully converged parameters, so the final result should not be considered very accurate.&lt;br /&gt;
&lt;br /&gt;
==Step 1:  Speeding up the self-energy convergence in the k-grid ==&lt;br /&gt;
&lt;br /&gt;
In this section, you will learn to use two algorithms present in Yambo that lead to a speed up of the self-energy convergence with respect to the k-grid.&lt;br /&gt;
&lt;br /&gt;
To appreciate the impact of these algorithms, let us first perform a GW computation for the monolayer of MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enter the &amp;lt;code&amp;gt; 01_GW_first_run&amp;lt;/code&amp;gt; folder and generate the input file:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p&lt;br /&gt;
&lt;br /&gt;
Modify the input file as follows:&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 80 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;BG&amp;quot;                  # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
Here, consider the number of G vectors and the number of bands as already being converged. So, compute the gap at GW level:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry&lt;br /&gt;
&lt;br /&gt;
Once terminated the computation, you can now inspect the output file &amp;lt;code&amp;gt; o-80b_10Ry.qp&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
You should have obtained a GW gap of 2.483 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM==&lt;br /&gt;
[[File:Circle box.gif|thumb]]&lt;br /&gt;
&lt;br /&gt;
To understand how we can improve the calculation in the k-grid to achieve a speed-up, consider briefly again the expression of the exchange part of the self-energy&lt;br /&gt;
&lt;br /&gt;
[[File:Sx.png|none|x50px|caption]]&lt;br /&gt;
&lt;br /&gt;
You can notice that the integration around q=0 here is problematic for the presence of a 1/q from the Coulomb potential that diverges, while all the other terms are slowly varying in q. Usually in Yambo this integration is performed analytically in a small sphere around q=0.&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 &amp;lt;code&amp;gt;-r&amp;lt;/code&amp;gt;. So as&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r&lt;br /&gt;
&lt;br /&gt;
In this manner, you 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] G0W0 Quasiparticle energy levels&lt;br /&gt;
 em1d                         # [R Xd] Dynamical Inverse Dielectric Matrix&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rim_cut&amp;lt;/span&amp;gt;                      # [R] Coulomb potential&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red &amp;gt;RandQpts=  1000000&amp;lt;/span&amp;gt;           # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RandGvec=  100           RL&amp;lt;/span&amp;gt;  # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;CUTGeo= &amp;quot;slab z&amp;quot;&amp;lt;/span&amp;gt;             # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&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 number of component of the Coulomb potential we want integrate numerically and &amp;lt;code&amp;gt;[[Variables#RandQpts|RandQpts]]&amp;lt;/code&amp;gt; is the number of random points used to perform the integral by Monte Carlo. &lt;br /&gt;
The [CUT] keyword refers to the truncation of the Coulomb interaction to avoid spurious interaction between periodically repeated copies of the simulation supercell along the z-direction (that in this case is the non periodic direction). Keep in mind that the vacuum space between two copies of the system should be converged: here we are using 20 bohr but a value of 40 bohr would be more realistic. &lt;br /&gt;
&lt;br /&gt;
If you turn on this integration you will get a slightly different band gap, but in the limit of large k points the final results will be the same of the standard method.&lt;br /&gt;
However this correction is important for systems that converge with few k-points or with gamma only and it is applied both at the exchange and correlation part of the self-energy.&lt;br /&gt;
&lt;br /&gt;
Now make a GW computation using the RIM method&lt;br /&gt;
&lt;br /&gt;
 gw0                              # [R] GW approximation&lt;br /&gt;
 ppa                              # [R][Xp] Plasmon Pole Approximation for the Screened Interaction&lt;br /&gt;
 dyson                            # [R] Dyson Equation solver&lt;br /&gt;
 HF_and_locXC                     # [R] Hartree-Fock&lt;br /&gt;
 em1d                             # [R][X] Dynamically Screened Interaction&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;
 rim_cut                          # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                 # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL    # [RIM] Coulomb interaction RS components&lt;br /&gt;
 CUTGeo= &amp;quot;slab z&amp;quot;                   # [CUT] Coulomb Cutoff geometry: box/cylinder/sphere/ws/slab X/Y/Z/XY..&lt;br /&gt;
 % CUTBox&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [CUT] [au] Box sides&lt;br /&gt;
 %&lt;br /&gt;
 CUTRadius= 0.000000              # [CUT] [au] Sphere/Cylinder radius&lt;br /&gt;
 CUTCylLen= 0.000000              # [CUT] [au] Cylinder length&lt;br /&gt;
 CUTwsGvec= 0.700000              # [CUT] WS cutoff: number of G to be modified&lt;br /&gt;
 EXXRLvcs=  37965           RL    # [XX] Exchange    RL components&lt;br /&gt;
 VXCRLvcs=  37965           RL    # [XC] XCpotential RL components&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % BndsRnXp&lt;br /&gt;
    1 | 80 |                       # [Xp] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXp= 10                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;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
 % GbndRnge&lt;br /&gt;
    1 | 20 |                         # [GW] G[W] bands range&lt;br /&gt;
 %&lt;br /&gt;
 GTermKind= &amp;quot;none&amp;quot;                # [GW] GW terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze,&amp;quot;BRS&amp;quot; Berger-Reining-Sottile)&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|13|14|&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rim&lt;br /&gt;
&lt;br /&gt;
You can now inspect the output file &amp;lt;code&amp;gt;o-80b_10Ry_rim.qp&amp;lt;/code&amp;gt;. The GW gap should have increased to 2.598 eV.&lt;br /&gt;
&lt;br /&gt;
==RIM-W==&lt;br /&gt;
&lt;br /&gt;
In 2D systems, the improvement granted by the better integration around q=0 of the Coulomb potential via the RIM approach does not work well for the correlation part of self-energy &lt;br /&gt;
&lt;br /&gt;
[[File:Sigma_c.png|none|x50px|caption]] &lt;br /&gt;
&lt;br /&gt;
[[File:Rimw.png|thumb| Convergence of the quasiparticle band gap of MoS2&lt;br /&gt;
 with respect to the number of sampling points of the&lt;br /&gt;
BZ. Blue lines: standard integration methods. The extrapolated values are indicated with&lt;br /&gt;
an horizontal dashed line. Orange lines: RIM-W method.  The grey shaded regions show&lt;br /&gt;
the converge tolerance (±50 meV) centered at the centered at the extrapolated values.]]&lt;br /&gt;
&lt;br /&gt;
as the dielectric function &amp;lt;math&amp;gt;\epsilon_{00}&amp;lt;/math&amp;gt; goes as q around q=0, matching the 1/q behavior of the Coulomb potential. &lt;br /&gt;
&lt;br /&gt;
To solve this issue, it has been developed a method specific for 2D systems that performs the integration of &amp;lt;math&amp;gt;\epsilon_{0 0}(\mathbf{q}) \ v(\mathbf{q})&amp;lt;/math&amp;gt; rather than only of &amp;lt;math&amp;gt;v(\mathbf{q})&amp;lt;/math&amp;gt; when computing the correlation part of self-energy.&lt;br /&gt;
&lt;br /&gt;
Details of this method can be found in the paper [https://www.nature.com/articles/s41524-023-00989-7| Efficient GW calculations in two-dimensional materials through a stochastic integration of the screened potential]. You can activate the RIM-W algorithm adding a further flag to your input:&lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -p p -r -rw&lt;br /&gt;
 &lt;br /&gt;
In your input three further lines should have appeared:&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 rim_cut                           # [R] Coulomb potential&lt;br /&gt;
 RandQpts=1000000                  # [RIM] Number of random q-points in the BZ&lt;br /&gt;
 RandGvec= 100              RL     # [RIM] Coulomb interaction RS components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RIM_W&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;RandGvecW= 15              RL&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red  &amp;gt;rimw_type=&amp;quot;semiconductor&amp;quot;&amp;lt;/span&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
The variable &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; defines the number of G vectors to integrate W numerically. &amp;lt;code&amp;gt;RandGvecW&amp;lt;/code&amp;gt; &#039;&#039;&#039;must&#039;&#039;&#039; be always smaller than the size of the &amp;lt;math&amp;gt;\chi&amp;lt;/math&amp;gt; matrix.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now repeat the computation again using the RIM-W algorithm. &lt;br /&gt;
&lt;br /&gt;
 yambo -F gw_ppa.in -J 80b_10Ry_rimw&lt;br /&gt;
&lt;br /&gt;
How much has the band gap changed ?&lt;br /&gt;
&lt;br /&gt;
==Step 2: GW parallel strategies==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will see how to use a parallel strategy on Yambo. As a test calculation, we compute the full band structure on a larger number of bands with respect the previous calculation. &lt;br /&gt;
&lt;br /&gt;
Differently to the approach used up to now, we will not work interactively but rather we will submit a job script as is commonly done on when using Yambo on clusters. So now exit the interactive mode and in the login node access the folder:&lt;br /&gt;
&lt;br /&gt;
 cd $CINECA_SCRATCH/YAMBO_TUTORIALS/MoS2_HPC_tutorial/02_GW_parallel&lt;br /&gt;
&lt;br /&gt;
Here, inspect the input &amp;lt;code&amp;gt;gw.in&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 ...&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|7|13|17|&lt;br /&gt;
 %&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will be using the slurm submission script job_parallel.sh, which is available in the calculation directory.&lt;br /&gt;
If you inspect it, you will see that the script adds additional variables to the yambo input file.&lt;br /&gt;
These variables control the parallel execution of the code:&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_and_IO_CPU= &amp;quot;1 1 1 $ncpu 1&amp;quot;     # [PARALLEL] CPUs for each role&lt;br /&gt;
 X_and_IO_ROLEs= &amp;quot;q g k c v&amp;quot;       # [PARALLEL] CPUs roles (q,g,k,c,v)&lt;br /&gt;
 X_and_IO_nCPU_LinAlg_INV= 1   # [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             # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
The keyword &amp;lt;code&amp;gt;DIP&amp;lt;/code&amp;gt; refers to the calculations of the screening matrix elements (also called “dipoles”) needed for the screening function, &amp;lt;code&amp;gt;X&amp;lt;/code&amp;gt; is the screening function (it stands for χ since it is a response function), &amp;lt;code&amp;gt;SE&amp;lt;/code&amp;gt; the self-energy.&lt;br /&gt;
These three sections of the code can be parallelised independently.&lt;br /&gt;
&lt;br /&gt;
Tthe [PARALLEL] variables refer to MPI tasks, instead the threads are used for [OPENMP] parallelisation.&lt;br /&gt;
&lt;br /&gt;
We start by calculating the QP corrections using only the MPI tasks and a single openMP thread. Therefore, edit the submission script as:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=8&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
and submit the job&lt;br /&gt;
 sbatch job_parallel.sh&lt;br /&gt;
&lt;br /&gt;
This will create a new input file and run it. The calculation databases and the human-readable files will be put in separate directories. Check the location of the report &amp;lt;code&amp;gt;r-*&amp;lt;/code&amp;gt; file and the log &amp;lt;code&amp;gt;l-*&amp;lt;/code&amp;gt; files, and inspect them while the calculation runs (it should take a couple of minutes).&lt;br /&gt;
&lt;br /&gt;
For simplicity you could just type&lt;br /&gt;
&lt;br /&gt;
 tail -f run_MPI8_OMP1.out/LOG/l-*_CPU_1&lt;br /&gt;
&lt;br /&gt;
to monitor the progress in the master thread (&amp;lt;code&amp;gt;Ctrl+C&amp;lt;/code&amp;gt; to exit). As you can see, the run takes some time, even though we are using minimal parameters.&lt;br /&gt;
&lt;br /&gt;
On a cluster like m100, to activate the full potential of the machine, it is useful to activate OpenMP threads by modifying cpus-per-task in the submission file. The product of the number of OpenMP and MPI tasks is equal to the total number of CPUs. &lt;br /&gt;
&lt;br /&gt;
Therefore, we can distribute 8 cpus with 4 MPI tasks and then use 2 OpenMP threads:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node4&lt;br /&gt;
 #SBATCH --cpus-per-task=2&lt;br /&gt;
&lt;br /&gt;
Actually, we don’t need to change the related openMP variables for the yambo input, since the value 0 means “use the value of OMP_NUM_THREADS” and we have now set this environment variable to 2 via our script.&lt;br /&gt;
Otherwise, any positive number can directly specify the number of threads to be used in each section of the code.&lt;br /&gt;
&lt;br /&gt;
 DIP_Threads=  0     # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 ...&lt;br /&gt;
 X_Threads=  0       # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 ...&lt;br /&gt;
 SE_Threads=  0      # [OPENMP/GW] Number of threads for self-energy&lt;br /&gt;
&lt;br /&gt;
You can try to run this calculation and check if it is faster than the pure MPI one from before. In general, you expect to a massive gain with OpenMP if you are already close to an efficient MPI scaling&lt;br /&gt;
&lt;br /&gt;
You can also try any other thread combinations including the pure OpenMP scaling, and compare the timings.&lt;br /&gt;
&lt;br /&gt;
In real-life calculations running on a large number of cores, as we have seen, it may be a good idea to adopt a hybrid approach. The most efficient scaling can depend both on your system and on the HPC facility you’re running on.&lt;br /&gt;
&lt;br /&gt;
In general, OpenMP can help lower memory requirements within a node. You can try to increase the OpenMP share of threads if getting Out Of Memory errors.&lt;br /&gt;
&lt;br /&gt;
==Step 3: Running on GPU==&lt;br /&gt;
&lt;br /&gt;
For this part of the tutorial, we will repeat the calculation of before, making use of gpus. &lt;br /&gt;
&lt;br /&gt;
So now move to:&lt;br /&gt;
&lt;br /&gt;
 02_GW_gpu&lt;br /&gt;
&lt;br /&gt;
Here we are using yet another capability of yambo: running on GPUs instead of CPUs. This usually leads to extreme speedups in the calculations. Fortunately, the m100 cluster also has some GPU nodes! So now let us have a look at the submission script:&lt;br /&gt;
&lt;br /&gt;
 vim gpu_job.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #SBATCH --nodes=1&lt;br /&gt;
 #SBATCH --ntasks-per-node=2&lt;br /&gt;
 #SBATCH --cpus-per-task=1&lt;br /&gt;
 #SBATCH --gres=gpu:4&lt;br /&gt;
&lt;br /&gt;
each GPU node contains four GPUs (&amp;lt;code&amp;gt;--gres=gpu:4&amp;lt;/code&amp;gt;). In yambo, each GPU corresponds to a single MPI task, therefore we have &amp;lt;code&amp;gt;ntasks-per-node=2&amp;lt;/code&amp;gt;. OpenMP threading is allowed - but not too much, otherwise we lose efficiency. Here in fact, even though we are we are not using OpenMP so &amp;lt;/code&amp;gt;export OMP_NUM_THREADS=1&amp;lt;/code&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
In addition, you will see that in order to run on GPUs we are now using a different executable than before, obtained with a GPU-specific compilation of the code.&lt;br /&gt;
&lt;br /&gt;
 module purge&lt;br /&gt;
 module load hpc-sdk/2022--binary spectrum_mpi/10.4.0--binary&lt;br /&gt;
 export PATH=/m100_work/tra23_Yambo/softwares/YAMBO/5.2-gpu/bin:$PATH&lt;br /&gt;
&lt;br /&gt;
In general, the gpu compilation might be different on your machine, or the executable may be the same with no need to load an additional modules. In conclusion, we are running over 4 GPU cards, distributed with 8 MPI tasks, and using 4 threads.&lt;br /&gt;
&lt;br /&gt;
The calculation should faster, about 2 minutes instead of 2 min and 30s with a purely MPI calculation. The gain can become even greater in larger systems. You can have a look at the results collected in folder &amp;lt;code&amp;gt;MPI2_OMP1&amp;lt;/code&amp;gt;. The quasiparticle corrections are stored in human-readable form in the file &amp;lt;code&amp;gt;MPI2_OMP1.out/o-GW_bnds.qp&amp;lt;/code&amp;gt;, and in netCDF format in the quasiparticle database &amp;lt;code&amp;gt;MPI2_OMP1/ndb.QP&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Giacomo.sesti</name></author>
	</entry>
</feed>