<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.lumen-code.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wikiadmin</id>
	<title>Lumen wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.lumen-code.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wikiadmin"/>
	<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Special:Contributions/Wikiadmin"/>
	<updated>2026-08-27T01:22:01Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_release_notes&amp;diff=1007</id>
		<title>Lumen release notes</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_release_notes&amp;diff=1007"/>
		<updated>2026-07-07T13:48:19Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Lumen Releases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains the list of the releases of the lumen code.&lt;br /&gt;
&lt;br /&gt;
Starting from version 2.0, the release notes are available in a dedicated page on the wiki, while the source code is available on gitlab. &lt;br /&gt;
&lt;br /&gt;
== Lumen Releases ==&lt;br /&gt;
&lt;br /&gt;
* Lumen 2.1: [[Lumen 2.1|Release Notes]]&lt;br /&gt;
** [https://gitlab.com/lumen-code/lumen/-/releases/2.1.0 Version 2.1.0] (06/07/2026)&lt;br /&gt;
&lt;br /&gt;
* Lumen 2.0: [[Lumen 2.0|Release Notes]]&lt;br /&gt;
** [https://gitlab.com/lumen-code/lumen/-/releases/2.0.1 Version 2.0.1] (29/01/2026); [https://zenodo.org/records/20121198 Zenodo 20121198]&lt;br /&gt;
** [https://gitlab.com/lumen-code/lumen/-/releases/2.0.0 Version 2.0.0] (04/12/2025);&lt;br /&gt;
&lt;br /&gt;
== Previous versions ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.attaccalite.com/lumen/ Lumen 1.X] (2018)&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=994</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=994"/>
		<updated>2026-07-06T08:14:26Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Fixes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3. A Partial sync with branch 5.4 of the yambo code was done.&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, &amp;lt;br&amp;gt; for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. &amp;lt;br&amp;gt;Tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Exciton symmetries&amp;lt;/u&amp;gt;: Lumen 2.1 is now able to detect the point group of the system based on the list of symmetry operations. It is then possible to compute exciton symmetries via ypp after solving BSE with diagonalization solver. &amp;lt;br&amp;gt;Tutorials: [[LiF#Detection of excitons symmetries (requires lumen 2.1 or better)| Excitons symmetries in LiF]]; [[How to analyse excitons#Detection of excitons symmetries (requires lumen 2.1 or better)| Excitons symmetries in 2D-hBN]]&lt;br /&gt;
&lt;br /&gt;
* Exciton radiative lifetimes: old implementation of exciton radiative lifetimes in ypp has been recovered.&lt;br /&gt;
* Excitonic TR-ARPES: with ypp it is possible to compute TR-ARPES from BSE post-processing&lt;br /&gt;
* Exciton-exciton transitions: with ypp it is possible to compute exciton-exciton transitions from BSE post-processing&lt;br /&gt;
* Coded symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the [https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_with_external_chase_libraries CHASE library] as [[BSE solvers overview|BSE solver]]&lt;br /&gt;
* In spin polarized systems, it is now possible to get the contribution of a given spin-channel to absorption&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
* Added preliminary support for system with non-symmorphic symmetry operations. At present the database conversion can be done, and later the non-symmorphic symmetry operation can be removed via ypp&lt;br /&gt;
* Added support to Covariant dipoles in shifted grids with multiple shifts&lt;br /&gt;
* Plotting of exciton wave-function: it is now possible to plot both fixed electron and fixed hole case. Moreover it is possible to plot the coefficients of the excitonic WF in k-space. File bxsf is produced.&lt;br /&gt;
* Ypp now prints the absolute value of the dipoles&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
* Memory is now distributed in the old diagonalization solver (without using the ldiago library) interfaced with scalapack&lt;br /&gt;
* Fixed memory duplication in Slepc solver&lt;br /&gt;
* I/O in BSE can now be controlled by input as none/low/medium/high&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, openACC, etc....&lt;br /&gt;
* Collisions table: added missing n_sp_pol variable&lt;br /&gt;
* Fixed missing variable in the ndb.QP_interpolated database&lt;br /&gt;
&lt;br /&gt;
===More===&lt;br /&gt;
* added support to llvm compiler&lt;br /&gt;
* upgraded internal version of the following libraries: libxc, slepc, petsc, devxlib &lt;br /&gt;
* upgraded interface with libxc to work with version 7.0, and to handle different versions (with different API)&lt;br /&gt;
* upgraded interface with slepc/petsc to handle different versions (with different API)&lt;br /&gt;
* ExcPh databases now can be loaded also if requested band ranges is smaller than available one&lt;br /&gt;
* support for BSE with frozen states improved&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=973</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=973"/>
		<updated>2026-06-16T09:51:10Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Main new features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3. A Partial sync with branch 5.4 of the yambo code was done.&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, &amp;lt;br&amp;gt; for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. &amp;lt;br&amp;gt;Tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Exciton symmetries&amp;lt;/u&amp;gt;: Lumen 2.1 is now able to detect the point group of the system based on the list of symmetry operations. It is then possible to compute exciton symmetries via ypp after solving BSE with diagonalization solver. &amp;lt;br&amp;gt;Tutorials: [[LiF#Detection of excitons symmetries (requires lumen 2.1 or better)| Excitons symmetries in LiF]]; [[How to analyse excitons#Detection of excitons symmetries (requires lumen 2.1 or better)| Excitons symmetries in 2D-hBN]]&lt;br /&gt;
&lt;br /&gt;
* Exciton radiative lifetimes: old implementation of exciton radiative lifetimes in ypp has been recovered.&lt;br /&gt;
* Excitonic TR-ARPES: with ypp it is possible to compute TR-ARPES from BSE post-processing&lt;br /&gt;
* Exciton-exciton transitions: with ypp it is possible to compute exciton-exciton transitions from BSE post-processing&lt;br /&gt;
* Coded symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the CHASE library as BSE solver&lt;br /&gt;
* In spin polarized systems, it is now possible to get the contribution of a given spin-channel to absorption&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
* Added preliminary support for system with non-symmorphic symmetry operations. At present the database conversion can be done, and later the non-symmorphic symmetry operation can be removed via ypp&lt;br /&gt;
* Added support to Covariant dipoles in shifted grids with multiple shifts&lt;br /&gt;
* Plotting of exciton wave-function: it is now possible to plot both fixed electron and fixed hole case. Moreover it is possible to plot the coefficients of the excitonic WF in k-space. File bxsf is produced.&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
* Memory is now distributed in the old diagonalization solver (without using the ldiago library) interfaced with scalapack&lt;br /&gt;
* Fixed memory duplication in Slepc solver&lt;br /&gt;
* I/O in BSE can now be controlled by input as none/low/medium/high&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, openACC, etc....&lt;br /&gt;
* Collisions table: added missing n_sp_pol variable&lt;br /&gt;
&lt;br /&gt;
===More===&lt;br /&gt;
* added support to llvm compiler&lt;br /&gt;
* upgraded internal version of the following libraries: libxc, slepc, petsc, devxlib &lt;br /&gt;
* upgraded interface with libxc to work with version 7.0, and to handle different versions (with different API)&lt;br /&gt;
* upgraded interface with slepc/petsc to handle different versions (with different API)&lt;br /&gt;
* ExcPh databases now can be loaded also if requested band ranges is smaller than available one&lt;br /&gt;
* support for BSE with frozen states improved&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=966</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=966"/>
		<updated>2026-06-15T14:32:07Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
* navigation&lt;br /&gt;
** mainpage| Lumen Wiki&lt;br /&gt;
** Installation | Installation&lt;br /&gt;
** Tutorials | Tutorials&lt;br /&gt;
** https://www.lumen-code.org/ford/ | Ford&lt;br /&gt;
** https://www.lumen-code.org/ | Lumen website&lt;br /&gt;
** Lumen release notes | Lumen Releases&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** helppage|help-mediawiki&lt;br /&gt;
** specialpages-url|specialpages&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=963</id>
		<title>MediaWiki:Sidebar</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=MediaWiki:Sidebar&amp;diff=963"/>
		<updated>2026-06-11T20:54:11Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
* navigation&lt;br /&gt;
** mainpage| Lumen Wiki&lt;br /&gt;
** Installation | Installation&lt;br /&gt;
** Tutorials | Tutorials&lt;br /&gt;
** https://www.lumen-code.org/ford/ | Ford&lt;br /&gt;
** https://www.lumen-code.org/ | Lumen website&lt;br /&gt;
** https://gitlab.com/lumen-code/lumen/-/releases | Lumen Releases&lt;br /&gt;
** recentchanges-url|recentchanges&lt;br /&gt;
** helppage|help-mediawiki&lt;br /&gt;
** specialpages-url|specialpages&lt;br /&gt;
* SEARCH&lt;br /&gt;
* TOOLBOX&lt;br /&gt;
* LANGUAGES&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=959</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=959"/>
		<updated>2026-06-11T12:33:27Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Fixes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, &amp;lt;br&amp;gt; for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
* Symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the CHASE library&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
* ExcPh databases now can be loaded also if requested band ranges is smaller than available one&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, openACC, etc....&lt;br /&gt;
* Collisions table: added missing n_sp_pol variable&amp;lt;br /&amp;gt;&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=958</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=958"/>
		<updated>2026-06-11T10:29:02Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, &amp;lt;br&amp;gt; for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
* Symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the CHASE library&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
* ExcPh databases now can be loaded also if requested band ranges is smaller than available one&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, etc.... &lt;br /&gt;
* Collisions table: added missing n_sp_pol variable&amp;lt;br /&amp;gt;&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=957</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=957"/>
		<updated>2026-06-11T10:28:47Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Main new features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism,  for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
* Symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the CHASE library&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
* ExcPh databases now can be loaded also if requested band ranges is smaller than available one&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, etc.... &lt;br /&gt;
* Collisions table: added missing n_sp_pol variable&amp;lt;br /&amp;gt;&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=956</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=956"/>
		<updated>2026-06-11T10:12:22Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Main new features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism,  for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
* Symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the CHASE library&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, etc.... &amp;lt;br /&amp;gt;&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=955</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=955"/>
		<updated>2026-06-11T10:12:03Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Fixes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
* Symmetry average of the dielectric constant for q=0 momentum &lt;br /&gt;
* Added interface to the CHASE library&lt;br /&gt;
* Added Gaussian smearing for the phonon-assisted response functions&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
* Fixed compilation on MacOsX&lt;br /&gt;
* Fixed reading imaginary part from ndb.QP in yambo_nl&lt;br /&gt;
* Different compilation issues fixed: with intel compilers, hdf5, etc.... &amp;lt;br /&amp;gt;&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=954</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=954"/>
		<updated>2026-06-11T10:01:25Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Release Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [[SHG from Floquet formulation]]&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=953</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=953"/>
		<updated>2026-06-11T10:01:06Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Main new features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;u&amp;gt;Non-linear response with the Floquet formalism:&amp;lt;/u&amp;gt; in Lumen 2.1 it is possible to calculate non-linear response functions using Floquet formalism, for the moment this implementation is limited to the independent particle approximation with or without quasi-particle correction. See tutorial: [SHG from Floquet formulation]&lt;br /&gt;
&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=952</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=952"/>
		<updated>2026-06-11T09:58:44Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Main new features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;br /&gt;
===Code optimization===&lt;br /&gt;
&lt;br /&gt;
===Fixes===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=951</id>
		<title>Lumen 2.1</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_2.1&amp;diff=951"/>
		<updated>2026-06-11T09:52:49Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: Created page with &amp;quot;Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]  ==Release Notes==  This is the second release of the lumen code, after the reboot based on yambo 5.3  ===Main new features===&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Times_logo_red.png|right|thumb|250px|TIMES logo red|Lumen 2.1 release was supported by the EU through the [https://times.uv.es/ TIMES MSCA-DN]]]&lt;br /&gt;
&lt;br /&gt;
==Release Notes==&lt;br /&gt;
&lt;br /&gt;
This is the second release of the lumen code, after the reboot based on yambo 5.3&lt;br /&gt;
&lt;br /&gt;
===Main new features===&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Lumen_release_notes&amp;diff=950</id>
		<title>Lumen release notes</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Lumen_release_notes&amp;diff=950"/>
		<updated>2026-06-11T09:51:54Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Lumen Releases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Lumen Releases ==&lt;br /&gt;
&lt;br /&gt;
* Lumen 2.1 (11/06/2026) [[Lumen 2.1|Release Notes]]&lt;br /&gt;
* [https://gitlab.com/lumen-code/lumen/-/releases/2.0.0 Lumen 2.0] (04/12/2025) [[Lumen 2.0|Release Notes]]&lt;br /&gt;
* [https://www.attaccalite.com/lumen/ Lumen 1.X] (2018)&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_on_MacOsX_(from_Yuncheng_Mao)&amp;diff=949</id>
		<title>Install Lumen on MacOsX (from Yuncheng Mao)</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_on_MacOsX_(from_Yuncheng_Mao)&amp;diff=949"/>
		<updated>2026-05-29T08:41:42Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: Created page with &amp;quot; = Lumen 2.0.1 macOS Compilation Guide = This guide records a working macOS/Homebrew recipe for compiling the Lumen executables with MPI parallel execution enabled. Two build configurations are documented:  * &amp;#039;&amp;#039;&amp;#039;MPI+SLK+HDF5_IO&amp;#039;&amp;#039;&amp;#039;: Serial HDF5/NetCDF I/O. Simpler setup using Homebrew libraries directly. MPI execution and ScaLAPACK are still active. * &amp;#039;&amp;#039;&amp;#039;MPI+SLK+HDF5_MPI_IO&amp;#039;&amp;#039;&amp;#039;: Parallel HDF5/NetCDF I/O. Requires building HDF5, NetCDF-C, and NetCDF-Fortran from source with...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Lumen 2.0.1 macOS Compilation Guide =&lt;br /&gt;
This guide records a working macOS/Homebrew recipe for compiling the Lumen executables with MPI parallel execution enabled. Two build configurations are documented:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;MPI+SLK+HDF5_IO&#039;&#039;&#039;: Serial HDF5/NetCDF I/O. Simpler setup using Homebrew libraries directly. MPI execution and ScaLAPACK are still active.&lt;br /&gt;
* &#039;&#039;&#039;MPI+SLK+HDF5_MPI_IO&#039;&#039;&#039;: Parallel HDF5/NetCDF I/O. Requires building HDF5, NetCDF-C, and NetCDF-Fortran from source with MPI support into a local prefix.&lt;br /&gt;
&lt;br /&gt;
The commands below intentionally avoid conda. Run configure, build, and verification commands through the clean environment wrapper shown here so that Homebrew compilers and libraries are used first.&lt;br /&gt;
&lt;br /&gt;
== Verified Platform ==&lt;br /&gt;
This recipe was verified on:&lt;br /&gt;
&lt;br /&gt;
* macOS on Apple Silicon (&amp;lt;code&amp;gt;apple@arm&amp;lt;/code&amp;gt;)&lt;br /&gt;
* Homebrew under &amp;lt;code&amp;gt;/opt/homebrew&amp;lt;/code&amp;gt;&lt;br /&gt;
* GNU Fortran from Homebrew GCC&lt;br /&gt;
* Open MPI from Homebrew&lt;br /&gt;
&lt;br /&gt;
The final verified executable set from either build is:&amp;lt;pre&amp;gt;&lt;br /&gt;
bin/a2y&lt;br /&gt;
bin/p2y&lt;br /&gt;
bin/yambo&lt;br /&gt;
bin/yambo_nl&lt;br /&gt;
bin/yambo_ph&lt;br /&gt;
bin/yambo_rt&lt;br /&gt;
bin/yambo_sc&lt;br /&gt;
bin/ypp&lt;br /&gt;
bin/ypp_nl&lt;br /&gt;
bin/ypp_ph&lt;br /&gt;
bin/ypp_rt&lt;br /&gt;
bin/ypp_sc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt; is enabled in this configuration. &amp;lt;code&amp;gt;e2y&amp;lt;/code&amp;gt; is disabled by &amp;lt;code&amp;gt;config/mk/global/defs.mk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Required Homebrew Packages ==&lt;br /&gt;
Install the needed tools and libraries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; brew install gcc open-mpi openblas scalapack fftw netcdf netcdf-fortran hdf5 automake libtool wget cmake &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The verified versions were:&amp;lt;pre&amp;gt;&lt;br /&gt;
automake 1.18.1&lt;br /&gt;
cmake 4.x&lt;br /&gt;
fftw 3.3.11&lt;br /&gt;
gcc 15.2.0_1&lt;br /&gt;
hdf5 2.1.1&lt;br /&gt;
libtool 2.5.4&lt;br /&gt;
netcdf 4.10.0&lt;br /&gt;
netcdf-fortran 4.6.2&lt;br /&gt;
open-mpi 5.0.9&lt;br /&gt;
openblas 0.3.33&lt;br /&gt;
scalapack 2.2.3&lt;br /&gt;
&amp;lt;/pre&amp;gt;Check that the tools resolve to Homebrew, not conda:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; which mpicc mpifort mpirun gfortran nc-config nf-config h5fc cmake &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected paths are under &amp;lt;code&amp;gt;/opt/homebrew/bin&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Clean Build Environment ==&lt;br /&gt;
Use this wrapper for all configure, build, and verification commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin &amp;lt;command&amp;gt; &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Why:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;env -i&amp;lt;/code&amp;gt; removes conda variables and library paths.&lt;br /&gt;
* &amp;lt;code&amp;gt;PATH&amp;lt;/code&amp;gt; puts Homebrew and system tools in a known order.&lt;br /&gt;
* &amp;lt;code&amp;gt;TMPDIR=/private/tmp&amp;lt;/code&amp;gt; avoids macOS compiler temp-file failures seen with a stripped environment.&lt;br /&gt;
&lt;br /&gt;
The examples below use the explicit path form that was verified:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin &amp;lt;command&amp;gt; &amp;lt;/source&amp;gt;G&lt;br /&gt;
&lt;br /&gt;
== Build Configuration A: MPI+SLK+HDF5_IO (Serial I/O) ==&lt;br /&gt;
This is the simpler configuration. Homebrew HDF5 and NetCDF are used directly, but parallel HDF5 I/O is disabled. MPI execution and ScaLAPACK are still active.&lt;br /&gt;
&lt;br /&gt;
Check whether Homebrew NetCDF has parallel I/O support: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; nc-config --has-parallel4 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this prints &amp;lt;code&amp;gt;no&amp;lt;/code&amp;gt; (the typical Homebrew default), use this configuration.&lt;br /&gt;
&lt;br /&gt;
=== Configure (Serial I/O) ===&lt;br /&gt;
Run from the repository root: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ./configure \&lt;br /&gt;
  CC=mpicc \&lt;br /&gt;
  FC=gfortran \&lt;br /&gt;
  F77=gfortran \&lt;br /&gt;
  MPICC=mpicc \&lt;br /&gt;
  MPIFC=mpifort \&lt;br /&gt;
  MPIF77=mpifort \&lt;br /&gt;
  LDFLAGS=-Wl,-rpath,/opt/homebrew/lib \&lt;br /&gt;
  --enable-mpi \&lt;br /&gt;
  --enable-par-linalg \&lt;br /&gt;
  --disable-hdf5-par-io \&lt;br /&gt;
  --with-blas-libs=&amp;quot;-L/opt/homebrew/opt/openblas/lib -lopenblas&amp;quot; \&lt;br /&gt;
  --with-lapack-libs=&amp;quot;-L/opt/homebrew/opt/openblas/lib -lopenblas&amp;quot; \&lt;br /&gt;
  --with-scalapack-libs=&amp;quot;-L/opt/homebrew/opt/scalapack/lib -lscalapack&amp;quot; \&lt;br /&gt;
  --with-fft-path=/opt/homebrew/opt/fftw \&lt;br /&gt;
  --with-netcdf-path=/opt/homebrew/opt/netcdf \&lt;br /&gt;
  --with-netcdff-path=/opt/homebrew/opt/netcdf-fortran \&lt;br /&gt;
  --with-hdf5-path=/opt/homebrew/opt/hdf5&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected &amp;lt;code&amp;gt;config/report&amp;lt;/code&amp;gt; highlights:&amp;lt;pre&amp;gt;&lt;br /&gt;
[E] MPI&lt;br /&gt;
[E] SCALAPACK&lt;br /&gt;
[E] BLAS      : OpenBLAS&lt;br /&gt;
[E] LAPACK    : OpenBLAS&lt;br /&gt;
[E] FFT       : FFTW v3&lt;br /&gt;
[E] NETCDF&lt;br /&gt;
[E] NETCDFF&lt;br /&gt;
[E] HDF5      : Serial_lib&lt;br /&gt;
[-] Parallel I/O&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Build Configuration B: MPI+SLK+HDF5_MPI_IO (Parallel I/O) ==&lt;br /&gt;
This configuration enables parallel HDF5/NetCDF I/O, which allows Lumen to read and write HDF5 files collectively across MPI ranks. It requires building HDF5, NetCDF-C, and NetCDF-Fortran from source because Homebrew&#039;s &amp;lt;code&amp;gt;netcdf&amp;lt;/code&amp;gt; formula is not compiled with parallel HDF5 support.&lt;br /&gt;
&lt;br /&gt;
The local libraries are installed into &amp;lt;code&amp;gt;./external/parallel-libs/&amp;lt;/code&amp;gt; so that Homebrew packages remain untouched.&lt;br /&gt;
&lt;br /&gt;
=== Build Local Parallel HDF5 ===&lt;br /&gt;
Download, configure, and install HDF5 with MPI support: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; PARLIB=$PWD/external/parallel-libs mkdir -p $PARLIB/src cd $PARLIB/src&lt;br /&gt;
&lt;br /&gt;
# HDF5 1.14.5&lt;br /&gt;
&lt;br /&gt;
wget -O hdf5-1.14.5.tar.gz &amp;quot;https://github.com/HDFGroup/hdf5/releases/download/hdf5_1.14.5/hdf5-1.14.5.tar.gz&amp;quot; tar xzf hdf5-1.14.5.tar.gz cd hdf5-1.14.5&lt;br /&gt;
&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  ./configure --prefix=$PARLIB --enable-fortran --enable-parallel CC=mpicc FC=mpifort F77=mpifort&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  make -j$(sysctl -n hw.ncpu)&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  make install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verify parallel support: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; $PARLIB/bin/h5pcc -showconfig 2&amp;gt;&amp;amp;1 | grep &amp;quot;Parallel HDF5&amp;quot; &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected: &amp;lt;code&amp;gt;Parallel HDF5: yes&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Build Local Parallel NetCDF-C ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; cd $PARLIB/src&lt;br /&gt;
&lt;br /&gt;
# NetCDF-C 4.9.2&lt;br /&gt;
&lt;br /&gt;
wget -O netcdf-c-4.9.2.tar.gz &amp;quot;https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz&amp;quot; tar xzf netcdf-c-4.9.2.tar.gz cd netcdf-c-4.9.2&lt;br /&gt;
&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  cmake -S . -B build \&lt;br /&gt;
    -DCMAKE_INSTALL_PREFIX=$PARLIB \&lt;br /&gt;
    -DCMAKE_C_COMPILER=mpicc \&lt;br /&gt;
    -DENABLE_PNETCDF=OFF \&lt;br /&gt;
    -DENABLE_PARALLEL4=ON \&lt;br /&gt;
    -DENABLE_HDF5=ON \&lt;br /&gt;
    -DHDF5_DIR=$PARLIB \&lt;br /&gt;
    -DENABLE_DAP=OFF \&lt;br /&gt;
    -DENABLE_TESTS=OFF \&lt;br /&gt;
    -DENABLE_BYTERANGE=OFF \&lt;br /&gt;
    -DENABLE_DISKLESS=OFF&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  cmake --build build -j$(sysctl -n hw.ncpu)&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  cmake --install build&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Verify parallel support: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; $PARLIB/bin/nc-config --has-parallel4 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected: &amp;lt;code&amp;gt;yes&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Build Local Parallel NetCDF-Fortran ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; cd $PARLIB/src&lt;br /&gt;
&lt;br /&gt;
# NetCDF-Fortran 4.6.1&lt;br /&gt;
&lt;br /&gt;
wget -O netcdf-fortran-4.6.1.tar.gz &amp;quot;https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.1.tar.gz&amp;quot; tar xzf netcdf-fortran-4.6.1.tar.gz cd netcdf-fortran-4.6.1&lt;br /&gt;
&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  cmake -S . -B build \&lt;br /&gt;
    -DCMAKE_INSTALL_PREFIX=$PARLIB \&lt;br /&gt;
    -DCMAKE_C_COMPILER=mpicc \&lt;br /&gt;
    -DCMAKE_Fortran_COMPILER=mpifort \&lt;br /&gt;
    -DENABLE_TESTS=OFF \&lt;br /&gt;
    -DCMAKE_PREFIX_PATH=$PARLIB \&lt;br /&gt;
    -DnetCDF_INCLUDE_DIR=$PARLIB/include \&lt;br /&gt;
    -DnetCDF_LIBRARIES=$PARLIB/lib/libnetcdf.dylib&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  cmake --build build -j$(sysctl -n hw.ncpu)&lt;br /&gt;
/usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin \&lt;br /&gt;
  cmake --install build&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The cmake configure output should show &amp;lt;code&amp;gt;Parallel IO: yes&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;NetCDF4 Parallel IO: yes&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Summary of Local Parallel Libraries ===&lt;br /&gt;
After the steps above, &amp;lt;code&amp;gt;./external/parallel-libs/&amp;lt;/code&amp;gt; contains:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Library&lt;br /&gt;
!Version&lt;br /&gt;
!Parallel&lt;br /&gt;
|-&lt;br /&gt;
|HDF5&lt;br /&gt;
|1.14.5&lt;br /&gt;
|yes&lt;br /&gt;
|-&lt;br /&gt;
|NetCDF-C&lt;br /&gt;
|4.9.2&lt;br /&gt;
|yes (parallel4)&lt;br /&gt;
|-&lt;br /&gt;
|NetCDF-Fortran&lt;br /&gt;
|4.6.1&lt;br /&gt;
|yes&lt;br /&gt;
|}&lt;br /&gt;
These are self-contained and do not affect Homebrew.&lt;br /&gt;
&lt;br /&gt;
=== Configure (Parallel I/O) ===&lt;br /&gt;
Run from the repository root, pointing to the local parallel libraries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; PARLIB=$PWD/external/parallel-libs /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ./configure \&lt;br /&gt;
  CC=mpicc \&lt;br /&gt;
  FC=gfortran \&lt;br /&gt;
  F77=gfortran \&lt;br /&gt;
  MPICC=mpicc \&lt;br /&gt;
  MPIFC=mpifort \&lt;br /&gt;
  MPIF77=mpifort \&lt;br /&gt;
  LDFLAGS=&amp;quot;-Wl,-rpath,$PARLIB/lib&amp;quot; \&lt;br /&gt;
  --enable-mpi \&lt;br /&gt;
  --enable-par-linalg \&lt;br /&gt;
  --enable-hdf5-par-io \&lt;br /&gt;
  --with-blas-libs=&amp;quot;-L/opt/homebrew/opt/openblas/lib -lopenblas&amp;quot; \&lt;br /&gt;
  --with-lapack-libs=&amp;quot;-L/opt/homebrew/opt/openblas/lib -lopenblas&amp;quot; \&lt;br /&gt;
  --with-scalapack-libs=&amp;quot;-L/opt/homebrew/opt/scalapack/lib -lscalapack&amp;quot; \&lt;br /&gt;
  --with-fft-path=/opt/homebrew/opt/fftw \&lt;br /&gt;
  --with-netcdf-path=$PARLIB \&lt;br /&gt;
  --with-netcdff-path=$PARLIB \&lt;br /&gt;
  --with-hdf5-path=$PARLIB&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected &amp;lt;code&amp;gt;config/report&amp;lt;/code&amp;gt; highlights:&amp;lt;pre&amp;gt;&lt;br /&gt;
[E] MPI&lt;br /&gt;
[E] SCALAPACK&lt;br /&gt;
[E] BLAS      : OpenBLAS&lt;br /&gt;
[E] LAPACK    : OpenBLAS&lt;br /&gt;
[E] FFT       : FFTW v3&lt;br /&gt;
[C] NETCDF&lt;br /&gt;
[C] NETCDFF&lt;br /&gt;
[E] HDF5      : Parallel_lib&lt;br /&gt;
[X] Parallel I/O (via HDF5)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&#039;&#039;Note: NetCDF and NetCDF-Fortran are marked &amp;lt;code&amp;gt;[C]&amp;lt;/code&amp;gt; (to be compiled) because the build system compiles them internally against the parallel HDF5. The &amp;lt;code&amp;gt;[E]&amp;lt;/code&amp;gt; HDF5 points to the local parallel build.&#039;&#039;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Build the Internal Libraries ==&lt;br /&gt;
After configure (either configuration), build the internal libraries first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 iotk ldiago devxlib &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Build bundled LibXC:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 libxc &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Do not force Homebrew LibXC for this Lumen source. Current Homebrew LibXC is too new for the Fortran module symbols expected by this code. The bundled &amp;lt;code&amp;gt;libxc-5.2.3&amp;lt;/code&amp;gt; builds and links correctly.&lt;br /&gt;
&lt;br /&gt;
If the internal tarballs are missing and the machine has network access, these targets download the needed archives into &amp;lt;code&amp;gt;lib/archive/&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make ldiago-dl iotk-dl devxlib-dl libxc-dl &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected archives:&amp;lt;pre&amp;gt;&lt;br /&gt;
lib/archive/Ldiago-0.5.1.tar.gz&lt;br /&gt;
lib/archive/iotk-y1.2.2.tar.gz&lt;br /&gt;
lib/archive/devicexlib-0.8.5.tar.gz&lt;br /&gt;
lib/archive/libxc-5.2.3.tar.gz&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build the Executables ==&lt;br /&gt;
Build the project executables one target at a time. Do not put multiple project targets in the same make invocation: project flags are selected from &amp;lt;code&amp;gt;MAKECMDGOALS&amp;lt;/code&amp;gt;, and the internal library/stamp setup is sensitive to target switching.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;-j1&amp;lt;/code&amp;gt; for project executables. Higher parallelism can race Fortran module availability during target switches; the compiled programs themselves are still MPI-enabled.&lt;br /&gt;
&lt;br /&gt;
During builds on macOS, this warning can appear many times:&amp;lt;pre&amp;gt;&lt;br /&gt;
grep: /proc/cpuinfo: No such file or directory&lt;br /&gt;
&amp;lt;/pre&amp;gt;It is harmless. The build scripts probe Linux CPU information, but the absence of &amp;lt;code&amp;gt;/proc/cpuinfo&amp;lt;/code&amp;gt; on macOS does not prevent compilation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 yambo &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then build the remaining enabled targets:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 ypp /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 a2y /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 p2y /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 yambo_ph /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 ypp_ph /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 yambo_sc /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 ypp_sc /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 yambo_rt /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 ypp_rt /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 yambo_nl /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -j1 ypp_nl &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this configuration &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt; is enabled and &amp;lt;code&amp;gt;e2y&amp;lt;/code&amp;gt; is disabled. The expected outputs are:&amp;lt;pre&amp;gt;&lt;br /&gt;
bin/a2y&lt;br /&gt;
bin/p2y&lt;br /&gt;
bin/yambo&lt;br /&gt;
bin/yambo_nl&lt;br /&gt;
bin/yambo_ph&lt;br /&gt;
bin/yambo_rt&lt;br /&gt;
bin/yambo_sc&lt;br /&gt;
bin/ypp&lt;br /&gt;
bin/ypp_nl&lt;br /&gt;
bin/ypp_ph&lt;br /&gt;
bin/ypp_rt&lt;br /&gt;
bin/ypp_sc&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Precision Switching for NL Targets ==&lt;br /&gt;
The &amp;lt;code&amp;gt;yambo_nl&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt; targets are compiled with &amp;lt;code&amp;gt;-D_DOUBLE&amp;lt;/code&amp;gt; (double precision). The build system&#039;s object save/restore mechanism handles switching between single and double precision automatically: when you build &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; (single precision) first and then &amp;lt;code&amp;gt;yambo_nl&amp;lt;/code&amp;gt; (double precision), the build system saves the single-precision objects and compiles fresh double-precision ones.&lt;br /&gt;
&lt;br /&gt;
If the save/restore mechanism gets confused (e.g., after a failed build or manual cleanup), remove all stamps and library objects for a clean rebuild:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; rm -f config/stamps_and_lists/*.stamp find lib/qe_pseudo lib/slatec lib/math77 lib/local -name &#039;*.lock&#039; -delete 2&amp;gt;/dev/null find lib/qe_pseudo lib/slatec lib/math77 lib/local -name &#039;objects.save&#039; -type d -exec rm -rf {} + 2&amp;gt;/dev/null find lib/qe_pseudo lib/slatec lib/math77 lib/local -name &#039;DOUBLE_objects.save&#039; -type d -exec rm -rf {} + 2&amp;gt;/dev/null find src -name &#039;*.o&#039; -delete 2&amp;gt;/dev/null find src -name &#039;*.mod&#039; -delete 2&amp;gt;/dev/null &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then rebuild the targets in order. Single-precision targets first, then NL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Single precision targets&lt;br /&gt;
&lt;br /&gt;
make -j1 yambo ypp a2y p2y yambo_ph ypp_ph yambo_sc ypp_sc yambo_rt ypp_rt&lt;br /&gt;
&lt;br /&gt;
# Double precision targets&lt;br /&gt;
&lt;br /&gt;
make -j1 yambo_nl ypp_nl &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Stale Stamp Recovery ==&lt;br /&gt;
If a previous failed or cleaned build leaves stamps but missing generated libraries/modules, remove only the stale stamp for the failing library and rerun the target. Examples encountered during this build:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; rm -f config/stamps_and_lists/lib_Y_tools.a.stamp rm -f config/stamps_and_lists/libqe_pseudo.a.stamp &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The symptom for the &amp;lt;code&amp;gt;libqe_pseudo&amp;lt;/code&amp;gt; case is usually:&amp;lt;pre&amp;gt;&lt;br /&gt;
Fatal Error: Cannot open module file &#039;qe_pseudo_m.mod&#039; for reading&lt;br /&gt;
&amp;lt;/pre&amp;gt;This was seen while switching to the &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt; targets after previous project builds. The module had been built in &amp;lt;code&amp;gt;lib/qe_pseudo/*objects.save/&amp;lt;/code&amp;gt;, but the stale stamp prevented the build system from recreating &amp;lt;code&amp;gt;include/qe_pseudo_m.mod&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you prefer not to remove the stamp, move it aside instead: &amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; mv config/stamps_and_lists/libqe_pseudo.a.stamp config/stamps_and_lists/libqe_pseudo.a.stamp.stale &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then rerun the failed target with &amp;lt;code&amp;gt;make -j1 &amp;lt;target&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If &amp;lt;code&amp;gt;libiotk.a&amp;lt;/code&amp;gt; is missing after a partial clean, rebuild and copy it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin make -C lib/iotk/iotk/src libiotk.a /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ranlib lib/iotk/iotk/src/libiotk.a /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin cp lib/iotk/iotk/src/libiotk.a lib/external/gfortran/mpifort/lib/ &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prefer targeted stamp recovery over broad clean commands. The source tarball is not necessarily a git checkout, and &amp;lt;code&amp;gt;make veryclean&amp;lt;/code&amp;gt; can assume git metadata.&lt;br /&gt;
&lt;br /&gt;
== Verification ==&lt;br /&gt;
Check the files:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ls -l bin /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin file bin/* &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Expected:&amp;lt;pre&amp;gt;&lt;br /&gt;
Mach-O 64-bit executable arm64&lt;br /&gt;
&amp;lt;/pre&amp;gt;Check linked libraries:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin otool -L bin/* &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dynamic libraries should resolve to &amp;lt;code&amp;gt;/opt/homebrew/opt/...&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;./external/parallel-libs/&amp;lt;/code&amp;gt; (for the parallel I/O build), or &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt;. There should be no conda, miniforge, or anaconda paths.&lt;br /&gt;
&lt;br /&gt;
This command should print nothing:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin otool -L bin/* | rg -i &#039;conda|anaconda|miniforge|mambaforge&#039; &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Check help output:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin zsh -lc &#039;for exe in a2y p2y yambo yambo_nl yambo_ph yambo_rt yambo_sc ypp ypp_nl ypp_ph ypp_rt ypp_sc; do ./bin/$exe -h &amp;gt;/tmp/lumen_${exe}_help.out 2&amp;gt;&amp;amp;1; st=$?; echo &amp;quot;$exe $st&amp;quot;; done&#039; &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The verified run printed exit status &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; for every executable.&lt;br /&gt;
&lt;br /&gt;
Check MPI launch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin mpirun -np 2 ./bin/yambo -h /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin mpirun -np 2 ./bin/yambo_nl -h /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin mpirun -np 2 ./bin/ypp -h /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin mpirun -np 2 ./bin/ypp_nl -h &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In restricted sandboxes, Open MPI may fail with socket &amp;lt;code&amp;gt;bind()&amp;lt;/code&amp;gt; permission errors. On a normal macOS shell, the two-rank smoke tests should print help from both MPI ranks and exit with status 0.&lt;br /&gt;
&lt;br /&gt;
== Running Later ==&lt;br /&gt;
Use the same clean environment for production runs if conda is installed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin mpirun -np 4 ./bin/yambo_nl &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For single-process runs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt; /usr/bin/env -i HOME=&amp;quot;$HOME&amp;quot; TMPDIR=/private/tmp PATH=/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ./bin/yambo &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Installation&amp;diff=948</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Installation&amp;diff=948"/>
		<updated>2026-05-29T08:40:16Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this page we explain how to install Lumen on different machine with different compiler and configurations.&lt;br /&gt;
&lt;br /&gt;
===General installations===&lt;br /&gt;
* [[Install Lumen on Ubuntu/LinuxMint]]&lt;br /&gt;
* [[Install Lumen on Ubuntu/LinuxMint with Intel compiler]]&lt;br /&gt;
* [[Install Lumen on Ubuntu/LinuxMint with NVfortran compiler]]&lt;br /&gt;
* [[Install Lumenon MacOS (ARM)]]&lt;br /&gt;
* [[Install Lumen on a Debian machine with some libraries provided via modules]]&lt;br /&gt;
* [[Install Lumen on MacOsX (from Yuncheng Mao)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Libraries===&lt;br /&gt;
* [[Compile the libraries in Lumen independently]]&lt;br /&gt;
* [[Install Lumen with external HDF5 and NetCDF libraries]]&lt;br /&gt;
* [[Install Lumen with external chase libraries|Install Lumen with external ChASE libraries]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Installations on specific machines===&lt;br /&gt;
* [[Install Lumen Claudia cluster in Marseille|Install Lumen on Claudia cluster (Marseille]])&lt;br /&gt;
* [[Install Lumen on Mesocentre (Marseille)]]&lt;br /&gt;
* [[Install Lumen on IRENE machine  (TGCC Joliot Curie)]]&lt;br /&gt;
* [[Install Lumen on ISM cluster (Rome)]]&lt;br /&gt;
* [[Install Lumen on Leonardo|Install Lumen on Leonardo (Cineca, Bologna)]]&lt;br /&gt;
* [[Install Lumen on Tirant|Install Lumen/LetzElPhC/Yambopy on Tirant (Univ. of Valencia Cluster)]]&lt;br /&gt;
* [[Install Lumen/LetzElPhC/Yambopy on Lynx(Univ. of Valencia)| Install Lumen on Lynx (Univ. of Valencia Cluster)]]&lt;br /&gt;
* [[Install Lumen on Viper (MPCDF, Munich)]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=First_steps:_a_walk_through_from_DFT_to_optical_properties&amp;diff=947</id>
		<title>First steps: a walk through from DFT to optical properties</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=First_steps:_a_walk_through_from_DFT_to_optical_properties&amp;diff=947"/>
		<updated>2026-05-19T13:38:03Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Step 0: Download the Files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial you will learn how to calculate optical spectra using Yambo, starting from a DFT calculation and ending with a look at local field effects in the optical response.   &lt;br /&gt;
&lt;br /&gt;
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;
Before starting, you need to obtain the tarballs for hBN and hBN-2D. See instructions on the [[Tutorials|main tutorials page]].&lt;br /&gt;
&lt;br /&gt;
The steps are the following: &amp;lt;!--Menu appears here--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Step 0: Download the Files===&lt;br /&gt;
You can download inputs file for [https://media.yambo-code.eu/educational/tutorials/files/hBN.tar.gz hBN bulk] and [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D.tar.gz hBN-2D].&lt;br /&gt;
&lt;br /&gt;
===Step 1: DFT calculation of bulk hBN and conversion to Yambo===&lt;br /&gt;
Follow the DFT and p2y module on &#039;&#039;&#039;[[Bulk material: h-BN|database generation for bulk hBN]]&#039;&#039;&#039; and then &#039;&#039;&#039;return to this tutorial &amp;quot;First steps...&amp;quot; &#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
There is no need to complete the DFT and p2y module on &#039;&#039;&#039;[[2D material: h-BN sheet|database generation in 2D hBN]]&#039;&#039;&#039;, but you may do so if you wish. &lt;br /&gt;
&lt;br /&gt;
===Step 2: Initialization of Yambo databases===&lt;br /&gt;
Use the &#039;&#039;SAVE&#039;&#039; folders that are already provided, rather than any ones you may have generated previously. &lt;br /&gt;
&lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Initialization]]&#039;&#039;&#039;, for both hBN and 2D-hBN, and &#039;&#039;&#039;return to this tutorial &amp;quot;First steps...&amp;quot; &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Step 3: 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 behavior. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
For Yambo 4.5: Follow the module on &#039;&#039;&#039;[[Input_file_generation_and_command_line_options|Input file generation and command line options (4.5)]]&#039;&#039;&#039; for bulk hBN and then return to this tutorial &amp;quot;First steps...&amp;quot;.&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For Yambo 5.0: Follow the module on &#039;&#039;&#039;[[Input file generation and command line options 5.0|Input file generation and command line options (5.0)]]&#039;&#039;&#039; for bulk hBN and then return to this tutorial &amp;quot;First steps...&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Step 4: Optical absorption in hBN===&lt;br /&gt;
Follow the module on &#039;&#039;&#039;[[Optics at the independent particle level]]&#039;&#039;&#039; for  bulk hBN and &#039;&#039;&#039;return to this tutorial &amp;quot;First steps...&amp;quot;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Step 5: Optical absorption in 2D BN===&lt;br /&gt;
&lt;br /&gt;
To complete the tutorial you should use the preprepared &#039;&#039;SAVE&#039;&#039; folder for 2D BN and follow the module on &#039;&#039;&#039;[[Local fields]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;!-- {{Tutorialsmenu1|Prev=[[Tutorials]]|Now=[[Initialization]]|Next=[[Tutorials]]}} --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:15%; text-align:left&amp;quot;|Prev: [[Tutorials|Tutorials Home]]&lt;br /&gt;
|style=&amp;quot;width:50%; text-align:center&amp;quot;|Now: [[Tutorials|Tutorials Home]] --&amp;gt; [[First steps: a walk through from DFT to optical properties|First steps]]&lt;br /&gt;
|style=&amp;quot;width:35%; text-align:right&amp;quot;|Next: If you did everything, choose another tutorial in the menu&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=909</id>
		<title>Exciton-phonon coupling and luminescence</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=909"/>
		<updated>2026-04-30T08:00:10Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Exciton lifetimes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Tdgw-phonon-usc-01-1024x829.jpg|thumb|right|400px|(c) Zhenglu Li, University of Southern California]]&lt;br /&gt;
&lt;br /&gt;
In this advanced tutorial, we will calculate exciton-phonon interactions from first principles by interfacing DFPT (for phonon calculations) and BSE (for exciton calculations).&lt;br /&gt;
&lt;br /&gt;
The DFTP calculations are run with Quantum ESPRESSO, while the many-body GW-BSE calculations are run with Yambo. Finally, the exciton-phonon interaction will be obtained by combining and postprocessing the databases computed in the two previous runs. The great advantage of this workflow is that the calculations can be run in the irreducible Brillouin zones both for the electronic momenta (&#039;&#039;&#039;k&#039;&#039;&#039;) and the transfer momenta (&#039;&#039;&#039;Q&#039;&#039;&#039;, &#039;&#039;&#039;q&#039;&#039;&#039;) of excitons and phonons, thus speeding up considerably the jobs while reducing the IO and memory load.&lt;br /&gt;
&lt;br /&gt;
We will first compute the exciton-phonon coupling matrix elements: these are the building blocks needed to construct experimental observables such as phonon-assisted optical spectra (such as luminescence), Raman spectra and exciton lifetimes. We will do this in the case of monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, a 2D system with large spin-orbit interaction.&lt;br /&gt;
&lt;br /&gt;
As an example of application, we will consider the case of phonon-assisted luminescence. We will do this in the case of bulk hBN, a layered indirect insulator with strong electron-phonon coupling.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; this tutorial will be updated when new exc-ph tools become available in Yambopy (including full-python postprocessing, Raman spectra, interpolated lifetimes, etc).&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
This is an advanced topic: we assume that you already know something about the theory&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;antonius2017&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cudazzo2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2019_PhD&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2022&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot; /&amp;gt; and applications&amp;lt;ref name=&amp;quot;paleari2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cannuccia2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chen2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;marini2024&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;murali2025&amp;quot; /&amp;gt; of exciton-phonon physics. &lt;br /&gt;
&lt;br /&gt;
Also, we assume that you already know how to run both a basic &#039;&#039;&#039;Yambo&#039;&#039;&#039; GW-BSE calculation and a DFPT phonon calculation with &#039;&#039;&#039;Quantum ESPRESSO&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Besides the QE executables &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt;, we also use the yambo phonon-specific executable &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; and the python utility &#039;&#039;&#039;Yambopy&#039;&#039;&#039;. The auxiliary code &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; (executable &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt;) will be used to obtain the electron-phonon matrix elements by reading the same electronic wavefunctions used by Yambo (and stored in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory), while also making full use of crystal symmetries. [https://github.com/yambo-code/LetzElPhC LetzElPhC] will be run by Yambopy, but it must nonetheless be installed. Finally, the exciton-phonon properties can be computed either using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; or using Yambopy itself. Both cases will be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
[[File:Workflow scheme.png|800px|center]]&lt;br /&gt;
&lt;br /&gt;
== Step 0: Pseudopotentials, equilibrium structure and convergence ==&lt;br /&gt;
&lt;br /&gt;
In a real calculation, it is important to ensure that both the pseudopotential and the lattice parameters that we are using are compatible and perform well for the electronic excited states and for the lattice vibrations simultaneously. Furthermore, you have to make sure that the wave function cutoff &amp;lt;code&amp;gt;ecutwfc&amp;lt;/code&amp;gt; is converged with respect to the DFPT step and not just to the DFT one. This is in addition to the other customary convergence tests for DFT, DFPT, GW and BSE calculations.&lt;br /&gt;
&lt;br /&gt;
This is often the most time-demanding step when starting on a new system.&lt;br /&gt;
&lt;br /&gt;
For the sake of this tutorial, we assume that we have already done all these tests and we are starting the final workflow to get the exciton-phonon properties.&lt;br /&gt;
&lt;br /&gt;
== Step 1: scf calculation ==&lt;br /&gt;
&lt;br /&gt;
First of all, we run a standard scf calculation with &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; for Yambo. We stick with non-symmorphic symmetries. At the end, we will have the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
This is the input &amp;lt;code&amp;gt;mos2.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;scf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
Here we are using full relativistic pseudopotentials from the SG-15 database.&lt;br /&gt;
&lt;br /&gt;
We can run it on our machine (for example using 4 MPI tasks) as:&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
== Step 2: nscf calculation for Yambo ==&lt;br /&gt;
&lt;br /&gt;
Copy the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the scf calculation and run the nscf calculation for any number of empty states, with the correct &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we want to use in Yambo. Here we are using a badly underconverged grid of 6x6x1.&lt;br /&gt;
&lt;br /&gt;
This reciprocal-space grid will also match the momentum transfer &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt; grid on which excitons and phonons will be defined!&lt;br /&gt;
&lt;br /&gt;
The electronic wavefunctions computed at this step and stored in the new nscf &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory will be used both by Yambo and by the electron-phonon code: this is important because using different sets of wavefunctions would lead to a phase mismatch issue in the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
The nscf input &amp;lt;code&amp;gt;mos2.nscf&amp;lt;/code&amp;gt; is&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;nscf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
                nbnd  = 250&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, we run the calculation&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
== Step 3: dvscf phonon calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we run the phonon calculation.&lt;br /&gt;
&lt;br /&gt;
Copy the &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the &#039;&#039;&#039;scf&#039;&#039;&#039; calculation and run &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt; for a dvscf calculation with a standard &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt;-grid matching the &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we wanna use in Yambo.&lt;br /&gt;
&lt;br /&gt;
At the end, we will have the &amp;lt;code&amp;gt;_ph0&amp;lt;/code&amp;gt; directory containing the variation of the self-consistent potential, &amp;lt;math&amp;gt;\Delta V_{SCF}(q)&amp;lt;/math&amp;gt;, and the &amp;lt;code&amp;gt;*.dyn&amp;lt;/code&amp;gt; files with the phonon energies and eigenvectors.&lt;br /&gt;
&lt;br /&gt;
NB: one could further refine the phonon energies by enforcing the acoustic sum rule, including non-analytic long-range contributions, interpolating to finer grids... all of this can be done within Quantum ESPRESSO and will not be covered in this version of the tutorial.&lt;br /&gt;
&lt;br /&gt;
The input is &amp;lt;code&amp;gt;mos2.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &lt;br /&gt;
 mos2_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;mos2&#039;,&lt;br /&gt;
   fildvscf = &#039;mos2-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;mos2.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=1&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
And now we run as&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 ph.x -inp mos2.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
This time we use nohup and more processes because this calculation may take some time. It is a good idea to set &amp;lt;code&amp;gt;recover=.true.&amp;lt;/code&amp;gt; as in a real calculation you will easily breach walltime, and in this way you can safely restart.&lt;br /&gt;
&lt;br /&gt;
== Step 4: create Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory ==&lt;br /&gt;
&lt;br /&gt;
This is just the standard Yambo initialization: run &lt;br /&gt;
 &lt;br /&gt;
 p2y &lt;br /&gt;
&lt;br /&gt;
and then &lt;br /&gt;
&lt;br /&gt;
 yambo &lt;br /&gt;
&lt;br /&gt;
in the &#039;&#039;&#039;nscf&#039;&#039;&#039; &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; folder and then move the newly generated &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory to a convenient place.&lt;br /&gt;
&lt;br /&gt;
== Step 5: run a BSE calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we switch from QE to Yambo. Here, we forgo the GW step for simplicity (we can use a scissor operator to open the band gap).&lt;br /&gt;
&lt;br /&gt;
This calculation has a couple of differences with respect to a standard BSE calculation for optical absorption. We can look at the input file &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Runlevels&amp;lt;/span&amp;gt;&lt;br /&gt;
 optics                       # [R OPT] Optics&lt;br /&gt;
 rim_cut                      # [R RIM CUT] Coulomb potential&lt;br /&gt;
 bss                          # [R BSS] Bethe Salpeter Equation solver&lt;br /&gt;
 em1s                         # [R Xs] Static Inverse Dielectric Matrix&lt;br /&gt;
 bse                          # [R BSE] Bethe Salpeter Equation.&lt;br /&gt;
 bsk                          # [R BSK] Bethe Salpeter Equation kernel&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# RIM and cutoff settings&amp;lt;/span&amp;gt;&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 X/Y/Z/XY..&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Static screening&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_and_IO_CPU= &amp;quot;1 1 4 2 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;
 Chimod= &amp;quot;hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 |  200 |                 # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 8000            mRy    # [Xs] Response block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# BSE&amp;lt;/span&amp;gt;&lt;br /&gt;
 BS_CPU= &amp;quot;4.1.2&amp;quot;                   # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k.eh.t&amp;quot;                 # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_diago=4              # [PARALLEL] CPUs for matrix diagonalization&lt;br /&gt;
 BSEmod= &amp;quot;causal&amp;quot;             # [BSE] resonant/causal/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                  # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  40000      mRy    # [BSK] Exchange components&lt;br /&gt;
 ALLGexx                      # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  8000       mRy    # [BSK] Screened interaction block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind=&amp;quot;full&amp;quot;                  #[BSE,X] bar(default)/full/tilde&amp;lt;/span&amp;gt;&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.00000 |  4.00000 | eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
   0.05000 |  0.05000 | eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 2000               # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 7 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BSEBands&lt;br /&gt;
    25 |  28 |                 # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                      # [BSS] Write to disk excitonic the FWs&lt;br /&gt;
 &lt;br /&gt;
This file was generated using the command: &amp;lt;code&amp;gt; yambo -X s -o b -k sex -y d -r&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all, we compute the excitons for all the momenta in the irreducible Brillouin zone for our discrete grid via the &amp;lt;code&amp;gt;BSEQptR&amp;lt;/code&amp;gt; variable. This will be a &#039;&#039;&#039;finite-momentum&#039;&#039;&#039; BSE calculation, analogous to the phonon one.&lt;br /&gt;
&lt;br /&gt;
Second, we change the variable &amp;lt;code&amp;gt;Lkind&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;full&amp;lt;/code&amp;gt;. In Yambo, &amp;lt;code&amp;gt;Lkind=&amp;quot;bar&amp;quot;&amp;lt;/code&amp;gt;, which is the default for optical absorption, means that we are computing the excitonic response function without the long-range component of the exchange interaction. This cannot be used when computing the exciton momentum dependence, where the long-range exchange interaction can play a role, therefore we have to include it with &amp;lt;code&amp;gt;Lkind=&amp;quot;full&amp;quot;&amp;lt;/code&amp;gt;. This allows for the calculation of the excitonic longitudinal-transverse splitting (in 3D systems) as well.&lt;br /&gt;
&lt;br /&gt;
We can now run the code:&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation, we have obtained the &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; databases inside the directory &amp;lt;code&amp;gt;bse_Lfull&amp;lt;/code&amp;gt;. They contain information on the exciton energies and wavefunctions at each momentum. Do not forget to check the report and logs of your calculation in the same directory to make sure that the code is doing what you want.&lt;br /&gt;
&lt;br /&gt;
== Step 6: obtain the electron-phonon matrix elements ==&lt;br /&gt;
&lt;br /&gt;
We have finished the heavy simulations. Now it&#039;s time for the postprocessing. The first order of business is the reconstruction of the electron-phonon coupling matrix elements from the dvscf results and the electronic wavefunctions.&lt;br /&gt;
&lt;br /&gt;
In order to do this, we will run the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable of the &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; code. We will run via command line using yambopy, although it will be instructive to have look at the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; input files later.&lt;br /&gt;
&lt;br /&gt;
We run in the same directory where the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; is (remember than you can also virtually move it with a symbolic link).&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y&lt;br /&gt;
&lt;br /&gt;
to see the help for the calculation. Have a look at the various flags and their description.&lt;br /&gt;
For example, if we want to do a serial run of LetzElPhC for bands from &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt;, we should type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/ph_input.in -b n_i n_f&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt; are integers representing the initial and final band indices. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 1 and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f]&amp;lt;/math&amp;gt; including the extrema of the interval.&lt;br /&gt;
&lt;br /&gt;
These should coincide with those used for the Bethe-Salpeter kernel, i.e. those specified in the &amp;lt;code&amp;gt;BSEBands&amp;lt;/code&amp;gt; variable of the BSE input file (this is not strictly necessary, but certainly efficient since these calculations use a lot of disk space). &lt;br /&gt;
&lt;br /&gt;
For our system, we want to do a parallel calculation with 4 qpools and 2 kpools. In addition, we want to explicitly specify the path of the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable and avoid automatically deleting the LetzElPhC data. So we type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/mos2.dvscf -b 25 28 -par 4 2 -lelphc path/to/lelphc_exe&lt;br /&gt;
&lt;br /&gt;
At the end, check your directory: you should find the &amp;lt;code&amp;gt;lelphc.in&amp;lt;/code&amp;gt; input file that was run, let&#039;s inspect it: &lt;br /&gt;
&lt;br /&gt;
 # LetzElPhC input for yambo generated by yambopy&lt;br /&gt;
 nqpool      = 2&lt;br /&gt;
 nkpool      = 4&lt;br /&gt;
 start_bnd   = 25&lt;br /&gt;
 end_bnd     = 28&lt;br /&gt;
 save_dir    = ./SAVE&lt;br /&gt;
 kernel      = dfpt&lt;br /&gt;
 ph_save_dir = dvscf/ph_save&lt;br /&gt;
 convention = yambo&lt;br /&gt;
&lt;br /&gt;
Notice the variable &amp;lt;code&amp;gt;convention=yambo&amp;lt;/code&amp;gt;: what does it mean? At variance with QE and many other codes, Yambo uses the &amp;quot;backward&amp;quot; momentum transfer convention for electronic scatterings. That is, an electronic transition goes from band &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k-q&amp;lt;/math&amp;gt; to band &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. In the &amp;quot;forward&amp;quot; momentum transfer convention (the more standard one), the transitions go from &amp;lt;math&amp;gt;nk&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;mk+q&amp;lt;/math&amp;gt;. Therefore, this variable ensures that the electron-phonon coupling matrix elements are computed as &amp;lt;math&amp;gt;\langle mk|dV|nk-q\rangle&amp;lt;/math&amp;gt;. This will have consequences also in the formulation of the &#039;&#039;exciton&#039;&#039;-phonon coupling matrix element.&lt;br /&gt;
&lt;br /&gt;
You will also find a &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; database that contains the computed electron-phonon matrix elements, in the output format of &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In addition, if you check the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder:&lt;br /&gt;
&lt;br /&gt;
 ls SAVE/ndb.elph_gkkp*&lt;br /&gt;
&lt;br /&gt;
you will see that yambopy has created the Yambo-compatible electron-phonon databases.&lt;br /&gt;
&lt;br /&gt;
If you want to run LetzElPhC directly, without using yambopy, you can refer to its [https://github.com/yambo-code/LetzElPhC/blob/main/docs/tex_doc/main.pdf|user guide].&lt;br /&gt;
Keep in mind that in this case, in order to convert the database to the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases of Yambo, you will then need a couple of lines of python using the Yambopy class &amp;lt;code&amp;gt;ConvertElectronPhononDB&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;yambopy/letzelph_interface/lelph2y.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases -- e.g., because you are doing the exc-ph postprocessing with yambopy -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_gkkp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases -- e.g., because you are using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; for the exc-ph part -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_lelphc_dbs&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
== Step 7: Obtain the exciton-phonon coupling ==&lt;br /&gt;
&lt;br /&gt;
Now, we can finally access our basic building block for exciton-phonon physics. This could be done entirely in python (using &#039;&#039;&#039;Yambopy&#039;&#039;&#039;), or by running &#039;&#039;&#039;Yambo&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambo postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (running yambo inputs with the &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; executable), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;follow the alternative route to Steps 7-8 [[Exciton-phonon coupling and luminescence - Yambo postprocessing|at this link]]&#039;&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambopy postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (using flexible python scripting), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;keep following Steps 7-8 on this page&#039;&#039;&#039;&amp;lt;/span&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Our objective is obtaining the following quantity: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathcal{G}^\mu_{\alpha\lambda}(0,q)=\sum_{vv^\prime c k} A^{\alpha, *}_{cv^\prime} (k, q) g_{vv^\prime}^\mu (k,q) A^{\lambda}_{cv}(k,0) - \sum_{cc^\prime vk} A^{\alpha, *}_{c^\prime v} (k+q, q) g_{c^\prime c}^\mu (k+q,q) A^{\lambda}_{cv}(k, 0)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;A^{\alpha}_{cv}(k,q)&amp;lt;/math&amp;gt; are the exciton coefficients extracted from the eigenvector of the two-particles Hamiltonian during the BSE calculation in step 5, while &amp;lt;math&amp;gt;g_{nm}^\mu (k,q)&amp;lt;/math&amp;gt; are the electron-phonon coupling matrix elements obtained in step 6. As you can see, the exciton &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; undergoes phonon-mediated scattering to state &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; via phonon mode &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;. The scattering can happen for the hole (valence, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;) or for the electron (conduction, &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
NB: &lt;br /&gt;
&lt;br /&gt;
(1) This is written in the &amp;quot;backward&amp;quot; momentum transfer convention used by Yambo. The momentum dependence is different in the &amp;quot;forward&amp;quot; transfer convention. &lt;br /&gt;
&lt;br /&gt;
(2) For simplicity, this is written for zero initial exciton momentum. This means that one of the two states involved in the phonon-mediated scattering process will be in the optical limit (and possibly an optically generated exciton), while the other state can have any momentum: this momentum will be the same as the phonon one. This matrix element can be used to describe phonon-assisted absorption and emission spectra.&lt;br /&gt;
&lt;br /&gt;
In order to calculate this quantity using python, we need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases natively generated by the &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt; code, as well as the BSE databases &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; containing the information on exciton wavefunctions and energies.&lt;br /&gt;
&lt;br /&gt;
Next, we write a python user script importing the yambopy exciton-phonon tools. You can find a version of this script in &amp;lt;code&amp;gt;yambopy/tutorials/exciton-phonon/calculate_excph.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np &lt;br /&gt;
 from yambopy import YamboLatticeDB,YamboWFDB,LetzElphElectronPhononDB &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific Yambopy dbs loading classes&amp;lt;/span&amp;gt;&lt;br /&gt;
 from yambopy.exciton_phonon.excph_matrix_elements import exciton_phonon_matelem &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific exc-ph functions&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 path = &#039;1L_MoS2&#039;&lt;br /&gt;
 bands_range=[24,28] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence bands, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# number of excitonic states&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 bsepath    = f&#039;{path}/bse-allq_full&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lin=Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath   = f&#039;{path}/SAVE&#039;     &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Yambo SAVE&amp;lt;/span&amp;gt;&lt;br /&gt;
 ndb_elph   = f&#039;{path}/ndb.elph&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# LetzElPhC electron-phonon database (any convention)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice&amp;lt;/span&amp;gt;&lt;br /&gt;
 lattice = YamboLatticeDB.from_db_file(filename=f&#039;{savepath}/ns.db1&#039;)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read electron-phonon&amp;lt;/span&amp;gt;&lt;br /&gt;
 elph    = LetzElphElectronPhononDB(ndb_elph,read_all=False)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read wave functions&amp;lt;/span&amp;gt;&lt;br /&gt;
 wfcs    = YamboWFDB(filename=&#039;ns.wf&#039;,save=savepath,latdb=lattice,bands_range=bands_range)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Calculate exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 exph = exciton_phonon_matelem(lattice,elph,wfcs,BSE_dir=bsepath,nexc_in=nexc,nexc_out=nexc,dmat_mode=&#039;save&#039;,exph_file=&#039;MoS2_Ex-ph.npy&#039;)&lt;br /&gt;
&lt;br /&gt;
In this script, we can select the number exciton states &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; with &amp;lt;code&amp;gt;nexc&amp;lt;/code&amp;gt;, the single-particle bands range with &amp;lt;code&amp;gt;bands_range&amp;lt;/code&amp;gt;. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 0 (python indexing) and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f)&amp;lt;/math&amp;gt;, therefore the last value (28 in the example) is excluded. That is, in the example we are selecting the 25th, 26th, 27th and 28th bands. Those bands have to be present in both the electron-phonon and BSE calculations. &lt;br /&gt;
&lt;br /&gt;
Here we calculate the couplings of the first twelve states at each finite-&amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; point including &amp;lt;math&amp;gt;q=0&amp;lt;/math&amp;gt;. We also include all the nine phonon modes of monolayer MoS2. We also need access to the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory in order to read the electronic wavefunctions: they are used to compute the electronic representation matrices (&amp;lt;code&amp;gt;dmat&amp;lt;/code&amp;gt; in the code). The argument &amp;lt;code&amp;gt;dmat_mode&amp;lt;/code&amp;gt; can be set to &amp;lt;code&amp;gt;&#039;load&#039;&amp;lt;/code&amp;gt; for subsequent calculations.&lt;br /&gt;
&lt;br /&gt;
When we are satisfied with the input, we run the code:&lt;br /&gt;
&lt;br /&gt;
 python calculate_excph.py&lt;br /&gt;
&lt;br /&gt;
If you check the output, you should find the &amp;lt;code&amp;gt;MoS2_Ex-ph.npy&amp;lt;/code&amp;gt; binary file in the directory where you ran.&lt;br /&gt;
&lt;br /&gt;
=== Analysis of the couplings ===&lt;br /&gt;
&lt;br /&gt;
It is a good idea to have a look at what we computed up to now in order to make sure nothing has gone wrong. &lt;br /&gt;
&lt;br /&gt;
It is not easy to know what to expect (apart from symmetry and gauge compliance of the matrix elements), but one can work out the exciton-phonon selection rules in advance, check that the magnitude is reasonable, etc.&lt;br /&gt;
&lt;br /&gt;
It is also not easy to meaningfully plot this quantity. We have to make sure that we are not breaking degenerate states, otherwise the plots will not be invariant. &lt;br /&gt;
&lt;br /&gt;
First of all, we have to know our system: in monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, the first four excitons are all doubly degenerate. The first exciton responsible for a bright peak in the absorption spectrum (the &#039;&#039;&#039;A&#039;&#039;&#039; peak), is the second state, corresponding to state indices &amp;lt;code&amp;gt;(3,4)&amp;lt;/code&amp;gt; in fortran indexing or &amp;lt;code&amp;gt;(2,3)&amp;lt;/code&amp;gt; in python indexing. &lt;br /&gt;
&lt;br /&gt;
All these information can be obtained by analyzing the BSE results (this stuff is explained in the BSE tutorials) and by knowledge of the system or class of systems from the literature.&lt;br /&gt;
&lt;br /&gt;
Thus, a good quantity to plot may be the norm of the matrix elements, summed over the degenerate subspace of exciton A, for a certain number of scattered final states mediated by certain phonon modes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;F_A(q)= \sqrt{ \sum_{\alpha \in A,\lambda,\mu} |\mathcal{G}_{\alpha\lambda}^\mu (0,q)|^2 }&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to do this, we create a python script &amp;lt;code&amp;gt;analyse_excph.py&amp;lt;/code&amp;gt; in which we first load the excph dabatases. &lt;br /&gt;
You can find a version of this script in the yambopy directory, in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;. &lt;br /&gt;
First, we select the exciton and phonon states to be included in &amp;lt;code&amp;gt;F_A&amp;lt;/code&amp;gt;, together with the path of databases and plot details:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Exciton &amp;quot;in&amp;quot; states&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_in  = [2,3]  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# First bright peak (A: 2,3 -- B: 6,7)&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_out = [0,1,2,3] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# first 4 states (dispersion of dark triplet state and A)&amp;lt;/span&amp;gt;&lt;br /&gt;
 ph_in  = &#039;all&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Paths of databases&amp;lt;/span&amp;gt;&lt;br /&gt;
 ns_db1 =f&#039;{path}/SAVE/ns.db1&#039;&lt;br /&gt;
 ns_ypy = &#039;MoS2_Ex-ph.npy&#039;&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Then, we load the data:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 ylat = YamboLatticeDB.from_db_file(filename=ns_db1)&lt;br /&gt;
 print(ylat)&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Load exc-ph database&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_py = np.load(ns_ypy)&lt;br /&gt;
 G_squared = np.abs(X_py)**2.&lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt;F_A(q)&amp;lt;/math&amp;gt; is obtained from a dedicated function as:&lt;br /&gt;
 &lt;br /&gt;
 if exc_in  == &#039;all&#039;: exc_in  = range(G_squared.shape[2])&lt;br /&gt;
 if exc_out == &#039;all&#039;: exc_out = range(G_squared.shape[3])&lt;br /&gt;
 if ph_in   == &#039;all&#039;: ph_in   = range(G_squared.shape[1])&lt;br /&gt;
 &lt;br /&gt;
 G_squared = G_squared[:, ph_in, :, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_in, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_out].sum(axis=(1))&lt;br /&gt;
 &lt;br /&gt;
 F_q = np.sqrt( G_squared )*ha2ev &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Switch from Ha to eV&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally, we have to make a plotting function. For this tutorial we will use a custom scatterplot employing some of the plotting tools provided by yambopy (but you can do whatever you want).&lt;br /&gt;
&lt;br /&gt;
 plot_2D_excph(qgrid,G2_to_plot,rlat=ylat.rlat,plt_cbar=True,\&lt;br /&gt;
               marker=&#039;H&#039;,s=700,cmap=&#039;magma&#039;)&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can get more experience on using Yambopy for these kinds of visualization by following the [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy Yambopy tutorials]. In fact, remember that these scripts and all the other Yambopy tutorial scripts are just suggestions, not source code written in stone: if you know &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt; you can do your own analysis and your own plots, you just need to import the required Yambopy modules to load the data.&lt;br /&gt;
&lt;br /&gt;
In our case, the resulting plot is the following.&lt;br /&gt;
&lt;br /&gt;
[[File:1L MoS2 MoS2 Ex-ph.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
This can be checked against Fig. 2(d) of reference &amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;, although you have to keep in mind that our results are badly undersampled in terms of the reciprocal-space grid, as can be easily seen, and the quantity plotted is not exactly the same. However, the main features are already there since they are dictated mostly by crystal symmetries.&lt;br /&gt;
&lt;br /&gt;
Now that we have the exciton-phonon matrix elements, we can use them to build several kinds of observables. Below, we give an example related to phonon-assisted luminescence, but we may update this tutorial in the future to include more cases.&lt;br /&gt;
&lt;br /&gt;
== Step 8: Compute phonon-assisted luminescence ==&lt;br /&gt;
&lt;br /&gt;
[[File:Luminescence scheme.png|250px|right]]&lt;br /&gt;
&lt;br /&gt;
We want to compute the experimental optical signature due to the phonon-assisted recombination of an exciton (as sketched in the figure).&lt;br /&gt;
&lt;br /&gt;
The signal from the phonon replicas can be modeled as a second-order scattering process involving one phonon and one photon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;I^{Sat}(\omega)=\frac{1}{ N_q} \frac{1}{3} \sum_{\epsilon s\beta \mu q} \frac{1}{E_{\beta q}-s\Omega_{\mu q}}\left|\sum_\alpha\frac{ D^{\epsilon}_\alpha \mathcal{G}_{\beta \alpha}^{\mu,*}(q)}{E_\alpha -E_{\beta q} +s\Omega_{\mu q}+\mathrm{i}\eta}\right|^2 \frac{N^{exc}_{\beta q}(T_{exc})[\frac{1+s}{2}+n_{\mu q}(T)]}{\omega -[E_{\beta q}-s\Omega_{\mu q}]+\mathrm{i}\eta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this equation, the oscillator strength of the peak is given by the exciton-phonon coupling matrix elements &amp;lt;math&amp;gt;\mathcal{G}&amp;lt;/math&amp;gt; multiplied by the exciton dipoles &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; (they are called &amp;quot;residuals&amp;quot; in Yambo). Here &amp;lt;math&amp;gt;E_\lambda&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{\alpha q}&amp;lt;/math&amp;gt; are the energies of the optical and finite-momentum excitons, respectively, while &amp;lt;math&amp;gt;\Omega_{\mu q}&amp;lt;/math&amp;gt; are the phonon energies. &lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;n_{\mu q}(T)&amp;lt;/math&amp;gt; is the temperature-dependent phonon Bose-Einstein occupation function. As it can be seen, &amp;lt;math&amp;gt;s=1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;emission&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)+1&amp;lt;/math&amp;gt;), while &amp;lt;math&amp;gt;s=-1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;absorption&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)&amp;lt;/math&amp;gt;). Therefore, &amp;lt;math&amp;gt;I^{Sat}_{PL}(\omega;T)&amp;lt;/math&amp;gt; describes &#039;&#039;light&#039;&#039; emission by recombining excitons mediated by either &#039;&#039;phonon&#039;&#039; absorption or emission. &lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt; N_{\alpha q}(T_{exc})&amp;lt;/math&amp;gt; is the exciton occupation function. Luminescence is technically an out-of-equilibrium process, but we can assume that for very low density of excitations and in steady-state conditions, the exciton population can be approximately described by an equilibrium distribution evaluated at an effective temperature. Here, we use the Boltzmann distribution. Experimentally, &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; tends to coincide with the lattice temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; more or less above 100 K, while at very low temperature (&amp;lt; 10 K), &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; may vary between 10-50 K. It goes without saying that this needs to carefully be checked in your realistic calculations.&lt;br /&gt;
&lt;br /&gt;
Finally, the spectrum is averaged over the polarization directions of the emitted photons (&amp;lt;math&amp;gt;\epsilon=x,y,z&amp;lt;/math&amp;gt; representing the respective dipole components).&lt;br /&gt;
&lt;br /&gt;
=== Running the jobs ===&lt;br /&gt;
&lt;br /&gt;
In order to study luminescence in a paradigmatic system, we switch to bulk hexagonal boron nitride and we repeat the workflow. As you can easily see, one can think about automatizing the execution of all these calculations via scripting or more advanced tools. However, in the case of very large simulations (memory-limited or disk-space limited) or for systems whose electronic and lattice properties are fragile with respect to tiny calculation details, one must be very careful and run many basic tests.&lt;br /&gt;
&lt;br /&gt;
Fortunately, we are running a fast underconverged example. We use LDA pseudopotentials from the pseudo-dojo library and the following are the calculations steps.&lt;br /&gt;
&lt;br /&gt;
1. Input &amp;lt;code&amp;gt;hbn.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;scf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
     outdir = &#039;./tmp&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
2. Input &amp;lt;code&amp;gt;hbn.nscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;nscf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;&lt;br /&gt;
     outdir = &#039;./&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 	nbnd = 120&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
3. Input &amp;lt;code&amp;gt;hbn.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 hbn_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;hBN&#039;,&lt;br /&gt;
   fildvscf = &#039;hBN-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;hBN.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=2&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 pw.x -inp hbn.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
4. Input &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt; (we include 2 valence and 2 conduction bands):&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 em1s&lt;br /&gt;
 DIP_CPU= &amp;quot;1 8 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 8 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;
 BS_CPU= &amp;quot;8 1 1&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k eh t&amp;quot;                     # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_LinAlg_INV=-1            # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&lt;br /&gt;
 BS_nCPU_LinAlg_DIAGO=-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;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 % QpntsRXs&lt;br /&gt;
    1 | 14 |                         # [Xs] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 | 120 |                         # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 10                Ry    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lfull&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 % DipBands&lt;br /&gt;
    1 | 120 |                         # [DIP] Bands range for dipoles&lt;br /&gt;
 %&lt;br /&gt;
 DipApproach= &amp;quot;G-space v&amp;quot;         # [DIP] [G-space v/R-space x/Covariant/Shifted grids]&lt;br /&gt;
 DipComputed= &amp;quot;R V P&amp;quot;             # [DIP] [default R P V; extra P2 Spin Orb]&lt;br /&gt;
 BSENGexx= 30000            Ry    # [BSK] Exchange components&lt;br /&gt;
 #ALLGexx                       # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  9000            Ry    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.25997 | 1.08816 | 1.12683 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 14 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEBands&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   7 | 10 |                         # [BSK] Bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.50000 | 8.00000 |         eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
  0.050000 | 0.050000 |         eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 1000                    # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
Importantly, since we want to describe the phonon-assisted recombination process of an *optical* exciton (i.e., emitting a transverse photon), this time we also run an additional calculation at `Q=0` omitting the nonanalytic long-range Coulomb exchange. Make a second input &amp;lt;code&amp;gt;bse_Lbar.in&amp;lt;/code&amp;gt; with the following changes: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lbar&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4b. So now we make a second BSE run in a different directory specified by &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt;. Here, we also pass to yambo the directory of the previous run as it includes the important screening databases &amp;lt;code&amp;gt;ndb.em1s*&amp;lt;/code&amp;gt; that we do not want to recompute from scratch.&lt;br /&gt;
 &lt;br /&gt;
 mpirun -np 8 yambo -F bse_Lbar.in -J bse_Lbar,bse_Lfull -C bse_Lbar&lt;br /&gt;
&lt;br /&gt;
5. Now we run &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; (with or without yambopy: in the latter case remember the option &amp;lt;code&amp;gt;-D&amp;lt;/code&amp;gt;) to get the el-ph matrix elements, particularly the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/hbn.dvscf -b 7 10 -par 4 2 -D&lt;br /&gt;
&lt;br /&gt;
=== Luminescence calculation ===&lt;br /&gt;
&lt;br /&gt;
6. And finally we calculate exciton-phonon matrix elements and the luminescence spectrum in one go using a python script importing the Yambopy exciton-phonon tools: in order to do this, we need to take a look at all the necessary input variables for the formula written above.&lt;br /&gt;
&lt;br /&gt;
We can start from the script &amp;lt;code&amp;gt;luminescence.py&amp;lt;/code&amp;gt; available in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import matplotlib.pyplot as plt&lt;br /&gt;
 from yambopy.exciton_phonon.excph_luminescence import exc_ph_luminescence&lt;br /&gt;
 from yambopy.exciton_phonon.excph_input_data import exc_ph_get_inputs&lt;br /&gt;
&lt;br /&gt;
We import the necessary tools...&lt;br /&gt;
&lt;br /&gt;
 path = &#039;3D_hBN&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lout--&amp;gt; response is Lfull)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bsepath =  f&#039;{path}/bse_Lfull&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q* databases are needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation for optically active exciton (Lin --&amp;gt; response is Lbar)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bseBARpath =  f&#039;{path}/bse_Lbar&#039;  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to electron-phonon calculation&amp;lt;/span&amp;gt;&lt;br /&gt;
 elphpath = path &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.elph is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to unprojected dipoles matrix elements (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 dipolespath = bsepath &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.dipoles is needed (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath = f&#039;{path}/SAVE&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ns.db1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... and we specify the paths to the necessary databases. Note that, if we want to perform polarization averaging, we have to recompute the excitonic dipoles in python as seen here.&lt;br /&gt;
&lt;br /&gt;
What about &amp;lt;code&amp;gt;bseBARpath&amp;lt;/code&amp;gt;? This variable points to the directory where the databases for the optical (zero-momentum) excitons &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; (which may be computed with &amp;lt;code&amp;gt;Lkind=&#039;Lbar&#039;&amp;lt;/code&amp;gt;) is located, which can be different from the directory with the full indirect exciton dispersion &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; (usually computed with &amp;lt;code&amp;gt;Lkind=&#039;Lfull&#039;&amp;lt;/code&amp;gt;, however &amp;lt;code&amp;gt;Lkind=&#039;Ltilde&#039;&amp;lt;/code&amp;gt; can also be used if one is interested in &amp;quot;irreducible&amp;quot; excitons). This makes it possible to compute the coupling between different exciton kinds.&lt;br /&gt;
&lt;br /&gt;
 bands_range=[6,10] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 phonons_range=[0,12] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# All phonons&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_out = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at each momentum (Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_in  = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at Q=0 (Lin)&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_ph  = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Lattice temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_exc = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Effective excitonic temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 emin=4.4      &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Energy range and plot details (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
 emax=4.7&lt;br /&gt;
 estep=0.0002&lt;br /&gt;
 broad = 0.005 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Broadening parameter for peak width (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we specify the parameters for the calculation. We include valence bands from 7 to 10 (6 to 9 in python index) and the contribution of all 12 phonon modes. We consider 12 excitonic states for the coupling matrix elements.&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;code&amp;gt;T_ph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;T_exc&amp;lt;/code&amp;gt; are the lattice and excitonic temperatures, respectively.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate and load all the inputs:&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Excitonic dipole matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Phonon energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * We specify bse_path2=bseBARpath meaning we use Lbar calculation for Q=0 excitons&amp;lt;/span&amp;gt;&lt;br /&gt;
 input_data = exc_ph_get_inputs(savepath,elphpath,bsepath,\&lt;br /&gt;
                                bse_path2=bseBARpath,dipoles_path=dipolespath,\&lt;br /&gt;
                                nexc_in=12,nexc_out=12,\&lt;br /&gt;
                                bands_range=[6,10],phonons_range=[0,12])&lt;br /&gt;
&lt;br /&gt;
 ph_energies, exc_energies, exc_energies_in, G, exc_dipoles = input_data&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;exc_ph_get_inputs&amp;lt;/code&amp;gt; gives us all the input data for luminescence in the correct format: phonon energies, exciton energies, optical exciton energies (if needed), exciton-phonon matrix elements (calculated on the fly and printed to file), unprojected exciton dipoles (optional, calculated on the fly and printed to file).&lt;br /&gt;
The exc-ph matrix element calculation is just a wrapper of the same tools that we have tested in the above section on MoS2.&lt;br /&gt;
&lt;br /&gt;
Finally, there is the calculation of the luminescence spectrum via the function &amp;lt;code&amp;gt;exc_ph_luminescence&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate the luminescence spectrum including the input data from before&amp;lt;/span&amp;gt;&lt;br /&gt;
 w,PL = exc_ph_luminescence(T_ph,ph_energies,exc_energies,exc_dipoles,G,\&lt;br /&gt;
                            exc_energies_in=exc_energies_in,exc_temp=T_exc,\&lt;br /&gt;
                            nexc_out=nexc_out,nexc_in=nexc_in,emin=emin,emax=emax,\&lt;br /&gt;
                            estep=estep,broad=broad)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to print the luminescence data for later plotting, you can also add the following line to the script:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Save to file&amp;lt;/span&amp;gt;&lt;br /&gt;
 data = np.column_stack((w, PL))&lt;br /&gt;
 np.savetxt(&amp;quot;hBN_luminescence_12x12x1.dat&amp;quot;, data, fmt=&amp;quot;%.8f&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
It is now time to run the whole script:&lt;br /&gt;
&lt;br /&gt;
 python luminescence.py&lt;br /&gt;
 &lt;br /&gt;
NB: By using Yambopy for Step 6, we have limited the use of the Yambo code to just step 4 in the entire workflow. This option is more flexible, as it allows for a greater degree of control by the user. On the other hand the Yambo postprocessing route features a Yambo-style input that doesn&#039;t require python knowledge and the calculation is currently faster in fortran. However, the luminescence expression computed in Yambo is a slightly different than this one: it is more approximated in the description of the satellite oscillator strengths, but it explicitly includes the renormalization of the direct exciton peak. You can check the differences [[Exciton-phonon coupling and luminescence - Yambo postprocessing|here]].&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
We can plot the results of the step 6 calculation. If we do it in the same script we can add something like this:&lt;br /&gt;
 fig = plt.figure()&lt;br /&gt;
 ax = fig.add_subplot(1,1,1)&lt;br /&gt;
 ax.set_xlim(emin,emax)&lt;br /&gt;
 ax.set_ylim(0,np.max(PL)*1.1)&lt;br /&gt;
 ax.get_yaxis().set_visible(False)&lt;br /&gt;
 &lt;br /&gt;
 ax.plot(w, PL, &#039;-&#039;,c=&#039;red&#039;, label=&amp;quot;AA&#039; hBN luminescence&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 plt.legend()&lt;br /&gt;
 plt.savefig(&#039;hBN_luminescence.png&#039;)&lt;br /&gt;
 plt.show()&lt;br /&gt;
&lt;br /&gt;
[[File:HBN luminescence satellites.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
Here, the signal corresponds to a finite-momentum exciton that recombines with the help of several different phonon modes, both optical and acoustic. Each phonon mode whose coupling with the exciton is allowed can generate a peak, and the energy shifts of these peaks with respect to the initial exciton energy correspond to the phonon energies. This result is underconverged, but the main features are all there. In the plot, we show a more converged example using a 12x12x4 grid (all the other parameters being equal). These plots can be compared with Fig. 4(a) of reference &amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Exciton lifetimes==&lt;br /&gt;
&lt;br /&gt;
Using the exciton-phonon coupling it is possible also to calculate exciton life-time due to the scattering with phonon. For this kind of calculation input file can be generated with the command &#039;&#039;yambo_ph -excph l&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 excph                            # [R] Exction-phonon&lt;br /&gt;
 ExcGkkp                          # [R][EXCPH] Exciton-Phonon Matrix Elelements&lt;br /&gt;
 ExcPhLifeT                       # [R][EXCPH] Exciton-Phonon Life-Times&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 % ELPhExcStates&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 |  4 |&amp;lt;/span&amp;gt;                           # [EXCPH] Incoming (external) exciton states&lt;br /&gt;
 %&lt;br /&gt;
 % ELPhExcSum&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 |  8 |    &amp;lt;/span&amp;gt;                       # [EXCPH] Outgoing (virtual) exciton states&lt;br /&gt;
 %&lt;br /&gt;
 LoutPath= &amp;quot;none&amp;quot;                 # [EXCPH] Path of the outgoing L&lt;br /&gt;
 FANdEtresh= 0.100000E-5    eV    # [ELPH] Energy treshold for Fan denominator&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 | 12 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 EXCTemp= 0.000000          eV    # [EXCPH] Excitonic Temperature (for luminescence spectra)&lt;br /&gt;
 AlphaQ= 0.000000                 # [EXCPH] Excitonic band structure 2D distortion&lt;br /&gt;
 #ExcPhOffDiago                 # [EXCPH] Exciton-Phonon off-diagonal self-energy&lt;br /&gt;
 #NoMatrxEl                     # [EXCPH] Set all exciton-phonon matrix elements to one (for testing purpose)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;LDamping= 0.1 &amp;lt;/span&amp;gt;     meV               # [EXCPH] Damping of exc-ph self-energy&lt;br /&gt;
&lt;br /&gt;
notice that in this case &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;LDamping&amp;lt;/span&amp;gt; is the broadening of the exciton-phonon self energy and it should be a very small value of the order of the phonon life-times around the meV.&amp;lt;ref&amp;gt;[https://arxiv.org/abs/1411.5628 First-principles calculations of phonon frequencies, lifetimes, and spectral functions from weak to strong an-harmonicity: The example of palladium hydrides], L. Paulatto, et al. Phys. Rev. B &#039;&#039;&#039;91&#039;&#039;&#039;, 054304 (2015) &amp;lt;/ref&amp;gt;. Running this input you will get:&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton lifetimes:&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [1] Lifetime: 0.697314 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [2] Lifetime: 0.697314 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [3] Lifetime: 20.22155 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [4] Lifetime: 32.95292 meV&lt;br /&gt;
&lt;br /&gt;
the life-time of the first four excitons. Note that this result is not converged respect to the Q-points. In order to speedup convergence that double-grid&amp;lt;ref name=&#039;lechifflart2023&#039;/&amp;gt; can be used also in the life-time calculations, see tutorial on electron-phonon coupling for tricks on the convergence of the double-grid. &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; &amp;gt;Toyozawa, Yutaka, and Chris Oxlade, &#039;&#039;Optical processes in solids&#039;&#039;, [https://m.booksee.org/book/1121964?force_lang=en Cambridge University Press, (2003)]. &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;lechifflart2023&#039;&amp;gt;P. Lechifflart, F. Paleari, D. Sangalli, C. Attaccalite, &#039;&#039;First-principles study of luminescence in hexagonal boron nitride single layer: Exciton-phonon coupling and the role of substrate&#039;&#039;, &lt;br /&gt;
[https://doi.org/10.1103/PhysRevMaterials.7.024006 Phys. Rev. M, &#039;&#039;&#039;7&#039;&#039;&#039; (2), 024006 (2023)]; [https://arxiv.org/abs/2212.10407 arXiv2212.1047]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cannuccia2019&#039;&amp;gt;E. Cannuccia, B. Monserrat and C. Attaccalite, &#039;&#039;Theory of phonon-assisted luminescence in solids: Application to hexagonal boron nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]; [https://arxiv.org/abs/1807.11797 arXiv1807.11797]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019&#039;&amp;gt;F. Paleari et al., &#039;&#039;Exciton-Phonon Coupling in the Ultraviolet Absorption and Emission Spectra of Bulk Hexagonal Boron Nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.122.187401 Phys. Rev. Lett. &#039;&#039;&#039;122&#039;&#039;&#039;, 187401 (2019)]; [https://arxiv.org/abs/1810.08976 arXiv1810.089776] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chen2020&#039;&amp;gt;&#039;&#039;Exciton-Phonon Interaction and Relaxation Times from First Principles&#039;&#039;,&lt;br /&gt;
Hsiao-Yi Chen, Davide Sangalli, and Marco Bernardi, [https://doi.org/10.1103/PhysRevLett.125.107401  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 107401 (2020)]; [https://arxiv.org/abs/2002.08913 arXiv 2002.08913 (2020)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot;&amp;gt;P. Lechifflart, &#039;&#039;Exciton-phonon coupling and phonon-assisted luminescence in hexagonal Boron Nitride nanostructures&#039;&#039;, [https://hal.science/tel-04266805v1 PhD Thesis, University of Marseille (2023)]; [https://www.yambo-code.eu/wiki/images/5/54/These_final.pdf From the yambo website]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019_PhD&#039;&amp;gt;F. Paleari, &#039;&#039;First-principles approaches to the description of indirect absorption and luminescence spectroscopy: exciton-phonon coupling in hexagonal boron nitride&#039;&#039;, [https://wwwen.uni.lu/research/fstm/dphyms/people/fulvio_paleari PhD thesis, University of Luxembourg (2019)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;zanfrognini2023&#039;&amp;gt;M. Zanfrognini et al., &#039;&#039;Distinguishing different stackings in layered materials via luminescence spectroscopy&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.131.206902 Phys. Rev. Lett. &#039;&#039;&#039;131&#039;&#039;&#039;, 206902 (2023)]; [https://arxiv.org/abs/2305.17554 arXiv 2305.17554] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;marini2024&#039;&amp;gt;G. Marini, M. Calandra, P. Cudazzo, &#039;&#039;Optical absorption and photoluminescence of single layer boron nitride from a first principles cumulant approach&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.4c00669 Nano Lett., &#039;&#039;&#039;24&#039;&#039;&#039;, 20, 6017 (2024)]; [https://arxiv.org/abs/2402.03826 arXiv 2402.03826 (2024)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;antonius2017&#039;&amp;gt;G. Antonius, S. G. Louie, &#039;&#039;Theory of exciton-phonon coupling&#039;&#039;, [https://doi.org/10.1103/PhysRevB.105.085111 Phys. Rev. B, &#039;&#039;&#039;105&#039;&#039;&#039;, 085111 (2022)]; [https://arxiv.org/abs/1705.04245 arXiv1705.04245 (2017)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2022&#039;&amp;gt; F. Paleari, and A. Marini, &#039;&#039;Exciton-phonon interaction calls for a revision of the “exciton” concept&#039;&#039;, [https://doi.org/10.1103/PhysRevB.106.125403 Phys. Rev. B, &#039;&#039;&#039;106&#039;&#039;&#039;, 125403 (2022)]; [https://arxiv.org/abs/2205.02783 arXiv 2205.02783]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cudazzo2020&#039;&amp;gt; P. Cudazzo, &#039;&#039;First-principles description of the exciton-phonon interaction: A cumulant approach&#039;&#039;, [https://doi.org/10.1103/PhysRevB.102.045136 Phys. Rev. B, &#039;&#039;&#039;102&#039;&#039;&#039;, 045136 (2020)]; [https://orbilu.uni.lu/bitstream/10993/44769/1/main.pdf Open access pdf from Luxembourg University]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chan2023&#039;&amp;gt;Y-h Chan, J. B. Haber, M. H. Naik, J. B. Neaton, D. Y. Qiu, F. H. da Jornada, S. G. Louie, &#039;&#039;Exciton Lifetime and Optical Line Width Profile via Exciton–Phonon Interactions: Theory and First-Principles Calculations for Monolayer MoS2&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.3c00732 Nano Lett., &#039;&#039;&#039;23&#039;&#039;&#039;, 9 (2023)]; [https://arxiv.org/abs/2212.08451 arXiv 2212.08451 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;murali2025&#039;&amp;gt;M. Nalabothula, S. Reichardt, L. Wirtz, &#039;&#039;Origin of Interlayer Exciton–Phonon Coupling in 2D Heterostructures&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.5c00355 Nano Lett., &#039;&#039;&#039;25&#039;&#039;&#039;, 15 (2025)], [https://arxiv.org/abs/2407.16111 arXiv 2407.16111 (2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=908</id>
		<title>Exciton-phonon coupling and luminescence</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=908"/>
		<updated>2026-04-30T07:58:35Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Exciton lifetimes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Tdgw-phonon-usc-01-1024x829.jpg|thumb|right|400px|(c) Zhenglu Li, University of Southern California]]&lt;br /&gt;
&lt;br /&gt;
In this advanced tutorial, we will calculate exciton-phonon interactions from first principles by interfacing DFPT (for phonon calculations) and BSE (for exciton calculations).&lt;br /&gt;
&lt;br /&gt;
The DFTP calculations are run with Quantum ESPRESSO, while the many-body GW-BSE calculations are run with Yambo. Finally, the exciton-phonon interaction will be obtained by combining and postprocessing the databases computed in the two previous runs. The great advantage of this workflow is that the calculations can be run in the irreducible Brillouin zones both for the electronic momenta (&#039;&#039;&#039;k&#039;&#039;&#039;) and the transfer momenta (&#039;&#039;&#039;Q&#039;&#039;&#039;, &#039;&#039;&#039;q&#039;&#039;&#039;) of excitons and phonons, thus speeding up considerably the jobs while reducing the IO and memory load.&lt;br /&gt;
&lt;br /&gt;
We will first compute the exciton-phonon coupling matrix elements: these are the building blocks needed to construct experimental observables such as phonon-assisted optical spectra (such as luminescence), Raman spectra and exciton lifetimes. We will do this in the case of monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, a 2D system with large spin-orbit interaction.&lt;br /&gt;
&lt;br /&gt;
As an example of application, we will consider the case of phonon-assisted luminescence. We will do this in the case of bulk hBN, a layered indirect insulator with strong electron-phonon coupling.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; this tutorial will be updated when new exc-ph tools become available in Yambopy (including full-python postprocessing, Raman spectra, interpolated lifetimes, etc).&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
This is an advanced topic: we assume that you already know something about the theory&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;antonius2017&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cudazzo2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2019_PhD&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2022&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot; /&amp;gt; and applications&amp;lt;ref name=&amp;quot;paleari2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cannuccia2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chen2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;marini2024&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;murali2025&amp;quot; /&amp;gt; of exciton-phonon physics. &lt;br /&gt;
&lt;br /&gt;
Also, we assume that you already know how to run both a basic &#039;&#039;&#039;Yambo&#039;&#039;&#039; GW-BSE calculation and a DFPT phonon calculation with &#039;&#039;&#039;Quantum ESPRESSO&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Besides the QE executables &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt;, we also use the yambo phonon-specific executable &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; and the python utility &#039;&#039;&#039;Yambopy&#039;&#039;&#039;. The auxiliary code &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; (executable &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt;) will be used to obtain the electron-phonon matrix elements by reading the same electronic wavefunctions used by Yambo (and stored in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory), while also making full use of crystal symmetries. [https://github.com/yambo-code/LetzElPhC LetzElPhC] will be run by Yambopy, but it must nonetheless be installed. Finally, the exciton-phonon properties can be computed either using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; or using Yambopy itself. Both cases will be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
[[File:Workflow scheme.png|800px|center]]&lt;br /&gt;
&lt;br /&gt;
== Step 0: Pseudopotentials, equilibrium structure and convergence ==&lt;br /&gt;
&lt;br /&gt;
In a real calculation, it is important to ensure that both the pseudopotential and the lattice parameters that we are using are compatible and perform well for the electronic excited states and for the lattice vibrations simultaneously. Furthermore, you have to make sure that the wave function cutoff &amp;lt;code&amp;gt;ecutwfc&amp;lt;/code&amp;gt; is converged with respect to the DFPT step and not just to the DFT one. This is in addition to the other customary convergence tests for DFT, DFPT, GW and BSE calculations.&lt;br /&gt;
&lt;br /&gt;
This is often the most time-demanding step when starting on a new system.&lt;br /&gt;
&lt;br /&gt;
For the sake of this tutorial, we assume that we have already done all these tests and we are starting the final workflow to get the exciton-phonon properties.&lt;br /&gt;
&lt;br /&gt;
== Step 1: scf calculation ==&lt;br /&gt;
&lt;br /&gt;
First of all, we run a standard scf calculation with &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; for Yambo. We stick with non-symmorphic symmetries. At the end, we will have the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
This is the input &amp;lt;code&amp;gt;mos2.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;scf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
Here we are using full relativistic pseudopotentials from the SG-15 database.&lt;br /&gt;
&lt;br /&gt;
We can run it on our machine (for example using 4 MPI tasks) as:&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
== Step 2: nscf calculation for Yambo ==&lt;br /&gt;
&lt;br /&gt;
Copy the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the scf calculation and run the nscf calculation for any number of empty states, with the correct &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we want to use in Yambo. Here we are using a badly underconverged grid of 6x6x1.&lt;br /&gt;
&lt;br /&gt;
This reciprocal-space grid will also match the momentum transfer &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt; grid on which excitons and phonons will be defined!&lt;br /&gt;
&lt;br /&gt;
The electronic wavefunctions computed at this step and stored in the new nscf &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory will be used both by Yambo and by the electron-phonon code: this is important because using different sets of wavefunctions would lead to a phase mismatch issue in the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
The nscf input &amp;lt;code&amp;gt;mos2.nscf&amp;lt;/code&amp;gt; is&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;nscf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
                nbnd  = 250&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, we run the calculation&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
== Step 3: dvscf phonon calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we run the phonon calculation.&lt;br /&gt;
&lt;br /&gt;
Copy the &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the &#039;&#039;&#039;scf&#039;&#039;&#039; calculation and run &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt; for a dvscf calculation with a standard &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt;-grid matching the &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we wanna use in Yambo.&lt;br /&gt;
&lt;br /&gt;
At the end, we will have the &amp;lt;code&amp;gt;_ph0&amp;lt;/code&amp;gt; directory containing the variation of the self-consistent potential, &amp;lt;math&amp;gt;\Delta V_{SCF}(q)&amp;lt;/math&amp;gt;, and the &amp;lt;code&amp;gt;*.dyn&amp;lt;/code&amp;gt; files with the phonon energies and eigenvectors.&lt;br /&gt;
&lt;br /&gt;
NB: one could further refine the phonon energies by enforcing the acoustic sum rule, including non-analytic long-range contributions, interpolating to finer grids... all of this can be done within Quantum ESPRESSO and will not be covered in this version of the tutorial.&lt;br /&gt;
&lt;br /&gt;
The input is &amp;lt;code&amp;gt;mos2.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &lt;br /&gt;
 mos2_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;mos2&#039;,&lt;br /&gt;
   fildvscf = &#039;mos2-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;mos2.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=1&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
And now we run as&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 ph.x -inp mos2.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
This time we use nohup and more processes because this calculation may take some time. It is a good idea to set &amp;lt;code&amp;gt;recover=.true.&amp;lt;/code&amp;gt; as in a real calculation you will easily breach walltime, and in this way you can safely restart.&lt;br /&gt;
&lt;br /&gt;
== Step 4: create Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory ==&lt;br /&gt;
&lt;br /&gt;
This is just the standard Yambo initialization: run &lt;br /&gt;
 &lt;br /&gt;
 p2y &lt;br /&gt;
&lt;br /&gt;
and then &lt;br /&gt;
&lt;br /&gt;
 yambo &lt;br /&gt;
&lt;br /&gt;
in the &#039;&#039;&#039;nscf&#039;&#039;&#039; &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; folder and then move the newly generated &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory to a convenient place.&lt;br /&gt;
&lt;br /&gt;
== Step 5: run a BSE calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we switch from QE to Yambo. Here, we forgo the GW step for simplicity (we can use a scissor operator to open the band gap).&lt;br /&gt;
&lt;br /&gt;
This calculation has a couple of differences with respect to a standard BSE calculation for optical absorption. We can look at the input file &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Runlevels&amp;lt;/span&amp;gt;&lt;br /&gt;
 optics                       # [R OPT] Optics&lt;br /&gt;
 rim_cut                      # [R RIM CUT] Coulomb potential&lt;br /&gt;
 bss                          # [R BSS] Bethe Salpeter Equation solver&lt;br /&gt;
 em1s                         # [R Xs] Static Inverse Dielectric Matrix&lt;br /&gt;
 bse                          # [R BSE] Bethe Salpeter Equation.&lt;br /&gt;
 bsk                          # [R BSK] Bethe Salpeter Equation kernel&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# RIM and cutoff settings&amp;lt;/span&amp;gt;&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 X/Y/Z/XY..&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Static screening&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_and_IO_CPU= &amp;quot;1 1 4 2 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;
 Chimod= &amp;quot;hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 |  200 |                 # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 8000            mRy    # [Xs] Response block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# BSE&amp;lt;/span&amp;gt;&lt;br /&gt;
 BS_CPU= &amp;quot;4.1.2&amp;quot;                   # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k.eh.t&amp;quot;                 # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_diago=4              # [PARALLEL] CPUs for matrix diagonalization&lt;br /&gt;
 BSEmod= &amp;quot;causal&amp;quot;             # [BSE] resonant/causal/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                  # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  40000      mRy    # [BSK] Exchange components&lt;br /&gt;
 ALLGexx                      # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  8000       mRy    # [BSK] Screened interaction block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind=&amp;quot;full&amp;quot;                  #[BSE,X] bar(default)/full/tilde&amp;lt;/span&amp;gt;&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.00000 |  4.00000 | eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
   0.05000 |  0.05000 | eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 2000               # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 7 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BSEBands&lt;br /&gt;
    25 |  28 |                 # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                      # [BSS] Write to disk excitonic the FWs&lt;br /&gt;
 &lt;br /&gt;
This file was generated using the command: &amp;lt;code&amp;gt; yambo -X s -o b -k sex -y d -r&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all, we compute the excitons for all the momenta in the irreducible Brillouin zone for our discrete grid via the &amp;lt;code&amp;gt;BSEQptR&amp;lt;/code&amp;gt; variable. This will be a &#039;&#039;&#039;finite-momentum&#039;&#039;&#039; BSE calculation, analogous to the phonon one.&lt;br /&gt;
&lt;br /&gt;
Second, we change the variable &amp;lt;code&amp;gt;Lkind&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;full&amp;lt;/code&amp;gt;. In Yambo, &amp;lt;code&amp;gt;Lkind=&amp;quot;bar&amp;quot;&amp;lt;/code&amp;gt;, which is the default for optical absorption, means that we are computing the excitonic response function without the long-range component of the exchange interaction. This cannot be used when computing the exciton momentum dependence, where the long-range exchange interaction can play a role, therefore we have to include it with &amp;lt;code&amp;gt;Lkind=&amp;quot;full&amp;quot;&amp;lt;/code&amp;gt;. This allows for the calculation of the excitonic longitudinal-transverse splitting (in 3D systems) as well.&lt;br /&gt;
&lt;br /&gt;
We can now run the code:&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation, we have obtained the &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; databases inside the directory &amp;lt;code&amp;gt;bse_Lfull&amp;lt;/code&amp;gt;. They contain information on the exciton energies and wavefunctions at each momentum. Do not forget to check the report and logs of your calculation in the same directory to make sure that the code is doing what you want.&lt;br /&gt;
&lt;br /&gt;
== Step 6: obtain the electron-phonon matrix elements ==&lt;br /&gt;
&lt;br /&gt;
We have finished the heavy simulations. Now it&#039;s time for the postprocessing. The first order of business is the reconstruction of the electron-phonon coupling matrix elements from the dvscf results and the electronic wavefunctions.&lt;br /&gt;
&lt;br /&gt;
In order to do this, we will run the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable of the &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; code. We will run via command line using yambopy, although it will be instructive to have look at the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; input files later.&lt;br /&gt;
&lt;br /&gt;
We run in the same directory where the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; is (remember than you can also virtually move it with a symbolic link).&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y&lt;br /&gt;
&lt;br /&gt;
to see the help for the calculation. Have a look at the various flags and their description.&lt;br /&gt;
For example, if we want to do a serial run of LetzElPhC for bands from &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt;, we should type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/ph_input.in -b n_i n_f&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt; are integers representing the initial and final band indices. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 1 and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f]&amp;lt;/math&amp;gt; including the extrema of the interval.&lt;br /&gt;
&lt;br /&gt;
These should coincide with those used for the Bethe-Salpeter kernel, i.e. those specified in the &amp;lt;code&amp;gt;BSEBands&amp;lt;/code&amp;gt; variable of the BSE input file (this is not strictly necessary, but certainly efficient since these calculations use a lot of disk space). &lt;br /&gt;
&lt;br /&gt;
For our system, we want to do a parallel calculation with 4 qpools and 2 kpools. In addition, we want to explicitly specify the path of the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable and avoid automatically deleting the LetzElPhC data. So we type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/mos2.dvscf -b 25 28 -par 4 2 -lelphc path/to/lelphc_exe&lt;br /&gt;
&lt;br /&gt;
At the end, check your directory: you should find the &amp;lt;code&amp;gt;lelphc.in&amp;lt;/code&amp;gt; input file that was run, let&#039;s inspect it: &lt;br /&gt;
&lt;br /&gt;
 # LetzElPhC input for yambo generated by yambopy&lt;br /&gt;
 nqpool      = 2&lt;br /&gt;
 nkpool      = 4&lt;br /&gt;
 start_bnd   = 25&lt;br /&gt;
 end_bnd     = 28&lt;br /&gt;
 save_dir    = ./SAVE&lt;br /&gt;
 kernel      = dfpt&lt;br /&gt;
 ph_save_dir = dvscf/ph_save&lt;br /&gt;
 convention = yambo&lt;br /&gt;
&lt;br /&gt;
Notice the variable &amp;lt;code&amp;gt;convention=yambo&amp;lt;/code&amp;gt;: what does it mean? At variance with QE and many other codes, Yambo uses the &amp;quot;backward&amp;quot; momentum transfer convention for electronic scatterings. That is, an electronic transition goes from band &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k-q&amp;lt;/math&amp;gt; to band &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. In the &amp;quot;forward&amp;quot; momentum transfer convention (the more standard one), the transitions go from &amp;lt;math&amp;gt;nk&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;mk+q&amp;lt;/math&amp;gt;. Therefore, this variable ensures that the electron-phonon coupling matrix elements are computed as &amp;lt;math&amp;gt;\langle mk|dV|nk-q\rangle&amp;lt;/math&amp;gt;. This will have consequences also in the formulation of the &#039;&#039;exciton&#039;&#039;-phonon coupling matrix element.&lt;br /&gt;
&lt;br /&gt;
You will also find a &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; database that contains the computed electron-phonon matrix elements, in the output format of &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In addition, if you check the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder:&lt;br /&gt;
&lt;br /&gt;
 ls SAVE/ndb.elph_gkkp*&lt;br /&gt;
&lt;br /&gt;
you will see that yambopy has created the Yambo-compatible electron-phonon databases.&lt;br /&gt;
&lt;br /&gt;
If you want to run LetzElPhC directly, without using yambopy, you can refer to its [https://github.com/yambo-code/LetzElPhC/blob/main/docs/tex_doc/main.pdf|user guide].&lt;br /&gt;
Keep in mind that in this case, in order to convert the database to the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases of Yambo, you will then need a couple of lines of python using the Yambopy class &amp;lt;code&amp;gt;ConvertElectronPhononDB&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;yambopy/letzelph_interface/lelph2y.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases -- e.g., because you are doing the exc-ph postprocessing with yambopy -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_gkkp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases -- e.g., because you are using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; for the exc-ph part -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_lelphc_dbs&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
== Step 7: Obtain the exciton-phonon coupling ==&lt;br /&gt;
&lt;br /&gt;
Now, we can finally access our basic building block for exciton-phonon physics. This could be done entirely in python (using &#039;&#039;&#039;Yambopy&#039;&#039;&#039;), or by running &#039;&#039;&#039;Yambo&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambo postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (running yambo inputs with the &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; executable), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;follow the alternative route to Steps 7-8 [[Exciton-phonon coupling and luminescence - Yambo postprocessing|at this link]]&#039;&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambopy postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (using flexible python scripting), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;keep following Steps 7-8 on this page&#039;&#039;&#039;&amp;lt;/span&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Our objective is obtaining the following quantity: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathcal{G}^\mu_{\alpha\lambda}(0,q)=\sum_{vv^\prime c k} A^{\alpha, *}_{cv^\prime} (k, q) g_{vv^\prime}^\mu (k,q) A^{\lambda}_{cv}(k,0) - \sum_{cc^\prime vk} A^{\alpha, *}_{c^\prime v} (k+q, q) g_{c^\prime c}^\mu (k+q,q) A^{\lambda}_{cv}(k, 0)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;A^{\alpha}_{cv}(k,q)&amp;lt;/math&amp;gt; are the exciton coefficients extracted from the eigenvector of the two-particles Hamiltonian during the BSE calculation in step 5, while &amp;lt;math&amp;gt;g_{nm}^\mu (k,q)&amp;lt;/math&amp;gt; are the electron-phonon coupling matrix elements obtained in step 6. As you can see, the exciton &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; undergoes phonon-mediated scattering to state &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; via phonon mode &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;. The scattering can happen for the hole (valence, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;) or for the electron (conduction, &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
NB: &lt;br /&gt;
&lt;br /&gt;
(1) This is written in the &amp;quot;backward&amp;quot; momentum transfer convention used by Yambo. The momentum dependence is different in the &amp;quot;forward&amp;quot; transfer convention. &lt;br /&gt;
&lt;br /&gt;
(2) For simplicity, this is written for zero initial exciton momentum. This means that one of the two states involved in the phonon-mediated scattering process will be in the optical limit (and possibly an optically generated exciton), while the other state can have any momentum: this momentum will be the same as the phonon one. This matrix element can be used to describe phonon-assisted absorption and emission spectra.&lt;br /&gt;
&lt;br /&gt;
In order to calculate this quantity using python, we need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases natively generated by the &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt; code, as well as the BSE databases &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; containing the information on exciton wavefunctions and energies.&lt;br /&gt;
&lt;br /&gt;
Next, we write a python user script importing the yambopy exciton-phonon tools. You can find a version of this script in &amp;lt;code&amp;gt;yambopy/tutorials/exciton-phonon/calculate_excph.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np &lt;br /&gt;
 from yambopy import YamboLatticeDB,YamboWFDB,LetzElphElectronPhononDB &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific Yambopy dbs loading classes&amp;lt;/span&amp;gt;&lt;br /&gt;
 from yambopy.exciton_phonon.excph_matrix_elements import exciton_phonon_matelem &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific exc-ph functions&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 path = &#039;1L_MoS2&#039;&lt;br /&gt;
 bands_range=[24,28] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence bands, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# number of excitonic states&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 bsepath    = f&#039;{path}/bse-allq_full&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lin=Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath   = f&#039;{path}/SAVE&#039;     &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Yambo SAVE&amp;lt;/span&amp;gt;&lt;br /&gt;
 ndb_elph   = f&#039;{path}/ndb.elph&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# LetzElPhC electron-phonon database (any convention)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice&amp;lt;/span&amp;gt;&lt;br /&gt;
 lattice = YamboLatticeDB.from_db_file(filename=f&#039;{savepath}/ns.db1&#039;)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read electron-phonon&amp;lt;/span&amp;gt;&lt;br /&gt;
 elph    = LetzElphElectronPhononDB(ndb_elph,read_all=False)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read wave functions&amp;lt;/span&amp;gt;&lt;br /&gt;
 wfcs    = YamboWFDB(filename=&#039;ns.wf&#039;,save=savepath,latdb=lattice,bands_range=bands_range)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Calculate exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 exph = exciton_phonon_matelem(lattice,elph,wfcs,BSE_dir=bsepath,nexc_in=nexc,nexc_out=nexc,dmat_mode=&#039;save&#039;,exph_file=&#039;MoS2_Ex-ph.npy&#039;)&lt;br /&gt;
&lt;br /&gt;
In this script, we can select the number exciton states &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; with &amp;lt;code&amp;gt;nexc&amp;lt;/code&amp;gt;, the single-particle bands range with &amp;lt;code&amp;gt;bands_range&amp;lt;/code&amp;gt;. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 0 (python indexing) and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f)&amp;lt;/math&amp;gt;, therefore the last value (28 in the example) is excluded. That is, in the example we are selecting the 25th, 26th, 27th and 28th bands. Those bands have to be present in both the electron-phonon and BSE calculations. &lt;br /&gt;
&lt;br /&gt;
Here we calculate the couplings of the first twelve states at each finite-&amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; point including &amp;lt;math&amp;gt;q=0&amp;lt;/math&amp;gt;. We also include all the nine phonon modes of monolayer MoS2. We also need access to the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory in order to read the electronic wavefunctions: they are used to compute the electronic representation matrices (&amp;lt;code&amp;gt;dmat&amp;lt;/code&amp;gt; in the code). The argument &amp;lt;code&amp;gt;dmat_mode&amp;lt;/code&amp;gt; can be set to &amp;lt;code&amp;gt;&#039;load&#039;&amp;lt;/code&amp;gt; for subsequent calculations.&lt;br /&gt;
&lt;br /&gt;
When we are satisfied with the input, we run the code:&lt;br /&gt;
&lt;br /&gt;
 python calculate_excph.py&lt;br /&gt;
&lt;br /&gt;
If you check the output, you should find the &amp;lt;code&amp;gt;MoS2_Ex-ph.npy&amp;lt;/code&amp;gt; binary file in the directory where you ran.&lt;br /&gt;
&lt;br /&gt;
=== Analysis of the couplings ===&lt;br /&gt;
&lt;br /&gt;
It is a good idea to have a look at what we computed up to now in order to make sure nothing has gone wrong. &lt;br /&gt;
&lt;br /&gt;
It is not easy to know what to expect (apart from symmetry and gauge compliance of the matrix elements), but one can work out the exciton-phonon selection rules in advance, check that the magnitude is reasonable, etc.&lt;br /&gt;
&lt;br /&gt;
It is also not easy to meaningfully plot this quantity. We have to make sure that we are not breaking degenerate states, otherwise the plots will not be invariant. &lt;br /&gt;
&lt;br /&gt;
First of all, we have to know our system: in monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, the first four excitons are all doubly degenerate. The first exciton responsible for a bright peak in the absorption spectrum (the &#039;&#039;&#039;A&#039;&#039;&#039; peak), is the second state, corresponding to state indices &amp;lt;code&amp;gt;(3,4)&amp;lt;/code&amp;gt; in fortran indexing or &amp;lt;code&amp;gt;(2,3)&amp;lt;/code&amp;gt; in python indexing. &lt;br /&gt;
&lt;br /&gt;
All these information can be obtained by analyzing the BSE results (this stuff is explained in the BSE tutorials) and by knowledge of the system or class of systems from the literature.&lt;br /&gt;
&lt;br /&gt;
Thus, a good quantity to plot may be the norm of the matrix elements, summed over the degenerate subspace of exciton A, for a certain number of scattered final states mediated by certain phonon modes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;F_A(q)= \sqrt{ \sum_{\alpha \in A,\lambda,\mu} |\mathcal{G}_{\alpha\lambda}^\mu (0,q)|^2 }&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to do this, we create a python script &amp;lt;code&amp;gt;analyse_excph.py&amp;lt;/code&amp;gt; in which we first load the excph dabatases. &lt;br /&gt;
You can find a version of this script in the yambopy directory, in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;. &lt;br /&gt;
First, we select the exciton and phonon states to be included in &amp;lt;code&amp;gt;F_A&amp;lt;/code&amp;gt;, together with the path of databases and plot details:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Exciton &amp;quot;in&amp;quot; states&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_in  = [2,3]  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# First bright peak (A: 2,3 -- B: 6,7)&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_out = [0,1,2,3] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# first 4 states (dispersion of dark triplet state and A)&amp;lt;/span&amp;gt;&lt;br /&gt;
 ph_in  = &#039;all&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Paths of databases&amp;lt;/span&amp;gt;&lt;br /&gt;
 ns_db1 =f&#039;{path}/SAVE/ns.db1&#039;&lt;br /&gt;
 ns_ypy = &#039;MoS2_Ex-ph.npy&#039;&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Then, we load the data:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 ylat = YamboLatticeDB.from_db_file(filename=ns_db1)&lt;br /&gt;
 print(ylat)&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Load exc-ph database&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_py = np.load(ns_ypy)&lt;br /&gt;
 G_squared = np.abs(X_py)**2.&lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt;F_A(q)&amp;lt;/math&amp;gt; is obtained from a dedicated function as:&lt;br /&gt;
 &lt;br /&gt;
 if exc_in  == &#039;all&#039;: exc_in  = range(G_squared.shape[2])&lt;br /&gt;
 if exc_out == &#039;all&#039;: exc_out = range(G_squared.shape[3])&lt;br /&gt;
 if ph_in   == &#039;all&#039;: ph_in   = range(G_squared.shape[1])&lt;br /&gt;
 &lt;br /&gt;
 G_squared = G_squared[:, ph_in, :, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_in, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_out].sum(axis=(1))&lt;br /&gt;
 &lt;br /&gt;
 F_q = np.sqrt( G_squared )*ha2ev &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Switch from Ha to eV&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally, we have to make a plotting function. For this tutorial we will use a custom scatterplot employing some of the plotting tools provided by yambopy (but you can do whatever you want).&lt;br /&gt;
&lt;br /&gt;
 plot_2D_excph(qgrid,G2_to_plot,rlat=ylat.rlat,plt_cbar=True,\&lt;br /&gt;
               marker=&#039;H&#039;,s=700,cmap=&#039;magma&#039;)&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can get more experience on using Yambopy for these kinds of visualization by following the [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy Yambopy tutorials]. In fact, remember that these scripts and all the other Yambopy tutorial scripts are just suggestions, not source code written in stone: if you know &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt; you can do your own analysis and your own plots, you just need to import the required Yambopy modules to load the data.&lt;br /&gt;
&lt;br /&gt;
In our case, the resulting plot is the following.&lt;br /&gt;
&lt;br /&gt;
[[File:1L MoS2 MoS2 Ex-ph.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
This can be checked against Fig. 2(d) of reference &amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;, although you have to keep in mind that our results are badly undersampled in terms of the reciprocal-space grid, as can be easily seen, and the quantity plotted is not exactly the same. However, the main features are already there since they are dictated mostly by crystal symmetries.&lt;br /&gt;
&lt;br /&gt;
Now that we have the exciton-phonon matrix elements, we can use them to build several kinds of observables. Below, we give an example related to phonon-assisted luminescence, but we may update this tutorial in the future to include more cases.&lt;br /&gt;
&lt;br /&gt;
== Step 8: Compute phonon-assisted luminescence ==&lt;br /&gt;
&lt;br /&gt;
[[File:Luminescence scheme.png|250px|right]]&lt;br /&gt;
&lt;br /&gt;
We want to compute the experimental optical signature due to the phonon-assisted recombination of an exciton (as sketched in the figure).&lt;br /&gt;
&lt;br /&gt;
The signal from the phonon replicas can be modeled as a second-order scattering process involving one phonon and one photon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;I^{Sat}(\omega)=\frac{1}{ N_q} \frac{1}{3} \sum_{\epsilon s\beta \mu q} \frac{1}{E_{\beta q}-s\Omega_{\mu q}}\left|\sum_\alpha\frac{ D^{\epsilon}_\alpha \mathcal{G}_{\beta \alpha}^{\mu,*}(q)}{E_\alpha -E_{\beta q} +s\Omega_{\mu q}+\mathrm{i}\eta}\right|^2 \frac{N^{exc}_{\beta q}(T_{exc})[\frac{1+s}{2}+n_{\mu q}(T)]}{\omega -[E_{\beta q}-s\Omega_{\mu q}]+\mathrm{i}\eta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this equation, the oscillator strength of the peak is given by the exciton-phonon coupling matrix elements &amp;lt;math&amp;gt;\mathcal{G}&amp;lt;/math&amp;gt; multiplied by the exciton dipoles &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; (they are called &amp;quot;residuals&amp;quot; in Yambo). Here &amp;lt;math&amp;gt;E_\lambda&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{\alpha q}&amp;lt;/math&amp;gt; are the energies of the optical and finite-momentum excitons, respectively, while &amp;lt;math&amp;gt;\Omega_{\mu q}&amp;lt;/math&amp;gt; are the phonon energies. &lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;n_{\mu q}(T)&amp;lt;/math&amp;gt; is the temperature-dependent phonon Bose-Einstein occupation function. As it can be seen, &amp;lt;math&amp;gt;s=1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;emission&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)+1&amp;lt;/math&amp;gt;), while &amp;lt;math&amp;gt;s=-1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;absorption&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)&amp;lt;/math&amp;gt;). Therefore, &amp;lt;math&amp;gt;I^{Sat}_{PL}(\omega;T)&amp;lt;/math&amp;gt; describes &#039;&#039;light&#039;&#039; emission by recombining excitons mediated by either &#039;&#039;phonon&#039;&#039; absorption or emission. &lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt; N_{\alpha q}(T_{exc})&amp;lt;/math&amp;gt; is the exciton occupation function. Luminescence is technically an out-of-equilibrium process, but we can assume that for very low density of excitations and in steady-state conditions, the exciton population can be approximately described by an equilibrium distribution evaluated at an effective temperature. Here, we use the Boltzmann distribution. Experimentally, &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; tends to coincide with the lattice temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; more or less above 100 K, while at very low temperature (&amp;lt; 10 K), &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; may vary between 10-50 K. It goes without saying that this needs to carefully be checked in your realistic calculations.&lt;br /&gt;
&lt;br /&gt;
Finally, the spectrum is averaged over the polarization directions of the emitted photons (&amp;lt;math&amp;gt;\epsilon=x,y,z&amp;lt;/math&amp;gt; representing the respective dipole components).&lt;br /&gt;
&lt;br /&gt;
=== Running the jobs ===&lt;br /&gt;
&lt;br /&gt;
In order to study luminescence in a paradigmatic system, we switch to bulk hexagonal boron nitride and we repeat the workflow. As you can easily see, one can think about automatizing the execution of all these calculations via scripting or more advanced tools. However, in the case of very large simulations (memory-limited or disk-space limited) or for systems whose electronic and lattice properties are fragile with respect to tiny calculation details, one must be very careful and run many basic tests.&lt;br /&gt;
&lt;br /&gt;
Fortunately, we are running a fast underconverged example. We use LDA pseudopotentials from the pseudo-dojo library and the following are the calculations steps.&lt;br /&gt;
&lt;br /&gt;
1. Input &amp;lt;code&amp;gt;hbn.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;scf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
     outdir = &#039;./tmp&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
2. Input &amp;lt;code&amp;gt;hbn.nscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;nscf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;&lt;br /&gt;
     outdir = &#039;./&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 	nbnd = 120&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
3. Input &amp;lt;code&amp;gt;hbn.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 hbn_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;hBN&#039;,&lt;br /&gt;
   fildvscf = &#039;hBN-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;hBN.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=2&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 pw.x -inp hbn.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
4. Input &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt; (we include 2 valence and 2 conduction bands):&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 em1s&lt;br /&gt;
 DIP_CPU= &amp;quot;1 8 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 8 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;
 BS_CPU= &amp;quot;8 1 1&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k eh t&amp;quot;                     # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_LinAlg_INV=-1            # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&lt;br /&gt;
 BS_nCPU_LinAlg_DIAGO=-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;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 % QpntsRXs&lt;br /&gt;
    1 | 14 |                         # [Xs] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 | 120 |                         # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 10                Ry    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lfull&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 % DipBands&lt;br /&gt;
    1 | 120 |                         # [DIP] Bands range for dipoles&lt;br /&gt;
 %&lt;br /&gt;
 DipApproach= &amp;quot;G-space v&amp;quot;         # [DIP] [G-space v/R-space x/Covariant/Shifted grids]&lt;br /&gt;
 DipComputed= &amp;quot;R V P&amp;quot;             # [DIP] [default R P V; extra P2 Spin Orb]&lt;br /&gt;
 BSENGexx= 30000            Ry    # [BSK] Exchange components&lt;br /&gt;
 #ALLGexx                       # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  9000            Ry    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.25997 | 1.08816 | 1.12683 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 14 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEBands&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   7 | 10 |                         # [BSK] Bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.50000 | 8.00000 |         eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
  0.050000 | 0.050000 |         eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 1000                    # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
Importantly, since we want to describe the phonon-assisted recombination process of an *optical* exciton (i.e., emitting a transverse photon), this time we also run an additional calculation at `Q=0` omitting the nonanalytic long-range Coulomb exchange. Make a second input &amp;lt;code&amp;gt;bse_Lbar.in&amp;lt;/code&amp;gt; with the following changes: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lbar&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4b. So now we make a second BSE run in a different directory specified by &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt;. Here, we also pass to yambo the directory of the previous run as it includes the important screening databases &amp;lt;code&amp;gt;ndb.em1s*&amp;lt;/code&amp;gt; that we do not want to recompute from scratch.&lt;br /&gt;
 &lt;br /&gt;
 mpirun -np 8 yambo -F bse_Lbar.in -J bse_Lbar,bse_Lfull -C bse_Lbar&lt;br /&gt;
&lt;br /&gt;
5. Now we run &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; (with or without yambopy: in the latter case remember the option &amp;lt;code&amp;gt;-D&amp;lt;/code&amp;gt;) to get the el-ph matrix elements, particularly the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/hbn.dvscf -b 7 10 -par 4 2 -D&lt;br /&gt;
&lt;br /&gt;
=== Luminescence calculation ===&lt;br /&gt;
&lt;br /&gt;
6. And finally we calculate exciton-phonon matrix elements and the luminescence spectrum in one go using a python script importing the Yambopy exciton-phonon tools: in order to do this, we need to take a look at all the necessary input variables for the formula written above.&lt;br /&gt;
&lt;br /&gt;
We can start from the script &amp;lt;code&amp;gt;luminescence.py&amp;lt;/code&amp;gt; available in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import matplotlib.pyplot as plt&lt;br /&gt;
 from yambopy.exciton_phonon.excph_luminescence import exc_ph_luminescence&lt;br /&gt;
 from yambopy.exciton_phonon.excph_input_data import exc_ph_get_inputs&lt;br /&gt;
&lt;br /&gt;
We import the necessary tools...&lt;br /&gt;
&lt;br /&gt;
 path = &#039;3D_hBN&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lout--&amp;gt; response is Lfull)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bsepath =  f&#039;{path}/bse_Lfull&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q* databases are needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation for optically active exciton (Lin --&amp;gt; response is Lbar)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bseBARpath =  f&#039;{path}/bse_Lbar&#039;  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to electron-phonon calculation&amp;lt;/span&amp;gt;&lt;br /&gt;
 elphpath = path &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.elph is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to unprojected dipoles matrix elements (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 dipolespath = bsepath &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.dipoles is needed (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath = f&#039;{path}/SAVE&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ns.db1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... and we specify the paths to the necessary databases. Note that, if we want to perform polarization averaging, we have to recompute the excitonic dipoles in python as seen here.&lt;br /&gt;
&lt;br /&gt;
What about &amp;lt;code&amp;gt;bseBARpath&amp;lt;/code&amp;gt;? This variable points to the directory where the databases for the optical (zero-momentum) excitons &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; (which may be computed with &amp;lt;code&amp;gt;Lkind=&#039;Lbar&#039;&amp;lt;/code&amp;gt;) is located, which can be different from the directory with the full indirect exciton dispersion &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; (usually computed with &amp;lt;code&amp;gt;Lkind=&#039;Lfull&#039;&amp;lt;/code&amp;gt;, however &amp;lt;code&amp;gt;Lkind=&#039;Ltilde&#039;&amp;lt;/code&amp;gt; can also be used if one is interested in &amp;quot;irreducible&amp;quot; excitons). This makes it possible to compute the coupling between different exciton kinds.&lt;br /&gt;
&lt;br /&gt;
 bands_range=[6,10] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 phonons_range=[0,12] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# All phonons&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_out = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at each momentum (Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_in  = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at Q=0 (Lin)&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_ph  = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Lattice temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_exc = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Effective excitonic temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 emin=4.4      &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Energy range and plot details (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
 emax=4.7&lt;br /&gt;
 estep=0.0002&lt;br /&gt;
 broad = 0.005 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Broadening parameter for peak width (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we specify the parameters for the calculation. We include valence bands from 7 to 10 (6 to 9 in python index) and the contribution of all 12 phonon modes. We consider 12 excitonic states for the coupling matrix elements.&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;code&amp;gt;T_ph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;T_exc&amp;lt;/code&amp;gt; are the lattice and excitonic temperatures, respectively.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate and load all the inputs:&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Excitonic dipole matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Phonon energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * We specify bse_path2=bseBARpath meaning we use Lbar calculation for Q=0 excitons&amp;lt;/span&amp;gt;&lt;br /&gt;
 input_data = exc_ph_get_inputs(savepath,elphpath,bsepath,\&lt;br /&gt;
                                bse_path2=bseBARpath,dipoles_path=dipolespath,\&lt;br /&gt;
                                nexc_in=12,nexc_out=12,\&lt;br /&gt;
                                bands_range=[6,10],phonons_range=[0,12])&lt;br /&gt;
&lt;br /&gt;
 ph_energies, exc_energies, exc_energies_in, G, exc_dipoles = input_data&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;exc_ph_get_inputs&amp;lt;/code&amp;gt; gives us all the input data for luminescence in the correct format: phonon energies, exciton energies, optical exciton energies (if needed), exciton-phonon matrix elements (calculated on the fly and printed to file), unprojected exciton dipoles (optional, calculated on the fly and printed to file).&lt;br /&gt;
The exc-ph matrix element calculation is just a wrapper of the same tools that we have tested in the above section on MoS2.&lt;br /&gt;
&lt;br /&gt;
Finally, there is the calculation of the luminescence spectrum via the function &amp;lt;code&amp;gt;exc_ph_luminescence&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate the luminescence spectrum including the input data from before&amp;lt;/span&amp;gt;&lt;br /&gt;
 w,PL = exc_ph_luminescence(T_ph,ph_energies,exc_energies,exc_dipoles,G,\&lt;br /&gt;
                            exc_energies_in=exc_energies_in,exc_temp=T_exc,\&lt;br /&gt;
                            nexc_out=nexc_out,nexc_in=nexc_in,emin=emin,emax=emax,\&lt;br /&gt;
                            estep=estep,broad=broad)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to print the luminescence data for later plotting, you can also add the following line to the script:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Save to file&amp;lt;/span&amp;gt;&lt;br /&gt;
 data = np.column_stack((w, PL))&lt;br /&gt;
 np.savetxt(&amp;quot;hBN_luminescence_12x12x1.dat&amp;quot;, data, fmt=&amp;quot;%.8f&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
It is now time to run the whole script:&lt;br /&gt;
&lt;br /&gt;
 python luminescence.py&lt;br /&gt;
 &lt;br /&gt;
NB: By using Yambopy for Step 6, we have limited the use of the Yambo code to just step 4 in the entire workflow. This option is more flexible, as it allows for a greater degree of control by the user. On the other hand the Yambo postprocessing route features a Yambo-style input that doesn&#039;t require python knowledge and the calculation is currently faster in fortran. However, the luminescence expression computed in Yambo is a slightly different than this one: it is more approximated in the description of the satellite oscillator strengths, but it explicitly includes the renormalization of the direct exciton peak. You can check the differences [[Exciton-phonon coupling and luminescence - Yambo postprocessing|here]].&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
We can plot the results of the step 6 calculation. If we do it in the same script we can add something like this:&lt;br /&gt;
 fig = plt.figure()&lt;br /&gt;
 ax = fig.add_subplot(1,1,1)&lt;br /&gt;
 ax.set_xlim(emin,emax)&lt;br /&gt;
 ax.set_ylim(0,np.max(PL)*1.1)&lt;br /&gt;
 ax.get_yaxis().set_visible(False)&lt;br /&gt;
 &lt;br /&gt;
 ax.plot(w, PL, &#039;-&#039;,c=&#039;red&#039;, label=&amp;quot;AA&#039; hBN luminescence&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 plt.legend()&lt;br /&gt;
 plt.savefig(&#039;hBN_luminescence.png&#039;)&lt;br /&gt;
 plt.show()&lt;br /&gt;
&lt;br /&gt;
[[File:HBN luminescence satellites.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
Here, the signal corresponds to a finite-momentum exciton that recombines with the help of several different phonon modes, both optical and acoustic. Each phonon mode whose coupling with the exciton is allowed can generate a peak, and the energy shifts of these peaks with respect to the initial exciton energy correspond to the phonon energies. This result is underconverged, but the main features are all there. In the plot, we show a more converged example using a 12x12x4 grid (all the other parameters being equal). These plots can be compared with Fig. 4(a) of reference &amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Exciton lifetimes==&lt;br /&gt;
&lt;br /&gt;
Using the exciton-phonon coupling it is possible also to calculate exciton life-time due to the scattering with phonon. For this kind of calculation input file can be generated with the command &#039;&#039;yambo_ph -excph l&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 excph                            # [R] Exction-phonon&lt;br /&gt;
 ExcGkkp                          # [R][EXCPH] Exciton-Phonon Matrix Elelements&lt;br /&gt;
 ExcPhLifeT                       # [R][EXCPH] Exciton-Phonon Life-Times&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 % ELPhExcStates&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 |  4 |&amp;lt;/span&amp;gt;                           # [EXCPH] Incoming (external) exciton states&lt;br /&gt;
 %&lt;br /&gt;
 % ELPhExcSum&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 |  8 |    &amp;lt;/span&amp;gt;                       # [EXCPH] Outgoing (virtual) exciton states&lt;br /&gt;
 %&lt;br /&gt;
 LoutPath= &amp;quot;none&amp;quot;                 # [EXCPH] Path of the outgoing L&lt;br /&gt;
 FANdEtresh= 0.100000E-5    eV    # [ELPH] Energy treshold for Fan denominator&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 | 12 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 EXCTemp= 0.000000          eV    # [EXCPH] Excitonic Temperature (for luminescence spectra)&lt;br /&gt;
 AlphaQ= 0.000000                 # [EXCPH] Excitonic band structure 2D distortion&lt;br /&gt;
 #ExcPhOffDiago                 # [EXCPH] Exciton-Phonon off-diagonal self-energy&lt;br /&gt;
 #NoMatrxEl                     # [EXCPH] Set all exciton-phonon matrix elements to one (for testing purpose)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;LDamping= 0.1 &amp;lt;/span&amp;gt;     meV               # [EXCPH] Damping of exc-ph self-energy&lt;br /&gt;
&lt;br /&gt;
notice that in this case &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;LDamping&amp;lt;/span&amp;gt; is the broadening of the exciton-phonon self energy and it should be a very small value of the order of the phonon life-times around the meV.&amp;lt;ref&amp;gt;[https://arxiv.org/abs/1411.5628 First-principles calculations of phonon frequencies, lifetimes, and spectral functions from weak to strong an-harmonicity: The example of palladium hydrides], L. Paulatto, et al. Phys. Rev. B &#039;&#039;&#039;91&#039;&#039;&#039;, 054304 (2015) &amp;lt;/ref&amp;gt;. Running this input you will get:&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton lifetimes:&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [1] Lifetime: 0.697314 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [2] Lifetime: 0.697314 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [3] Lifetime: 20.22155 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [4] Lifetime: 32.95292 meV&lt;br /&gt;
&lt;br /&gt;
the life-time of the first four excitons. Note that this result is not converged respect to the Q-points. In order to speedup convergence that double-grid&amp;lt;ref name=&#039;pierre&#039; /&amp;gt; can be used also in the life-time calculations, see tutorial on electron-phonon coupling for tricks on the convergence of the double-grid. &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; &amp;gt;Toyozawa, Yutaka, and Chris Oxlade, &#039;&#039;Optical processes in solids&#039;&#039;, [https://m.booksee.org/book/1121964?force_lang=en Cambridge University Press, (2003)]. &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;lechifflart2023&#039;&amp;gt;P. Lechifflart, F. Paleari, D. Sangalli, C. Attaccalite, &#039;&#039;First-principles study of luminescence in hexagonal boron nitride single layer: Exciton-phonon coupling and the role of substrate&#039;&#039;, &lt;br /&gt;
[https://doi.org/10.1103/PhysRevMaterials.7.024006 Phys. Rev. M, &#039;&#039;&#039;7&#039;&#039;&#039; (2), 024006 (2023)]; [https://arxiv.org/abs/2212.10407 arXiv2212.1047]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cannuccia2019&#039;&amp;gt;E. Cannuccia, B. Monserrat and C. Attaccalite, &#039;&#039;Theory of phonon-assisted luminescence in solids: Application to hexagonal boron nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]; [https://arxiv.org/abs/1807.11797 arXiv1807.11797]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019&#039;&amp;gt;F. Paleari et al., &#039;&#039;Exciton-Phonon Coupling in the Ultraviolet Absorption and Emission Spectra of Bulk Hexagonal Boron Nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.122.187401 Phys. Rev. Lett. &#039;&#039;&#039;122&#039;&#039;&#039;, 187401 (2019)]; [https://arxiv.org/abs/1810.08976 arXiv1810.089776] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chen2020&#039;&amp;gt;&#039;&#039;Exciton-Phonon Interaction and Relaxation Times from First Principles&#039;&#039;,&lt;br /&gt;
Hsiao-Yi Chen, Davide Sangalli, and Marco Bernardi, [https://doi.org/10.1103/PhysRevLett.125.107401  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 107401 (2020)]; [https://arxiv.org/abs/2002.08913 arXiv 2002.08913 (2020)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot;&amp;gt;P. Lechifflart, &#039;&#039;Exciton-phonon coupling and phonon-assisted luminescence in hexagonal Boron Nitride nanostructures&#039;&#039;, [https://hal.science/tel-04266805v1 PhD Thesis, University of Marseille (2023)]; [https://www.yambo-code.eu/wiki/images/5/54/These_final.pdf From the yambo website]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019_PhD&#039;&amp;gt;F. Paleari, &#039;&#039;First-principles approaches to the description of indirect absorption and luminescence spectroscopy: exciton-phonon coupling in hexagonal boron nitride&#039;&#039;, [https://wwwen.uni.lu/research/fstm/dphyms/people/fulvio_paleari PhD thesis, University of Luxembourg (2019)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;zanfrognini2023&#039;&amp;gt;M. Zanfrognini et al., &#039;&#039;Distinguishing different stackings in layered materials via luminescence spectroscopy&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.131.206902 Phys. Rev. Lett. &#039;&#039;&#039;131&#039;&#039;&#039;, 206902 (2023)]; [https://arxiv.org/abs/2305.17554 arXiv 2305.17554] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;marini2024&#039;&amp;gt;G. Marini, M. Calandra, P. Cudazzo, &#039;&#039;Optical absorption and photoluminescence of single layer boron nitride from a first principles cumulant approach&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.4c00669 Nano Lett., &#039;&#039;&#039;24&#039;&#039;&#039;, 20, 6017 (2024)]; [https://arxiv.org/abs/2402.03826 arXiv 2402.03826 (2024)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;antonius2017&#039;&amp;gt;G. Antonius, S. G. Louie, &#039;&#039;Theory of exciton-phonon coupling&#039;&#039;, [https://doi.org/10.1103/PhysRevB.105.085111 Phys. Rev. B, &#039;&#039;&#039;105&#039;&#039;&#039;, 085111 (2022)]; [https://arxiv.org/abs/1705.04245 arXiv1705.04245 (2017)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2022&#039;&amp;gt; F. Paleari, and A. Marini, &#039;&#039;Exciton-phonon interaction calls for a revision of the “exciton” concept&#039;&#039;, [https://doi.org/10.1103/PhysRevB.106.125403 Phys. Rev. B, &#039;&#039;&#039;106&#039;&#039;&#039;, 125403 (2022)]; [https://arxiv.org/abs/2205.02783 arXiv 2205.02783]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cudazzo2020&#039;&amp;gt; P. Cudazzo, &#039;&#039;First-principles description of the exciton-phonon interaction: A cumulant approach&#039;&#039;, [https://doi.org/10.1103/PhysRevB.102.045136 Phys. Rev. B, &#039;&#039;&#039;102&#039;&#039;&#039;, 045136 (2020)]; [https://orbilu.uni.lu/bitstream/10993/44769/1/main.pdf Open access pdf from Luxembourg University]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chan2023&#039;&amp;gt;Y-h Chan, J. B. Haber, M. H. Naik, J. B. Neaton, D. Y. Qiu, F. H. da Jornada, S. G. Louie, &#039;&#039;Exciton Lifetime and Optical Line Width Profile via Exciton–Phonon Interactions: Theory and First-Principles Calculations for Monolayer MoS2&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.3c00732 Nano Lett., &#039;&#039;&#039;23&#039;&#039;&#039;, 9 (2023)]; [https://arxiv.org/abs/2212.08451 arXiv 2212.08451 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;murali2025&#039;&amp;gt;M. Nalabothula, S. Reichardt, L. Wirtz, &#039;&#039;Origin of Interlayer Exciton–Phonon Coupling in 2D Heterostructures&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.5c00355 Nano Lett., &#039;&#039;&#039;25&#039;&#039;&#039;, 15 (2025)], [https://arxiv.org/abs/2407.16111 arXiv 2407.16111 (2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=907</id>
		<title>Exciton-phonon coupling and luminescence</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=907"/>
		<updated>2026-04-30T07:58:17Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Tdgw-phonon-usc-01-1024x829.jpg|thumb|right|400px|(c) Zhenglu Li, University of Southern California]]&lt;br /&gt;
&lt;br /&gt;
In this advanced tutorial, we will calculate exciton-phonon interactions from first principles by interfacing DFPT (for phonon calculations) and BSE (for exciton calculations).&lt;br /&gt;
&lt;br /&gt;
The DFTP calculations are run with Quantum ESPRESSO, while the many-body GW-BSE calculations are run with Yambo. Finally, the exciton-phonon interaction will be obtained by combining and postprocessing the databases computed in the two previous runs. The great advantage of this workflow is that the calculations can be run in the irreducible Brillouin zones both for the electronic momenta (&#039;&#039;&#039;k&#039;&#039;&#039;) and the transfer momenta (&#039;&#039;&#039;Q&#039;&#039;&#039;, &#039;&#039;&#039;q&#039;&#039;&#039;) of excitons and phonons, thus speeding up considerably the jobs while reducing the IO and memory load.&lt;br /&gt;
&lt;br /&gt;
We will first compute the exciton-phonon coupling matrix elements: these are the building blocks needed to construct experimental observables such as phonon-assisted optical spectra (such as luminescence), Raman spectra and exciton lifetimes. We will do this in the case of monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, a 2D system with large spin-orbit interaction.&lt;br /&gt;
&lt;br /&gt;
As an example of application, we will consider the case of phonon-assisted luminescence. We will do this in the case of bulk hBN, a layered indirect insulator with strong electron-phonon coupling.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; this tutorial will be updated when new exc-ph tools become available in Yambopy (including full-python postprocessing, Raman spectra, interpolated lifetimes, etc).&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
This is an advanced topic: we assume that you already know something about the theory&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;antonius2017&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cudazzo2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2019_PhD&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2022&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot; /&amp;gt; and applications&amp;lt;ref name=&amp;quot;paleari2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cannuccia2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chen2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;marini2024&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;murali2025&amp;quot; /&amp;gt; of exciton-phonon physics. &lt;br /&gt;
&lt;br /&gt;
Also, we assume that you already know how to run both a basic &#039;&#039;&#039;Yambo&#039;&#039;&#039; GW-BSE calculation and a DFPT phonon calculation with &#039;&#039;&#039;Quantum ESPRESSO&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Besides the QE executables &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt;, we also use the yambo phonon-specific executable &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; and the python utility &#039;&#039;&#039;Yambopy&#039;&#039;&#039;. The auxiliary code &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; (executable &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt;) will be used to obtain the electron-phonon matrix elements by reading the same electronic wavefunctions used by Yambo (and stored in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory), while also making full use of crystal symmetries. [https://github.com/yambo-code/LetzElPhC LetzElPhC] will be run by Yambopy, but it must nonetheless be installed. Finally, the exciton-phonon properties can be computed either using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; or using Yambopy itself. Both cases will be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
[[File:Workflow scheme.png|800px|center]]&lt;br /&gt;
&lt;br /&gt;
== Step 0: Pseudopotentials, equilibrium structure and convergence ==&lt;br /&gt;
&lt;br /&gt;
In a real calculation, it is important to ensure that both the pseudopotential and the lattice parameters that we are using are compatible and perform well for the electronic excited states and for the lattice vibrations simultaneously. Furthermore, you have to make sure that the wave function cutoff &amp;lt;code&amp;gt;ecutwfc&amp;lt;/code&amp;gt; is converged with respect to the DFPT step and not just to the DFT one. This is in addition to the other customary convergence tests for DFT, DFPT, GW and BSE calculations.&lt;br /&gt;
&lt;br /&gt;
This is often the most time-demanding step when starting on a new system.&lt;br /&gt;
&lt;br /&gt;
For the sake of this tutorial, we assume that we have already done all these tests and we are starting the final workflow to get the exciton-phonon properties.&lt;br /&gt;
&lt;br /&gt;
== Step 1: scf calculation ==&lt;br /&gt;
&lt;br /&gt;
First of all, we run a standard scf calculation with &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; for Yambo. We stick with non-symmorphic symmetries. At the end, we will have the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
This is the input &amp;lt;code&amp;gt;mos2.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;scf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
Here we are using full relativistic pseudopotentials from the SG-15 database.&lt;br /&gt;
&lt;br /&gt;
We can run it on our machine (for example using 4 MPI tasks) as:&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
== Step 2: nscf calculation for Yambo ==&lt;br /&gt;
&lt;br /&gt;
Copy the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the scf calculation and run the nscf calculation for any number of empty states, with the correct &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we want to use in Yambo. Here we are using a badly underconverged grid of 6x6x1.&lt;br /&gt;
&lt;br /&gt;
This reciprocal-space grid will also match the momentum transfer &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt; grid on which excitons and phonons will be defined!&lt;br /&gt;
&lt;br /&gt;
The electronic wavefunctions computed at this step and stored in the new nscf &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory will be used both by Yambo and by the electron-phonon code: this is important because using different sets of wavefunctions would lead to a phase mismatch issue in the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
The nscf input &amp;lt;code&amp;gt;mos2.nscf&amp;lt;/code&amp;gt; is&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;nscf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
                nbnd  = 250&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, we run the calculation&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
== Step 3: dvscf phonon calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we run the phonon calculation.&lt;br /&gt;
&lt;br /&gt;
Copy the &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the &#039;&#039;&#039;scf&#039;&#039;&#039; calculation and run &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt; for a dvscf calculation with a standard &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt;-grid matching the &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we wanna use in Yambo.&lt;br /&gt;
&lt;br /&gt;
At the end, we will have the &amp;lt;code&amp;gt;_ph0&amp;lt;/code&amp;gt; directory containing the variation of the self-consistent potential, &amp;lt;math&amp;gt;\Delta V_{SCF}(q)&amp;lt;/math&amp;gt;, and the &amp;lt;code&amp;gt;*.dyn&amp;lt;/code&amp;gt; files with the phonon energies and eigenvectors.&lt;br /&gt;
&lt;br /&gt;
NB: one could further refine the phonon energies by enforcing the acoustic sum rule, including non-analytic long-range contributions, interpolating to finer grids... all of this can be done within Quantum ESPRESSO and will not be covered in this version of the tutorial.&lt;br /&gt;
&lt;br /&gt;
The input is &amp;lt;code&amp;gt;mos2.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &lt;br /&gt;
 mos2_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;mos2&#039;,&lt;br /&gt;
   fildvscf = &#039;mos2-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;mos2.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=1&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
And now we run as&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 ph.x -inp mos2.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
This time we use nohup and more processes because this calculation may take some time. It is a good idea to set &amp;lt;code&amp;gt;recover=.true.&amp;lt;/code&amp;gt; as in a real calculation you will easily breach walltime, and in this way you can safely restart.&lt;br /&gt;
&lt;br /&gt;
== Step 4: create Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory ==&lt;br /&gt;
&lt;br /&gt;
This is just the standard Yambo initialization: run &lt;br /&gt;
 &lt;br /&gt;
 p2y &lt;br /&gt;
&lt;br /&gt;
and then &lt;br /&gt;
&lt;br /&gt;
 yambo &lt;br /&gt;
&lt;br /&gt;
in the &#039;&#039;&#039;nscf&#039;&#039;&#039; &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; folder and then move the newly generated &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory to a convenient place.&lt;br /&gt;
&lt;br /&gt;
== Step 5: run a BSE calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we switch from QE to Yambo. Here, we forgo the GW step for simplicity (we can use a scissor operator to open the band gap).&lt;br /&gt;
&lt;br /&gt;
This calculation has a couple of differences with respect to a standard BSE calculation for optical absorption. We can look at the input file &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Runlevels&amp;lt;/span&amp;gt;&lt;br /&gt;
 optics                       # [R OPT] Optics&lt;br /&gt;
 rim_cut                      # [R RIM CUT] Coulomb potential&lt;br /&gt;
 bss                          # [R BSS] Bethe Salpeter Equation solver&lt;br /&gt;
 em1s                         # [R Xs] Static Inverse Dielectric Matrix&lt;br /&gt;
 bse                          # [R BSE] Bethe Salpeter Equation.&lt;br /&gt;
 bsk                          # [R BSK] Bethe Salpeter Equation kernel&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# RIM and cutoff settings&amp;lt;/span&amp;gt;&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 X/Y/Z/XY..&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Static screening&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_and_IO_CPU= &amp;quot;1 1 4 2 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;
 Chimod= &amp;quot;hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 |  200 |                 # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 8000            mRy    # [Xs] Response block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# BSE&amp;lt;/span&amp;gt;&lt;br /&gt;
 BS_CPU= &amp;quot;4.1.2&amp;quot;                   # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k.eh.t&amp;quot;                 # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_diago=4              # [PARALLEL] CPUs for matrix diagonalization&lt;br /&gt;
 BSEmod= &amp;quot;causal&amp;quot;             # [BSE] resonant/causal/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                  # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  40000      mRy    # [BSK] Exchange components&lt;br /&gt;
 ALLGexx                      # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  8000       mRy    # [BSK] Screened interaction block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind=&amp;quot;full&amp;quot;                  #[BSE,X] bar(default)/full/tilde&amp;lt;/span&amp;gt;&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.00000 |  4.00000 | eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
   0.05000 |  0.05000 | eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 2000               # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 7 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BSEBands&lt;br /&gt;
    25 |  28 |                 # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                      # [BSS] Write to disk excitonic the FWs&lt;br /&gt;
 &lt;br /&gt;
This file was generated using the command: &amp;lt;code&amp;gt; yambo -X s -o b -k sex -y d -r&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all, we compute the excitons for all the momenta in the irreducible Brillouin zone for our discrete grid via the &amp;lt;code&amp;gt;BSEQptR&amp;lt;/code&amp;gt; variable. This will be a &#039;&#039;&#039;finite-momentum&#039;&#039;&#039; BSE calculation, analogous to the phonon one.&lt;br /&gt;
&lt;br /&gt;
Second, we change the variable &amp;lt;code&amp;gt;Lkind&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;full&amp;lt;/code&amp;gt;. In Yambo, &amp;lt;code&amp;gt;Lkind=&amp;quot;bar&amp;quot;&amp;lt;/code&amp;gt;, which is the default for optical absorption, means that we are computing the excitonic response function without the long-range component of the exchange interaction. This cannot be used when computing the exciton momentum dependence, where the long-range exchange interaction can play a role, therefore we have to include it with &amp;lt;code&amp;gt;Lkind=&amp;quot;full&amp;quot;&amp;lt;/code&amp;gt;. This allows for the calculation of the excitonic longitudinal-transverse splitting (in 3D systems) as well.&lt;br /&gt;
&lt;br /&gt;
We can now run the code:&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation, we have obtained the &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; databases inside the directory &amp;lt;code&amp;gt;bse_Lfull&amp;lt;/code&amp;gt;. They contain information on the exciton energies and wavefunctions at each momentum. Do not forget to check the report and logs of your calculation in the same directory to make sure that the code is doing what you want.&lt;br /&gt;
&lt;br /&gt;
== Step 6: obtain the electron-phonon matrix elements ==&lt;br /&gt;
&lt;br /&gt;
We have finished the heavy simulations. Now it&#039;s time for the postprocessing. The first order of business is the reconstruction of the electron-phonon coupling matrix elements from the dvscf results and the electronic wavefunctions.&lt;br /&gt;
&lt;br /&gt;
In order to do this, we will run the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable of the &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; code. We will run via command line using yambopy, although it will be instructive to have look at the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; input files later.&lt;br /&gt;
&lt;br /&gt;
We run in the same directory where the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; is (remember than you can also virtually move it with a symbolic link).&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y&lt;br /&gt;
&lt;br /&gt;
to see the help for the calculation. Have a look at the various flags and their description.&lt;br /&gt;
For example, if we want to do a serial run of LetzElPhC for bands from &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt;, we should type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/ph_input.in -b n_i n_f&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt; are integers representing the initial and final band indices. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 1 and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f]&amp;lt;/math&amp;gt; including the extrema of the interval.&lt;br /&gt;
&lt;br /&gt;
These should coincide with those used for the Bethe-Salpeter kernel, i.e. those specified in the &amp;lt;code&amp;gt;BSEBands&amp;lt;/code&amp;gt; variable of the BSE input file (this is not strictly necessary, but certainly efficient since these calculations use a lot of disk space). &lt;br /&gt;
&lt;br /&gt;
For our system, we want to do a parallel calculation with 4 qpools and 2 kpools. In addition, we want to explicitly specify the path of the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable and avoid automatically deleting the LetzElPhC data. So we type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/mos2.dvscf -b 25 28 -par 4 2 -lelphc path/to/lelphc_exe&lt;br /&gt;
&lt;br /&gt;
At the end, check your directory: you should find the &amp;lt;code&amp;gt;lelphc.in&amp;lt;/code&amp;gt; input file that was run, let&#039;s inspect it: &lt;br /&gt;
&lt;br /&gt;
 # LetzElPhC input for yambo generated by yambopy&lt;br /&gt;
 nqpool      = 2&lt;br /&gt;
 nkpool      = 4&lt;br /&gt;
 start_bnd   = 25&lt;br /&gt;
 end_bnd     = 28&lt;br /&gt;
 save_dir    = ./SAVE&lt;br /&gt;
 kernel      = dfpt&lt;br /&gt;
 ph_save_dir = dvscf/ph_save&lt;br /&gt;
 convention = yambo&lt;br /&gt;
&lt;br /&gt;
Notice the variable &amp;lt;code&amp;gt;convention=yambo&amp;lt;/code&amp;gt;: what does it mean? At variance with QE and many other codes, Yambo uses the &amp;quot;backward&amp;quot; momentum transfer convention for electronic scatterings. That is, an electronic transition goes from band &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k-q&amp;lt;/math&amp;gt; to band &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. In the &amp;quot;forward&amp;quot; momentum transfer convention (the more standard one), the transitions go from &amp;lt;math&amp;gt;nk&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;mk+q&amp;lt;/math&amp;gt;. Therefore, this variable ensures that the electron-phonon coupling matrix elements are computed as &amp;lt;math&amp;gt;\langle mk|dV|nk-q\rangle&amp;lt;/math&amp;gt;. This will have consequences also in the formulation of the &#039;&#039;exciton&#039;&#039;-phonon coupling matrix element.&lt;br /&gt;
&lt;br /&gt;
You will also find a &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; database that contains the computed electron-phonon matrix elements, in the output format of &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In addition, if you check the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder:&lt;br /&gt;
&lt;br /&gt;
 ls SAVE/ndb.elph_gkkp*&lt;br /&gt;
&lt;br /&gt;
you will see that yambopy has created the Yambo-compatible electron-phonon databases.&lt;br /&gt;
&lt;br /&gt;
If you want to run LetzElPhC directly, without using yambopy, you can refer to its [https://github.com/yambo-code/LetzElPhC/blob/main/docs/tex_doc/main.pdf|user guide].&lt;br /&gt;
Keep in mind that in this case, in order to convert the database to the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases of Yambo, you will then need a couple of lines of python using the Yambopy class &amp;lt;code&amp;gt;ConvertElectronPhononDB&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;yambopy/letzelph_interface/lelph2y.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases -- e.g., because you are doing the exc-ph postprocessing with yambopy -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_gkkp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases -- e.g., because you are using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; for the exc-ph part -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_lelphc_dbs&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
== Step 7: Obtain the exciton-phonon coupling ==&lt;br /&gt;
&lt;br /&gt;
Now, we can finally access our basic building block for exciton-phonon physics. This could be done entirely in python (using &#039;&#039;&#039;Yambopy&#039;&#039;&#039;), or by running &#039;&#039;&#039;Yambo&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambo postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (running yambo inputs with the &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; executable), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;follow the alternative route to Steps 7-8 [[Exciton-phonon coupling and luminescence - Yambo postprocessing|at this link]]&#039;&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambopy postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (using flexible python scripting), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;keep following Steps 7-8 on this page&#039;&#039;&#039;&amp;lt;/span&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Our objective is obtaining the following quantity: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathcal{G}^\mu_{\alpha\lambda}(0,q)=\sum_{vv^\prime c k} A^{\alpha, *}_{cv^\prime} (k, q) g_{vv^\prime}^\mu (k,q) A^{\lambda}_{cv}(k,0) - \sum_{cc^\prime vk} A^{\alpha, *}_{c^\prime v} (k+q, q) g_{c^\prime c}^\mu (k+q,q) A^{\lambda}_{cv}(k, 0)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;A^{\alpha}_{cv}(k,q)&amp;lt;/math&amp;gt; are the exciton coefficients extracted from the eigenvector of the two-particles Hamiltonian during the BSE calculation in step 5, while &amp;lt;math&amp;gt;g_{nm}^\mu (k,q)&amp;lt;/math&amp;gt; are the electron-phonon coupling matrix elements obtained in step 6. As you can see, the exciton &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; undergoes phonon-mediated scattering to state &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; via phonon mode &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;. The scattering can happen for the hole (valence, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;) or for the electron (conduction, &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
NB: &lt;br /&gt;
&lt;br /&gt;
(1) This is written in the &amp;quot;backward&amp;quot; momentum transfer convention used by Yambo. The momentum dependence is different in the &amp;quot;forward&amp;quot; transfer convention. &lt;br /&gt;
&lt;br /&gt;
(2) For simplicity, this is written for zero initial exciton momentum. This means that one of the two states involved in the phonon-mediated scattering process will be in the optical limit (and possibly an optically generated exciton), while the other state can have any momentum: this momentum will be the same as the phonon one. This matrix element can be used to describe phonon-assisted absorption and emission spectra.&lt;br /&gt;
&lt;br /&gt;
In order to calculate this quantity using python, we need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases natively generated by the &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt; code, as well as the BSE databases &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; containing the information on exciton wavefunctions and energies.&lt;br /&gt;
&lt;br /&gt;
Next, we write a python user script importing the yambopy exciton-phonon tools. You can find a version of this script in &amp;lt;code&amp;gt;yambopy/tutorials/exciton-phonon/calculate_excph.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np &lt;br /&gt;
 from yambopy import YamboLatticeDB,YamboWFDB,LetzElphElectronPhononDB &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific Yambopy dbs loading classes&amp;lt;/span&amp;gt;&lt;br /&gt;
 from yambopy.exciton_phonon.excph_matrix_elements import exciton_phonon_matelem &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific exc-ph functions&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 path = &#039;1L_MoS2&#039;&lt;br /&gt;
 bands_range=[24,28] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence bands, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# number of excitonic states&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 bsepath    = f&#039;{path}/bse-allq_full&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lin=Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath   = f&#039;{path}/SAVE&#039;     &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Yambo SAVE&amp;lt;/span&amp;gt;&lt;br /&gt;
 ndb_elph   = f&#039;{path}/ndb.elph&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# LetzElPhC electron-phonon database (any convention)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice&amp;lt;/span&amp;gt;&lt;br /&gt;
 lattice = YamboLatticeDB.from_db_file(filename=f&#039;{savepath}/ns.db1&#039;)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read electron-phonon&amp;lt;/span&amp;gt;&lt;br /&gt;
 elph    = LetzElphElectronPhononDB(ndb_elph,read_all=False)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read wave functions&amp;lt;/span&amp;gt;&lt;br /&gt;
 wfcs    = YamboWFDB(filename=&#039;ns.wf&#039;,save=savepath,latdb=lattice,bands_range=bands_range)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Calculate exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 exph = exciton_phonon_matelem(lattice,elph,wfcs,BSE_dir=bsepath,nexc_in=nexc,nexc_out=nexc,dmat_mode=&#039;save&#039;,exph_file=&#039;MoS2_Ex-ph.npy&#039;)&lt;br /&gt;
&lt;br /&gt;
In this script, we can select the number exciton states &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; with &amp;lt;code&amp;gt;nexc&amp;lt;/code&amp;gt;, the single-particle bands range with &amp;lt;code&amp;gt;bands_range&amp;lt;/code&amp;gt;. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 0 (python indexing) and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f)&amp;lt;/math&amp;gt;, therefore the last value (28 in the example) is excluded. That is, in the example we are selecting the 25th, 26th, 27th and 28th bands. Those bands have to be present in both the electron-phonon and BSE calculations. &lt;br /&gt;
&lt;br /&gt;
Here we calculate the couplings of the first twelve states at each finite-&amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; point including &amp;lt;math&amp;gt;q=0&amp;lt;/math&amp;gt;. We also include all the nine phonon modes of monolayer MoS2. We also need access to the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory in order to read the electronic wavefunctions: they are used to compute the electronic representation matrices (&amp;lt;code&amp;gt;dmat&amp;lt;/code&amp;gt; in the code). The argument &amp;lt;code&amp;gt;dmat_mode&amp;lt;/code&amp;gt; can be set to &amp;lt;code&amp;gt;&#039;load&#039;&amp;lt;/code&amp;gt; for subsequent calculations.&lt;br /&gt;
&lt;br /&gt;
When we are satisfied with the input, we run the code:&lt;br /&gt;
&lt;br /&gt;
 python calculate_excph.py&lt;br /&gt;
&lt;br /&gt;
If you check the output, you should find the &amp;lt;code&amp;gt;MoS2_Ex-ph.npy&amp;lt;/code&amp;gt; binary file in the directory where you ran.&lt;br /&gt;
&lt;br /&gt;
=== Analysis of the couplings ===&lt;br /&gt;
&lt;br /&gt;
It is a good idea to have a look at what we computed up to now in order to make sure nothing has gone wrong. &lt;br /&gt;
&lt;br /&gt;
It is not easy to know what to expect (apart from symmetry and gauge compliance of the matrix elements), but one can work out the exciton-phonon selection rules in advance, check that the magnitude is reasonable, etc.&lt;br /&gt;
&lt;br /&gt;
It is also not easy to meaningfully plot this quantity. We have to make sure that we are not breaking degenerate states, otherwise the plots will not be invariant. &lt;br /&gt;
&lt;br /&gt;
First of all, we have to know our system: in monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, the first four excitons are all doubly degenerate. The first exciton responsible for a bright peak in the absorption spectrum (the &#039;&#039;&#039;A&#039;&#039;&#039; peak), is the second state, corresponding to state indices &amp;lt;code&amp;gt;(3,4)&amp;lt;/code&amp;gt; in fortran indexing or &amp;lt;code&amp;gt;(2,3)&amp;lt;/code&amp;gt; in python indexing. &lt;br /&gt;
&lt;br /&gt;
All these information can be obtained by analyzing the BSE results (this stuff is explained in the BSE tutorials) and by knowledge of the system or class of systems from the literature.&lt;br /&gt;
&lt;br /&gt;
Thus, a good quantity to plot may be the norm of the matrix elements, summed over the degenerate subspace of exciton A, for a certain number of scattered final states mediated by certain phonon modes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;F_A(q)= \sqrt{ \sum_{\alpha \in A,\lambda,\mu} |\mathcal{G}_{\alpha\lambda}^\mu (0,q)|^2 }&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to do this, we create a python script &amp;lt;code&amp;gt;analyse_excph.py&amp;lt;/code&amp;gt; in which we first load the excph dabatases. &lt;br /&gt;
You can find a version of this script in the yambopy directory, in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;. &lt;br /&gt;
First, we select the exciton and phonon states to be included in &amp;lt;code&amp;gt;F_A&amp;lt;/code&amp;gt;, together with the path of databases and plot details:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Exciton &amp;quot;in&amp;quot; states&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_in  = [2,3]  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# First bright peak (A: 2,3 -- B: 6,7)&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_out = [0,1,2,3] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# first 4 states (dispersion of dark triplet state and A)&amp;lt;/span&amp;gt;&lt;br /&gt;
 ph_in  = &#039;all&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Paths of databases&amp;lt;/span&amp;gt;&lt;br /&gt;
 ns_db1 =f&#039;{path}/SAVE/ns.db1&#039;&lt;br /&gt;
 ns_ypy = &#039;MoS2_Ex-ph.npy&#039;&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Then, we load the data:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 ylat = YamboLatticeDB.from_db_file(filename=ns_db1)&lt;br /&gt;
 print(ylat)&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Load exc-ph database&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_py = np.load(ns_ypy)&lt;br /&gt;
 G_squared = np.abs(X_py)**2.&lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt;F_A(q)&amp;lt;/math&amp;gt; is obtained from a dedicated function as:&lt;br /&gt;
 &lt;br /&gt;
 if exc_in  == &#039;all&#039;: exc_in  = range(G_squared.shape[2])&lt;br /&gt;
 if exc_out == &#039;all&#039;: exc_out = range(G_squared.shape[3])&lt;br /&gt;
 if ph_in   == &#039;all&#039;: ph_in   = range(G_squared.shape[1])&lt;br /&gt;
 &lt;br /&gt;
 G_squared = G_squared[:, ph_in, :, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_in, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_out].sum(axis=(1))&lt;br /&gt;
 &lt;br /&gt;
 F_q = np.sqrt( G_squared )*ha2ev &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Switch from Ha to eV&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally, we have to make a plotting function. For this tutorial we will use a custom scatterplot employing some of the plotting tools provided by yambopy (but you can do whatever you want).&lt;br /&gt;
&lt;br /&gt;
 plot_2D_excph(qgrid,G2_to_plot,rlat=ylat.rlat,plt_cbar=True,\&lt;br /&gt;
               marker=&#039;H&#039;,s=700,cmap=&#039;magma&#039;)&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can get more experience on using Yambopy for these kinds of visualization by following the [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy Yambopy tutorials]. In fact, remember that these scripts and all the other Yambopy tutorial scripts are just suggestions, not source code written in stone: if you know &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt; you can do your own analysis and your own plots, you just need to import the required Yambopy modules to load the data.&lt;br /&gt;
&lt;br /&gt;
In our case, the resulting plot is the following.&lt;br /&gt;
&lt;br /&gt;
[[File:1L MoS2 MoS2 Ex-ph.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
This can be checked against Fig. 2(d) of reference &amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;, although you have to keep in mind that our results are badly undersampled in terms of the reciprocal-space grid, as can be easily seen, and the quantity plotted is not exactly the same. However, the main features are already there since they are dictated mostly by crystal symmetries.&lt;br /&gt;
&lt;br /&gt;
Now that we have the exciton-phonon matrix elements, we can use them to build several kinds of observables. Below, we give an example related to phonon-assisted luminescence, but we may update this tutorial in the future to include more cases.&lt;br /&gt;
&lt;br /&gt;
== Step 8: Compute phonon-assisted luminescence ==&lt;br /&gt;
&lt;br /&gt;
[[File:Luminescence scheme.png|250px|right]]&lt;br /&gt;
&lt;br /&gt;
We want to compute the experimental optical signature due to the phonon-assisted recombination of an exciton (as sketched in the figure).&lt;br /&gt;
&lt;br /&gt;
The signal from the phonon replicas can be modeled as a second-order scattering process involving one phonon and one photon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;I^{Sat}(\omega)=\frac{1}{ N_q} \frac{1}{3} \sum_{\epsilon s\beta \mu q} \frac{1}{E_{\beta q}-s\Omega_{\mu q}}\left|\sum_\alpha\frac{ D^{\epsilon}_\alpha \mathcal{G}_{\beta \alpha}^{\mu,*}(q)}{E_\alpha -E_{\beta q} +s\Omega_{\mu q}+\mathrm{i}\eta}\right|^2 \frac{N^{exc}_{\beta q}(T_{exc})[\frac{1+s}{2}+n_{\mu q}(T)]}{\omega -[E_{\beta q}-s\Omega_{\mu q}]+\mathrm{i}\eta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this equation, the oscillator strength of the peak is given by the exciton-phonon coupling matrix elements &amp;lt;math&amp;gt;\mathcal{G}&amp;lt;/math&amp;gt; multiplied by the exciton dipoles &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; (they are called &amp;quot;residuals&amp;quot; in Yambo). Here &amp;lt;math&amp;gt;E_\lambda&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{\alpha q}&amp;lt;/math&amp;gt; are the energies of the optical and finite-momentum excitons, respectively, while &amp;lt;math&amp;gt;\Omega_{\mu q}&amp;lt;/math&amp;gt; are the phonon energies. &lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;n_{\mu q}(T)&amp;lt;/math&amp;gt; is the temperature-dependent phonon Bose-Einstein occupation function. As it can be seen, &amp;lt;math&amp;gt;s=1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;emission&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)+1&amp;lt;/math&amp;gt;), while &amp;lt;math&amp;gt;s=-1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;absorption&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)&amp;lt;/math&amp;gt;). Therefore, &amp;lt;math&amp;gt;I^{Sat}_{PL}(\omega;T)&amp;lt;/math&amp;gt; describes &#039;&#039;light&#039;&#039; emission by recombining excitons mediated by either &#039;&#039;phonon&#039;&#039; absorption or emission. &lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt; N_{\alpha q}(T_{exc})&amp;lt;/math&amp;gt; is the exciton occupation function. Luminescence is technically an out-of-equilibrium process, but we can assume that for very low density of excitations and in steady-state conditions, the exciton population can be approximately described by an equilibrium distribution evaluated at an effective temperature. Here, we use the Boltzmann distribution. Experimentally, &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; tends to coincide with the lattice temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; more or less above 100 K, while at very low temperature (&amp;lt; 10 K), &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; may vary between 10-50 K. It goes without saying that this needs to carefully be checked in your realistic calculations.&lt;br /&gt;
&lt;br /&gt;
Finally, the spectrum is averaged over the polarization directions of the emitted photons (&amp;lt;math&amp;gt;\epsilon=x,y,z&amp;lt;/math&amp;gt; representing the respective dipole components).&lt;br /&gt;
&lt;br /&gt;
=== Running the jobs ===&lt;br /&gt;
&lt;br /&gt;
In order to study luminescence in a paradigmatic system, we switch to bulk hexagonal boron nitride and we repeat the workflow. As you can easily see, one can think about automatizing the execution of all these calculations via scripting or more advanced tools. However, in the case of very large simulations (memory-limited or disk-space limited) or for systems whose electronic and lattice properties are fragile with respect to tiny calculation details, one must be very careful and run many basic tests.&lt;br /&gt;
&lt;br /&gt;
Fortunately, we are running a fast underconverged example. We use LDA pseudopotentials from the pseudo-dojo library and the following are the calculations steps.&lt;br /&gt;
&lt;br /&gt;
1. Input &amp;lt;code&amp;gt;hbn.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;scf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
     outdir = &#039;./tmp&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
2. Input &amp;lt;code&amp;gt;hbn.nscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;nscf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;&lt;br /&gt;
     outdir = &#039;./&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 	nbnd = 120&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
3. Input &amp;lt;code&amp;gt;hbn.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 hbn_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;hBN&#039;,&lt;br /&gt;
   fildvscf = &#039;hBN-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;hBN.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=2&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 pw.x -inp hbn.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
4. Input &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt; (we include 2 valence and 2 conduction bands):&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 em1s&lt;br /&gt;
 DIP_CPU= &amp;quot;1 8 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 8 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;
 BS_CPU= &amp;quot;8 1 1&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k eh t&amp;quot;                     # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_LinAlg_INV=-1            # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&lt;br /&gt;
 BS_nCPU_LinAlg_DIAGO=-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;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 % QpntsRXs&lt;br /&gt;
    1 | 14 |                         # [Xs] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 | 120 |                         # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 10                Ry    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lfull&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 % DipBands&lt;br /&gt;
    1 | 120 |                         # [DIP] Bands range for dipoles&lt;br /&gt;
 %&lt;br /&gt;
 DipApproach= &amp;quot;G-space v&amp;quot;         # [DIP] [G-space v/R-space x/Covariant/Shifted grids]&lt;br /&gt;
 DipComputed= &amp;quot;R V P&amp;quot;             # [DIP] [default R P V; extra P2 Spin Orb]&lt;br /&gt;
 BSENGexx= 30000            Ry    # [BSK] Exchange components&lt;br /&gt;
 #ALLGexx                       # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  9000            Ry    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.25997 | 1.08816 | 1.12683 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 14 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEBands&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   7 | 10 |                         # [BSK] Bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.50000 | 8.00000 |         eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
  0.050000 | 0.050000 |         eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 1000                    # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
Importantly, since we want to describe the phonon-assisted recombination process of an *optical* exciton (i.e., emitting a transverse photon), this time we also run an additional calculation at `Q=0` omitting the nonanalytic long-range Coulomb exchange. Make a second input &amp;lt;code&amp;gt;bse_Lbar.in&amp;lt;/code&amp;gt; with the following changes: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lbar&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4b. So now we make a second BSE run in a different directory specified by &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt;. Here, we also pass to yambo the directory of the previous run as it includes the important screening databases &amp;lt;code&amp;gt;ndb.em1s*&amp;lt;/code&amp;gt; that we do not want to recompute from scratch.&lt;br /&gt;
 &lt;br /&gt;
 mpirun -np 8 yambo -F bse_Lbar.in -J bse_Lbar,bse_Lfull -C bse_Lbar&lt;br /&gt;
&lt;br /&gt;
5. Now we run &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; (with or without yambopy: in the latter case remember the option &amp;lt;code&amp;gt;-D&amp;lt;/code&amp;gt;) to get the el-ph matrix elements, particularly the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/hbn.dvscf -b 7 10 -par 4 2 -D&lt;br /&gt;
&lt;br /&gt;
=== Luminescence calculation ===&lt;br /&gt;
&lt;br /&gt;
6. And finally we calculate exciton-phonon matrix elements and the luminescence spectrum in one go using a python script importing the Yambopy exciton-phonon tools: in order to do this, we need to take a look at all the necessary input variables for the formula written above.&lt;br /&gt;
&lt;br /&gt;
We can start from the script &amp;lt;code&amp;gt;luminescence.py&amp;lt;/code&amp;gt; available in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import matplotlib.pyplot as plt&lt;br /&gt;
 from yambopy.exciton_phonon.excph_luminescence import exc_ph_luminescence&lt;br /&gt;
 from yambopy.exciton_phonon.excph_input_data import exc_ph_get_inputs&lt;br /&gt;
&lt;br /&gt;
We import the necessary tools...&lt;br /&gt;
&lt;br /&gt;
 path = &#039;3D_hBN&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lout--&amp;gt; response is Lfull)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bsepath =  f&#039;{path}/bse_Lfull&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q* databases are needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation for optically active exciton (Lin --&amp;gt; response is Lbar)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bseBARpath =  f&#039;{path}/bse_Lbar&#039;  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to electron-phonon calculation&amp;lt;/span&amp;gt;&lt;br /&gt;
 elphpath = path &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.elph is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to unprojected dipoles matrix elements (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 dipolespath = bsepath &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.dipoles is needed (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath = f&#039;{path}/SAVE&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ns.db1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... and we specify the paths to the necessary databases. Note that, if we want to perform polarization averaging, we have to recompute the excitonic dipoles in python as seen here.&lt;br /&gt;
&lt;br /&gt;
What about &amp;lt;code&amp;gt;bseBARpath&amp;lt;/code&amp;gt;? This variable points to the directory where the databases for the optical (zero-momentum) excitons &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; (which may be computed with &amp;lt;code&amp;gt;Lkind=&#039;Lbar&#039;&amp;lt;/code&amp;gt;) is located, which can be different from the directory with the full indirect exciton dispersion &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; (usually computed with &amp;lt;code&amp;gt;Lkind=&#039;Lfull&#039;&amp;lt;/code&amp;gt;, however &amp;lt;code&amp;gt;Lkind=&#039;Ltilde&#039;&amp;lt;/code&amp;gt; can also be used if one is interested in &amp;quot;irreducible&amp;quot; excitons). This makes it possible to compute the coupling between different exciton kinds.&lt;br /&gt;
&lt;br /&gt;
 bands_range=[6,10] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 phonons_range=[0,12] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# All phonons&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_out = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at each momentum (Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_in  = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at Q=0 (Lin)&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_ph  = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Lattice temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_exc = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Effective excitonic temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 emin=4.4      &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Energy range and plot details (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
 emax=4.7&lt;br /&gt;
 estep=0.0002&lt;br /&gt;
 broad = 0.005 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Broadening parameter for peak width (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we specify the parameters for the calculation. We include valence bands from 7 to 10 (6 to 9 in python index) and the contribution of all 12 phonon modes. We consider 12 excitonic states for the coupling matrix elements.&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;code&amp;gt;T_ph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;T_exc&amp;lt;/code&amp;gt; are the lattice and excitonic temperatures, respectively.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate and load all the inputs:&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Excitonic dipole matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Phonon energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * We specify bse_path2=bseBARpath meaning we use Lbar calculation for Q=0 excitons&amp;lt;/span&amp;gt;&lt;br /&gt;
 input_data = exc_ph_get_inputs(savepath,elphpath,bsepath,\&lt;br /&gt;
                                bse_path2=bseBARpath,dipoles_path=dipolespath,\&lt;br /&gt;
                                nexc_in=12,nexc_out=12,\&lt;br /&gt;
                                bands_range=[6,10],phonons_range=[0,12])&lt;br /&gt;
&lt;br /&gt;
 ph_energies, exc_energies, exc_energies_in, G, exc_dipoles = input_data&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;exc_ph_get_inputs&amp;lt;/code&amp;gt; gives us all the input data for luminescence in the correct format: phonon energies, exciton energies, optical exciton energies (if needed), exciton-phonon matrix elements (calculated on the fly and printed to file), unprojected exciton dipoles (optional, calculated on the fly and printed to file).&lt;br /&gt;
The exc-ph matrix element calculation is just a wrapper of the same tools that we have tested in the above section on MoS2.&lt;br /&gt;
&lt;br /&gt;
Finally, there is the calculation of the luminescence spectrum via the function &amp;lt;code&amp;gt;exc_ph_luminescence&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate the luminescence spectrum including the input data from before&amp;lt;/span&amp;gt;&lt;br /&gt;
 w,PL = exc_ph_luminescence(T_ph,ph_energies,exc_energies,exc_dipoles,G,\&lt;br /&gt;
                            exc_energies_in=exc_energies_in,exc_temp=T_exc,\&lt;br /&gt;
                            nexc_out=nexc_out,nexc_in=nexc_in,emin=emin,emax=emax,\&lt;br /&gt;
                            estep=estep,broad=broad)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to print the luminescence data for later plotting, you can also add the following line to the script:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Save to file&amp;lt;/span&amp;gt;&lt;br /&gt;
 data = np.column_stack((w, PL))&lt;br /&gt;
 np.savetxt(&amp;quot;hBN_luminescence_12x12x1.dat&amp;quot;, data, fmt=&amp;quot;%.8f&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
It is now time to run the whole script:&lt;br /&gt;
&lt;br /&gt;
 python luminescence.py&lt;br /&gt;
 &lt;br /&gt;
NB: By using Yambopy for Step 6, we have limited the use of the Yambo code to just step 4 in the entire workflow. This option is more flexible, as it allows for a greater degree of control by the user. On the other hand the Yambo postprocessing route features a Yambo-style input that doesn&#039;t require python knowledge and the calculation is currently faster in fortran. However, the luminescence expression computed in Yambo is a slightly different than this one: it is more approximated in the description of the satellite oscillator strengths, but it explicitly includes the renormalization of the direct exciton peak. You can check the differences [[Exciton-phonon coupling and luminescence - Yambo postprocessing|here]].&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
We can plot the results of the step 6 calculation. If we do it in the same script we can add something like this:&lt;br /&gt;
 fig = plt.figure()&lt;br /&gt;
 ax = fig.add_subplot(1,1,1)&lt;br /&gt;
 ax.set_xlim(emin,emax)&lt;br /&gt;
 ax.set_ylim(0,np.max(PL)*1.1)&lt;br /&gt;
 ax.get_yaxis().set_visible(False)&lt;br /&gt;
 &lt;br /&gt;
 ax.plot(w, PL, &#039;-&#039;,c=&#039;red&#039;, label=&amp;quot;AA&#039; hBN luminescence&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 plt.legend()&lt;br /&gt;
 plt.savefig(&#039;hBN_luminescence.png&#039;)&lt;br /&gt;
 plt.show()&lt;br /&gt;
&lt;br /&gt;
[[File:HBN luminescence satellites.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
Here, the signal corresponds to a finite-momentum exciton that recombines with the help of several different phonon modes, both optical and acoustic. Each phonon mode whose coupling with the exciton is allowed can generate a peak, and the energy shifts of these peaks with respect to the initial exciton energy correspond to the phonon energies. This result is underconverged, but the main features are all there. In the plot, we show a more converged example using a 12x12x4 grid (all the other parameters being equal). These plots can be compared with Fig. 4(a) of reference &amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Exciton lifetimes==&lt;br /&gt;
&lt;br /&gt;
Using the exciton-phonon coupling it is possible also to calculate exciton life-time due to the scattering with phonon. For this kind of calculation input file can be generated with the command &#039;&#039;yambo -excph l&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 excph                            # [R] Exction-phonon&lt;br /&gt;
 ExcGkkp                          # [R][EXCPH] Exciton-Phonon Matrix Elelements&lt;br /&gt;
 ExcPhLifeT                       # [R][EXCPH] Exciton-Phonon Life-Times&lt;br /&gt;
 BoseTemp= 0.000000         eV    # Bosonic Temperature&lt;br /&gt;
 % ELPhExcStates&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 |  4 |&amp;lt;/span&amp;gt;                           # [EXCPH] Incoming (external) exciton states&lt;br /&gt;
 %&lt;br /&gt;
 % ELPhExcSum&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1 |  8 |    &amp;lt;/span&amp;gt;                       # [EXCPH] Outgoing (virtual) exciton states&lt;br /&gt;
 %&lt;br /&gt;
 LoutPath= &amp;quot;none&amp;quot;                 # [EXCPH] Path of the outgoing L&lt;br /&gt;
 FANdEtresh= 0.100000E-5    eV    # [ELPH] Energy treshold for Fan denominator&lt;br /&gt;
 % ElPhModes&lt;br /&gt;
   1 | 12 |                           # [ELPH] Phonon modes included&lt;br /&gt;
 %&lt;br /&gt;
 EXCTemp= 0.000000          eV    # [EXCPH] Excitonic Temperature (for luminescence spectra)&lt;br /&gt;
 AlphaQ= 0.000000                 # [EXCPH] Excitonic band structure 2D distortion&lt;br /&gt;
 #ExcPhOffDiago                 # [EXCPH] Exciton-Phonon off-diagonal self-energy&lt;br /&gt;
 #NoMatrxEl                     # [EXCPH] Set all exciton-phonon matrix elements to one (for testing purpose)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;LDamping= 0.1 &amp;lt;/span&amp;gt;     meV               # [EXCPH] Damping of exc-ph self-energy&lt;br /&gt;
&lt;br /&gt;
notice that in this case &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;LDamping&amp;lt;/span&amp;gt; is the broadening of the exciton-phonon self energy and it should be a very small value of the order of the phonon life-times around the meV.&amp;lt;ref&amp;gt;[https://arxiv.org/abs/1411.5628 First-principles calculations of phonon frequencies, lifetimes, and spectral functions from weak to strong an-harmonicity: The example of palladium hydrides], L. Paulatto, et al. Phys. Rev. B &#039;&#039;&#039;91&#039;&#039;&#039;, 054304 (2015) &amp;lt;/ref&amp;gt;. Running this input you will get:&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton lifetimes:&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [1] Lifetime: 0.697314 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [2] Lifetime: 0.697314 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [3] Lifetime: 20.22155 meV&lt;br /&gt;
 &amp;lt;-&amp;gt; Exciton [4] Lifetime: 32.95292 meV&lt;br /&gt;
&lt;br /&gt;
the life-time of the first four excitons. Note that this result is not converged respect to the Q-points. In order to speedup convergence that double-grid&amp;lt;ref name=&#039;pierre&#039; /&amp;gt; can be used also in the life-time calculations, see tutorial on electron-phonon coupling for tricks on the convergence of the double-grid. &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; &amp;gt;Toyozawa, Yutaka, and Chris Oxlade, &#039;&#039;Optical processes in solids&#039;&#039;, [https://m.booksee.org/book/1121964?force_lang=en Cambridge University Press, (2003)]. &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;lechifflart2023&#039;&amp;gt;P. Lechifflart, F. Paleari, D. Sangalli, C. Attaccalite, &#039;&#039;First-principles study of luminescence in hexagonal boron nitride single layer: Exciton-phonon coupling and the role of substrate&#039;&#039;, &lt;br /&gt;
[https://doi.org/10.1103/PhysRevMaterials.7.024006 Phys. Rev. M, &#039;&#039;&#039;7&#039;&#039;&#039; (2), 024006 (2023)]; [https://arxiv.org/abs/2212.10407 arXiv2212.1047]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cannuccia2019&#039;&amp;gt;E. Cannuccia, B. Monserrat and C. Attaccalite, &#039;&#039;Theory of phonon-assisted luminescence in solids: Application to hexagonal boron nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]; [https://arxiv.org/abs/1807.11797 arXiv1807.11797]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019&#039;&amp;gt;F. Paleari et al., &#039;&#039;Exciton-Phonon Coupling in the Ultraviolet Absorption and Emission Spectra of Bulk Hexagonal Boron Nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.122.187401 Phys. Rev. Lett. &#039;&#039;&#039;122&#039;&#039;&#039;, 187401 (2019)]; [https://arxiv.org/abs/1810.08976 arXiv1810.089776] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chen2020&#039;&amp;gt;&#039;&#039;Exciton-Phonon Interaction and Relaxation Times from First Principles&#039;&#039;,&lt;br /&gt;
Hsiao-Yi Chen, Davide Sangalli, and Marco Bernardi, [https://doi.org/10.1103/PhysRevLett.125.107401  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 107401 (2020)]; [https://arxiv.org/abs/2002.08913 arXiv 2002.08913 (2020)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot;&amp;gt;P. Lechifflart, &#039;&#039;Exciton-phonon coupling and phonon-assisted luminescence in hexagonal Boron Nitride nanostructures&#039;&#039;, [https://hal.science/tel-04266805v1 PhD Thesis, University of Marseille (2023)]; [https://www.yambo-code.eu/wiki/images/5/54/These_final.pdf From the yambo website]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019_PhD&#039;&amp;gt;F. Paleari, &#039;&#039;First-principles approaches to the description of indirect absorption and luminescence spectroscopy: exciton-phonon coupling in hexagonal boron nitride&#039;&#039;, [https://wwwen.uni.lu/research/fstm/dphyms/people/fulvio_paleari PhD thesis, University of Luxembourg (2019)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;zanfrognini2023&#039;&amp;gt;M. Zanfrognini et al., &#039;&#039;Distinguishing different stackings in layered materials via luminescence spectroscopy&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.131.206902 Phys. Rev. Lett. &#039;&#039;&#039;131&#039;&#039;&#039;, 206902 (2023)]; [https://arxiv.org/abs/2305.17554 arXiv 2305.17554] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;marini2024&#039;&amp;gt;G. Marini, M. Calandra, P. Cudazzo, &#039;&#039;Optical absorption and photoluminescence of single layer boron nitride from a first principles cumulant approach&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.4c00669 Nano Lett., &#039;&#039;&#039;24&#039;&#039;&#039;, 20, 6017 (2024)]; [https://arxiv.org/abs/2402.03826 arXiv 2402.03826 (2024)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;antonius2017&#039;&amp;gt;G. Antonius, S. G. Louie, &#039;&#039;Theory of exciton-phonon coupling&#039;&#039;, [https://doi.org/10.1103/PhysRevB.105.085111 Phys. Rev. B, &#039;&#039;&#039;105&#039;&#039;&#039;, 085111 (2022)]; [https://arxiv.org/abs/1705.04245 arXiv1705.04245 (2017)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2022&#039;&amp;gt; F. Paleari, and A. Marini, &#039;&#039;Exciton-phonon interaction calls for a revision of the “exciton” concept&#039;&#039;, [https://doi.org/10.1103/PhysRevB.106.125403 Phys. Rev. B, &#039;&#039;&#039;106&#039;&#039;&#039;, 125403 (2022)]; [https://arxiv.org/abs/2205.02783 arXiv 2205.02783]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cudazzo2020&#039;&amp;gt; P. Cudazzo, &#039;&#039;First-principles description of the exciton-phonon interaction: A cumulant approach&#039;&#039;, [https://doi.org/10.1103/PhysRevB.102.045136 Phys. Rev. B, &#039;&#039;&#039;102&#039;&#039;&#039;, 045136 (2020)]; [https://orbilu.uni.lu/bitstream/10993/44769/1/main.pdf Open access pdf from Luxembourg University]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chan2023&#039;&amp;gt;Y-h Chan, J. B. Haber, M. H. Naik, J. B. Neaton, D. Y. Qiu, F. H. da Jornada, S. G. Louie, &#039;&#039;Exciton Lifetime and Optical Line Width Profile via Exciton–Phonon Interactions: Theory and First-Principles Calculations for Monolayer MoS2&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.3c00732 Nano Lett., &#039;&#039;&#039;23&#039;&#039;&#039;, 9 (2023)]; [https://arxiv.org/abs/2212.08451 arXiv 2212.08451 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;murali2025&#039;&amp;gt;M. Nalabothula, S. Reichardt, L. Wirtz, &#039;&#039;Origin of Interlayer Exciton–Phonon Coupling in 2D Heterostructures&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.5c00355 Nano Lett., &#039;&#039;&#039;25&#039;&#039;&#039;, 15 (2025)], [https://arxiv.org/abs/2407.16111 arXiv 2407.16111 (2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=906</id>
		<title>Exciton-phonon coupling and luminescence</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Exciton-phonon_coupling_and_luminescence&amp;diff=906"/>
		<updated>2026-04-30T07:57:07Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Tdgw-phonon-usc-01-1024x829.jpg|thumb|right|400px|(c) Zhenglu Li, University of Southern California]]&lt;br /&gt;
&lt;br /&gt;
In this advanced tutorial, we will calculate exciton-phonon interactions from first principles by interfacing DFPT (for phonon calculations) and BSE (for exciton calculations).&lt;br /&gt;
&lt;br /&gt;
The DFTP calculations are run with Quantum ESPRESSO, while the many-body GW-BSE calculations are run with Yambo. Finally, the exciton-phonon interaction will be obtained by combining and postprocessing the databases computed in the two previous runs. The great advantage of this workflow is that the calculations can be run in the irreducible Brillouin zones both for the electronic momenta (&#039;&#039;&#039;k&#039;&#039;&#039;) and the transfer momenta (&#039;&#039;&#039;Q&#039;&#039;&#039;, &#039;&#039;&#039;q&#039;&#039;&#039;) of excitons and phonons, thus speeding up considerably the jobs while reducing the IO and memory load.&lt;br /&gt;
&lt;br /&gt;
We will first compute the exciton-phonon coupling matrix elements: these are the building blocks needed to construct experimental observables such as phonon-assisted optical spectra (such as luminescence), Raman spectra and exciton lifetimes. We will do this in the case of monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, a 2D system with large spin-orbit interaction.&lt;br /&gt;
&lt;br /&gt;
As an example of application, we will consider the case of phonon-assisted luminescence. We will do this in the case of bulk hBN, a layered indirect insulator with strong electron-phonon coupling.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; this tutorial will be updated when new exc-ph tools become available in Yambopy (including full-python postprocessing, Raman spectra, interpolated lifetimes, etc).&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
This is an advanced topic: we assume that you already know something about the theory&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;antonius2017&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cudazzo2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2019_PhD&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;paleari2022&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot; /&amp;gt; and applications&amp;lt;ref name=&amp;quot;paleari2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;cannuccia2019&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chen2020&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;lechifflart2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;marini2024&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;murali2025&amp;quot; /&amp;gt; of exciton-phonon physics. &lt;br /&gt;
&lt;br /&gt;
Also, we assume that you already know how to run both a basic &#039;&#039;&#039;Yambo&#039;&#039;&#039; GW-BSE calculation and a DFPT phonon calculation with &#039;&#039;&#039;Quantum ESPRESSO&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Besides the QE executables &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt;, we also use the yambo phonon-specific executable &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; and the python utility &#039;&#039;&#039;Yambopy&#039;&#039;&#039;. The auxiliary code &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; (executable &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt;) will be used to obtain the electron-phonon matrix elements by reading the same electronic wavefunctions used by Yambo (and stored in the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory), while also making full use of crystal symmetries. [https://github.com/yambo-code/LetzElPhC LetzElPhC] will be run by Yambopy, but it must nonetheless be installed. Finally, the exciton-phonon properties can be computed either using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; or using Yambopy itself. Both cases will be covered in this tutorial.&lt;br /&gt;
&lt;br /&gt;
[[File:Workflow scheme.png|800px|center]]&lt;br /&gt;
&lt;br /&gt;
== Step 0: Pseudopotentials, equilibrium structure and convergence ==&lt;br /&gt;
&lt;br /&gt;
In a real calculation, it is important to ensure that both the pseudopotential and the lattice parameters that we are using are compatible and perform well for the electronic excited states and for the lattice vibrations simultaneously. Furthermore, you have to make sure that the wave function cutoff &amp;lt;code&amp;gt;ecutwfc&amp;lt;/code&amp;gt; is converged with respect to the DFPT step and not just to the DFT one. This is in addition to the other customary convergence tests for DFT, DFPT, GW and BSE calculations.&lt;br /&gt;
&lt;br /&gt;
This is often the most time-demanding step when starting on a new system.&lt;br /&gt;
&lt;br /&gt;
For the sake of this tutorial, we assume that we have already done all these tests and we are starting the final workflow to get the exciton-phonon properties.&lt;br /&gt;
&lt;br /&gt;
== Step 1: scf calculation ==&lt;br /&gt;
&lt;br /&gt;
First of all, we run a standard scf calculation with &amp;lt;code&amp;gt;pw.x&amp;lt;/code&amp;gt; for Yambo. We stick with non-symmorphic symmetries. At the end, we will have the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
This is the input &amp;lt;code&amp;gt;mos2.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;scf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
Here we are using full relativistic pseudopotentials from the SG-15 database.&lt;br /&gt;
&lt;br /&gt;
We can run it on our machine (for example using 4 MPI tasks) as:&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
== Step 2: nscf calculation for Yambo ==&lt;br /&gt;
&lt;br /&gt;
Copy the QE &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the scf calculation and run the nscf calculation for any number of empty states, with the correct &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we want to use in Yambo. Here we are using a badly underconverged grid of 6x6x1.&lt;br /&gt;
&lt;br /&gt;
This reciprocal-space grid will also match the momentum transfer &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt; grid on which excitons and phonons will be defined!&lt;br /&gt;
&lt;br /&gt;
The electronic wavefunctions computed at this step and stored in the new nscf &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory will be used both by Yambo and by the electron-phonon code: this is important because using different sets of wavefunctions would lead to a phase mismatch issue in the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
The nscf input &amp;lt;code&amp;gt;mos2.nscf&amp;lt;/code&amp;gt; is&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
           wf_collect = .true.,&lt;br /&gt;
          calculation = &amp;quot;nscf&amp;quot;,&lt;br /&gt;
            verbosity = &#039;high&#039;,&lt;br /&gt;
           pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
               prefix = &amp;quot;mos2&amp;quot;,&lt;br /&gt;
               outdir = &#039;.&#039;,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;system&lt;br /&gt;
              ecutwfc = 100.0,&lt;br /&gt;
          occupations = &#039;fixed&#039;,&lt;br /&gt;
                ibrav = 4,&lt;br /&gt;
            celldm(1) = 5.9000811881,&lt;br /&gt;
            celldm(3) = 6.7795677253,&lt;br /&gt;
                  nat = 3,&lt;br /&gt;
                 ntyp = 2,&lt;br /&gt;
             lspinorb = .true.&lt;br /&gt;
             noncolin = .true.&lt;br /&gt;
                nbnd  = 250&lt;br /&gt;
             assume_isolated = &#039;2D&#039;&lt;br /&gt;
         force_symmorphic = .true.&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
  &amp;amp;electrons&lt;br /&gt;
     electron_maxstep = 200,&lt;br /&gt;
          mixing_beta = 0.7,&lt;br /&gt;
             conv_thr = 1.d-08,&lt;br /&gt;
  /&amp;amp;end&lt;br /&gt;
   ATOMIC_SPECIES&lt;br /&gt;
    Mo  95.940      Mo_ONCV_PBE_FR-1.0.upf&lt;br /&gt;
    S    32.065     S_ONCV_PBE_FR-1.1.upf&lt;br /&gt;
   ATOMIC_POSITIONS { crystal }&lt;br /&gt;
 Mo       0.333333333   0.666666667   0.000000000&lt;br /&gt;
 S        0.666666667   0.333333333   0.073413577&lt;br /&gt;
 S        0.666666667   0.333333333  -0.073413577&lt;br /&gt;
  K_POINTS { automatic }&lt;br /&gt;
 6 6 1 0 0 0&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Again, we run the calculation&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp mos2.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
== Step 3: dvscf phonon calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we run the phonon calculation.&lt;br /&gt;
&lt;br /&gt;
Copy the &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; directory from the &#039;&#039;&#039;scf&#039;&#039;&#039; calculation and run &amp;lt;code&amp;gt;ph.x&amp;lt;/code&amp;gt; for a dvscf calculation with a standard &amp;lt;code&amp;gt;q&amp;lt;/code&amp;gt;-grid matching the &amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;-grid we wanna use in Yambo.&lt;br /&gt;
&lt;br /&gt;
At the end, we will have the &amp;lt;code&amp;gt;_ph0&amp;lt;/code&amp;gt; directory containing the variation of the self-consistent potential, &amp;lt;math&amp;gt;\Delta V_{SCF}(q)&amp;lt;/math&amp;gt;, and the &amp;lt;code&amp;gt;*.dyn&amp;lt;/code&amp;gt; files with the phonon energies and eigenvectors.&lt;br /&gt;
&lt;br /&gt;
NB: one could further refine the phonon energies by enforcing the acoustic sum rule, including non-analytic long-range contributions, interpolating to finer grids... all of this can be done within Quantum ESPRESSO and will not be covered in this version of the tutorial.&lt;br /&gt;
&lt;br /&gt;
The input is &amp;lt;code&amp;gt;mos2.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &lt;br /&gt;
 mos2_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;mos2&#039;,&lt;br /&gt;
   fildvscf = &#039;mos2-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;mos2.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=1&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
And now we run as&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 ph.x -inp mos2.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
This time we use nohup and more processes because this calculation may take some time. It is a good idea to set &amp;lt;code&amp;gt;recover=.true.&amp;lt;/code&amp;gt; as in a real calculation you will easily breach walltime, and in this way you can safely restart.&lt;br /&gt;
&lt;br /&gt;
== Step 4: create Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory ==&lt;br /&gt;
&lt;br /&gt;
This is just the standard Yambo initialization: run &lt;br /&gt;
 &lt;br /&gt;
 p2y &lt;br /&gt;
&lt;br /&gt;
and then &lt;br /&gt;
&lt;br /&gt;
 yambo &lt;br /&gt;
&lt;br /&gt;
in the &#039;&#039;&#039;nscf&#039;&#039;&#039; &amp;lt;code&amp;gt;save&amp;lt;/code&amp;gt; folder and then move the newly generated &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory to a convenient place.&lt;br /&gt;
&lt;br /&gt;
== Step 5: run a BSE calculation ==&lt;br /&gt;
&lt;br /&gt;
Now we switch from QE to Yambo. Here, we forgo the GW step for simplicity (we can use a scissor operator to open the band gap).&lt;br /&gt;
&lt;br /&gt;
This calculation has a couple of differences with respect to a standard BSE calculation for optical absorption. We can look at the input file &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Runlevels&amp;lt;/span&amp;gt;&lt;br /&gt;
 optics                       # [R OPT] Optics&lt;br /&gt;
 rim_cut                      # [R RIM CUT] Coulomb potential&lt;br /&gt;
 bss                          # [R BSS] Bethe Salpeter Equation solver&lt;br /&gt;
 em1s                         # [R Xs] Static Inverse Dielectric Matrix&lt;br /&gt;
 bse                          # [R BSE] Bethe Salpeter Equation.&lt;br /&gt;
 bsk                          # [R BSK] Bethe Salpeter Equation kernel&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# RIM and cutoff settings&amp;lt;/span&amp;gt;&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 X/Y/Z/XY..&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Static screening&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_and_IO_CPU= &amp;quot;1 1 4 2 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;
 Chimod= &amp;quot;hartree&amp;quot;            # [X] IP/Hartree/ALDA/LRC/BSfxc&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 |  200 |                 # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 8000            mRy    # [Xs] Response block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# BSE&amp;lt;/span&amp;gt;&lt;br /&gt;
 BS_CPU= &amp;quot;4.1.2&amp;quot;                   # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k.eh.t&amp;quot;                 # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_diago=4              # [PARALLEL] CPUs for matrix diagonalization&lt;br /&gt;
 BSEmod= &amp;quot;causal&amp;quot;             # [BSE] resonant/causal/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                  # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  40000      mRy    # [BSK] Exchange components&lt;br /&gt;
 ALLGexx                      # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  8000       mRy    # [BSK] Screened interaction block size&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind=&amp;quot;full&amp;quot;                  #[BSE,X] bar(default)/full/tilde&amp;lt;/span&amp;gt;&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.00000 |  4.00000 | eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
   0.05000 |  0.05000 | eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 2000               # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 7 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BSEBands&lt;br /&gt;
    25 |  28 |                 # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                      # [BSS] Write to disk excitonic the FWs&lt;br /&gt;
 &lt;br /&gt;
This file was generated using the command: &amp;lt;code&amp;gt; yambo -X s -o b -k sex -y d -r&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all, we compute the excitons for all the momenta in the irreducible Brillouin zone for our discrete grid via the &amp;lt;code&amp;gt;BSEQptR&amp;lt;/code&amp;gt; variable. This will be a &#039;&#039;&#039;finite-momentum&#039;&#039;&#039; BSE calculation, analogous to the phonon one.&lt;br /&gt;
&lt;br /&gt;
Second, we change the variable &amp;lt;code&amp;gt;Lkind&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;full&amp;lt;/code&amp;gt;. In Yambo, &amp;lt;code&amp;gt;Lkind=&amp;quot;bar&amp;quot;&amp;lt;/code&amp;gt;, which is the default for optical absorption, means that we are computing the excitonic response function without the long-range component of the exchange interaction. This cannot be used when computing the exciton momentum dependence, where the long-range exchange interaction can play a role, therefore we have to include it with &amp;lt;code&amp;gt;Lkind=&amp;quot;full&amp;quot;&amp;lt;/code&amp;gt;. This allows for the calculation of the excitonic longitudinal-transverse splitting (in 3D systems) as well.&lt;br /&gt;
&lt;br /&gt;
We can now run the code:&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
At the end of the calculation, we have obtained the &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; databases inside the directory &amp;lt;code&amp;gt;bse_Lfull&amp;lt;/code&amp;gt;. They contain information on the exciton energies and wavefunctions at each momentum. Do not forget to check the report and logs of your calculation in the same directory to make sure that the code is doing what you want.&lt;br /&gt;
&lt;br /&gt;
== Step 6: obtain the electron-phonon matrix elements ==&lt;br /&gt;
&lt;br /&gt;
We have finished the heavy simulations. Now it&#039;s time for the postprocessing. The first order of business is the reconstruction of the electron-phonon coupling matrix elements from the dvscf results and the electronic wavefunctions.&lt;br /&gt;
&lt;br /&gt;
In order to do this, we will run the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable of the &#039;&#039;&#039;LetzElPhC&#039;&#039;&#039; code. We will run via command line using yambopy, although it will be instructive to have look at the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; input files later.&lt;br /&gt;
&lt;br /&gt;
We run in the same directory where the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; is (remember than you can also virtually move it with a symbolic link).&lt;br /&gt;
&lt;br /&gt;
Type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y&lt;br /&gt;
&lt;br /&gt;
to see the help for the calculation. Have a look at the various flags and their description.&lt;br /&gt;
For example, if we want to do a serial run of LetzElPhC for bands from &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt;, we should type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/ph_input.in -b n_i n_f&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;math&amp;gt;n_i&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;n_f&amp;lt;/math&amp;gt; are integers representing the initial and final band indices. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 1 and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f]&amp;lt;/math&amp;gt; including the extrema of the interval.&lt;br /&gt;
&lt;br /&gt;
These should coincide with those used for the Bethe-Salpeter kernel, i.e. those specified in the &amp;lt;code&amp;gt;BSEBands&amp;lt;/code&amp;gt; variable of the BSE input file (this is not strictly necessary, but certainly efficient since these calculations use a lot of disk space). &lt;br /&gt;
&lt;br /&gt;
For our system, we want to do a parallel calculation with 4 qpools and 2 kpools. In addition, we want to explicitly specify the path of the &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; executable and avoid automatically deleting the LetzElPhC data. So we type:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/mos2.dvscf -b 25 28 -par 4 2 -lelphc path/to/lelphc_exe&lt;br /&gt;
&lt;br /&gt;
At the end, check your directory: you should find the &amp;lt;code&amp;gt;lelphc.in&amp;lt;/code&amp;gt; input file that was run, let&#039;s inspect it: &lt;br /&gt;
&lt;br /&gt;
 # LetzElPhC input for yambo generated by yambopy&lt;br /&gt;
 nqpool      = 2&lt;br /&gt;
 nkpool      = 4&lt;br /&gt;
 start_bnd   = 25&lt;br /&gt;
 end_bnd     = 28&lt;br /&gt;
 save_dir    = ./SAVE&lt;br /&gt;
 kernel      = dfpt&lt;br /&gt;
 ph_save_dir = dvscf/ph_save&lt;br /&gt;
 convention = yambo&lt;br /&gt;
&lt;br /&gt;
Notice the variable &amp;lt;code&amp;gt;convention=yambo&amp;lt;/code&amp;gt;: what does it mean? At variance with QE and many other codes, Yambo uses the &amp;quot;backward&amp;quot; momentum transfer convention for electronic scatterings. That is, an electronic transition goes from band &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k-q&amp;lt;/math&amp;gt; to band &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; and momentum &amp;lt;math&amp;gt;k&amp;lt;/math&amp;gt;. In the &amp;quot;forward&amp;quot; momentum transfer convention (the more standard one), the transitions go from &amp;lt;math&amp;gt;nk&amp;lt;/math&amp;gt; to &amp;lt;math&amp;gt;mk+q&amp;lt;/math&amp;gt;. Therefore, this variable ensures that the electron-phonon coupling matrix elements are computed as &amp;lt;math&amp;gt;\langle mk|dV|nk-q\rangle&amp;lt;/math&amp;gt;. This will have consequences also in the formulation of the &#039;&#039;exciton&#039;&#039;-phonon coupling matrix element.&lt;br /&gt;
&lt;br /&gt;
You will also find a &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; database that contains the computed electron-phonon matrix elements, in the output format of &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In addition, if you check the &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder:&lt;br /&gt;
&lt;br /&gt;
 ls SAVE/ndb.elph_gkkp*&lt;br /&gt;
&lt;br /&gt;
you will see that yambopy has created the Yambo-compatible electron-phonon databases.&lt;br /&gt;
&lt;br /&gt;
If you want to run LetzElPhC directly, without using yambopy, you can refer to its [https://github.com/yambo-code/LetzElPhC/blob/main/docs/tex_doc/main.pdf|user guide].&lt;br /&gt;
Keep in mind that in this case, in order to convert the database to the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases of Yambo, you will then need a couple of lines of python using the Yambopy class &amp;lt;code&amp;gt;ConvertElectronPhononDB&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;yambopy/letzelph_interface/lelph2y.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph_gkkp*&amp;lt;/code&amp;gt; databases -- e.g., because you are doing the exc-ph postprocessing with yambopy -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_gkkp&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases -- e.g., because you are using &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; for the exc-ph part -- you can run &amp;lt;code&amp;gt;yambopy l2y ...&amp;lt;/code&amp;gt; with the &amp;lt;code&amp;gt;--no_lelphc_dbs&amp;lt;/code&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
== Step 7: Obtain the exciton-phonon coupling ==&lt;br /&gt;
&lt;br /&gt;
Now, we can finally access our basic building block for exciton-phonon physics. This could be done entirely in python (using &#039;&#039;&#039;Yambopy&#039;&#039;&#039;), or by running &#039;&#039;&#039;Yambo&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambo postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (running yambo inputs with the &amp;lt;code&amp;gt;yambo_ph&amp;lt;/code&amp;gt; executable), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;follow the alternative route to Steps 7-8 [[Exciton-phonon coupling and luminescence - Yambo postprocessing|at this link]]&#039;&#039;&#039;&amp;lt;/span&amp;gt;.&lt;br /&gt;
* For the &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Yambopy postprocessing&#039;&#039;&#039;&amp;lt;/span&amp;gt; case (using flexible python scripting), &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;keep following Steps 7-8 on this page&#039;&#039;&#039;&amp;lt;/span&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
Our objective is obtaining the following quantity: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\mathcal{G}^\mu_{\alpha\lambda}(0,q)=\sum_{vv^\prime c k} A^{\alpha, *}_{cv^\prime} (k, q) g_{vv^\prime}^\mu (k,q) A^{\lambda}_{cv}(k,0) - \sum_{cc^\prime vk} A^{\alpha, *}_{c^\prime v} (k+q, q) g_{c^\prime c}^\mu (k+q,q) A^{\lambda}_{cv}(k, 0)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;A^{\alpha}_{cv}(k,q)&amp;lt;/math&amp;gt; are the exciton coefficients extracted from the eigenvector of the two-particles Hamiltonian during the BSE calculation in step 5, while &amp;lt;math&amp;gt;g_{nm}^\mu (k,q)&amp;lt;/math&amp;gt; are the electron-phonon coupling matrix elements obtained in step 6. As you can see, the exciton &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; undergoes phonon-mediated scattering to state &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; via phonon mode &amp;lt;math&amp;gt;\mu&amp;lt;/math&amp;gt;. The scattering can happen for the hole (valence, &amp;lt;math&amp;gt;v&amp;lt;/math&amp;gt;) or for the electron (conduction, &amp;lt;math&amp;gt;c&amp;lt;/math&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
NB: &lt;br /&gt;
&lt;br /&gt;
(1) This is written in the &amp;quot;backward&amp;quot; momentum transfer convention used by Yambo. The momentum dependence is different in the &amp;quot;forward&amp;quot; transfer convention. &lt;br /&gt;
&lt;br /&gt;
(2) For simplicity, this is written for zero initial exciton momentum. This means that one of the two states involved in the phonon-mediated scattering process will be in the optical limit (and possibly an optically generated exciton), while the other state can have any momentum: this momentum will be the same as the phonon one. This matrix element can be used to describe phonon-assisted absorption and emission spectra.&lt;br /&gt;
&lt;br /&gt;
In order to calculate this quantity using python, we need the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases natively generated by the &amp;lt;code&amp;gt;LetzElPhC&amp;lt;/code&amp;gt; code, as well as the BSE databases &amp;lt;code&amp;gt;ndb.BS_diago_Q*&amp;lt;/code&amp;gt; containing the information on exciton wavefunctions and energies.&lt;br /&gt;
&lt;br /&gt;
Next, we write a python user script importing the yambopy exciton-phonon tools. You can find a version of this script in &amp;lt;code&amp;gt;yambopy/tutorials/exciton-phonon/calculate_excph.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np &lt;br /&gt;
 from yambopy import YamboLatticeDB,YamboWFDB,LetzElphElectronPhononDB &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific Yambopy dbs loading classes&amp;lt;/span&amp;gt;&lt;br /&gt;
 from yambopy.exciton_phonon.excph_matrix_elements import exciton_phonon_matelem &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;#Specific exc-ph functions&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 path = &#039;1L_MoS2&#039;&lt;br /&gt;
 bands_range=[24,28] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence bands, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# number of excitonic states&amp;lt;/span&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 bsepath    = f&#039;{path}/bse-allq_full&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lin=Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath   = f&#039;{path}/SAVE&#039;     &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Yambo SAVE&amp;lt;/span&amp;gt;&lt;br /&gt;
 ndb_elph   = f&#039;{path}/ndb.elph&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# LetzElPhC electron-phonon database (any convention)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice&amp;lt;/span&amp;gt;&lt;br /&gt;
 lattice = YamboLatticeDB.from_db_file(filename=f&#039;{savepath}/ns.db1&#039;)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read electron-phonon&amp;lt;/span&amp;gt;&lt;br /&gt;
 elph    = LetzElphElectronPhononDB(ndb_elph,read_all=False)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read wave functions&amp;lt;/span&amp;gt;&lt;br /&gt;
 wfcs    = YamboWFDB(filename=&#039;ns.wf&#039;,save=savepath,latdb=lattice,bands_range=bands_range)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Calculate exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 exph = exciton_phonon_matelem(lattice,elph,wfcs,BSE_dir=bsepath,nexc_in=nexc,nexc_out=nexc,dmat_mode=&#039;save&#039;,exph_file=&#039;MoS2_Ex-ph.npy&#039;)&lt;br /&gt;
&lt;br /&gt;
In this script, we can select the number exciton states &amp;lt;math&amp;gt;\lambda&amp;lt;/math&amp;gt; with &amp;lt;code&amp;gt;nexc&amp;lt;/code&amp;gt;, the single-particle bands range with &amp;lt;code&amp;gt;bands_range&amp;lt;/code&amp;gt;. &#039;&#039;&#039;Please note&#039;&#039;&#039;: in this case, the band index starts from 0 (python indexing) and the the interval of bands read by the code is &amp;lt;math&amp;gt;[n_i,n_f)&amp;lt;/math&amp;gt;, therefore the last value (28 in the example) is excluded. That is, in the example we are selecting the 25th, 26th, 27th and 28th bands. Those bands have to be present in both the electron-phonon and BSE calculations. &lt;br /&gt;
&lt;br /&gt;
Here we calculate the couplings of the first twelve states at each finite-&amp;lt;math&amp;gt;q&amp;lt;/math&amp;gt; point including &amp;lt;math&amp;gt;q=0&amp;lt;/math&amp;gt;. We also include all the nine phonon modes of monolayer MoS2. We also need access to the Yambo &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; directory in order to read the electronic wavefunctions: they are used to compute the electronic representation matrices (&amp;lt;code&amp;gt;dmat&amp;lt;/code&amp;gt; in the code). The argument &amp;lt;code&amp;gt;dmat_mode&amp;lt;/code&amp;gt; can be set to &amp;lt;code&amp;gt;&#039;load&#039;&amp;lt;/code&amp;gt; for subsequent calculations.&lt;br /&gt;
&lt;br /&gt;
When we are satisfied with the input, we run the code:&lt;br /&gt;
&lt;br /&gt;
 python calculate_excph.py&lt;br /&gt;
&lt;br /&gt;
If you check the output, you should find the &amp;lt;code&amp;gt;MoS2_Ex-ph.npy&amp;lt;/code&amp;gt; binary file in the directory where you ran.&lt;br /&gt;
&lt;br /&gt;
=== Analysis of the couplings ===&lt;br /&gt;
&lt;br /&gt;
It is a good idea to have a look at what we computed up to now in order to make sure nothing has gone wrong. &lt;br /&gt;
&lt;br /&gt;
It is not easy to know what to expect (apart from symmetry and gauge compliance of the matrix elements), but one can work out the exciton-phonon selection rules in advance, check that the magnitude is reasonable, etc.&lt;br /&gt;
&lt;br /&gt;
It is also not easy to meaningfully plot this quantity. We have to make sure that we are not breaking degenerate states, otherwise the plots will not be invariant. &lt;br /&gt;
&lt;br /&gt;
First of all, we have to know our system: in monolayer MoS&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;, the first four excitons are all doubly degenerate. The first exciton responsible for a bright peak in the absorption spectrum (the &#039;&#039;&#039;A&#039;&#039;&#039; peak), is the second state, corresponding to state indices &amp;lt;code&amp;gt;(3,4)&amp;lt;/code&amp;gt; in fortran indexing or &amp;lt;code&amp;gt;(2,3)&amp;lt;/code&amp;gt; in python indexing. &lt;br /&gt;
&lt;br /&gt;
All these information can be obtained by analyzing the BSE results (this stuff is explained in the BSE tutorials) and by knowledge of the system or class of systems from the literature.&lt;br /&gt;
&lt;br /&gt;
Thus, a good quantity to plot may be the norm of the matrix elements, summed over the degenerate subspace of exciton A, for a certain number of scattered final states mediated by certain phonon modes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;F_A(q)= \sqrt{ \sum_{\alpha \in A,\lambda,\mu} |\mathcal{G}_{\alpha\lambda}^\mu (0,q)|^2 }&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In order to do this, we create a python script &amp;lt;code&amp;gt;analyse_excph.py&amp;lt;/code&amp;gt; in which we first load the excph dabatases. &lt;br /&gt;
You can find a version of this script in the yambopy directory, in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;. &lt;br /&gt;
First, we select the exciton and phonon states to be included in &amp;lt;code&amp;gt;F_A&amp;lt;/code&amp;gt;, together with the path of databases and plot details:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Exciton &amp;quot;in&amp;quot; states&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_in  = [2,3]  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# First bright peak (A: 2,3 -- B: 6,7)&amp;lt;/span&amp;gt;&lt;br /&gt;
 exc_out = [0,1,2,3] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# first 4 states (dispersion of dark triplet state and A)&amp;lt;/span&amp;gt;&lt;br /&gt;
 ph_in  = &#039;all&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Paths of databases&amp;lt;/span&amp;gt;&lt;br /&gt;
 ns_db1 =f&#039;{path}/SAVE/ns.db1&#039;&lt;br /&gt;
 ns_ypy = &#039;MoS2_Ex-ph.npy&#039;&lt;br /&gt;
 &lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Then, we load the data:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Read lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 ylat = YamboLatticeDB.from_db_file(filename=ns_db1)&lt;br /&gt;
 print(ylat)&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Load exc-ph database&amp;lt;/span&amp;gt;&lt;br /&gt;
 X_py = np.load(ns_ypy)&lt;br /&gt;
 G_squared = np.abs(X_py)**2.&lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt;F_A(q)&amp;lt;/math&amp;gt; is obtained from a dedicated function as:&lt;br /&gt;
 &lt;br /&gt;
 if exc_in  == &#039;all&#039;: exc_in  = range(G_squared.shape[2])&lt;br /&gt;
 if exc_out == &#039;all&#039;: exc_out = range(G_squared.shape[3])&lt;br /&gt;
 if ph_in   == &#039;all&#039;: ph_in   = range(G_squared.shape[1])&lt;br /&gt;
 &lt;br /&gt;
 G_squared = G_squared[:, ph_in, :, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_in, :].sum(axis=(1))&lt;br /&gt;
 G_squared = G_squared[:, exc_out].sum(axis=(1))&lt;br /&gt;
 &lt;br /&gt;
 F_q = np.sqrt( G_squared )*ha2ev &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Switch from Ha to eV&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally, we have to make a plotting function. For this tutorial we will use a custom scatterplot employing some of the plotting tools provided by yambopy (but you can do whatever you want).&lt;br /&gt;
&lt;br /&gt;
 plot_2D_excph(qgrid,G2_to_plot,rlat=ylat.rlat,plt_cbar=True,\&lt;br /&gt;
               marker=&#039;H&#039;,s=700,cmap=&#039;magma&#039;)&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
You can get more experience on using Yambopy for these kinds of visualization by following the [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy Yambopy tutorials]. In fact, remember that these scripts and all the other Yambopy tutorial scripts are just suggestions, not source code written in stone: if you know &amp;lt;code&amp;gt;numpy&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;matplotlib&amp;lt;/code&amp;gt; you can do your own analysis and your own plots, you just need to import the required Yambopy modules to load the data.&lt;br /&gt;
&lt;br /&gt;
In our case, the resulting plot is the following.&lt;br /&gt;
&lt;br /&gt;
[[File:1L MoS2 MoS2 Ex-ph.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
This can be checked against Fig. 2(d) of reference &amp;lt;ref name=&amp;quot;chan2023&amp;quot; /&amp;gt;, although you have to keep in mind that our results are badly undersampled in terms of the reciprocal-space grid, as can be easily seen, and the quantity plotted is not exactly the same. However, the main features are already there since they are dictated mostly by crystal symmetries.&lt;br /&gt;
&lt;br /&gt;
Now that we have the exciton-phonon matrix elements, we can use them to build several kinds of observables. Below, we give an example related to phonon-assisted luminescence, but we may update this tutorial in the future to include more cases.&lt;br /&gt;
&lt;br /&gt;
== Step 8: Compute phonon-assisted luminescence ==&lt;br /&gt;
&lt;br /&gt;
[[File:Luminescence scheme.png|250px|right]]&lt;br /&gt;
&lt;br /&gt;
We want to compute the experimental optical signature due to the phonon-assisted recombination of an exciton (as sketched in the figure).&lt;br /&gt;
&lt;br /&gt;
The signal from the phonon replicas can be modeled as a second-order scattering process involving one phonon and one photon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;I^{Sat}(\omega)=\frac{1}{ N_q} \frac{1}{3} \sum_{\epsilon s\beta \mu q} \frac{1}{E_{\beta q}-s\Omega_{\mu q}}\left|\sum_\alpha\frac{ D^{\epsilon}_\alpha \mathcal{G}_{\beta \alpha}^{\mu,*}(q)}{E_\alpha -E_{\beta q} +s\Omega_{\mu q}+\mathrm{i}\eta}\right|^2 \frac{N^{exc}_{\beta q}(T_{exc})[\frac{1+s}{2}+n_{\mu q}(T)]}{\omega -[E_{\beta q}-s\Omega_{\mu q}]+\mathrm{i}\eta}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this equation, the oscillator strength of the peak is given by the exciton-phonon coupling matrix elements &amp;lt;math&amp;gt;\mathcal{G}&amp;lt;/math&amp;gt; multiplied by the exciton dipoles &amp;lt;math&amp;gt;D&amp;lt;/math&amp;gt; (they are called &amp;quot;residuals&amp;quot; in Yambo). Here &amp;lt;math&amp;gt;E_\lambda&amp;lt;/math&amp;gt; and &amp;lt;math&amp;gt;E_{\alpha q}&amp;lt;/math&amp;gt; are the energies of the optical and finite-momentum excitons, respectively, while &amp;lt;math&amp;gt;\Omega_{\mu q}&amp;lt;/math&amp;gt; are the phonon energies. &lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;math&amp;gt;n_{\mu q}(T)&amp;lt;/math&amp;gt; is the temperature-dependent phonon Bose-Einstein occupation function. As it can be seen, &amp;lt;math&amp;gt;s=1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;emission&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)+1&amp;lt;/math&amp;gt;), while &amp;lt;math&amp;gt;s=-1&amp;lt;/math&amp;gt; corresponds to processes of phonon &#039;&#039;absorption&#039;&#039; (&amp;lt;math&amp;gt;\propto n(T)&amp;lt;/math&amp;gt;). Therefore, &amp;lt;math&amp;gt;I^{Sat}_{PL}(\omega;T)&amp;lt;/math&amp;gt; describes &#039;&#039;light&#039;&#039; emission by recombining excitons mediated by either &#039;&#039;phonon&#039;&#039; absorption or emission. &lt;br /&gt;
&lt;br /&gt;
The quantity &amp;lt;math&amp;gt; N_{\alpha q}(T_{exc})&amp;lt;/math&amp;gt; is the exciton occupation function. Luminescence is technically an out-of-equilibrium process, but we can assume that for very low density of excitations and in steady-state conditions, the exciton population can be approximately described by an equilibrium distribution evaluated at an effective temperature. Here, we use the Boltzmann distribution. Experimentally, &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; tends to coincide with the lattice temperature &amp;lt;math&amp;gt;T&amp;lt;/math&amp;gt; more or less above 100 K, while at very low temperature (&amp;lt; 10 K), &amp;lt;math&amp;gt;T_{exc}&amp;lt;/math&amp;gt; may vary between 10-50 K. It goes without saying that this needs to carefully be checked in your realistic calculations.&lt;br /&gt;
&lt;br /&gt;
Finally, the spectrum is averaged over the polarization directions of the emitted photons (&amp;lt;math&amp;gt;\epsilon=x,y,z&amp;lt;/math&amp;gt; representing the respective dipole components).&lt;br /&gt;
&lt;br /&gt;
=== Running the jobs ===&lt;br /&gt;
&lt;br /&gt;
In order to study luminescence in a paradigmatic system, we switch to bulk hexagonal boron nitride and we repeat the workflow. As you can easily see, one can think about automatizing the execution of all these calculations via scripting or more advanced tools. However, in the case of very large simulations (memory-limited or disk-space limited) or for systems whose electronic and lattice properties are fragile with respect to tiny calculation details, one must be very careful and run many basic tests.&lt;br /&gt;
&lt;br /&gt;
Fortunately, we are running a fast underconverged example. We use LDA pseudopotentials from the pseudo-dojo library and the following are the calculations steps.&lt;br /&gt;
&lt;br /&gt;
1. Input &amp;lt;code&amp;gt;hbn.scf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;scf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;,&lt;br /&gt;
     outdir = &#039;./tmp&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.scf &amp;gt; scf.out&lt;br /&gt;
&lt;br /&gt;
2. Input &amp;lt;code&amp;gt;hbn.nscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;control&lt;br /&gt;
     calculation=&#039;nscf&#039;,&lt;br /&gt;
     prefix=&#039;hBN&#039;,&lt;br /&gt;
     restart_mode=&#039;from_scratch&#039;&lt;br /&gt;
     pseudo_dir = &#039;$PSEUDO_DIR&#039;&lt;br /&gt;
     outdir = &#039;./&#039;&lt;br /&gt;
     verbosity = &#039;high&#039;&lt;br /&gt;
     wf_collect=.true.&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;system&lt;br /&gt;
     ibrav = 4,&lt;br /&gt;
     celldm(1) = 4.703675849&lt;br /&gt;
     celldm(3) = 2.603711434&lt;br /&gt;
     nat= 4,&lt;br /&gt;
     ntyp= 2,&lt;br /&gt;
     force_symmorphic=.true.&lt;br /&gt;
     ecutwfc = 100,&lt;br /&gt;
 	nbnd = 120&lt;br /&gt;
 /&lt;br /&gt;
 &amp;amp;electrons&lt;br /&gt;
   diago_david_ndim = 2&lt;br /&gt;
   diago_full_acc=.true.&lt;br /&gt;
   diago_thr_init=5.0e-6&lt;br /&gt;
   mixing_mode = &#039;plain&#039;&lt;br /&gt;
   mixing_beta = 0.7&lt;br /&gt;
   conv_thr =  1.0d-16&lt;br /&gt;
 /&lt;br /&gt;
 ATOMIC_SPECIES&lt;br /&gt;
  B 10.81100  B_LDA_dojo.UPF&lt;br /&gt;
  N 14.00674  N_LDA_dojo.UPF&lt;br /&gt;
 ATOMIC_POSITIONS {crystal}&lt;br /&gt;
 N             0.6666666670        0.3333333330        -0.250000000000&lt;br /&gt;
 B             0.3333333330        0.6666666670        -0.250000000000&lt;br /&gt;
 B             0.6666666670        0.3333333330        0.25000000000&lt;br /&gt;
 N             0.3333333330        0.6666666670        0.25000000000&lt;br /&gt;
 K_POINTS {automatic}&lt;br /&gt;
 6 6 2 0 0 0&lt;br /&gt;
&lt;br /&gt;
 mpirun -np 4 pw.x -inp hbn.nscf &amp;gt; nscf.out&lt;br /&gt;
&lt;br /&gt;
3. Input &amp;lt;code&amp;gt;hbn.dvscf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 hbn_dvscf&lt;br /&gt;
 &amp;amp;inputph&lt;br /&gt;
   tr2_ph=1.0d-12,&lt;br /&gt;
   verbosity=&#039;high&#039;&lt;br /&gt;
   prefix=&#039;hBN&#039;,&lt;br /&gt;
   fildvscf = &#039;hBN-dvscf&#039;,&lt;br /&gt;
   electron_phonon = &#039;dvscf&#039;,&lt;br /&gt;
   fildyn=&#039;hBN.dyn&#039;,&lt;br /&gt;
   epsil=.false.,&lt;br /&gt;
   ldisp=.true.,&lt;br /&gt;
   recover=.true.,&lt;br /&gt;
   nq1=6,&lt;br /&gt;
   nq2=6,&lt;br /&gt;
   nq3=2&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 pw.x -inp hbn.dvscf &amp;gt; dvscf.out &amp;amp;&lt;br /&gt;
&lt;br /&gt;
4. Input &amp;lt;code&amp;gt;bse.in&amp;lt;/code&amp;gt; (we include 2 valence and 2 conduction bands):&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 em1s&lt;br /&gt;
 DIP_CPU= &amp;quot;1 8 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 8 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;
 BS_CPU= &amp;quot;8 1 1&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 BS_ROLEs= &amp;quot;k eh t&amp;quot;                     # [PARALLEL] CPUs roles (k,eh,t)&lt;br /&gt;
 BS_nCPU_LinAlg_INV=-1            # [PARALLEL] CPUs for Linear Algebra (if -1 it is automatically set)&lt;br /&gt;
 BS_nCPU_LinAlg_DIAGO=-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;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 % QpntsRXs&lt;br /&gt;
    1 | 14 |                         # [Xs] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
    1 | 120 |                         # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 NGsBlkXs= 10                Ry    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lfull&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 % DipBands&lt;br /&gt;
    1 | 120 |                         # [DIP] Bands range for dipoles&lt;br /&gt;
 %&lt;br /&gt;
 DipApproach= &amp;quot;G-space v&amp;quot;         # [DIP] [G-space v/R-space x/Covariant/Shifted grids]&lt;br /&gt;
 DipComputed= &amp;quot;R V P&amp;quot;             # [DIP] [default R P V; extra P2 Spin Orb]&lt;br /&gt;
 BSENGexx= 30000            Ry    # [BSK] Exchange components&lt;br /&gt;
 #ALLGexx                       # [BSS] Force the use use all RL vectors for the exchange part&lt;br /&gt;
 BSENGBlk=  9000            Ry    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
  1.25997 | 1.08816 | 1.12683 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 14 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEBands&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   7 | 10 |                         # [BSK] Bands range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   0.50000 | 8.00000 |         eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
  0.050000 | 0.050000 |         eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 1000                    # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
&lt;br /&gt;
 nohup mpirun -np 8 yambo -F bse.in -J bse_Lfull -C bse_Lfull &amp;amp;&lt;br /&gt;
&lt;br /&gt;
Importantly, since we want to describe the phonon-assisted recombination process of an *optical* exciton (i.e., emitting a transverse photon), this time we also run an additional calculation at `Q=0` omitting the nonanalytic long-range Coulomb exchange. Make a second input &amp;lt;code&amp;gt;bse_Lbar.in&amp;lt;/code&amp;gt; with the following changes: &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Lkind= &amp;quot;Lbar&amp;quot;                    # [BSE] Lbar (default) / full&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;% BSEQptR&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 |                     # [BSK] Transferred momenta range&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;%&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4b. So now we make a second BSE run in a different directory specified by &amp;lt;code&amp;gt;-J&amp;lt;/code&amp;gt;. Here, we also pass to yambo the directory of the previous run as it includes the important screening databases &amp;lt;code&amp;gt;ndb.em1s*&amp;lt;/code&amp;gt; that we do not want to recompute from scratch.&lt;br /&gt;
 &lt;br /&gt;
 mpirun -np 8 yambo -F bse_Lbar.in -J bse_Lbar,bse_Lfull -C bse_Lbar&lt;br /&gt;
&lt;br /&gt;
5. Now we run &amp;lt;code&amp;gt;lelphc&amp;lt;/code&amp;gt; (with or without yambopy: in the latter case remember the option &amp;lt;code&amp;gt;-D&amp;lt;/code&amp;gt;) to get the el-ph matrix elements, particularly the &amp;lt;code&amp;gt;ndb.elph&amp;lt;/code&amp;gt; databases:&lt;br /&gt;
&lt;br /&gt;
 yambopy l2y -ph path/of/dvscf/hbn.dvscf -b 7 10 -par 4 2 -D&lt;br /&gt;
&lt;br /&gt;
=== Luminescence calculation ===&lt;br /&gt;
&lt;br /&gt;
6. And finally we calculate exciton-phonon matrix elements and the luminescence spectrum in one go using a python script importing the Yambopy exciton-phonon tools: in order to do this, we need to take a look at all the necessary input variables for the formula written above.&lt;br /&gt;
&lt;br /&gt;
We can start from the script &amp;lt;code&amp;gt;luminescence.py&amp;lt;/code&amp;gt; available in &amp;lt;code&amp;gt;tutorials/exciton-phonon&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 import numpy as np&lt;br /&gt;
 import matplotlib.pyplot as plt&lt;br /&gt;
 from yambopy.exciton_phonon.excph_luminescence import exc_ph_luminescence&lt;br /&gt;
 from yambopy.exciton_phonon.excph_input_data import exc_ph_get_inputs&lt;br /&gt;
&lt;br /&gt;
We import the necessary tools...&lt;br /&gt;
&lt;br /&gt;
 path = &#039;3D_hBN&#039;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation (Lout--&amp;gt; response is Lfull)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bsepath =  f&#039;{path}/bse_Lfull&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q* databases are needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to BSE calculation for optically active exciton (Lin --&amp;gt; response is Lbar)&amp;lt;/span&amp;gt;&lt;br /&gt;
 bseBARpath =  f&#039;{path}/bse_Lbar&#039;  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.BS_diago_Q1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to electron-phonon calculation&amp;lt;/span&amp;gt;&lt;br /&gt;
 elphpath = path &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.elph is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to unprojected dipoles matrix elements (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 dipolespath = bsepath &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ndb.dipoles is needed (optional)&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Path to lattice and k-space info&amp;lt;/span&amp;gt;&lt;br /&gt;
 savepath = f&#039;{path}/SAVE&#039; &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# ns.db1 database is needed&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... and we specify the paths to the necessary databases. Note that, if we want to perform polarization averaging, we have to recompute the excitonic dipoles in python as seen here.&lt;br /&gt;
&lt;br /&gt;
What about &amp;lt;code&amp;gt;bseBARpath&amp;lt;/code&amp;gt;? This variable points to the directory where the databases for the optical (zero-momentum) excitons &amp;lt;math&amp;gt;\alpha&amp;lt;/math&amp;gt; (which may be computed with &amp;lt;code&amp;gt;Lkind=&#039;Lbar&#039;&amp;lt;/code&amp;gt;) is located, which can be different from the directory with the full indirect exciton dispersion &amp;lt;math&amp;gt;\beta&amp;lt;/math&amp;gt; (usually computed with &amp;lt;code&amp;gt;Lkind=&#039;Lfull&#039;&amp;lt;/code&amp;gt;, however &amp;lt;code&amp;gt;Lkind=&#039;Ltilde&#039;&amp;lt;/code&amp;gt; can also be used if one is interested in &amp;quot;irreducible&amp;quot; excitons). This makes it possible to compute the coupling between different exciton kinds.&lt;br /&gt;
&lt;br /&gt;
 bands_range=[6,10] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 2 valence, 2 conduction bands&amp;lt;/span&amp;gt;&lt;br /&gt;
 phonons_range=[0,12] &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# All phonons&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_out = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at each momentum (Lout)&amp;lt;/span&amp;gt;&lt;br /&gt;
 nexc_in  = 12 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# 12 excitonic states at Q=0 (Lin)&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_ph  = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Lattice temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
 T_exc = 10 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Effective excitonic temperature&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 emin=4.4      &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Energy range and plot details (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
 emax=4.7&lt;br /&gt;
 estep=0.0002&lt;br /&gt;
 broad = 0.005 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Broadening parameter for peak width (in eV)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we specify the parameters for the calculation. We include valence bands from 7 to 10 (6 to 9 in python index) and the contribution of all 12 phonon modes. We consider 12 excitonic states for the coupling matrix elements.&lt;br /&gt;
&lt;br /&gt;
Here &amp;lt;code&amp;gt;T_ph&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;T_exc&amp;lt;/code&amp;gt; are the lattice and excitonic temperatures, respectively.&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate and load all the inputs:&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton-phonon matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Excitonic dipole matrix elements&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Exciton energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * Phonon energies&amp;lt;/span&amp;gt;&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# * We specify bse_path2=bseBARpath meaning we use Lbar calculation for Q=0 excitons&amp;lt;/span&amp;gt;&lt;br /&gt;
 input_data = exc_ph_get_inputs(savepath,elphpath,bsepath,\&lt;br /&gt;
                                bse_path2=bseBARpath,dipoles_path=dipolespath,\&lt;br /&gt;
                                nexc_in=12,nexc_out=12,\&lt;br /&gt;
                                bands_range=[6,10],phonons_range=[0,12])&lt;br /&gt;
&lt;br /&gt;
 ph_energies, exc_energies, exc_energies_in, G, exc_dipoles = input_data&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;exc_ph_get_inputs&amp;lt;/code&amp;gt; gives us all the input data for luminescence in the correct format: phonon energies, exciton energies, optical exciton energies (if needed), exciton-phonon matrix elements (calculated on the fly and printed to file), unprojected exciton dipoles (optional, calculated on the fly and printed to file).&lt;br /&gt;
The exc-ph matrix element calculation is just a wrapper of the same tools that we have tested in the above section on MoS2.&lt;br /&gt;
&lt;br /&gt;
Finally, there is the calculation of the luminescence spectrum via the function &amp;lt;code&amp;gt;exc_ph_luminescence&amp;lt;/code&amp;gt;:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# We calculate the luminescence spectrum including the input data from before&amp;lt;/span&amp;gt;&lt;br /&gt;
 w,PL = exc_ph_luminescence(T_ph,ph_energies,exc_energies,exc_dipoles,G,\&lt;br /&gt;
                            exc_energies_in=exc_energies_in,exc_temp=T_exc,\&lt;br /&gt;
                            nexc_out=nexc_out,nexc_in=nexc_in,emin=emin,emax=emax,\&lt;br /&gt;
                            estep=estep,broad=broad)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to print the luminescence data for later plotting, you can also add the following line to the script:&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;# Save to file&amp;lt;/span&amp;gt;&lt;br /&gt;
 data = np.column_stack((w, PL))&lt;br /&gt;
 np.savetxt(&amp;quot;hBN_luminescence_12x12x1.dat&amp;quot;, data, fmt=&amp;quot;%.8f&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
It is now time to run the whole script:&lt;br /&gt;
&lt;br /&gt;
 python luminescence.py&lt;br /&gt;
 &lt;br /&gt;
NB: By using Yambopy for Step 6, we have limited the use of the Yambo code to just step 4 in the entire workflow. This option is more flexible, as it allows for a greater degree of control by the user. On the other hand the Yambo postprocessing route features a Yambo-style input that doesn&#039;t require python knowledge and the calculation is currently faster in fortran. However, the luminescence expression computed in Yambo is a slightly different than this one: it is more approximated in the description of the satellite oscillator strengths, but it explicitly includes the renormalization of the direct exciton peak. You can check the differences [[Exciton-phonon coupling and luminescence - Yambo postprocessing|here]].&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
We can plot the results of the step 6 calculation. If we do it in the same script we can add something like this:&lt;br /&gt;
 fig = plt.figure()&lt;br /&gt;
 ax = fig.add_subplot(1,1,1)&lt;br /&gt;
 ax.set_xlim(emin,emax)&lt;br /&gt;
 ax.set_ylim(0,np.max(PL)*1.1)&lt;br /&gt;
 ax.get_yaxis().set_visible(False)&lt;br /&gt;
 &lt;br /&gt;
 ax.plot(w, PL, &#039;-&#039;,c=&#039;red&#039;, label=&amp;quot;AA&#039; hBN luminescence&amp;quot;)&lt;br /&gt;
 &lt;br /&gt;
 plt.legend()&lt;br /&gt;
 plt.savefig(&#039;hBN_luminescence.png&#039;)&lt;br /&gt;
 plt.show()&lt;br /&gt;
&lt;br /&gt;
[[File:HBN luminescence satellites.png|500px|center]]&lt;br /&gt;
&lt;br /&gt;
Here, the signal corresponds to a finite-momentum exciton that recombines with the help of several different phonon modes, both optical and acoustic. Each phonon mode whose coupling with the exciton is allowed can generate a peak, and the energy shifts of these peaks with respect to the initial exciton energy correspond to the phonon energies. This result is underconverged, but the main features are all there. In the plot, we show a more converged example using a 12x12x4 grid (all the other parameters being equal). These plots can be compared with Fig. 4(a) of reference &amp;lt;ref name=&amp;quot;zanfrognini2023&amp;quot; /&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;toyozawa2003&amp;quot; &amp;gt;Toyozawa, Yutaka, and Chris Oxlade, &#039;&#039;Optical processes in solids&#039;&#039;, [https://m.booksee.org/book/1121964?force_lang=en Cambridge University Press, (2003)]. &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;lechifflart2023&#039;&amp;gt;P. Lechifflart, F. Paleari, D. Sangalli, C. Attaccalite, &#039;&#039;First-principles study of luminescence in hexagonal boron nitride single layer: Exciton-phonon coupling and the role of substrate&#039;&#039;, &lt;br /&gt;
[https://doi.org/10.1103/PhysRevMaterials.7.024006 Phys. Rev. M, &#039;&#039;&#039;7&#039;&#039;&#039; (2), 024006 (2023)]; [https://arxiv.org/abs/2212.10407 arXiv2212.1047]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cannuccia2019&#039;&amp;gt;E. Cannuccia, B. Monserrat and C. Attaccalite, &#039;&#039;Theory of phonon-assisted luminescence in solids: Application to hexagonal boron nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]; [https://arxiv.org/abs/1807.11797 arXiv1807.11797]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019&#039;&amp;gt;F. Paleari et al., &#039;&#039;Exciton-Phonon Coupling in the Ultraviolet Absorption and Emission Spectra of Bulk Hexagonal Boron Nitride&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.122.187401 Phys. Rev. Lett. &#039;&#039;&#039;122&#039;&#039;&#039;, 187401 (2019)]; [https://arxiv.org/abs/1810.08976 arXiv1810.089776] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chen2020&#039;&amp;gt;&#039;&#039;Exciton-Phonon Interaction and Relaxation Times from First Principles&#039;&#039;,&lt;br /&gt;
Hsiao-Yi Chen, Davide Sangalli, and Marco Bernardi, [https://doi.org/10.1103/PhysRevLett.125.107401  Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 107401 (2020)]; [https://arxiv.org/abs/2002.08913 arXiv 2002.08913 (2020)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;lechifflart2023_PhD&amp;quot;&amp;gt;P. Lechifflart, &#039;&#039;Exciton-phonon coupling and phonon-assisted luminescence in hexagonal Boron Nitride nanostructures&#039;&#039;, [https://hal.science/tel-04266805v1 PhD Thesis, University of Marseille (2023)]; [https://www.yambo-code.eu/wiki/images/5/54/These_final.pdf From the yambo website]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2019_PhD&#039;&amp;gt;F. Paleari, &#039;&#039;First-principles approaches to the description of indirect absorption and luminescence spectroscopy: exciton-phonon coupling in hexagonal boron nitride&#039;&#039;, [https://wwwen.uni.lu/research/fstm/dphyms/people/fulvio_paleari PhD thesis, University of Luxembourg (2019)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;zanfrognini2023&#039;&amp;gt;M. Zanfrognini et al., &#039;&#039;Distinguishing different stackings in layered materials via luminescence spectroscopy&#039;&#039;, [https://doi.org/10.1103/PhysRevLett.131.206902 Phys. Rev. Lett. &#039;&#039;&#039;131&#039;&#039;&#039;, 206902 (2023)]; [https://arxiv.org/abs/2305.17554 arXiv 2305.17554] &amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;marini2024&#039;&amp;gt;G. Marini, M. Calandra, P. Cudazzo, &#039;&#039;Optical absorption and photoluminescence of single layer boron nitride from a first principles cumulant approach&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.4c00669 Nano Lett., &#039;&#039;&#039;24&#039;&#039;&#039;, 20, 6017 (2024)]; [https://arxiv.org/abs/2402.03826 arXiv 2402.03826 (2024)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;antonius2017&#039;&amp;gt;G. Antonius, S. G. Louie, &#039;&#039;Theory of exciton-phonon coupling&#039;&#039;, [https://doi.org/10.1103/PhysRevB.105.085111 Phys. Rev. B, &#039;&#039;&#039;105&#039;&#039;&#039;, 085111 (2022)]; [https://arxiv.org/abs/1705.04245 arXiv1705.04245 (2017)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;paleari2022&#039;&amp;gt; F. Paleari, and A. Marini, &#039;&#039;Exciton-phonon interaction calls for a revision of the “exciton” concept&#039;&#039;, [https://doi.org/10.1103/PhysRevB.106.125403 Phys. Rev. B, &#039;&#039;&#039;106&#039;&#039;&#039;, 125403 (2022)]; [https://arxiv.org/abs/2205.02783 arXiv 2205.02783]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;cudazzo2020&#039;&amp;gt; P. Cudazzo, &#039;&#039;First-principles description of the exciton-phonon interaction: A cumulant approach&#039;&#039;, [https://doi.org/10.1103/PhysRevB.102.045136 Phys. Rev. B, &#039;&#039;&#039;102&#039;&#039;&#039;, 045136 (2020)]; [https://orbilu.uni.lu/bitstream/10993/44769/1/main.pdf Open access pdf from Luxembourg University]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;chan2023&#039;&amp;gt;Y-h Chan, J. B. Haber, M. H. Naik, J. B. Neaton, D. Y. Qiu, F. H. da Jornada, S. G. Louie, &#039;&#039;Exciton Lifetime and Optical Line Width Profile via Exciton–Phonon Interactions: Theory and First-Principles Calculations for Monolayer MoS2&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.3c00732 Nano Lett., &#039;&#039;&#039;23&#039;&#039;&#039;, 9 (2023)]; [https://arxiv.org/abs/2212.08451 arXiv 2212.08451 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&#039;murali2025&#039;&amp;gt;M. Nalabothula, S. Reichardt, L. Wirtz, &#039;&#039;Origin of Interlayer Exciton–Phonon Coupling in 2D Heterostructures&#039;&#039;, [https://doi.org/10.1021/acs.nanolett.5c00355 Nano Lett., &#039;&#039;&#039;25&#039;&#039;&#039;, 15 (2025)], [https://arxiv.org/abs/2407.16111 arXiv 2407.16111 (2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=893</id>
		<title>Shift current</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=893"/>
		<updated>2026-03-17T13:40:10Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Shift current.png|right|200px | Shift_current]]&lt;br /&gt;
== Introduction ==&lt;br /&gt;
In this tutorial we will show how to calculate Shift Current in bulk materials.&amp;lt;br&amp;gt;&lt;br /&gt;
We suppose you are already familiar with the non-linear response using the Yambo code.&lt;br /&gt;
If it is not the case please study the previous tutorials: &amp;lt;br&amp;gt;[[Linear response using Dynamical Berry Phase]] and [[Real time approach to non-linear response (SHG)]].&amp;lt;br&amp;gt;&lt;br /&gt;
This theoretical implementation of this tutorial is described in the paper  &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; , please cite it if you use it. &amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial was created with the help of [https://www.linkedin.com/in/yuncheng-mao-8aba6279/ Yuncheng Mao].&lt;br /&gt;
&lt;br /&gt;
== Setup calculations ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will take as example the two dimensional GeS monolayer.&amp;lt;br&amp;gt;&lt;br /&gt;
DFT inputs can be downloaded here: [http://www.attaccalite.com/tutorials_yambo/GeS_DFT.tgz  GeS_DFT.tgz].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all run the setup, then remove symmetries along the &#039;&#039;&#039;y&#039;&#039;&#039; direction, as explained in the tutorial above.&lt;br /&gt;
&lt;br /&gt;
== Real-time setup and calculations ==&lt;br /&gt;
&lt;br /&gt;
In order to generate input file for shift current you do: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -u n -V par -F input.in&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 NLogCPUs=0                       # [PARALLEL] Live-timing CPU`s (0 for all)&lt;br /&gt;
 PAR_def_mode= &amp;quot;balanced&amp;quot;         # [PARALLEL] Default distribution mode (&amp;quot;balanced&amp;quot;/&amp;quot;memory&amp;quot;/&amp;quot;workload&amp;quot;/&amp;quot;KQmemory&amp;quot;)&lt;br /&gt;
 NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;quot;                     # [PARALLEL] CPUs roles (w,k)&lt;br /&gt;
 DIP_CPU= &amp;quot;&amp;quot;                      # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 OSCLL_CPU= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs for each role&lt;br /&gt;
 OSCLL_ROLEs= &amp;quot;&amp;quot;                  # [PARALLEL] CPUs roles (k,b)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 NL_Threads=0                     # [OPENMP/NL] Number of threads for nl-optics&lt;br /&gt;
 OSCLL_Threads=0                  # [OPENMP/X] Number of threads for Oscillators&lt;br /&gt;
 % NLBands&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;17 |  24 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime=-1.000000           fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;           # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX/LSEX/LHF&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 8.000000 &amp;lt;/span&amp;gt; |         eV    # [NL] Energy range (for loop on frequencies NLEnSteps/=0&lt;br /&gt;
 %&lt;br /&gt;
 NLEnSteps=  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;24     &amp;lt;/span&amp;gt;               # [NL] Energy steps for the loop on frequencies&lt;br /&gt;
 % NLrotaxis&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [NL] Rotation axis (for the loop on angles NLAngSteps/=0)&lt;br /&gt;
 %&lt;br /&gt;
 NLAngSteps=0                     # [NL] Angular steps (if NLAngSteps/=0 field versor will be ignored)&lt;br /&gt;
 NLDamping= 0.200000        eV    # [NL] Damping (or dephasing)&lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative RADLifeTime=Phase_LifeTime)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt;                    # [NL] Evaluate the current&lt;br /&gt;
 #FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field&lt;br /&gt;
 Field1_Freq= 0.100000      eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=  1000.00       kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 Field1_kind= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field1] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.000000 | 1.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # [RT Field1] Versor &lt;br /&gt;
 %&lt;br /&gt;
 Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time&lt;br /&gt;
&lt;br /&gt;
Notice that in this input we turned one the evaluation of current  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt; and force the parallelization on the frequencies, &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, that is much more efficient than the one on k-points.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Then you can run simulation by doing: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -F input.in&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of the results ==&lt;br /&gt;
&lt;br /&gt;
In order to analyze the result we use  Yambopy: [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy YamboPy],&amp;lt;br&amp;gt; and the following script for the post-processing:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.units import fs2aut&lt;br /&gt;
 &lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 &lt;br /&gt;
 SIN = Xn_from_sine(NLDB,X_order=4,l_out_current=True)&lt;br /&gt;
 print(SIN)&lt;br /&gt;
 OUT = SIN.perform_analysis()&lt;br /&gt;
 SIN.output_analysis(OUT)&lt;br /&gt;
 SIN.reconstruct_signal(OUT)&lt;br /&gt;
&lt;br /&gt;
This script will produce different file containing the response function of the current and polarization respect to the total field.&lt;br /&gt;
From the second order response of the current at zero frequency, file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0&amp;lt;/code&amp;gt;  we can extract the shift current coefficient along the &#039;y&#039; direction&lt;br /&gt;
that correspond to the 5th column of the file. In the file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
the first column ti the energy&lt;br /&gt;
&lt;br /&gt;
columns 2,3 are the imaginary and real part along x-direction&lt;br /&gt;
&lt;br /&gt;
columns 4,5 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
columns 6,7 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that the imaginary part is zero within the numerical precision.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Hereafter we report the shift current spectrum compared with the results of Ibañez-Azpiroz et al. &amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Sigma2.png|center| 800px | Shift current]]&lt;br /&gt;
&lt;br /&gt;
The python script to plot the results, the data from the Ibañez-Azpiroz paper can be downloaded here: [https://www.attaccalite.com/tutorials_yambo/GeS_plot.tgz GeS_plot].  &amp;lt;br&amp;gt;&lt;br /&gt;
In this example we used very few k-points, increasing the number of k-points bring the result very close to the one of Ibañez-Azpiroz, see also Supp. Mat. of Ref. &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; .&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that we rescale the shift-currect for an effective thickness of 2.65 Angstrom, you can find all the rescaling factor in the python script.&lt;br /&gt;
&lt;br /&gt;
Correlation effects can be included in the SC response in the same way we do for other non-linear response functions, for more info look at the tutorial:&lt;br /&gt;
[https://wiki.yambo-code.eu/wiki/index.php?title=SHG_within_the_TD-aGW_level_(also_called_TD-HSEX,_TD-BSE) SHG within the TD-aGW level (also called TD-HSEX, TD-BSE)]&lt;br /&gt;
&lt;br /&gt;
== References == &lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;Yuncheng Mao, Myrta Grüning, Ju Zhou, and Claudio Attaccalite, &#039;&#039;Shift current in 2D Janus Transition-Metal Dichalcogenides: the role of excitons&lt;br /&gt;
&#039;&#039;, [https://arxiv.org/abs/2506.16067 arXiv:2506.16067(2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;Julen Ibañez-Azpiroz, Stepan S. Tsirkin, and Ivo Souza, &#039;&#039;Ab initio calculation of the shift photocurrent by Wannier interpolation&#039;&#039;, [https://doi.org/10.1103/PhysRevB.107.205204  Phys. Rev. B &#039;&#039;&#039;107&#039;&#039;&#039;, 205204 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Sum_frequency_generation&amp;diff=890</id>
		<title>Sum frequency generation</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Sum_frequency_generation&amp;diff=890"/>
		<updated>2026-03-06T15:37:21Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the single run */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[[File:Sum frequency.jpg|right|500px |Sum frequency generation]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This tutorial is for internal use only, these response functions are not implemented/tested in yambo/yambopy suite.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show you how to calculate Sum Frequency Generation(SFG) and also Difference Frequency Generation (DFG) in bulk materials.&amp;lt;br&amp;gt;&lt;br /&gt;
We assume you are already familiar with the non-linear response using the Yambo code.&lt;br /&gt;
If it is not the case please refer to the previous tutorials:  &amp;lt;br&amp;gt;[[Linear response using Dynamical Berry Phase]] and [[Real time approach to non-linear response (SHG)]]&lt;br /&gt;
and Ref.&amp;lt;ref name=nl&amp;gt;[https://arxiv.org/abs/1309.4012 Nonlinear optics from an ab initio approach by means of the dynamical Berry phase: Application to second- and third-harmonic generation in semiconductors], C. Attaccalite and M. Grüning, Phys. Rev. B &#039;&#039;&#039;88&#039;&#039;&#039;, 235113(2013)&amp;lt;/ref&amp;gt;.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This tutorial has been made possible thanks to the work of [https://www.uni-giessen.de/de/fbz/fb07/fachgebiete/physik/institute/theorie/agsanna/people/mike-pionteck Mike N. Pionteck] published in Ref. &amp;lt;ref name=sfg&amp;gt;[https://arxiv.org/abs/2503.07095 Sum frequency generation from real-time simulations in two-dimensional crystals], M. N. Pionteck, M. Grüning, S. Sanna, C. Attaccalite&amp;lt;/ref&amp;gt;, results are also presented in this Libreoffice presentation [https://www.attaccalite.com/wp-content/uploads/2025/04/sum_frequency.odp sum_frequency.odp].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DFT calculations ==&lt;br /&gt;
In this example, we will consider a single layer of hexagonal boron nitride (hBN).&lt;br /&gt;
If you haven&#039;t already done so, you can download the input files and Yambo databases for this tutorial here: [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-RT.tar.gz hBN-2D-RT.tar.gz].&lt;br /&gt;
and/or follow the instructions to generate the databases here: [[Prerequisites for Real Time propagation with Yambo]]&lt;br /&gt;
&lt;br /&gt;
== Removing symmetries ==&lt;br /&gt;
In this tutorial we will calculate the SFG along when both fields are in the &#039;x&#039; direction, &lt;br /&gt;
therefore we remove symmetries not compatible with an external field along this direction, with the command &amp;lt;code&amp;gt; ypp_nl -y&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
 fixsyms                          # [R] Remove symmetries not consistent with an &lt;br /&gt;
 external perturbation&lt;br /&gt;
 % Efield1&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 0.000000 | 0.000000 | &amp;lt;/span&amp;gt;       # First external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 % Efield2&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # Additional external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BField= 0.000000           T     # [MAG] Magnetic field modulus&lt;br /&gt;
 Bpsi= 0.000000             deg   # [MAG] Magnetic field psi angle [degree]&lt;br /&gt;
 Btheta= 0.000000           deg   # [MAG] Magnetic field theta angle [degree]&lt;br /&gt;
 #RmAllSymm                     # Remove all symmetries&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RmTimeRev      &amp;lt;/span&amp;gt;               # Remove Time Reversal&lt;br /&gt;
 #RmSpaceInv                    # Remove Spatial Inversion&lt;br /&gt;
&lt;br /&gt;
==  Real-time simulation with two external fields ==&lt;br /&gt;
You go in the &amp;lt;code&amp;gt;FixSymm&amp;lt;/code&amp;gt; folder and run again the setup. Then you can put the following input file, that has been generated with the command  &amp;lt;code&amp;gt;yambo_nl -u n &amp;lt;/code&amp;gt;, in the folder with the name &amp;lt;code&amp;gt;yambo.in_sfg&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 NLogCPUs=0                       # [PARALLEL] Live-timing CPU`s (0 for all)&lt;br /&gt;
 PAR_def_mode= &amp;quot;balanced&amp;quot;         # [PARALLEL] Default distribution mode (&amp;quot;balanced&amp;quot;/&amp;quot;memory&amp;quot;/&amp;quot;workload&amp;quot;/&amp;quot;KQmemory&amp;quot;)&lt;br /&gt;
 NL_CPU= &amp;quot;10 1&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 NL_ROLEs= &amp;quot;w k&amp;quot;                     # [PARALLEL] CPUs roles (w,k)&lt;br /&gt;
 DIP_CPU= &amp;quot;&amp;quot;                      # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 NL_Threads=0                     # [OPENMP/NL] Number of threads for nl-optics&lt;br /&gt;
 % NLBands&lt;br /&gt;
    &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;3 |  6 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;70.00000 &amp;lt;/span&amp;gt;          fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;         # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2.000000 | 8.000000 |   &amp;lt;/span&amp;gt;      eV    # [NL] Energy range (for loop on frequencies NLEnSteps/=0&lt;br /&gt;
 %&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NLEnSteps= 30  &amp;lt;/span&amp;gt;                # [NL] Energy steps for the loop on frequencies&lt;br /&gt;
 % NLrotaxis&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [NL] Rotation axis (for the loop on angles NLAngSteps/=0)&lt;br /&gt;
 %&lt;br /&gt;
 NLAngSteps=0                     # [NL] Angular steps (if NLAngSteps/=0 field versor will be ignored)&lt;br /&gt;
 NLDamping= 0.200000        eV    # [NL] Damping (or dephasing)&lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative Yambo sets it equal to Phase_LifeTime in NL)&lt;br /&gt;
 #EvalCurrent                   # [NL] Evaluate the current&lt;br /&gt;
 #FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field&lt;br /&gt;
 HARRLvcs= 18475            RL    # [HA] Hartree     RL components&lt;br /&gt;
 EXXRLvcs= 18475            RL    # [XX] Exchange    RL components&lt;br /&gt;
 Field1_Freq=  -0.100000    eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1000.00 &amp;lt;/span&amp;gt;      kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 Field1_kind= &amp;quot; &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field1] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1.000000 | 0.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # [RT Field1] Versor&lt;br /&gt;
 %&lt;br /&gt;
 Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time&lt;br /&gt;
 Field2_Freq=  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;3.000000 &amp;lt;/span&amp;gt;    eV    # [RT Field2] Frequency&lt;br /&gt;
 Field2_Int=   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1000.00    &amp;lt;/span&amp;gt;   kWLm2 # [RT Field2] Intensity&lt;br /&gt;
 Field2_Width= 0.000000     fs    # [RT Field2] Width&lt;br /&gt;
 Field2_kind= &amp;quot; &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field2] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field2_pol= &amp;quot;linear&amp;quot;             # [RT Field2] Pol(linear|circular)&lt;br /&gt;
 % Field2_Dir&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 0.000000 | 0.000000 |  &amp;lt;/span&amp;gt;      # [RT Field2] Versor &lt;br /&gt;
 %&lt;br /&gt;
 Field2_Tstart= 0.010000    fs    # [RT Field2] Initial Time&lt;br /&gt;
&lt;br /&gt;
If you run this input file with the command &amp;lt;code&amp;gt;yambo_nl -F yambo.in_sfg&amp;lt;/code&amp;gt;, the code will run 30 simulations for a first laser field with frequency between 2.0 and 8.0 while the frequency of the second field is fixed at 3.0 eV. For this reason we provide you a simple python script to change also the frequency of the second field (in blue in the input).&amp;lt;br&amp;gt;&lt;br /&gt;
In the next section we will show how to analyse the non-linear response generated by the presence of two external fields.&lt;br /&gt;
&lt;br /&gt;
== Analysis of the single run ==&lt;br /&gt;
We will use new approach to extract analyze time-dependent polarization in presence of two laser fields &amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt; and used for the tutorials on second/third harmonic generation: [[Real time approach to non-linear response (SHG)]]. These new subroutine are available in the new YamboPy package. Hereafter the python script for the analysis:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.nl.sum_frequencies import SF_Harmonic_Analysis&lt;br /&gt;
 from yambopy.units import fs2aut&lt;br /&gt;
 X_order=4&lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 SIN2=Xn_from_freqmix(NLDB,X_order=X_order,T_range=[50.0*fs2aut,-1.0])&lt;br /&gt;
 print(SIN2)&lt;br /&gt;
 OUT=SIN2.perform_analysis()&lt;br /&gt;
 SIN2.output_analysis(OUT)&lt;br /&gt;
 SIN2.reconstruct_signal(OUT)&lt;br /&gt;
&lt;br /&gt;
Notice that we set the beginning of time range where analysis is performed with the variable &amp;lt;code&amp;gt;T_range=[50.0*fs2aut,-1.0]&amp;lt;/code&amp;gt;, you can also omit this variable and the code automatically will set the optimal range for the analysis using the damping given in input in the real-time simulation.&amp;lt;br&amp;gt;&lt;br /&gt;
This script will analyse the real-time response and produce all the different &amp;lt;math&amp;gt;\chi^{(n)}(\omega)&amp;lt;/math&amp;gt; in the form:&lt;br /&gt;
 &lt;br /&gt;
o.YamboPy-X_probe_order_1_0 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(1)}(\omega=\omega_1)&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-X_probe_order_1_1 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(2)}(\omega=\omega_1+\omega_2)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-X_probe_order_2_0 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(2)}(\omega=2\omega_1)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-X_probe_order_0_2 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(2)}(\omega=2\omega_2)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-X_probe_order_1_2 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(3)}(\omega=\omega_1+2\omega_2)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-X_probe_order_2_2 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(4)}(\omega=2\omega_1+2\omega_2)&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
etc....&lt;br /&gt;
&lt;br /&gt;
for example we can plot the 4 and 5 columns of the file &amp;lt;code&amp;gt;o.YamboPy-X_probe_order_1_1&amp;lt;/code&amp;gt; that corresponds to the  &amp;lt;math&amp;gt;\chi^{(2)}_{xyy} (\omega=\omega_1+\omega_2)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;\omega_2 =3.0~eV&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
[[File:Xhi2 11.png|center | 700px |xhi11]]&lt;br /&gt;
&lt;br /&gt;
Here the python script used to generate the previous figure: [https://www.attaccalite.com/tutorials_yambo/plot_xhi2_monolayer.py plot_xhi2_monolayer.py]&lt;br /&gt;
&lt;br /&gt;
=== Checking the Fourier analysis===&lt;br /&gt;
In the previous script we turned on the flag  &amp;lt;code&amp;gt;prn_Peff=True&amp;lt;/code&amp;gt; that automatically will produce a series of file to check if the Fourier was successful.&lt;br /&gt;
The files &amp;lt;code&amp;gt;  o.YamboPy-sampling_F1&amp;lt;/code&amp;gt; contain the sampling points used to fix the real-time polarization, you can for example plot  &amp;lt;code&amp;gt;o.YamboPy-sampling_F1&amp;lt;/code&amp;gt; vs &amp;lt;code&amp;gt;o.polarization_F1&amp;lt;/code&amp;gt; together to see which part of &amp;lt;math&amp;gt;P(t)&amp;lt;/math&amp;gt; is used to extract the response functions:&lt;br /&gt;
[[File:Sampling vs p.png|center| 700px |sampling_p]]&lt;br /&gt;
&lt;br /&gt;
Then you can check if real-time polarization is well reconstructed by the Fourier coefficients calculated by the script by plotting &amp;lt;code&amp;gt; o.YamboPy-pol_reconstructed_F1&amp;lt;/code&amp;gt; vs &amp;lt;code&amp;gt;o.polarization_F1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Reconstructed p vs p.png|center |700px |Reconstructed polarization]]&lt;br /&gt;
&lt;br /&gt;
As you see the polarization is well reconstructed starting from the extracted Fourier coefficients, expect for the beginning, but this is normal because the initial signal is affected by the internal eigen--modes of the systems that later are washed out by the de-phasing. For this reason we use only the last part of the signal for the analysis, for more details see Ref. &amp;lt;ref name=nl&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of all runs ==&lt;br /&gt;
For this reason we provide you a simple python script to change also the frequency of the second field (in blue in the input).&lt;br /&gt;
&lt;br /&gt;
[https://www.attaccalite.com/tutorials_yambo/run_many_sfg.py run_many_sfg.py]&lt;br /&gt;
&lt;br /&gt;
please modify the python script by set the correct path of your executable, the parallelization and the number of frequency steps you are interested in. In this example we will do &#039;&#039;&#039;30&#039;&#039;&#039; frequency steps for both the first (in the Yambo input) and the second field (in the python script).&lt;br /&gt;
&lt;br /&gt;
Calculations will take some time, in the above example we parallelized on 10 cores to speed up them. &amp;lt;br&amp;gt;&lt;br /&gt;
When the calculations are terminated you will find many folders called  EF1, EF2,  ... EF29.  These folders are generated from the loop on the second field frequency(Field2_Freq), and each one contains the response real-time polarization at 30 different frequencies of the first external field (Field1_Freq).&lt;br /&gt;
&lt;br /&gt;
Now we will use a script to read all the real-time polarization, Fourier analyze them as it was done in the previous section for a single one, and the write the &amp;lt;math&amp;gt;\chi^{(2)}(\omega=\omega_1 + \omega_2)&amp;lt;/math&amp;gt; in a file in the form: &amp;lt;math&amp;gt;\omega_1 , \omega_2, Re \{\chi^{(2)}\} , Im \{\chi^{(2)}\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[https://www.attaccalite.com/tutorials_yambo/analysis_sfg.py analysis_sfg.py]&lt;br /&gt;
&lt;br /&gt;
then we can interpolate the results &amp;lt;math&amp;gt;\chi^{(2)}(\omega)&amp;lt;/math&amp;gt; and plot results in 3D or 2D: [https://www.attaccalite.com/tutorials_yambo/plot_xhi_2d.py plot_xhi_2d.py], [https://www.attaccalite.com/tutorials_yambo/plot_xhi_3d.py plot_xhi_3d.py]&lt;br /&gt;
&lt;br /&gt;
[[File:SFG 3D.png|center | 700px|SFG 3D]]&lt;br /&gt;
 &lt;br /&gt;
[[File:SFG 2D.png|center | 500px|SFG in 2D]]&lt;br /&gt;
&lt;br /&gt;
You can compare these results with those of Ref.&amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt;. Note that in order to get fully converged results, you need to increase: the number of k-points, the length of the simulations, and the number of frequencies used in the plots. Converged parameters for this system can be found in Ref.&amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt;, including all details to include excitonic effects.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: In case of degenerate or multiple frequencies &amp;lt;math&amp;gt;\omega_1 = n \omega_2&amp;lt;/math&amp;gt; where  &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is an integer, the algorithm used to extract the SFG/DFG coefficient could not converge. In this case you can discard these points and use the neighbour solution for interpolation, see discussion in reference &amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt;. Another possibility is to use a least-squares fit algohrithm that starts from the neighbour solution to find the SFG/DFG coefficents, this is implemented in YamboPy in the sum_frequency.py file, but is commented.&lt;br /&gt;
&lt;br /&gt;
== Comparison with SHG ==&lt;br /&gt;
&lt;br /&gt;
Finally you can compare the diagonal of &amp;lt;math&amp;gt;\chi^{(2)}(\omega=\omega_1 +\omega_2)&amp;lt;/math&amp;gt;, when &amp;lt;math&amp;gt;\omega_1 =\omega_2&amp;lt;/math&amp;gt;, with the standard second harmonic generation &amp;lt;math&amp;gt;\chi^{(2)}(\omega=2 \omega_1)&amp;lt;/math&amp;gt; calculated as explained in the tutorial [[Real time approach to non-linear response (SHG)]]:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Xhi2 vs xhi2.png|center | 700px|xhi2_vs_xhi2]]&lt;br /&gt;
&lt;br /&gt;
Notice that there is factor two between the two response functions, this is the so-called degeneracy factor, for more details see Sec. 1.3 in Ref.&amp;lt;ref&amp;gt;Boyd, Robert W., Alexander L. Gaeta, and Enno Giese. &amp;quot;Nonlinear optics.&amp;quot; Springer Handbook of Atomic, Molecular, and Optical Physics. Cham: Springer International Publishing, 1097-1110.(2008)&amp;lt;/ref&amp;gt;. The small differences between the two spectra are given the different sampling strategies of the &amp;lt;code&amp;gt;SF_Harmonic_Analysis&amp;lt;/code&amp;gt; function respect to the &amp;lt;code&amp;gt;Harmonic_Analysis&amp;lt;/code&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=889</id>
		<title>Shift current</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=889"/>
		<updated>2026-03-06T14:31:01Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Shift current.png|right|200px | Shift_current]]&lt;br /&gt;
== Introduction ==&lt;br /&gt;
In this tutorial we will show how to calculate Shift Current in bulk materials.&amp;lt;br&amp;gt;&lt;br /&gt;
We suppose you are already familiar with the non-linear response using the Yambo code.&lt;br /&gt;
If it is not the case please study the previous tutorials: &amp;lt;br&amp;gt;[[Linear response using Dynamical Berry Phase]] and [[Real time approach to non-linear response (SHG)]].&amp;lt;br&amp;gt;&lt;br /&gt;
This theoretical implementation of this tutorial is described in the paper  &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; , please cite it if you use it. &amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial was created with the help of [https://www.linkedin.com/in/yuncheng-mao-8aba6279/ Yuncheng Mao].&lt;br /&gt;
&lt;br /&gt;
== Setup calculations ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will take as example the two dimensional GeS monolayer.&amp;lt;br&amp;gt;&lt;br /&gt;
DFT inputs can be downloaded here: [http://www.attaccalite.com/tutorials_yambo/GeS_DFT.tgz  GeS_DFT.tgz].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all run the setup, then remove symmetries along the &#039;&#039;&#039;y&#039;&#039;&#039; direction, as explained in the tutorial above.&lt;br /&gt;
&lt;br /&gt;
== Real-time setup and calculations ==&lt;br /&gt;
&lt;br /&gt;
In order to generate input file for shift current you do: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -u n -V par -F input.in&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 NLogCPUs=0                       # [PARALLEL] Live-timing CPU`s (0 for all)&lt;br /&gt;
 PAR_def_mode= &amp;quot;balanced&amp;quot;         # [PARALLEL] Default distribution mode (&amp;quot;balanced&amp;quot;/&amp;quot;memory&amp;quot;/&amp;quot;workload&amp;quot;/&amp;quot;KQmemory&amp;quot;)&lt;br /&gt;
 NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;quot;                     # [PARALLEL] CPUs roles (w,k)&lt;br /&gt;
 DIP_CPU= &amp;quot;&amp;quot;                      # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 OSCLL_CPU= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs for each role&lt;br /&gt;
 OSCLL_ROLEs= &amp;quot;&amp;quot;                  # [PARALLEL] CPUs roles (k,b)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 NL_Threads=0                     # [OPENMP/NL] Number of threads for nl-optics&lt;br /&gt;
 OSCLL_Threads=0                  # [OPENMP/X] Number of threads for Oscillators&lt;br /&gt;
 % NLBands&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;17 |  24 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime=-1.000000           fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;           # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX/LSEX/LHF&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 8.000000 &amp;lt;/span&amp;gt; |         eV    # [NL] Energy range (for loop on frequencies NLEnSteps/=0&lt;br /&gt;
 %&lt;br /&gt;
 NLEnSteps=  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;24     &amp;lt;/span&amp;gt;               # [NL] Energy steps for the loop on frequencies&lt;br /&gt;
 % NLrotaxis&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [NL] Rotation axis (for the loop on angles NLAngSteps/=0)&lt;br /&gt;
 %&lt;br /&gt;
 NLAngSteps=0                     # [NL] Angular steps (if NLAngSteps/=0 field versor will be ignored)&lt;br /&gt;
 NLDamping= 0.200000        eV    # [NL] Damping (or dephasing)&lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative RADLifeTime=Phase_LifeTime)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt;                    # [NL] Evaluate the current&lt;br /&gt;
 #FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field&lt;br /&gt;
 Field1_Freq= 0.100000      eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=  1000.00       kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 Field1_kind= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field1] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.000000 | 1.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # [RT Field1] Versor &lt;br /&gt;
 %&lt;br /&gt;
 Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time&lt;br /&gt;
&lt;br /&gt;
Notice that in this input we turned one the evaluation of current  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt; and force the parallelization on the frequencies, &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, that is much more efficient than the one on k-points.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Then you can run simulation by doing: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -F input.in&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of the results ==&lt;br /&gt;
&lt;br /&gt;
In order to analyze the result we use  Yambopy: [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy YamboPy],&amp;lt;br&amp;gt; and the following script for the post-processing:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.nl.harmonic_analysis import Harmonic_Analysis&lt;br /&gt;
 from yambopy.units import fs2aut&lt;br /&gt;
 &lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 &lt;br /&gt;
 SIN = Xn_from_sine(NLDB,X_order=4,l_out_current=True)&lt;br /&gt;
 print(SIN)&lt;br /&gt;
 OUT = SIN.perform_analysis()&lt;br /&gt;
 SIN.output_analysis(OUT)&lt;br /&gt;
 SIN.reconstruct_signal(OUT)&lt;br /&gt;
&lt;br /&gt;
This script will produce different file containing the response function of the current and polarization respect to the total field.&lt;br /&gt;
From the second order response of the current at zero frequency, file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0&amp;lt;/code&amp;gt;  we can extract the shift current coefficient along the &#039;y&#039; direction&lt;br /&gt;
that correspond to the 5th column of the file. In the file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
the first column ti the energy&lt;br /&gt;
&lt;br /&gt;
columns 2,3 are the imaginary and real part along x-direction&lt;br /&gt;
&lt;br /&gt;
columns 4,5 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
columns 6,7 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that the imaginary part is zero within the numerical precision.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Hereafter we report the shift current spectrum compared with the results of Ibañez-Azpiroz et al. &amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Sigma2.png|center| 800px | Shift current]]&lt;br /&gt;
&lt;br /&gt;
The python script to plot the results, the data from the Ibañez-Azpiroz paper can be downloaded here: [https://www.attaccalite.com/tutorials_yambo/GeS_plot.tgz GeS_plot].  &amp;lt;br&amp;gt;&lt;br /&gt;
In this example we used very few k-points, increasing the number of k-points bring the result very close to the one of Ibañez-Azpiroz, see also Supp. Mat. of Ref. &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; .&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that we rescale the shift-currect for an effective thickness of 2.65 Angstrom, you can find all the rescaling factor in the python script.&lt;br /&gt;
&lt;br /&gt;
Correlation effects can be included in the SC response in the same way we do for other non-linear response functions, for more info look at the tutorial:&lt;br /&gt;
[https://wiki.yambo-code.eu/wiki/index.php?title=SHG_within_the_TD-aGW_level_(also_called_TD-HSEX,_TD-BSE) SHG within the TD-aGW level (also called TD-HSEX, TD-BSE)]&lt;br /&gt;
&lt;br /&gt;
== References == &lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;Yuncheng Mao, Myrta Grüning, Ju Zhou, and Claudio Attaccalite, &#039;&#039;Shift current in 2D Janus Transition-Metal Dichalcogenides: the role of excitons&lt;br /&gt;
&#039;&#039;, [https://arxiv.org/abs/2506.16067 arXiv:2506.16067(2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;Julen Ibañez-Azpiroz, Stepan S. Tsirkin, and Ivo Souza, &#039;&#039;Ab initio calculation of the shift photocurrent by Wannier interpolation&#039;&#039;, [https://doi.org/10.1103/PhysRevB.107.205204  Phys. Rev. B &#039;&#039;&#039;107&#039;&#039;&#039;, 205204 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=888</id>
		<title>Shift current</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=888"/>
		<updated>2026-03-06T14:30:24Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Shift current.png|right|200px | Shift_current]]&lt;br /&gt;
== Introduction ==&lt;br /&gt;
In this tutorial we will show how to calculate Shift Current in bulk materials.&amp;lt;br&amp;gt;&lt;br /&gt;
We suppose you are already familiar with the non-linear response using the Yambo code.&lt;br /&gt;
If it is not the case please study the previous tutorials: &amp;lt;br&amp;gt;[[Linear response using Dynamical Berry Phase]] and [[Real time approach to non-linear response (SHG)]].&amp;lt;br&amp;gt;&lt;br /&gt;
This theoretical implementation of this tutorial is described in the paper  &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; , please cite it if you use it. &amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial was created with the help of [https://www.linkedin.com/in/yuncheng-mao-8aba6279/ Yuncheng Mao].&lt;br /&gt;
&lt;br /&gt;
== Setup calculations ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will take as example the two dimensional GeS monolayer.&amp;lt;br&amp;gt;&lt;br /&gt;
DFT inputs can be downloaded here: [http://www.attaccalite.com/tutorials_yambo/GeS_DFT.tgz  GeS_DFT.tgz].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all run the setup, then remove symmetries along the &#039;&#039;&#039;y&#039;&#039;&#039; direction, as explained in the tutorial above.&lt;br /&gt;
&lt;br /&gt;
== Real-time setup and calculations ==&lt;br /&gt;
&lt;br /&gt;
In order to generate input file for shift current you do: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -u n -V par -F input.in&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 NLogCPUs=0                       # [PARALLEL] Live-timing CPU`s (0 for all)&lt;br /&gt;
 PAR_def_mode= &amp;quot;balanced&amp;quot;         # [PARALLEL] Default distribution mode (&amp;quot;balanced&amp;quot;/&amp;quot;memory&amp;quot;/&amp;quot;workload&amp;quot;/&amp;quot;KQmemory&amp;quot;)&lt;br /&gt;
 NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;quot;                     # [PARALLEL] CPUs roles (w,k)&lt;br /&gt;
 DIP_CPU= &amp;quot;&amp;quot;                      # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 OSCLL_CPU= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs for each role&lt;br /&gt;
 OSCLL_ROLEs= &amp;quot;&amp;quot;                  # [PARALLEL] CPUs roles (k,b)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 NL_Threads=0                     # [OPENMP/NL] Number of threads for nl-optics&lt;br /&gt;
 OSCLL_Threads=0                  # [OPENMP/X] Number of threads for Oscillators&lt;br /&gt;
 % NLBands&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;17 |  24 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime=-1.000000           fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;           # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX/LSEX/LHF&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 8.000000 &amp;lt;/span&amp;gt; |         eV    # [NL] Energy range (for loop on frequencies NLEnSteps/=0&lt;br /&gt;
 %&lt;br /&gt;
 NLEnSteps=  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;24     &amp;lt;/span&amp;gt;               # [NL] Energy steps for the loop on frequencies&lt;br /&gt;
 % NLrotaxis&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [NL] Rotation axis (for the loop on angles NLAngSteps/=0)&lt;br /&gt;
 %&lt;br /&gt;
 NLAngSteps=0                     # [NL] Angular steps (if NLAngSteps/=0 field versor will be ignored)&lt;br /&gt;
 NLDamping= 0.200000        eV    # [NL] Damping (or dephasing)&lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative RADLifeTime=Phase_LifeTime)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt;                    # [NL] Evaluate the current&lt;br /&gt;
 #FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field&lt;br /&gt;
 Field1_Freq= 0.100000      eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=  1000.00       kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 Field1_kind= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field1] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.000000 | 1.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # [RT Field1] Versor &lt;br /&gt;
 %&lt;br /&gt;
 Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time&lt;br /&gt;
&lt;br /&gt;
Notice that in this input we turned one the evaluation of current  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt; and force the parallelization on the frequencies, &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, that is much more efficient than the one on k-points.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Then you can run simulation by doing: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -F input.in&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of the results ==&lt;br /&gt;
&lt;br /&gt;
In order to analyze the result we use  Yambopy: [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy YamboPy],&amp;lt;br&amp;gt; and the following script for the post-processing:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.nl.harmonic_analysis import Harmonic_Analysis&lt;br /&gt;
 from yambopy.units import fs2aut&lt;br /&gt;
 X_order=4&lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 SIN = Xn_from_sine(NLDB,l_out_current=True)&lt;br /&gt;
 print(SIN)&lt;br /&gt;
 OUT = SIN.perform_analysis()&lt;br /&gt;
 SIN.output_analysis(OUT)&lt;br /&gt;
 SIN.reconstruct_signal(OUT)&lt;br /&gt;
&lt;br /&gt;
This script will produce different file containing the response function of the current and polarization respect to the total field.&lt;br /&gt;
From the second order response of the current at zero frequency, file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0&amp;lt;/code&amp;gt;  we can extract the shift current coefficient along the &#039;y&#039; direction&lt;br /&gt;
that correspond to the 5th column of the file. In the file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
the first column ti the energy&lt;br /&gt;
&lt;br /&gt;
columns 2,3 are the imaginary and real part along x-direction&lt;br /&gt;
&lt;br /&gt;
columns 4,5 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
columns 6,7 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that the imaginary part is zero within the numerical precision.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Hereafter we report the shift current spectrum compared with the results of Ibañez-Azpiroz et al. &amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Sigma2.png|center| 800px | Shift current]]&lt;br /&gt;
&lt;br /&gt;
The python script to plot the results, the data from the Ibañez-Azpiroz paper can be downloaded here: [https://www.attaccalite.com/tutorials_yambo/GeS_plot.tgz GeS_plot].  &amp;lt;br&amp;gt;&lt;br /&gt;
In this example we used very few k-points, increasing the number of k-points bring the result very close to the one of Ibañez-Azpiroz, see also Supp. Mat. of Ref. &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; .&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that we rescale the shift-currect for an effective thickness of 2.65 Angstrom, you can find all the rescaling factor in the python script.&lt;br /&gt;
&lt;br /&gt;
Correlation effects can be included in the SC response in the same way we do for other non-linear response functions, for more info look at the tutorial:&lt;br /&gt;
[https://wiki.yambo-code.eu/wiki/index.php?title=SHG_within_the_TD-aGW_level_(also_called_TD-HSEX,_TD-BSE) SHG within the TD-aGW level (also called TD-HSEX, TD-BSE)]&lt;br /&gt;
&lt;br /&gt;
== References == &lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;Yuncheng Mao, Myrta Grüning, Ju Zhou, and Claudio Attaccalite, &#039;&#039;Shift current in 2D Janus Transition-Metal Dichalcogenides: the role of excitons&lt;br /&gt;
&#039;&#039;, [https://arxiv.org/abs/2506.16067 arXiv:2506.16067(2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;Julen Ibañez-Azpiroz, Stepan S. Tsirkin, and Ivo Souza, &#039;&#039;Ab initio calculation of the shift photocurrent by Wannier interpolation&#039;&#039;, [https://doi.org/10.1103/PhysRevB.107.205204  Phys. Rev. B &#039;&#039;&#039;107&#039;&#039;&#039;, 205204 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Third_Harmonic_Generation_(THG)&amp;diff=887</id>
		<title>Third Harmonic Generation (THG)</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Third_Harmonic_Generation_(THG)&amp;diff=887"/>
		<updated>2026-03-06T14:28:42Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the results with YamboPy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Third Harmonic Generation in bulk Silicon== &lt;br /&gt;
&lt;br /&gt;
In this tutorial we will calculate third harmonic generation (THG) in bulk Silicon. &lt;br /&gt;
[[File:Thg silicon.jpg|center| 150px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;Calculation of third harmonic generation proceeds in similar way to the SHG calculations. &amp;lt;br&amp;gt;DFT input can be found here ([http://www.attaccalite.com/lumen/tutorials/silicon_dft.tgz abinit] or [http://www.attaccalite.com/lumen/tutorials/silicon_qe.tgz QuantumEspresso]). &amp;lt;br&amp;gt; We import the wave-functions as explained in the [[Real time approach to non-linear response]], then perform the setup using only 1000 plane waves. &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Removing symmetries==&lt;br /&gt;
We are interested in the &amp;lt;math&amp;gt; \chi^{(3)}_{1111} &amp;lt;/math&amp;gt; therefore we consider an external field in direction [1, 0, 0] (equivalent to [x,0,0]).&amp;lt;br /&amp;gt;&lt;br /&gt;
We remove all the symmetries not compatible with the external field plus the time-reversal symmetry by doing &amp;lt;code&amp;gt;ypp_nl (or ypp) -y&amp;lt;/code&amp;gt;:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 fixsyms                      # [R] Reduce Symmetries&lt;br /&gt;
 % Efield1&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;gt;1.00  &amp;lt;/span&amp;gt;   | 0.00     | 0.00     |        # First external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 % Efield2&lt;br /&gt;
  0.00     | 0.00     | 0.00     |        # Additional external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 #RmAllSymm                   # Remove all symmetries&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;gt;RmTimeRev&amp;lt;/span&amp;gt;                   # Remove Time Reversal&lt;br /&gt;
&lt;br /&gt;
==Real-time simulations==&lt;br /&gt;
Then you go in the FixSymm folder, run again the setup (as explained in the [[Linear response using Dynamical Berry Phase]]) and then generate the input file with the command &amp;lt;code&amp;gt;yambo_nl -u n -V qp -F input.in&amp;lt;/code&amp;gt;:&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 nloptics                      # [R NL] Non-linear optics&lt;br /&gt;
 % NLBands&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;gt;1 | 7 | &amp;lt;/span&amp;gt;                  # [NL] Bands&lt;br /&gt;
 %&lt;br /&gt;
 NLstep=   0.0100       fs    # [NL] Real Time step length&lt;br /&gt;
 NLtime=-1.000000       fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;gt;CRANKNIC&amp;lt;/span&amp;gt;&amp;amp;quot;     # [NL] Integrator (&amp;amp;quot;EULEREXP/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;amp;quot;IPA&amp;amp;quot;         # [NL] Correlation (&amp;amp;quot;IPA/HARTREE/TDDFT/LRC/JGM/HF/SEX&amp;amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000         # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;gt;0.200000 | 2.000000 &amp;lt;/span&amp;gt;|  eV    # [NL] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 NLEnSteps=  &amp;lt;span style=&amp;quot;color:red&amp;gt;6 &amp;lt;/span&amp;gt;              # [NL] Energy steps&lt;br /&gt;
 NLDamping= &amp;lt;span style=&amp;quot;color:red&amp;gt;0.200000&amp;lt;/span&amp;gt;    eV    # [NL] Damping&lt;br /&gt;
 %Field1_Dir&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;gt;1.000000 &amp;lt;/span&amp;gt;| 0.000000 | 0.000000 |        # [RT Field1] Versor&lt;br /&gt;
 Field1_kind= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;         # [NL ExtF] Kind(SIN|SOFTSIN|RES|ANTIRES|GAUSS|DELTA|QSSIN)&lt;br /&gt;
 Field1_Int= &amp;lt;span style=&amp;quot;color:red&amp;gt;0.1000E+8 &amp;lt;/span&amp;gt;        kWLm2 # [NL ExtF] Intensity&lt;br /&gt;
  % GfnQP_E&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;gt;0.600000&amp;lt;/span&amp;gt; | 1.000000 | 1.000000 |        # [EXTQP G] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
  %&lt;br /&gt;
We calculate the &amp;lt;math&amp;gt;\chi^{(3)}_{1111}&amp;lt;/math&amp;gt; only on 6 frequencies, but calculations can be extended to larger frequency range. &amp;lt;br&amp;gt;We introduce a scissor operator of 0.6 eV in such a way to reproduce the gap of bulk silicon. Notice that we increased the field intensity in such a way to improve the ratio between non-linear response and numerical noise.&amp;lt;br /&amp;gt;&lt;br /&gt;
Now that you have created the file &amp;lt;code&amp;gt;input.in&amp;lt;/code&amp;gt; you can run the non-linear optics calculation with the command:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;yambo_nl -F input.in&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
when the simulation will end, it will have produced the file &amp;lt;code&amp;gt;SAVE/ndb.Nonlinear&amp;lt;/code&amp;gt; with all information on the simulation and the files  &amp;lt;code&amp;gt;SAVE/ndb.Nonlinear_fragment_x&amp;lt;/code&amp;gt; with the polarization and current for each laser frequency.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Analysis of the results==&lt;br /&gt;
Results can be analyzed in the same way of the SHG, using the command &amp;lt;code&amp;gt;ypp_nl -u&amp;lt;/code&amp;gt;:&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 nonlinear                    # [R] NonLinear Optics Post-Processing&lt;br /&gt;
 Xorder=  &amp;lt;span style=&amp;quot;color:red&amp;gt;5  &amp;lt;/span&amp;gt;                 # Max order of the response functions&lt;br /&gt;
 % TimeRange&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;gt;40.000000 &amp;lt;/span&amp;gt;| -1.00000 | fs    # Time-window where processing is done&lt;br /&gt;
 %&lt;br /&gt;
 ETStpsRt= 200                # Total Energy steps&lt;br /&gt;
 % EnRngeRt&lt;br /&gt;
  0.00000 | 10.00000 | eV    # Energy range&lt;br /&gt;
 %&lt;br /&gt;
 DampMode= &amp;amp;quot;NONE&amp;amp;quot;             # Damping type ( NONE | LORENTZIAN | GAUSSIAN )&lt;br /&gt;
 DampFactor=  0.10000   eV    # Damping parameter&lt;br /&gt;
&lt;br /&gt;
This time we increase the de-phasing time to 40 fs in such a way to have a clean third-harmonic response.&amp;lt;br /&amp;gt;&lt;br /&gt;
Hereafter we report the result with the 8x8x8 k-points sampling and the converged result with the 24x24x24 k-points sampling:&lt;br /&gt;
[[File:Si THG results.png|center| 600px]]&lt;br /&gt;
Plot data can be downloaded [http://www.attaccalite.com/lumen/tutorials/Si_thg_results.tgz here].&lt;br /&gt;
&lt;br /&gt;
==Analysis of the results with YamboPy==&lt;br /&gt;
&#039;&#039;&#039;This part works only with Yambo 5.3 or the last version available on Github:&#039;&#039;&#039; [https://github.com/yambo-code/yambo https://github.com/yambo-code/yambo]&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The previous analysis can be performed using &amp;lt;code&amp;gt;YamboPy&amp;lt;/code&amp;gt;, see these other tutorials for more details ([[Real time approach to non-linear response#Analysis of the results using YamboPy]])&lt;br /&gt;
From the folder of the calculations in python you use the script:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.plot  import *&lt;br /&gt;
 from yambopy.units import fs2aut &lt;br /&gt;
  &lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 &lt;br /&gt;
 pol =NLDB.Polarization[0]&lt;br /&gt;
 time=NLDB.IO_TIME_points&lt;br /&gt;
 &lt;br /&gt;
 SIN = Xn_from_sine(NLDB,X_order=5,T_range=[40.0*fs2aut,-1.0])&lt;br /&gt;
 print(SIN)&lt;br /&gt;
 OUT = SIN.perform_analysis()&lt;br /&gt;
 SIN.output_analysis(OUT)&lt;br /&gt;
&lt;br /&gt;
it will produce files with the non-linear response &#039;&#039;o.YamboPY-X_probe_order_x&#039;&#039; equivalent to the ones produced by &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==How to choose the external field direction for the different X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;==&lt;br /&gt;
In the X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;abcd&amp;lt;/sub&amp;gt; response you have four field directions. The three components &#039;&#039;b&#039;&#039;,&#039;&#039;c&#039;&#039; and &#039;&#039;d&#039;&#039; are determined by the external field and the four &#039;&#039;a&#039;&#039;&lt;br /&gt;
is the direction where you measure the response.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The external field in Yambo is set using the variable&lt;br /&gt;
 %Field1_Dir &lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [NL ExtF] Versor .&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
For example if you set in Yambo field direction as:&lt;br /&gt;
&lt;br /&gt;
 1.0 | 0.0 | 0.0 | ---&amp;gt; you calculate all components X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;*xxx&amp;lt;/sub&amp;gt;&lt;br /&gt;
 0.0 | 1.0 | 0.0 | ---&amp;gt; you calculate all components X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;*yyy&amp;lt;/sub&amp;gt;&lt;br /&gt;
 0.0 | 0.0 | 1.0 | ---&amp;gt; you calculate all components X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;*zzz&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the * correspond to the different direction in the response file &amp;lt;code&amp;gt;o.YPP-X_probe_order_3&amp;lt;/code&amp;gt;.&lt;br /&gt;
In the &amp;lt;code&amp;gt;o.YPP-X_probe_order_3&amp;lt;/code&amp;gt; you have seven columns:&lt;br /&gt;
&lt;br /&gt;
 The first column is the energy [[omega]],&lt;br /&gt;
 the 2nd and 3rd columns are the imaginary and real part of X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;x***&amp;lt;/sub&amp;gt;&lt;br /&gt;
 the 4th and 5th columns are the imaginary and real part of X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;y***&amp;lt;/sub&amp;gt;&lt;br /&gt;
 the 6th and 7th columns are the imaginary and real part of X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;z***&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the *** are the direction of the incoming field, see above.&lt;br /&gt;
&lt;br /&gt;
Instead for an external field in Yambo in the direction&lt;br /&gt;
 %Field1_Dir &lt;br /&gt;
  1.000000 | 1.000000 | 1.000000 |        # [NL ExtF] Versor .&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
you can get in output in the &amp;lt;code&amp;gt;o.YPP-X_probe_order_3&amp;lt;/code&amp;gt; file the components:&lt;br /&gt;
&lt;br /&gt;
 the 2nd and 3rd columns are the imaginary and real part of X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;xxyz&amp;lt;/sub&amp;gt;&lt;br /&gt;
 the 4th and 5th columns are the imaginary and real part of X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;yxyz&amp;lt;/sub&amp;gt;&lt;br /&gt;
 the 6th and 7th columns are the imaginary and real part of X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;zxyz&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other terms of the X&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt; tensor can be obtained combining the different columns of the  &amp;lt;code&amp;gt;o.YPP-X_probe_order_3&amp;lt;/code&amp;gt; file and using external fields along linear combination of the Cartesian axes. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Nota bene:&#039;&#039;&#039; if you change the direction of the external field you have to remove the corresponding symmetries as explained in the tutorial &lt;br /&gt;
on [[Prerequisites for Real Time propagation with Yambo#Reduce symmetries real-time linear response tutorial]].&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Real_time_approach_to_non-linear_response_(SHG)&amp;diff=886</id>
		<title>Real time approach to non-linear response (SHG)</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Real_time_approach_to_non-linear_response_(SHG)&amp;diff=886"/>
		<updated>2026-03-06T14:25:18Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the results using YamboPy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Second Harmonic Generation in AlAs ==&lt;br /&gt;
In this tutorial, we will calculate the second harmonic generation of bulk AlAs, the Lumen databases can be downloaded here: [https://media.yambo-code.eu/educational/tutorials/files/AlAs_DBs.tar.gz AlAs_DBs.tar.gz] (10 MB). The first steps of this tutorials are the same as the one on [http://www.yambo-code.eu/wiki/index.php?title=Prerequisites_for_Real_Time_propagation_with_Yambo Prerequisites for Real-Time propagation with Yambo] with the only difference that we will work on AlAs and we will consider an external field in the direction &amp;lt;code&amp;gt; 1.000000 | 1.000000 | 0.000000 |&amp;lt;/code&amp;gt;. The DFT input are available here: [https://media.yambo-code.eu/educational/tutorials/files/AlAs_abinit.tar.gz ABINIT] or [https://media.yambo-code.eu/educational/tutorials/files/AlAs_pwscf.tar.gz QuantumEspresso].&lt;br /&gt;
You can run the DFT calculation with ABINIT with the command:&lt;br /&gt;
&lt;br /&gt;
 abinit &amp;lt; AlAs.in &amp;gt; output_AlAs                                             &lt;br /&gt;
&lt;br /&gt;
or using QuantumEspresso:&lt;br /&gt;
&lt;br /&gt;
 pw.x -inp AlAs.scf.in &amp;gt; output_scf&lt;br /&gt;
 pw.x -inp AlAs.nscf.in &amp;gt; output_scf                            &lt;br /&gt;
&lt;br /&gt;
and then import the ABINIT wave-function with the command:&lt;br /&gt;
&lt;br /&gt;
 a2y -F AlAso_DS2_WFK.nc                            &lt;br /&gt;
&lt;br /&gt;
and the QuantumEspresso one, in the folder AlAs.save with the command:&lt;br /&gt;
&lt;br /&gt;
 p2y                              &lt;br /&gt;
Now we consider an external field in the &amp;lt;code&amp;gt;[1,1,0]&amp;lt;/code&amp;gt; direction and remove symmetries not compatible with this field, as explained in the tutorial [http://www.yambo-code.eu/wiki/index.php?title=Prerequisites_for_Real_Time_propagation_with_Yambo Prerequisites for Real-Time propagation with Yambo].&lt;br /&gt;
&lt;br /&gt;
==Real-time simulation for the SHG==&lt;br /&gt;
&lt;br /&gt;
You can generate the input file with the command &amp;lt;code&amp;gt;yambo_nl -u n&amp;lt;/code&amp;gt;:&lt;br /&gt;
                       &lt;br /&gt;
 nloptics                      # [R NL] Non-linear optics&lt;br /&gt;
 % NLBands&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 3 | 6&amp;lt;/span&amp;gt; |                   # [NL] Bands&lt;br /&gt;
 %&lt;br /&gt;
 NLstep=   0.0100       fs    # [NL] Real Time step length&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NLverbosity= &amp;quot;high&amp;quot;&amp;lt;/span&amp;gt;               # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime=-1.000000           fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;       # [NL] Integrator (&amp;quot;EULEREXP/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;         # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/JGM/SEX/HF&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000         # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  1.000000 | 5.000000 &amp;lt;/span&amp;gt;| eV    # [NL] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 NLEnSteps= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 5  &amp;lt;/span&amp;gt;              # [NL] Energy steps&lt;br /&gt;
 NLDamping= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.150000  &amp;lt;/span&amp;gt;  eV    # [NL] Damping&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 1.000000 | 0.000000 &amp;lt;/span&amp;gt;|        # [RT Field1] Versor&lt;br /&gt;
 Field1_kind= &amp;quot;SOFTSIN&amp;quot;         # [NL ExtF] Kind(SIN|SOFTSIN|RES|ANTIRES|GAUSS|DELTA|QSSIN)&lt;br /&gt;
&lt;br /&gt;
The line &amp;lt;code&amp;gt;|1.000000 | 1.000000 | 0.000000 | # [RT Field1] Versor&amp;lt;/code&amp;gt; referees to the direction of the external field (x,y,0). &amp;lt;br&amp;gt;&lt;br /&gt;
The default parameters of Lumen are already tuned for second-harmonic generation, so the only thing you have to change is the band range, between 3 and 6 and the energy range between 1.0-5.0 eV and the number of energy steps in this interval that we set to 10.&amp;lt;br&amp;gt; Notice that you cannot set to zero the lowest value of the energy range because this will requires a simulation that lasts infinite time, see below. Finally, consider that Yambo performs a separate calculation for each frequency, so if you set many energy steps the computational time grows linearly with this number.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notice that we set &amp;lt;code&amp;gt;NLverbosity= &amp;quot;high&amp;quot;&amp;lt;/code&amp;gt; in this way the code will produce a file for each laser frequency containing the time dependent polarization.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;yambo_nl&amp;lt;/code&amp;gt;. Calculations will take about fifteen minutes on a single processor PC, you have time to study the next section that explains how non-linear response is extracted from the real-time simulations.&lt;br /&gt;
In order to speed up calculations, you can run them in parallel.&lt;br /&gt;
&lt;br /&gt;
==Non-linear response with Yambo==&lt;br /&gt;
&lt;br /&gt;
In order to calculate the non-linear response, the system is excited with different laser fields with a sinusoidal shape at frequencies &amp;lt;math&amp;gt;\omega_1, \omega_2, .... , \omega_n &amp;lt;/math&amp;gt; determined by the parameters [[Variables#NLEnRangev|NLEnRange]] and [[Variables#NLEnSteps|NLEnSteps]]. A dephasing term is added to the Hamiltonian &amp;lt;math&amp;gt;\gamma = &amp;lt;/math&amp;gt;[[Variables#NLDamping|NLDamping]] to simulate a finite broadening and to remove the eigenmodes that are excited by the sudden turning on of the external field. After the dephasing time the outgoing signal is analyzed to extract the non-linear coefficients as shown in the figure below: &lt;br /&gt;
&lt;br /&gt;
[[File:Pt analysis.png|600px|center|Non-linear response analysis]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the report file &amp;lt;code&amp;gt;r_nlinear&amp;lt;/code&amp;gt; you will find the length of the dephasing part and of the sampling one:&lt;br /&gt;
&lt;br /&gt;
  Dephasing Time          [fs]: 52.65695&lt;br /&gt;
  Sampling  Time          [fs]:  4.18566&lt;br /&gt;
  Total simulation time   [fs]: 56.84262                     &lt;br /&gt;
The length of the dephasing interval is inversely proportional to the damping term &amp;lt;math&amp;gt;T_{depth} \simeq 1/\gamma&amp;lt;/math&amp;gt; while the length of the sampling is dictated by the smallest frequency we are interested in: &amp;lt;math&amp;gt;T_{samp} \simeq 1/\omega_1 &amp;lt;/math&amp;gt;. For this reason if &amp;lt;math&amp;gt; \omega_1=0 &amp;lt;/math&amp;gt; or &amp;lt;math&amp;gt; \gamma = 0 &amp;lt;/math&amp;gt; simulation time goes to infinity. The response at zero frequency can be calculated as limit of small frequency perturbation.&lt;br /&gt;
You can have a look to the file &amp;lt;code&amp;gt;src/nloptics/NL_initialize.F&amp;lt;/code&amp;gt; to see how simulation lengths are defined.&lt;br /&gt;
Calculations can take some time, run them in parallel, the best number of processors = number of frequencies or reduce the number of frequencies step in the SHG.&lt;br /&gt;
&lt;br /&gt;
==Analysis of the results==&lt;br /&gt;
&lt;br /&gt;
In the sampling region we suppose that the polarization can be written as: &amp;lt;math&amp;gt;\bf{P}(t) = \sum_{n=-\infty}^{+\infty} \bf{p}_n e^{-i\omega_n t} &amp;lt;/math&amp;gt; where the coefficient &amp;lt;math&amp;gt;\bf{p}_1,...,\bf{p}_n &amp;lt;/math&amp;gt; are related to &amp;lt;math&amp;gt;\chi^{(1)},...,\chi^{(n)} &amp;lt;/math&amp;gt;. We sample the polarization signal at different times and invert the previous equation by truncating the sum at a finite order &amp;lt;ref&amp;gt;[https://arxiv.org/abs/1309.4012 Nonlinear optics from an ab initio approach by means of the dynamical Berry phase: Application to second- and third-harmonic generation in semiconductors], C. Attaccalite and M. Grüning, Phys. Rev. B 88, 235113(2013)&amp;lt;/ref&amp;gt;.&lt;br /&gt;
This is done with the command &amp;lt;code&amp;gt;ypp_nl -u&amp;lt;/code&amp;gt; that automatically produce an input with the correct values:&lt;br /&gt;
&lt;br /&gt;
 nonlinear                    # [R] NonLinear Optics Post-Processing&lt;br /&gt;
 Xorder=   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;4  &amp;lt;/span&amp;gt;                 # Max order of the response functions&lt;br /&gt;
 % TimeRange&lt;br /&gt;
  52.65695 | -1.00000 | fs    # Time-window where processing is done&lt;br /&gt;
 % &lt;br /&gt;
 ETStpsRt= 200                # Total Energy steps&lt;br /&gt;
 % EnRngeRt&lt;br /&gt;
   0.00000 | 10.00000 | eV    # Energy range&lt;br /&gt;
 %&lt;br /&gt;
 DampMode= &amp;quot;NONE&amp;quot;             # Damping type ( NONE | LORENTZIAN | GAUSSIAN )&lt;br /&gt;
 DampFactor=  0.10000   eV    # Damping parameter&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;code&amp;gt;Xorder&amp;lt;/code&amp;gt; is the order where the previous sum is truncated, and the TimeRange specifies the sampling region. Notice that differently from the first tutorial, in this case, we do not need Damping in &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt; because we already included it in the real-time dynamics. Run &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt; and it will produce a file called &amp;lt;code&amp;gt;o.YPP-X_probe_order_2&amp;lt;/code&amp;gt;. This file contains the different components of &amp;lt;math&amp;gt;\chi^2_{xy*} &amp;lt;/math&amp;gt; and in particular the columns 6 and 7 correspond to the imaginary and real part of &amp;lt;math&amp;gt;\chi^2_{xyz} &amp;lt;/math&amp;gt;. You can plot the result with gnuplot and the command:&lt;br /&gt;
&lt;br /&gt;
 p &#039;o.YPP-X_probe_order_2&#039; u 1:(sqrt($6**2+$7**2)) w lp ps 1.5 pt 7 lw 1.5&lt;br /&gt;
&lt;br /&gt;
the result should look like&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:AlAs results.png|700px|center|SHG in AlAs]]&lt;br /&gt;
&lt;br /&gt;
and compare it with the &amp;lt;math&amp;gt; \chi^2_{zxy} &amp;lt;/math&amp;gt; calculated with more frequencies and with the converged result on a &amp;lt;math&amp;gt; 18x18x18&amp;lt;/math&amp;gt; k-point grid and bands between 2 and 10. In the figure you can find also the comparison with the results of Ref. &amp;lt;ref&amp;gt;Luppi et al. [https://arxiv.org/abs/1006.2649 PRB B, &#039;&#039;&#039;82&#039;&#039;&#039;, 235201(2010)]&amp;lt;/ref&amp;gt;. &lt;br /&gt;
Notice that the QuantumEspresso results are slightly different from the Abinit ones. This is due to the different pseudo-potential employed in the calculations if pseudopotentials were the same calculation would have been identical. You can download the script to generate this plot and the converged results [http://www.attaccalite.com/lumen/tutorials/AlAs/AlAs_results.tgz here].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notice that&#039;&#039;&#039; : the following parameters are not used in the non-linear response analysis: &amp;lt;code&amp;gt; EnRngeRt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ETStpsRt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DampMode&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;DampFactor&amp;lt;/code&amp;gt;. The damping factor is set directly in the real-time simulation.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;System of units in Non-linear Optics&amp;lt;/span&amp;gt;&#039;&#039;&#039;: notice that in Yambo the non-linear response functions are in the gaussian system of units, for example the &amp;lt;math&amp;gt; \chi^2 (\omega) &amp;lt;/math&amp;gt;  is in cm/statvolt. In order to convert the non-linear coefficients between different system of units, you can have a look at the [https://www.attaccalite.com/tutorials_yambo/Appendix_C_Boyd.pdf Appendix C] of the book [https://www.elsevier.com/books/nonlinear-optics/boyd/978-0-12-369470-6 &amp;quot;Non-linear optics&amp;quot;  by Robert W. Boyd].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;More tutorials&amp;lt;/span&amp;gt; on non-linear response (Third harmonic generation, parallelization, spin-orbit etc..) with Yambo can be found here: [http://www.attaccalite.com/lumen/tutorials.html More Tutorials]. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Analysis of the results using YamboPy==&lt;br /&gt;
The analysis of the result performed in the previous section using &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt; can be performed using python script [https://github.com/yambo-code/yambopy YamboPy].&amp;lt;br&amp;gt;&lt;br /&gt;
In YamboPy we implemented all necessary functions to reads the Yambo databases and post-process the results. Here we show how to get the SHG signal from the previous &lt;br /&gt;
simulations. We suppose you correctly installed &amp;lt;code&amp;gt;YamboPy&amp;lt;/code&amp;gt; on your PC. Go in the folder where you ran non-linear calculation and type in the python:&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 pol =NLDB.Polarization[0]&lt;br /&gt;
 time=NLDB.IO_TIME_points&lt;br /&gt;
&lt;br /&gt;
in this way you read all the Non-linear databases. If your runs are in a different folder then the &#039;SAVE&#039; one you can specify it using the command:&lt;br /&gt;
 NLDB=YamboNLDB(calc=&#039;MYJOB&#039;)&lt;br /&gt;
&lt;br /&gt;
now in the array &amp;lt;code&amp;gt;pol&amp;lt;/code&amp;gt; you have all the polarization for all laser frequencies in the three Cartesian directions, while the variable &amp;lt;code&amp;gt;time&amp;lt;/code&amp;gt; contains all the time series of your simulation.&lt;br /&gt;
Now you can get the non-linear response with the command:&lt;br /&gt;
&lt;br /&gt;
 SIN = Xn_from_sine(NLDB,X_order=5)&lt;br /&gt;
 print(SIN)&lt;br /&gt;
 OUT = SIN.perform_analysis()&lt;br /&gt;
 SIN.output_analysis(OUT)&lt;br /&gt;
&lt;br /&gt;
this command will perform a Fourier analysis of the results in the same way of &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt; and generate new files with all the requested harmonics &#039;&#039;o.YamboPy-X_probe_order_1&#039;&#039;, &#039;&#039;o.YamboPy-X_probe_order_2&#039;&#039; etc...&lt;br /&gt;
equivalent to the one generated by &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt;. Results can be plot with gnuplot using the command:&lt;br /&gt;
 &lt;br /&gt;
 p &#039;o.YamboPy-X_probe_order_2&#039; u 1:(sqrt($6**2+$7**2)) w lp ps 1.5 pt 7 lw 1.5&lt;br /&gt;
&lt;br /&gt;
The script that performs non-linear analysis can be found in &amp;lt;code&amp;gt;yambopy/nl/harmonic_analysis.py&amp;lt;/code&amp;gt;. &amp;lt;br&amp;gt; We strongly advice you to have a look to this script and modify it according&lt;br /&gt;
to your needs and in order to extract other non-linear response functions.&lt;br /&gt;
&lt;br /&gt;
==How to choose the external field direction for the different X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;==&lt;br /&gt;
&lt;br /&gt;
In the X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;abc&amp;lt;/sub&amp;gt; response you have three field directions. The two components &#039;&#039;b&#039;&#039; and &#039;&#039;c&#039;&#039; are determined by the external field and the third &#039;&#039;a&#039;&#039;&lt;br /&gt;
is the direction where you measure the response.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The external field in Yambo is set using the variable&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
   1.000000 | 0.000000 | 0.000000 |        # [NL ExtF] Versor .&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
For example if you set in Yambo field direction as:&lt;br /&gt;
&lt;br /&gt;
 1.0 | 0.0 | 0.0 | ---&amp;gt; you calculate all components X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;*xx&amp;lt;/sub&amp;gt;&lt;br /&gt;
 0.0 | 1.0 | 0.0 | ---&amp;gt; you calculate all components X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;*yy&amp;lt;/sub&amp;gt;&lt;br /&gt;
 0.0 | 0.0 | 1.0 | ---&amp;gt; you calculate all components X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;*zz&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the * correspond to the different direction in the response file &amp;lt;code&amp;gt;o.YPP-X_probe_order_2&amp;lt;/code&amp;gt;.&lt;br /&gt;
In the &amp;lt;code&amp;gt;o.YPP-X_probe_order_2&amp;lt;/code&amp;gt; you have seven columns:&lt;br /&gt;
&lt;br /&gt;
 The first column is the energy [[omega]],&lt;br /&gt;
 the 2nd and 3rd columns are the imaginary and real part of X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;x**&amp;lt;/sub&amp;gt;&lt;br /&gt;
 the 4th and 5th columns are the imaginary and real part of X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;y**&amp;lt;/sub&amp;gt;&lt;br /&gt;
 the 6th and 7th columns are the imaginary and real part of X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt;&amp;lt;sub&amp;gt;z**&amp;lt;/sub&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where the ** are the direction of the incoming field, see above.&lt;br /&gt;
&lt;br /&gt;
For example if you want to calculate the &amp;lt;math&amp;gt;\chi^{(2)}_{zxx}&amp;lt;/math&amp;gt; you put the external field in the direction &amp;lt;code&amp;gt; 1.0 | 0.0 | 0.0 |&amp;lt;/code&amp;gt;&lt;br /&gt;
and then plot the column 6 and 7 of the &amp;lt;code&amp;gt;o.YPP-X_probe_order_2&amp;lt;/code&amp;gt; file.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to get the other components of the  X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; the calculation are more involved. For example if you put field in the&lt;br /&gt;
&lt;br /&gt;
 1.0 | 1.0 | 0.0 | &lt;br /&gt;
&lt;br /&gt;
this corresponds to &amp;lt;math&amp;gt;E(t)=\frac{1}{\sqrt{2}} [ E_x(t) + E_y(t) ]&amp;lt;/math&amp;gt; and so at the second order you will have &amp;lt;math&amp;gt;E^2(t)=\frac{1}{2} \left [ E^2_x(t) + E^2_y(t) +  E_x(t) E_y(t) +  E_y(t) E_x(t) \right]&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
this means that  the X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; in the &amp;lt;code&amp;gt;o.YPP-X_probe_order_2&amp;lt;/code&amp;gt;  will correspond to a linear combination of the following different response functions.&amp;lt;br&amp;gt;&lt;br /&gt;
For example in the the 2nd and 3rd columns are the imaginary and real part of:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;\chi^{(2)}_{x**}=\frac{1}{2} \left [\chi^2_{xxx}+\chi^{(2)}_{xyy} + \chi^{(2)}_{xxy} + \chi^{(2)}_{xyx} \right ]&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
the same for the other column replacing the first &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;y,z&amp;lt;/code&amp;gt;.&lt;br /&gt;
If you know that some components are zero this allow you to extract the corresponding off-diagonal part of &amp;lt;math&amp;gt;\chi^{(2)}_{abc}&amp;lt;/math&amp;gt; otherwise you have to perform different calculations to get the component you are interested in. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Now we present &#039;&#039;&#039;a simple example of monolayer hBN (m-hBN)&#039;&#039;&#039;. &amp;lt;br&amp;gt; In m-hBN there is only a non-zero component of the &amp;lt;math&amp;gt;\chi^{(2)}&amp;lt;/math&amp;gt;and all the others are related by symmetry:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\chi^{(2)}_{yyy}=-\chi^{(2)}_{yxx}=-\chi^{(2)}_{xxy}=-\chi^{(2)}_{xyx}&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
so if you put the field in the &amp;lt;code&amp;gt;|1|1|0|&amp;lt;/code&amp;gt; direction you will get:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\chi^{(2)}_{x**} = \frac{1}{2} \left[\chi^{(2)}_{xxy} + \chi^{(2)}_{xyx} \right] = - \chi^{(2)}_{yyy} &amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;math&amp;gt;\chi^{(2)}_{y**} =\frac{1}{2} \left[ \chi^{(2)}_{yyy} + \chi^{(2)}_{yxx}  \right] = 0.0 &amp;lt;/math&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In the figure below you can see the different &amp;lt;math&amp;gt;\chi^{(2)}&amp;lt;/math&amp;gt; of monolayer hBN. &lt;br /&gt;
&lt;br /&gt;
[[File:Xhi2 xy.png|center| 800px|xhi2_xy]]&lt;br /&gt;
&lt;br /&gt;
as you can see in the second panel, when the field is in the &amp;lt;code&amp;gt;xy&amp;lt;/code&amp;gt; you get a linear combination of  &amp;lt;math&amp;gt;\chi^{(2)}&amp;lt;/math&amp;gt; corresponding to the equation above, in this case the &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; is zero while the &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; component is equal to &amp;lt;math&amp;gt;-\chi^{(2)}_{yyy}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Nota bene:&#039;&#039;&#039; if you change the direction of the external field you must to remove the corresponding symmetries as explained in the tutorial [[Prerequisites for Real Time_propagation with Yambo#Reduce symmetries real-time linear response tutorial]]. If you have to calculate &amp;lt;math&amp;gt;\chi^{(2)}&amp;lt;/math&amp;gt; along many directions it can be convenient to remove all symmetries at once.&lt;br /&gt;
&lt;br /&gt;
==Non-linear response of low-dimensional structures: 2D or 1D ==&lt;br /&gt;
&lt;br /&gt;
The Yambo code is a 3D periodic code, so when you want to study a low-dimensional system 2D or 1D, you have to use a supercell approach.&lt;br /&gt;
For example to simulate the non-linear response in a 2D-crystal one, can put the crystal in the xy plane and choose a larger distance in the z-direction&lt;br /&gt;
in order to reduce the interaction between the periodic replica. Clearly in this case k-point sampling will be only in the x,y directions.&lt;br /&gt;
For calculations on this type of systems, these two warnings must be taken into account:&lt;br /&gt;
&lt;br /&gt;
* if you calculate GW corrections or include electron-hole interaction in the linear/non-linear response it is a good idea to use a &#039;&#039;&#039;Coulomb cutoff&#039;&#039;&#039;, similar to the 2D BSE case  [http://www.yambo-code.org/wiki/index.php?title=How_to_treat_low_dimensional_systems How to treat low dimensional systems]. You can add the cutoff just adding the &amp;quot;-r&amp;quot; in the input generation.&lt;br /&gt;
&lt;br /&gt;
* the calculation of SHG and THG are always performed respect to the supercell, therefore you have to &#039;&#039;&#039;re-scale&#039;&#039;&#039; the result to the effective thickness of the layer, usually the inter-layer distance of the corresponding bulk material for 2D systems: &amp;lt;math&amp;gt;\chi_{rescaled}(\omega) = L_z/d_{eff} \cdot \chi(\omega) &amp;lt;/math&amp;gt; where &amp;lt;math&amp;gt;L_z&amp;lt;/math&amp;gt; is the z-dimension of the supercell, and &amp;lt;math&amp;gt;d_{eff}&amp;lt;/math&amp;gt; is the effective thickness of the 2D system.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Nota bene&#039;&#039;&#039;: Non-linear response along &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;non-periodic directions&amp;lt;/span&amp;gt; is not implemented in Yambo, the code will print zero in these directions for all response functions. We plan to implement it in a future version of the code.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Links for schools==&lt;br /&gt;
* Back to [[Rome 2023#Tutorials]]&lt;br /&gt;
* Back to [[ICTP2020]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{| style=&amp;quot;width:100%&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
|style=&amp;quot;width:25%; text-align:left&amp;quot;|Prev: [[Linear response from real time simulations]]&lt;br /&gt;
|style=&amp;quot;width:45%; text-align:center&amp;quot;|Now: [[ICTP2020|ICTP  Tutorials]] --&amp;gt; [[Real time approach to non-linear response|Non Linear Response]]&lt;br /&gt;
|style=&amp;quot;width:50%; text-align:left&amp;quot;|Next: [[Correlation effects in the non-linear response]]&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Main_Page&amp;diff=885</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Main_Page&amp;diff=885"/>
		<updated>2026-03-04T17:06:23Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;strong&amp;gt;Lumen wiki&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Installation]]&lt;br /&gt;
* [[Tutorials]]&amp;lt;nowiki/&amp;gt;&lt;br /&gt;
* [https://enccs.github.io/max-coe-workshop/day5-tutorials/ Yambo tutorials on Markdown]&lt;br /&gt;
* [[Lumen release notes|Lumen Releases]]&lt;br /&gt;
* [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy YamboPy]&lt;br /&gt;
* [[Configure library externally]]&lt;br /&gt;
* [https://www.lumen-code.org/ford/index.html Ford documentation]&lt;br /&gt;
* [[Internal wiki]]&lt;br /&gt;
* [[Test-suite]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Magneto-electric_reponse&amp;diff=878</id>
		<title>Magneto-electric reponse</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Magneto-electric_reponse&amp;diff=878"/>
		<updated>2026-02-16T09:44:25Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: Created page with &amp;quot;Sum frequency generation  In this tutorial we show step by step how to calculate magneto-electric coefficents using the Lumen code.   &amp;#039;&amp;#039;&amp;#039;This tutorial has been supported by EU funding via the TIMES MASC-DN&amp;#039;&amp;#039;&amp;#039; == References ==&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Quantizedmag.jpg|right|300px |Sum frequency generation]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial we show step by step how to calculate magneto-electric coefficents using the Lumen code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This tutorial has been supported by EU funding via the TIMES MASC-DN&#039;&#039;&#039;&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=File:Quantizedmag.jpg&amp;diff=877</id>
		<title>File:Quantizedmag.jpg</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=File:Quantizedmag.jpg&amp;diff=877"/>
		<updated>2026-02-16T09:42:50Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Tutorials&amp;diff=876</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Tutorials&amp;diff=876"/>
		<updated>2026-02-16T09:41:06Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Advanced tutorials Linear response and BSE */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Basic ==&lt;br /&gt;
* [[First steps: a walk through from DFT to optical properties]] (modular tutorial) &lt;br /&gt;
* [[Silicon|GW on bulk silicon]]&lt;br /&gt;
* [[GW on h-BN (standalone)|GW on h-BN]] (standalone version);  [[How to obtain the quasi-particle band structure of a bulk material: h-BN|GW on h-BN]] (modular version) &lt;br /&gt;
* [[LiF|BSE in lithium-floride]]&lt;br /&gt;
* [[BSE tutorial on hBN standalone|BSE on h-BN]] (standalone version); [[BSE tutorial on hBN|BSE on h-BN]] (modular version); &lt;br /&gt;
* [[How to analyse excitons]]&lt;br /&gt;
&lt;br /&gt;
== Advanced tutorials on GW and Quasi-particles ==&lt;br /&gt;
* [[Real Axis and Lifetimes]]&lt;br /&gt;
* [[Self-consistent GW on eigenvalues only]]&lt;br /&gt;
* [[GW parallel strategies|GW parallel strategies v1]]; [[GW parallel strategies CECAM|GW parallel strategies v2]];  [[Pushing convergence in parallel|GW convergence in parallel]] (modular tutorials)&lt;br /&gt;
* [[GW tutorial on HPC]] (external tutorial on HackMD)&lt;br /&gt;
* [[Quasi-particles and Self-energy within the Multipole Approximation (MPA)]]&lt;br /&gt;
* [http://www.attaccalite.com/gw-correction-on-an-arbitrary-point-of-the-brillouin-zone GW on arbitrary k point] (external tutorial on www.attaccalite.com)&lt;br /&gt;
&lt;br /&gt;
== Advanced tutorials Linear response and BSE ==&lt;br /&gt;
=== Optical properties and more in extended systems ===&lt;br /&gt;
* [[SOC|Spin-orbit coupling in GaSb]]&lt;br /&gt;
* [[The magneto-optical Kerr effect|The magneto-optical Kerr effect in bulk iron, RPA]]&lt;br /&gt;
* [[The magneto-optical Kerr effect including excitonic effects|The magneto-optical Kerr effect in XXX, excitonic effects]] (todo)&lt;br /&gt;
* [[Magneto-electric reponse]]&lt;br /&gt;
* [[Magnons with BSE formalism]] (todo)&lt;br /&gt;
* [[Bands selection in BSE and application to semi-core states]] (todo)&lt;br /&gt;
* [[Surface spectroscopy]] (to restore from older version)&lt;br /&gt;
* [[Fast convergence of dielectric constant with double grid]]&lt;br /&gt;
=== Optical properties and more in lower dimensional systems (1D/2D) ===&lt;br /&gt;
* [[Hydrogen chain|TDDFT Failure and long range correlations]] (1D)&lt;br /&gt;
* [[Si wire|Linear Response from a silicon wire (1D)]] (to restore from old version)&lt;br /&gt;
* [[Si Surface|Linear Response of a silicon surface (2D)]]&lt;br /&gt;
&lt;br /&gt;
=== Optical properties and more in molecules ===&lt;br /&gt;
* [[H2|H2 molecule: Linear Response &amp;amp; TDDFT (0D)]] (to restore from old version)&lt;br /&gt;
* [[SiH4|SiH4: isolated molecule TDDFT &amp;amp; BSE (0D)]] (restored from old version, still to be finalized)&lt;br /&gt;
* [[Dichroism in molecules]]&lt;br /&gt;
&lt;br /&gt;
== Post Processing with ypp and YamboPy ==&lt;br /&gt;
* [[Yambo Post Processing (ypp)]]&lt;br /&gt;
* [[First steps in YamboPy]]&lt;br /&gt;
&lt;br /&gt;
== Electron-phonon and exciton-phonon coupling ==&lt;br /&gt;
* [[Electron Phonon Coupling (old tutorial)]]&lt;br /&gt;
* [[Electron Phonon Coupling (new)]]&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;
* [[Thermal lines and special displacements with YamboPy]]&lt;br /&gt;
&lt;br /&gt;
== Real time propagation ==&lt;br /&gt;
&lt;br /&gt;
=== Linear response from real time propagation ===&lt;br /&gt;
* [[Linear response from real time simulations (density matrix only)|Linear response using the density matrix (IP)]]&lt;br /&gt;
* [[Linear response using Dynamical Berry Phase|Linear response using wave-functions and Dynamical Berry Phase (IP)]]&lt;br /&gt;
* [[Linear response in velocity gauge|Linear response using wave-functions in velocity gauge (IP)]]&lt;br /&gt;
* [[Real time Bethe-Salpeter Equation (density matrix only)|Linear response using the density matrix (TD-HSEX)]]&lt;br /&gt;
* [[Linear response from real time simulations|Linear response from real time simulations (IP &amp;amp; TD-HSEX)]] (modular tutorial)&lt;br /&gt;
&lt;br /&gt;
=== Non-linear response from real time propagation ===&lt;br /&gt;
&lt;br /&gt;
* [[Real time approach to non-linear response (SHG)]]&lt;br /&gt;
* [[Correlation effects in the non-linear response]]&lt;br /&gt;
* [[SHG within the TD-HSEX level (also called TD-aGW or TD-BSE)]]&lt;br /&gt;
* [[Angular dependence of non-linear response]]&lt;br /&gt;
* [[Third Harmonic Generation (THG)]]&lt;br /&gt;
* [[Spin-orbit coupling and non-linear response]]&lt;br /&gt;
* [[Two-photon absorption]]&lt;br /&gt;
* [[Sum frequency generation]]&lt;br /&gt;
* [[Shift current]]&lt;br /&gt;
&lt;br /&gt;
=== Non-linear response in Floquet formulation ===&lt;br /&gt;
* [[SHG from Floquet formulation]]&lt;br /&gt;
=== Pump and Probe experiments ===&lt;br /&gt;
&lt;br /&gt;
* [[Nonequilibrium absorption in bulk silicon|Pump and Probe: Transient Absorption from BSE with NEQ occupations]]&lt;br /&gt;
* [[Pump and Probe|Pump and Probe: Transient Absorption from real time propagation with pump and probe]]&lt;br /&gt;
* [[Pump and Probe: Time resolved ARPES|Pump and Probe: Time resolved ARPES from real time propagation with pump]]&lt;br /&gt;
&lt;br /&gt;
=== More on real time propagation ===&lt;br /&gt;
&lt;br /&gt;
* [[Real-time dynamics with external field read from file]]&lt;br /&gt;
* [[Parallelization for non-linear response calculations]]&lt;br /&gt;
* [[A fast approach to excitonic effects in linear/non-linear response]]&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
== Developing Lumen ==&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Sum_frequency_generation&amp;diff=875</id>
		<title>Sum frequency generation</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Sum_frequency_generation&amp;diff=875"/>
		<updated>2026-02-05T10:24:04Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the single run */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[[File:Sum frequency.jpg|right|500px |Sum frequency generation]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This tutorial is for internal use only, these response functions are not implemented/tested in yambo/yambopy suite.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will show you how to calculate Sum Frequency Generation(SFG) and also Difference Frequency Generation (DFG) in bulk materials.&amp;lt;br&amp;gt;&lt;br /&gt;
We assume you are already familiar with the non-linear response using the Yambo code.&lt;br /&gt;
If it is not the case please refer to the previous tutorials:  &amp;lt;br&amp;gt;[[Linear response using Dynamical Berry Phase]] and [[Real time approach to non-linear response (SHG)]]&lt;br /&gt;
and Ref.&amp;lt;ref name=nl&amp;gt;[https://arxiv.org/abs/1309.4012 Nonlinear optics from an ab initio approach by means of the dynamical Berry phase: Application to second- and third-harmonic generation in semiconductors], C. Attaccalite and M. Grüning, Phys. Rev. B &#039;&#039;&#039;88&#039;&#039;&#039;, 235113(2013)&amp;lt;/ref&amp;gt;.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
This tutorial has been made possible thanks to the work of [https://www.uni-giessen.de/de/fbz/fb07/fachgebiete/physik/institute/theorie/agsanna/people/mike-pionteck Mike N. Pionteck] published in Ref. &amp;lt;ref name=sfg&amp;gt;[https://arxiv.org/abs/2503.07095 Sum frequency generation from real-time simulations in two-dimensional crystals], M. N. Pionteck, M. Grüning, S. Sanna, C. Attaccalite&amp;lt;/ref&amp;gt;, results are also presented in this Libreoffice presentation [https://www.attaccalite.com/wp-content/uploads/2025/04/sum_frequency.odp sum_frequency.odp].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== DFT calculations ==&lt;br /&gt;
In this example, we will consider a single layer of hexagonal boron nitride (hBN).&lt;br /&gt;
If you haven&#039;t already done so, you can download the input files and Yambo databases for this tutorial here: [https://media.yambo-code.eu/educational/tutorials/files/hBN-2D-RT.tar.gz hBN-2D-RT.tar.gz].&lt;br /&gt;
and/or follow the instructions to generate the databases here: [[Prerequisites for Real Time propagation with Yambo]]&lt;br /&gt;
&lt;br /&gt;
== Removing symmetries ==&lt;br /&gt;
In this tutorial we will calculate the SFG along when both fields are in the &#039;x&#039; direction, &lt;br /&gt;
therefore we remove symmetries not compatible with an external field along this direction, with the command &amp;lt;code&amp;gt; ypp_nl -y&amp;lt;/code&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
 fixsyms                          # [R] Remove symmetries not consistent with an &lt;br /&gt;
 external perturbation&lt;br /&gt;
 % Efield1&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 0.000000 | 0.000000 | &amp;lt;/span&amp;gt;       # First external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 % Efield2&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # Additional external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BField= 0.000000           T     # [MAG] Magnetic field modulus&lt;br /&gt;
 Bpsi= 0.000000             deg   # [MAG] Magnetic field psi angle [degree]&lt;br /&gt;
 Btheta= 0.000000           deg   # [MAG] Magnetic field theta angle [degree]&lt;br /&gt;
 #RmAllSymm                     # Remove all symmetries&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RmTimeRev      &amp;lt;/span&amp;gt;               # Remove Time Reversal&lt;br /&gt;
 #RmSpaceInv                    # Remove Spatial Inversion&lt;br /&gt;
&lt;br /&gt;
==  Real-time simulation with two external fields ==&lt;br /&gt;
You go in the &amp;lt;code&amp;gt;FixSymm&amp;lt;/code&amp;gt; folder and run again the setup. Then you can put the following input file, that has been generated with the command  &amp;lt;code&amp;gt;yambo_nl -u n &amp;lt;/code&amp;gt;, in the folder with the name &amp;lt;code&amp;gt;yambo.in_sfg&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 NLogCPUs=0                       # [PARALLEL] Live-timing CPU`s (0 for all)&lt;br /&gt;
 PAR_def_mode= &amp;quot;balanced&amp;quot;         # [PARALLEL] Default distribution mode (&amp;quot;balanced&amp;quot;/&amp;quot;memory&amp;quot;/&amp;quot;workload&amp;quot;/&amp;quot;KQmemory&amp;quot;)&lt;br /&gt;
 NL_CPU= &amp;quot;10 1&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 NL_ROLEs= &amp;quot;w k&amp;quot;                     # [PARALLEL] CPUs roles (w,k)&lt;br /&gt;
 DIP_CPU= &amp;quot;&amp;quot;                      # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 NL_Threads=0                     # [OPENMP/NL] Number of threads for nl-optics&lt;br /&gt;
 % NLBands&lt;br /&gt;
    &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;3 |  6 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;70.00000 &amp;lt;/span&amp;gt;          fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;         # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2.000000 | 8.000000 |   &amp;lt;/span&amp;gt;      eV    # [NL] Energy range (for loop on frequencies NLEnSteps/=0&lt;br /&gt;
 %&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NLEnSteps= 30  &amp;lt;/span&amp;gt;                # [NL] Energy steps for the loop on frequencies&lt;br /&gt;
 % NLrotaxis&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [NL] Rotation axis (for the loop on angles NLAngSteps/=0)&lt;br /&gt;
 %&lt;br /&gt;
 NLAngSteps=0                     # [NL] Angular steps (if NLAngSteps/=0 field versor will be ignored)&lt;br /&gt;
 NLDamping= 0.200000        eV    # [NL] Damping (or dephasing)&lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative Yambo sets it equal to Phase_LifeTime in NL)&lt;br /&gt;
 #EvalCurrent                   # [NL] Evaluate the current&lt;br /&gt;
 #FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field&lt;br /&gt;
 HARRLvcs= 18475            RL    # [HA] Hartree     RL components&lt;br /&gt;
 EXXRLvcs= 18475            RL    # [XX] Exchange    RL components&lt;br /&gt;
 Field1_Freq=  -0.100000    eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1000.00 &amp;lt;/span&amp;gt;      kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 Field1_kind= &amp;quot; &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field1] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1.000000 | 0.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # [RT Field1] Versor&lt;br /&gt;
 %&lt;br /&gt;
 Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time&lt;br /&gt;
 Field2_Freq=  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;3.000000 &amp;lt;/span&amp;gt;    eV    # [RT Field2] Frequency&lt;br /&gt;
 Field2_Int=   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;1000.00    &amp;lt;/span&amp;gt;   kWLm2 # [RT Field2] Intensity&lt;br /&gt;
 Field2_Width= 0.000000     fs    # [RT Field2] Width&lt;br /&gt;
 Field2_kind= &amp;quot; &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field2] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field2_pol= &amp;quot;linear&amp;quot;             # [RT Field2] Pol(linear|circular)&lt;br /&gt;
 % Field2_Dir&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 0.000000 | 0.000000 |  &amp;lt;/span&amp;gt;      # [RT Field2] Versor &lt;br /&gt;
 %&lt;br /&gt;
 Field2_Tstart= 0.010000    fs    # [RT Field2] Initial Time&lt;br /&gt;
&lt;br /&gt;
If you run this input file with the command &amp;lt;code&amp;gt;yambo_nl -F yambo.in_sfg&amp;lt;/code&amp;gt;, the code will run 30 simulations for a first laser field with frequency between 2.0 and 8.0 while the frequency of the second field is fixed at 3.0 eV. For this reason we provide you a simple python script to change also the frequency of the second field (in blue in the input).&amp;lt;br&amp;gt;&lt;br /&gt;
In the next section we will show how to analyse the non-linear response generated by the presence of two external fields.&lt;br /&gt;
&lt;br /&gt;
== Analysis of the single run ==&lt;br /&gt;
We will use new approach to extract analyze time-dependent polarization in presence of two laser fields &amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt; and used for the tutorials on second/third harmonic generation: [[Real time approach to non-linear response (SHG)]]. These new subroutine are available in the new YamboPy package. Hereafter the python script for the analysis:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.nl.sum_frequencies import SF_Harmonic_Analysis&lt;br /&gt;
 from yambopy.units import fs2aut&lt;br /&gt;
 X_order=4&lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 SF_Harmonic_Analysis(NLDB,X_order=X_order,T_range=[50.0*fs2aut,-1.0],prn_Peff=True,prn_Xhi=True)&lt;br /&gt;
&lt;br /&gt;
Notice that we set the beginning of time range where analysis is performed with the variable &amp;lt;code&amp;gt;T_range=[50.0*fs2aut,-1.0]&amp;lt;/code&amp;gt;, you can also omit this variable and the code automatically will set the optimal range for the analysis using the damping given in input in the real-time simulation.&amp;lt;br&amp;gt;&lt;br /&gt;
This script will analyse the real-time response and produce all the different &amp;lt;math&amp;gt;\chi^{(n)}(\omega)&amp;lt;/math&amp;gt; in the form:&lt;br /&gt;
 &lt;br /&gt;
o.YamboPy-SF_probe_order_1_0 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(1)}(\omega=\omega_1)&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-SF_probe_order_1_1 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(2)}(\omega=\omega_1+\omega_2)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-SF_probe_order_2_0 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(2)}(\omega=2\omega_1)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-SF_probe_order_0_2 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(2)}(\omega=2\omega_2)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-SF_probe_order_1_2 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(3)}(\omega=\omega_1+2\omega_2)&amp;lt;/math&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
o.YamboPy-SF_probe_order_2_2 ==&amp;gt; &amp;lt;math&amp;gt;\chi^{(4)}(\omega=2\omega_1+2\omega_2)&amp;lt;/math&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
etc....&lt;br /&gt;
&lt;br /&gt;
for example we can plot the 4 and 5 columns of the file &amp;lt;code&amp;gt;o.YamboPy-SF_probe_order_1_1&amp;lt;/code&amp;gt; that corresponds to the  &amp;lt;math&amp;gt;\chi^{(2)}_{xyy} (\omega=\omega_1+\omega_2)&amp;lt;/math&amp;gt; for &amp;lt;math&amp;gt;\omega_2 =3.0~eV&amp;lt;/math&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
[[File:Xhi2 11.png|center | 700px |xhi11]]&lt;br /&gt;
&lt;br /&gt;
Here the python script used to generate the previous figure: [https://www.attaccalite.com/tutorials_yambo/plot_xhi2_monolayer.py plot_xhi2_monolayer.py]&lt;br /&gt;
&lt;br /&gt;
=== Checking the Fourier analysis===&lt;br /&gt;
In the previous script we turned on the flag  &amp;lt;code&amp;gt;prn_Peff=True&amp;lt;/code&amp;gt; that automatically will produce a series of file to check if the Fourier was successful.&lt;br /&gt;
The files &amp;lt;code&amp;gt;  o.YamboPy-sampling_F1&amp;lt;/code&amp;gt; contain the sampling points used to fix the real-time polarization, you can for example plot  &amp;lt;code&amp;gt;o.YamboPy-sampling_F1&amp;lt;/code&amp;gt; vs &amp;lt;code&amp;gt;o.polarization_F1&amp;lt;/code&amp;gt; together to see which part of &amp;lt;math&amp;gt;P(t)&amp;lt;/math&amp;gt; is used to extract the response functions:&lt;br /&gt;
[[File:Sampling vs p.png|center| 700px |sampling_p]]&lt;br /&gt;
&lt;br /&gt;
Then you can check if real-time polarization is well reconstructed by the Fourier coefficients calculated by the script by plotting &amp;lt;code&amp;gt; o.YamboPy-pol_reconstructed_F1&amp;lt;/code&amp;gt; vs &amp;lt;code&amp;gt;o.polarization_F1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Reconstructed p vs p.png|center |700px |Reconstructed polarization]]&lt;br /&gt;
&lt;br /&gt;
As you see the polarization is well reconstructed starting from the extracted Fourier coefficients, expect for the beginning, but this is normal because the initial signal is affected by the internal eigen--modes of the systems that later are washed out by the de-phasing. For this reason we use only the last part of the signal for the analysis, for more details see Ref. &amp;lt;ref name=nl&amp;gt;&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of all runs ==&lt;br /&gt;
For this reason we provide you a simple python script to change also the frequency of the second field (in blue in the input).&lt;br /&gt;
&lt;br /&gt;
[https://www.attaccalite.com/tutorials_yambo/run_many_sfg.py run_many_sfg.py]&lt;br /&gt;
&lt;br /&gt;
please modify the python script by set the correct path of your executable, the parallelization and the number of frequency steps you are interested in. In this example we will do &#039;&#039;&#039;30&#039;&#039;&#039; frequency steps for both the first (in the Yambo input) and the second field (in the python script).&lt;br /&gt;
&lt;br /&gt;
Calculations will take some time, in the above example we parallelized on 10 cores to speed up them. &amp;lt;br&amp;gt;&lt;br /&gt;
When the calculations are terminated you will find many folders called  EF1, EF2,  ... EF29.  These folders are generated from the loop on the second field frequency(Field2_Freq), and each one contains the response real-time polarization at 30 different frequencies of the first external field (Field1_Freq).&lt;br /&gt;
&lt;br /&gt;
Now we will use a script to read all the real-time polarization, Fourier analyze them as it was done in the previous section for a single one, and the write the &amp;lt;math&amp;gt;\chi^{(2)}(\omega=\omega_1 + \omega_2)&amp;lt;/math&amp;gt; in a file in the form: &amp;lt;math&amp;gt;\omega_1 , \omega_2, Re \{\chi^{(2)}\} , Im \{\chi^{(2)}\}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[https://www.attaccalite.com/tutorials_yambo/analysis_sfg.py analysis_sfg.py]&lt;br /&gt;
&lt;br /&gt;
then we can interpolate the results &amp;lt;math&amp;gt;\chi^{(2)}(\omega)&amp;lt;/math&amp;gt; and plot results in 3D or 2D: [https://www.attaccalite.com/tutorials_yambo/plot_xhi_2d.py plot_xhi_2d.py], [https://www.attaccalite.com/tutorials_yambo/plot_xhi_3d.py plot_xhi_3d.py]&lt;br /&gt;
&lt;br /&gt;
[[File:SFG 3D.png|center | 700px|SFG 3D]]&lt;br /&gt;
 &lt;br /&gt;
[[File:SFG 2D.png|center | 500px|SFG in 2D]]&lt;br /&gt;
&lt;br /&gt;
You can compare these results with those of Ref.&amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt;. Note that in order to get fully converged results, you need to increase: the number of k-points, the length of the simulations, and the number of frequencies used in the plots. Converged parameters for this system can be found in Ref.&amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt;, including all details to include excitonic effects.&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: In case of degenerate or multiple frequencies &amp;lt;math&amp;gt;\omega_1 = n \omega_2&amp;lt;/math&amp;gt; where  &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; is an integer, the algorithm used to extract the SFG/DFG coefficient could not converge. In this case you can discard these points and use the neighbour solution for interpolation, see discussion in reference &amp;lt;ref name=sfg&amp;gt;&amp;lt;/ref&amp;gt;. Another possibility is to use a least-squares fit algohrithm that starts from the neighbour solution to find the SFG/DFG coefficents, this is implemented in YamboPy in the sum_frequency.py file, but is commented.&lt;br /&gt;
&lt;br /&gt;
== Comparison with SHG ==&lt;br /&gt;
&lt;br /&gt;
Finally you can compare the diagonal of &amp;lt;math&amp;gt;\chi^{(2)}(\omega=\omega_1 +\omega_2)&amp;lt;/math&amp;gt;, when &amp;lt;math&amp;gt;\omega_1 =\omega_2&amp;lt;/math&amp;gt;, with the standard second harmonic generation &amp;lt;math&amp;gt;\chi^{(2)}(\omega=2 \omega_1)&amp;lt;/math&amp;gt; calculated as explained in the tutorial [[Real time approach to non-linear response (SHG)]]:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Xhi2 vs xhi2.png|center | 700px|xhi2_vs_xhi2]]&lt;br /&gt;
&lt;br /&gt;
Notice that there is factor two between the two response functions, this is the so-called degeneracy factor, for more details see Sec. 1.3 in Ref.&amp;lt;ref&amp;gt;Boyd, Robert W., Alexander L. Gaeta, and Enno Giese. &amp;quot;Nonlinear optics.&amp;quot; Springer Handbook of Atomic, Molecular, and Optical Physics. Cham: Springer International Publishing, 1097-1110.(2008)&amp;lt;/ref&amp;gt;. The small differences between the two spectra are given the different sampling strategies of the &amp;lt;code&amp;gt;SF_Harmonic_Analysis&amp;lt;/code&amp;gt; function respect to the &amp;lt;code&amp;gt;Harmonic_Analysis&amp;lt;/code&amp;gt; one.&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature&amp;diff=874</id>
		<title>Optical properties at finite temperature</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature&amp;diff=874"/>
		<updated>2026-02-04T21:06:44Z</updated>

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

		<summary type="html">&lt;p&gt;Wikiadmin: /* Using electron-phonon quasi-particles in real-time simulations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:High low.png|thumb | 200px|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we will show you how to calculate optical properties including thermal effects due to the electron-phonon coupling.&amp;lt;br&amp;gt;&lt;br /&gt;
This tutorial assumes that you have completed all the steps from the previous tutorial on [[Electron Phonon Coupling]].&amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial is dived into different steps first we will calculate absorption at independent particle approximation, &amp;lt;br&amp;gt;then we will include excitonic effects,&lt;br /&gt;
and finally, we will show how to analyze the data.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;WARNING&amp;lt;/span&amp;gt;&#039;&#039;&#039;: Calculations in this tutorial are performed without double-grid, please check if the file &amp;lt;code&amp;gt;SAVE/ndb.PH_DoubleGrid&amp;lt;/code&amp;gt;  is present in your calculations, then remove it and rerun electron-phonon coupling before proceed with optics.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notice that there are two ways to include finite temperature effects in the BSE&#039;&#039;&#039;:&lt;br /&gt;
* The first is to use a full Bethe-Salpeter equation with all the coupling terms in such a way to treat complex quasi-particles that cannot be handled in standard (Hermitian) BSE, this is explained in section [[https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature#Bethe-Salpeter_at_finite_temperature_.28diagonalization_solver.29 Bethe-Salpeter at finite temperature (diagonalization solver)]]. This approach has the advantage that one can obtain excitonic eigenvalues and eigenfunctions at finite temperature and not only the optical spectrum.&lt;br /&gt;
 &lt;br /&gt;
* The second method is use of a standard Hermitinan (resonant) BSE plus the inversion solver &amp;lt;ref name=&#039;dbgrid&#039;&amp;gt;D. Kammerlander et al. [https://arxiv.org/abs/1209.1509 Phys. Rev. B &#039;&#039;&#039;86&#039;&#039;&#039;, 125203] &amp;lt;/ref&amp;gt;. In this case, a Lo two-particle Green&#039;s function that contains the complex quasi-particles is used in the solver to get a finite temperature spectrum. This approach has the advantage that can be used with the double-grid but it does not give access to eigenvalues and eigenfunctions of the BSE. This approach is described in the section: [[https://www.yambo-code.org/wiki/index.php?title=Optical_properties_at_finite_temperature#Bethe-Salpeter_at_finite_temperature_.28inversion_solver.29 Bethe-Salpeter at finite temperature (inversion solver)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Absorption at finite temperature ==&lt;br /&gt;
&lt;br /&gt;
Now you repeat the previous calculation but including all k-points, the last 3 valence and the first 3 conduction bands:&lt;br /&gt;
&lt;br /&gt;
 .....&lt;br /&gt;
 %QPkrange                        # [GW] QP generalized Kpoint/Band indices&lt;br /&gt;
 1|8|2|7|&lt;br /&gt;
 %&lt;br /&gt;
 ....&lt;br /&gt;
and save the results of the 0K and 300K temperature in two separate folder with the -J option. &lt;br /&gt;
Now you can use the correction to the energy levels and the induced width to calculate the optical absorption at finite temperature. Generate the input with the command  &amp;lt;code&amp;gt;yambo_ph -o c -V qp -F yambo.in_300K&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 chi                              # [R][CHI] Dyson equation for Chi.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 Chimod= &amp;quot;IP&amp;quot;                     # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 % QpntsRXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 |   &amp;lt;/span&amp;gt;                          # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXd&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 2 |  7 |  &amp;lt;/span&amp;gt;                         # [Xd] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % EnRngeXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.000000 | 5.000000 | &amp;lt;/span&amp;gt;        eV    # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % DmRngeXd&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.0100000 | 0.0100000 | &amp;lt;/span&amp;gt;        eV    # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ETStpsXd=  1500  &amp;lt;/span&amp;gt;                  # [Xd] Total Energy steps&lt;br /&gt;
 % LongDrXd&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;XfnQPdb= &amp;quot;E W &amp;lt; T300/ndb.QP&amp;quot; &amp;lt;/span&amp;gt;     # [EXTQP Xd] Database action&lt;br /&gt;
&lt;br /&gt;
set the path of the &#039;&#039;ndb.QP&#039;&#039; you want to read and perform the calculations. Notice that from the QP database we read two quantities the correction to the energy levels  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;E&amp;lt;/span&amp;gt; and the width  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;W&amp;lt;/span&amp;gt;. In this calculation we also included a small smearing 0.01eV to mimic the electronic smearing. Run your calculations with the command: &amp;lt;code&amp;gt;yambo_ph -F yambo.in_300K -J T300&amp;lt;/code&amp;gt; and do the same for the 0K case.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;You can plot the results with gnuplot using the command: &amp;lt;code&amp;gt; plot &#039;o-T300.eps_q1_ip&#039; w l t &#039;300 K&#039;, &#039;o-T0.eps_q1_ip&#039; w l t &#039;0 K&#039;&amp;lt;/code&amp;gt;.&amp;lt;br&amp;gt; Hereafter the result without and with electron-phonon coupling at two different temperatures:&lt;br /&gt;
[[File:Si absorption finite t.png|800px|center |Absorption of bulk silicon at finite temperature]]&lt;br /&gt;
&lt;br /&gt;
The temperature effect is clearly visible in the figure.&lt;br /&gt;
&lt;br /&gt;
== Bethe-Salpeter at finite temperature (diagonalization solver) ==&lt;br /&gt;
&lt;br /&gt;
In this section we will calculate the Bethe-Salpeter at finite temperature using the full-BSE.&lt;br /&gt;
&lt;br /&gt;
You can generate the input using the command &amp;lt;code&amp;gt;yambo_ph -X s -o b -k sex -y d -V qp -F yambo.in_BSE&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 em1s                             # [R][Xs] Statically Screened Interaction&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_Threads=0                      # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BSEmod= &amp;quot;coupling&amp;quot;      &amp;lt;/span&amp;gt;         # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;d&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  9257            RL    # [BSK] Exchange components&lt;br /&gt;
 BSENGBlk=-1                RL    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 #WehCpl                        # [BSK] eh interaction included also in coupling&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot;  &amp;lt;/span&amp;gt;     # [EXTQP BSK BSS] Database action&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.500000 | 1.000000 | 1.000000 |  &amp;lt;/span&amp;gt;      # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 BSEprop= &amp;quot;abs&amp;quot;                   # [BSS] Can be any among abs/jdos/kerr/magn/dich/photolum/esrt&lt;br /&gt;
 BSEdips= &amp;quot;none&amp;quot;                  # [BSS] Can be &amp;quot;trace/none&amp;quot; or &amp;quot;xy/xz/yz&amp;quot; to define off-diagonal rotation plane&lt;br /&gt;
 % BSEQptR&lt;br /&gt;
  1 | 1 |                             # [BSK] Transferred momenta range&lt;br /&gt;
 %&lt;br /&gt;
 % BSEBands&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 2 |  7 |&amp;lt;/span&amp;gt;                           # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.000000 | 5.000000 |&amp;lt;/span&amp;gt;         eV    # [BSS] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;0.010000 | 0.010000 | &amp;lt;/span&amp;gt;        eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BEnSteps= 1500    &amp;lt;/span&amp;gt;               # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 #WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
   1 | 12 |                           # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NGsBlkXs= 113                RL &amp;lt;/span&amp;gt;   # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this input file we asked Yambo to include finite temperature quasi-particle in the BSE with the line &amp;lt;code&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot; &amp;lt;/code&amp;gt;, notice that we also introduce an additional rigid shift of 0.5 eV to mimic the GW correction with the line &amp;lt;code&amp;gt; 0.500000 | 1.000000 | 1.000000 |  \# [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&amp;lt;/code&amp;gt;. You can now run the calculation with the command &amp;lt;code&amp;gt; yambo_ph -F yambo.in_BSE -J T0_BSE&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In principle you can calculate the GW correction following the [https://www.yambo-code.org/wiki/index.php?title=How_to_obtain_the_quasi-particle_band_structure_of_a_bulk_material:_h-BN this tutorial] and then merge the corresponding ndb.QP database with the one of the electron-phonon coupling using the command &amp;lt;code&amp;gt; ypp -qpdb m&amp;lt;/code&amp;gt;.&lt;br /&gt;
Notice that we changed the BSE type to &amp;quot;coupling&amp;quot; because you need the full Bethe-Salpeter to deal with complex quasi-particles.&amp;lt;br&amp;gt;&lt;br /&gt;
Now we do the same calculation at T = 300 K. Copy the previous input file &amp;lt;code&amp;gt; cp yambo.in_BSE yambo.in_BSE_300&amp;lt;/code&amp;gt;. Then modify where the code reads the QP database :&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T300/ndb.QP&amp;quot;  &amp;lt;/span&amp;gt;     # [EXTQP BSK BSS] Database action&lt;br /&gt;
Run the command with &amp;lt;code&amp;gt;yambo_ph -F yambo.in_BSE_300 -J T300_BSE&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Finally, you should be able to plot the absorption spectra from the outputs in gnuplot :&lt;br /&gt;
 &amp;lt;code&amp;gt; plot &#039;o-T0_BSE.eps_q1_diago_bse&#039; w l t &#039;0 K&#039;, &#039;o-T300_BSE.eps_q1_diago_bse&#039; w l t &#039;300 K&#039;&amp;lt;/code&amp;gt;&lt;br /&gt;
[[File:Si bse optics.png|800px|center |Bethe-Salpeter at finite temperature for bulk silicom]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Approximations:&#039;&#039;&#039;&amp;lt;br&amp;gt;&lt;br /&gt;
In this calculation we have made different approximations:&amp;lt;br&amp;gt;&lt;br /&gt;
1) we did not include the renormalization of excitons due to the change of the screening potential W with temperature. Including electron-phonon coupling&lt;br /&gt;
in the dielectric constant by changing the line &amp;lt;code&amp;gt; XfnQPdb= &amp;quot;none&amp;quot; &amp;lt;/code&amp;gt; is unfortunately not enough, for a discussion see ref. &amp;lt;ref&amp;gt;L. Adamska and P. Umari, [https://journals.aps.org/prb/abstract/10.1103/PhysRevB.103.075201 Phys. Rev. B &#039;&#039;&#039;103&#039;&#039;&#039;, 075201 (2021)] &amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
2) The electron-phonon coupling should enter in the BSE through the exciton-phonon matrix elements and not from the single-particle self-energy, as we have done in this tutorial. The approximation used in this tutorial is valid for not too strong bound excitons, and in general it generated a finite life-time also for the lowest exciton in direct materials that is not correct. For a discussion see refs.&amp;lt;ref&amp;gt;G. Antonius, S. G. Louie [https://arxiv.org/abs/1705.04245 Phys. Rev. B &#039;&#039;&#039;105&#039;&#039;&#039;, 085111 (2022)]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&#039;claudio&#039;&amp;gt; see Supp. Mat. of [https://journals.aps.org/prb/abstract/10.1103/PhysRevB.99.081109 Phys. Rev. B &#039;&#039;&#039;99&#039;&#039;&#039;, 081109(R) (2019)]&amp;lt;/ref&amp;gt;&amp;lt;ref name=&#039;fulvio&#039;&amp;gt;F. Paleari, [https://orbilu.uni.lu/handle/10993/41058 Phd Thesis (2019)]&amp;lt;/ref&amp;gt; and &amp;lt;ref&amp;gt;H. Chen, D. Sangalli, and M. Bernardi [https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.125.107401 Phys. Rev. Lett. &#039;&#039;&#039;125&#039;&#039;&#039;, 107401 (2020)]&amp;lt;/ref&amp;gt;.&amp;lt;br&amp;gt;&lt;br /&gt;
3) we did not include scattering between exciton and phonons, therefore our results do not contain phonon-assisted absorption peaks, you can include these terms by finite difference displacements see refs. &amp;lt;ref name=&#039;fulvio&#039;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Result analysis ==&lt;br /&gt;
Results of BSE at finite temperature can be analized in the same way of standard BSE. You can plot exciton binging energy as a function of the temperature, exciton wave-function and so, see [https://www.yambo-code.org/wiki/index.php?title=How_to_analyse_excitons Exciton Plot tutorial].&lt;br /&gt;
For example if you sort exciton with the command &amp;lt;code&amp;gt; ypp_ph -e s -J T0_BSE&amp;lt;/code&amp;gt; for the case T=0K, in addition to the exciton energy now you will find its line-width in the files .&lt;br /&gt;
&amp;lt;code&amp;gt;o-T0_BSE.exc_qpt1_E_sorted&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;o-T0_BSE.exc_qpt1_I_sorted&amp;lt;/code&amp;gt;.&lt;br /&gt;
 #&lt;br /&gt;
 #    Maximum Residual Value = .77136E+05&lt;br /&gt;
 #   &lt;br /&gt;
 #    E [ev]             Strength           Index              W [meV]&lt;br /&gt;
 #&lt;br /&gt;
 ...............&lt;br /&gt;
     2.82974172        0.388171151E-1      335.000000         11.9707289&lt;br /&gt;
     2.82976580        0.110338017         334.000000         11.9676380&lt;br /&gt;
     2.82979798        0.992550552         333.000000         11.9646358&lt;br /&gt;
     2.83366466        0.177820283E-2      336.000000         6.12744808&lt;br /&gt;
     2.83368802        0.183327938E-3      338.000000         6.12689734&lt;br /&gt;
     2.83369708        0.679280609E-3      337.000000         6.12836981&lt;br /&gt;
     2.87943292        0.146849517E-3      332.000000         2.51892495&lt;br /&gt;
     2.87945318        0.295515812E-3      331.000000         2.51745558&lt;br /&gt;
     2.89804840        0.539837289E-3      330.000000         1.42265606&lt;br /&gt;
     2.93557525        0.532299697         329.000000         12.5491867&lt;br /&gt;
     2.93559408        0.214365616         391.000000         12.5504198&lt;br /&gt;
     2.93561029        0.175688639         390.000000         12.5498590&lt;br /&gt;
     2.97320676        0.158064649E-3      388.000000         9.35168839&lt;br /&gt;
     2.97321057        0.300355150E-4      408.000000         9.35530090&lt;br /&gt;
     2.97321224        0.931323011E-4      389.000000         9.35327435&lt;br /&gt;
     2.97682190        0.551215744E-4      405.000000         8.87609196&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notice&#039;&#039;&#039; that in the files you will find many excitons with negative energy due the anti-resonant part of the full-BSE.&lt;br /&gt;
&lt;br /&gt;
== Excitonic Eliashberg Functions ==&lt;br /&gt;
If you run the BSE and save the excitonic wave-functions (uncomment the flag &amp;lt;code&amp;gt;WRbsWF&amp;lt;/code&amp;gt; in the BSE input file), tt is possible to plot the excitonic Eliashberg Functions with the command &amp;lt;code&amp;gt; ypp_ph -e e&amp;lt;/code&amp;gt;.&lt;br /&gt;
For an interpretation of these functions see the discussion in reference &amp;lt;ref&amp;gt;Andrea Marini&lt;br /&gt;
 [https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.101.106405 Phys. Rev. Lett. &#039;&#039;&#039;101&#039;&#039;&#039;, 106405 (2008)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Bethe-Salpeter at finite temperature (inversion solver) ==&lt;br /&gt;
&lt;br /&gt;
It is possible to take into account complex quasi-particles in the BSE solution by means of the inversion procedure.&lt;br /&gt;
The idea is to construct an Lo (Eq. 5 of Ref.&amp;lt;ref name=&#039;dbgrid&#039;&amp;gt;&amp;lt;/ref&amp;gt;) that includes the electron-phonon corrections including the imaginary part.&lt;br /&gt;
In order to generate the input you can type: &amp;lt;code&amp;gt;yambo_ph -X s -o b -k sex -y i -V qp&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 em1s                             # [R][Xs] Statically Screened Interaction&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_Threads=0                      # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 Chimod= &amp;quot;HARTREE&amp;quot;                # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSSmod= &amp;quot;i&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  9257            RL    # [BSK] Exchange components&lt;br /&gt;
 BSENGBlk=-1                RL    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 #WehCpl                        # [BSK] eh interaction included also in coupling&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;KfnQPdb= &amp;quot;E W &amp;lt; T0/ndb.QP&amp;quot;&amp;lt;/span&amp;gt;       # [EXTQP BSK BSS] Database action&lt;br /&gt;
 KfnQP_INTERP_NN= 1               # [EXTQP BSK BSS] Interpolation neighbours (NN mode)&lt;br /&gt;
 KfnQP_INTERP_shells= 20.00000    # [EXTQP BSK BSS] Interpolation shells (BOLTZ mode)&lt;br /&gt;
 KfnQP_DbGd_INTERP_mode= &amp;quot;NN&amp;quot;     # [EXTQP BSK BSS] Interpolation DbGd mode&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.500000 | 1.000000 | 1.000000 |  &amp;lt;/span&amp;gt;      # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 BSEprop= &amp;quot;abs&amp;quot;                   # [BSS] abs/kerr/magn/dichr trace&lt;br /&gt;
 % BSEQptR&lt;br /&gt;
  1 | 1 |                             # [BSK] Transferred momenta range&lt;br /&gt;
 %&lt;br /&gt;
 % BSEBands&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   2 |  7 |  &amp;lt;/span&amp;gt;                         # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.00000 | 5.00000 | &amp;lt;/span&amp;gt;        eV    # [BSS] Energy range &lt;br /&gt;
 %&lt;br /&gt;
 % BDmRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.010000 | 0.010000 |  &amp;lt;/span&amp;gt;       eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;BEnSteps= 1500  &amp;lt;/span&amp;gt;                  # [BSS] Energy steps&lt;br /&gt;
 % BLongDir &lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 #WRbsWF                        # [BSS] Write to disk excitonic the WFs&lt;br /&gt;
 XfnQPdb= &amp;quot;none&amp;quot;                  # [EXTQP Xd] Database action&lt;br /&gt;
 % BndsRnXs&lt;br /&gt;
   1 | 12 |                           # [Xs] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NGsBlkXs= 113  &amp;lt;/span&amp;gt;            RL    # [Xs] Response block size&lt;br /&gt;
 % LongDrXs&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [Xs] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 XTermKind= &amp;quot;none&amp;quot;                # [X] X terminator (&amp;quot;none&amp;quot;,&amp;quot;BG&amp;quot; Bruneval-Gonze)&lt;br /&gt;
&lt;br /&gt;
then if you run the job you will get the spectrum at finite temperature. Notice that with the inversion solver you can choose if you want the BSE with or without the coupling by changing the &amp;lt;code&amp;gt;BSEmod&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
This approach can be combined with double-grid as explained here: [http://www.attaccalite.com/speed-up-dielectric-constant-calculations-using-the-double-grid-method-with-yambo/ Speed up dielectric constant calculations using the double-grid method with Yambo ]. Yambo automatically will interpolate quasi-particle corrections on the fine grid. &amp;lt;br&amp;gt; Notice that BSE inversion can become unfeasible for large BSE matrices.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Nota bene:&amp;lt;/span&amp;gt; if you use the inversion solver you just get the optical spectra, but you do not have access to the excitonic eigenvalues and eigenvectors and by consequence you cannot plot the excitonic wave-function or print the  excitonic Eliashberg functions.&lt;br /&gt;
&lt;br /&gt;
== Using electron-phonon quasi-particles in real-time simulations ==&lt;br /&gt;
The electron-phonon quasi-particle correction can be used also in the real-time dynamics. In order to do so, put the &amp;lt;code&amp;gt;ndb.QP&amp;lt;/code&amp;gt; in the SAVE &amp;lt;br&amp;gt;folder and then remove the symmetries with comand &amp;lt;code&amp;gt;ypp_nl -y&amp;lt;/code&amp;gt;, see the tutorial [[Linear response_using Dynamical Berry Phase]].&lt;br /&gt;
&lt;br /&gt;
 fixsyms                          # [R] Remove symmetries not consistent with an external perturbation&lt;br /&gt;
 % Efield1&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 0.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # First external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 % Efield2&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # Additional external Electric Field&lt;br /&gt;
 %&lt;br /&gt;
 BField= 0.000000           T     # [MAG] Magnetic field modulus&lt;br /&gt;
 Bpsi= 0.000000             deg   # [MAG] Magnetic field psi angle [degree]&lt;br /&gt;
 Btheta= 0.000000           deg   # [MAG] Magnetic field theta angle [degree]&lt;br /&gt;
 #RmAllSymm                     # Remove all symmetries&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;RmTimeRev&amp;lt;/span&amp;gt;                     # Remove Time Reversal&lt;br /&gt;
 #RmSpaceInv                    # Remove Spatial Inversion&lt;br /&gt;
 #KeepKGrid                     # Do not expand the k-grid&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;Ypp_nl&amp;lt;/code&amp;gt; will create a new folder &amp;lt;code&amp;gt;FixSymm&amp;lt;/code&amp;gt; with a &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; folder that will contains a new &amp;lt;code&amp;gt;ndb.QP&amp;lt;/code&amp;gt; with removed symmetries. Now you can run a real-time simulation to get the linear response with the command &amp;lt;code&amp;gt;yambo_nl -u p&amp;lt;/code&amp;gt;;&lt;br /&gt;
 &lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 % NLBands&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  2 |  7 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NLtime=150.000000&amp;lt;/span&amp;gt;           fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;           # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX/LSEX/LHF&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NLDamping= 0.010000&amp;lt;/span&amp;gt;        eV    # [NL] Damping (or dephasing)        &lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative RADLifeTime=Phase_LifeTime)&lt;br /&gt;
 #EvalCurrent                   # [NL] Evaluate the current&lt;br /&gt;
 HARRLvcs=  9257            RL    # [HA] Hartree     RL components&lt;br /&gt;
 EXXRLvcs=  9257            RL    # [XX] Exchange    RL components&lt;br /&gt;
 CORRLvcs=  9257            RL    # [GW] Correlation RL components&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GfnQPdb= &amp;quot;E W &amp;lt; SAVE/ndb.QP&amp;quot;&amp;lt;/span&amp;gt;                  # [EXTQP G] Database action&lt;br /&gt;
 Field1_Freq= 0.100000      eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=  1000.00       kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Field1_kind= &amp;quot;DELTA&amp;quot;&amp;lt;/span&amp;gt;          &lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  1.000000 | 0.000000 | 0.000000 |  &amp;lt;/span&amp;gt;      # [RT Field1] Versor&lt;br /&gt;
 %&lt;br /&gt;
In this input we read the quasi-particle life time with the line: &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;GfnQPdb= &amp;quot;E W &amp;lt; SAVE/ndb.QP&amp;quot;&amp;lt;/span&amp;gt;.  Notice that we introduce also a small damping factor &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;NLDamping= 0.01 [eV]&amp;lt;/span&amp;gt; to take into account the dephasing due to the electron-eletrcon interaction and the electron-hole recombination.&lt;br /&gt;
&lt;br /&gt;
This small dephasing is the one that sets the total length of the simulation, because the el-ph one has different values for the different transitions. If you run the code in the output the code suggests you and optical length for the linear reponse, for the non-linear one see. Running the code, it will print in output information of the life-time read from the &amp;lt;code&amp;gt;ndb.QP&amp;lt;/code&amp;gt; database:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;---&amp;gt; Minimum damping detected: 0.001568 [eV]&lt;br /&gt;
 &amp;lt;---&amp;gt; Maximum damping detected: 1.704498 [eV]&lt;br /&gt;
 &amp;lt;---&amp;gt; Suggest simulation length: 131.6424 [fs]&lt;br /&gt;
&lt;br /&gt;
after the you can analyze results with the command &amp;lt;code&amp;gt;ypp_nl -u&amp;lt;/code&amp;gt; or using YamboPy. Hereafter the input for &amp;lt;code&amp;gt;ypp_nl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
 nonlinear                        # [R] Non-linear response analysis&lt;br /&gt;
 Xorder= 1                        # Max order of the response/exc functions&lt;br /&gt;
 % TimeRange&lt;br /&gt;
  -1. |  -1.0000 |         fs    # Time-window where processing is done&lt;br /&gt;
 %&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;ETStpsRt= 1500  &amp;lt;/span&amp;gt;                  # Total Energy steps&lt;br /&gt;
 % EnRngeRt&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;2.00000 | 5.00000 | &amp;lt;/span&amp;gt;        eV    # Energy range&lt;br /&gt;
  %&lt;br /&gt;
 DampMode= &amp;quot;NONE&amp;quot;                 # Damping type ( NONE | LORENTZIAN | GAUSSIAN )&lt;br /&gt;
 DampFactor= 0.000000       eV    # Damping parameter&lt;br /&gt;
 PumpPATH= &amp;quot;none&amp;quot;                 # Path of the simulation with the Pump only&lt;br /&gt;
&lt;br /&gt;
Then you can plot optical absorption at 300 Kelvin from real-time vs the linear response one:&lt;br /&gt;
&lt;br /&gt;
[[File:Rt_vs_lr_finite_T.png|center|800px]]The small wiggles in the real-time results indicate the simulation time is not enought and it should be increased.&lt;br /&gt;
&lt;br /&gt;
== Phonon-assisted density of states ==&lt;br /&gt;
Even if exciton-phonon scattering is not included in the BSE at finite temperature, it is possible to plot the phonon-assisted density of states (DOS) for light emission, defined as:&lt;br /&gt;
&lt;br /&gt;
[[File:Formula exc ph.png | 600px | center | Phonon-assisted JDOS ]]&lt;br /&gt;
&lt;br /&gt;
where &#039;&#039;&#039;E&amp;lt;sub&amp;gt;q&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;l&amp;lt;/sup&amp;gt;&#039;&#039;&#039; is the energy of the &#039;&#039;&#039;l&#039;&#039;&#039;-exciton at &#039;&#039;&#039;q&#039;&#039;&#039;-momentum,  &#039;&#039;&#039;ω&amp;lt;sub&amp;gt;q&amp;lt;/sub&amp;gt;&amp;lt;sup&amp;gt;λ&amp;lt;/sup&amp;gt;&#039;&#039;&#039; is the phonon energy, &#039;&#039;&#039;n&amp;lt;sub&amp;gt;B&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is the Bose function,  exciton are weighted with a Boltzamn factor and &#039;&#039;&#039;E&amp;lt;sub&amp;gt;min&amp;lt;/sub&amp;gt;&#039;&#039;&#039; is the lowest exciton energy in the all BZ.&lt;br /&gt;
In order to calculate these DOS you need to solve BSE for all the q-points for the lowest excitons, you can use SLEPC library to speed up calculations, then you need a converged phonon calculations.&lt;br /&gt;
Then you interpolate phonon on a dense phonon grid using &amp;lt;code&amp;gt;matdyn.x&amp;lt;/code&amp;gt; utility in QE, and Yambo will interpolate exicton on the same grid.&lt;br /&gt;
Here we present an example for hBN that is an indirect semiconductor.&lt;br /&gt;
Running &amp;lt;code&amp;gt; ypp_ph -e p&amp;lt;/code&amp;gt; you will get:&lt;br /&gt;
 &lt;br /&gt;
 BoseTemp= 50 K    # Bosonic Temperature&lt;br /&gt;
 excitons                         # [R] Excitonic properties&lt;br /&gt;
 ph_ass_dos                       # [R] Phonon-assisted DOS&lt;br /&gt;
 States= &amp;quot;1 - 4&amp;quot;                  # Index of the BS state(s)&lt;br /&gt;
 PHfreqF= &amp;quot;./bn.freq_54&amp;quot;            # PWscf format file containing the phonon frequencies&lt;br /&gt;
 % DOSERange&lt;br /&gt;
  5.000000 | 5.500000 |         eV    # Energy range&lt;br /&gt;
 %&lt;br /&gt;
 DOSESteps= 1000                  # Energy steps&lt;br /&gt;
 DOS_broad= 0.004        eV    # Broadening of the DOS &lt;br /&gt;
&lt;br /&gt;
where &amp;quot;bn.freq_54&amp;quot; is the file produced by matdyn.x with the input:&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;input&lt;br /&gt;
     asr=&#039;simple&#039;,&lt;br /&gt;
     flfrc=&#039;bn.fc&#039;,&lt;br /&gt;
     flfrq=&#039;bn.freq_54&#039;,&lt;br /&gt;
     dos=.true.,&lt;br /&gt;
     fldos=&#039;bn.dos&#039;,&lt;br /&gt;
     ndos=2&lt;br /&gt;
     nk1=54, nk2=54, nk3=18&lt;br /&gt;
 /&lt;br /&gt;
&lt;br /&gt;
and the BSE was calculated on a 18x18x6 grid. The final spectra will be:&lt;br /&gt;
&lt;br /&gt;
[[File:Test dos pl bulk.png| 700px | center| Phonon-assisted JDOS]]&lt;br /&gt;
&lt;br /&gt;
where the DOS has been shifted to match the experimental peaks. Notice that the peak intensities are complitely off, because of the lack of the exciton-phonon matrix elements.&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_on_Ubuntu/LinuxMint_with_Intel_compiler&amp;diff=872</id>
		<title>Install Lumen on Ubuntu/LinuxMint with Intel compiler</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_on_Ubuntu/LinuxMint_with_Intel_compiler&amp;diff=872"/>
		<updated>2026-02-01T11:49:43Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Intel compiler are freely available on Linux machines.&amp;lt;br&amp;gt; &lt;br /&gt;
From the Intel oneAPI page, download and install:&amp;lt;br&amp;gt;&lt;br /&gt;
* [https://www.intel.com/content/www/us/en/developer/tools/oneapi/overview.html Intel OneAPI]&lt;br /&gt;
&lt;br /&gt;
Now that you have installed all packages necessary to compile yambo, you can setup the Intel environment.&lt;br /&gt;
If you use the bash/sh shell and you have a local installation just do:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;source /&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;YOURHOME/intel/oneapi/setvars.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if you have an installed OneAPI as root do:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;source /opt/intel/oneapi/setvars.sh&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
now all intel compilers and libraries will be in your path, you are ready to install Yambo. &lt;br /&gt;
The Yambo configure automatically recognize BLAS, LAPACK and FFT from MKL, you have just to specify&lt;br /&gt;
to use MKL also for BLACS and SCALAPACK. &lt;br /&gt;
&lt;br /&gt;
 ./configure CC=icx MPICC=mpiicx MPIFC=mpiifx MPIF77=mpiifx --enable-open-mp --enable-par-linalg --with-scalapack-libs=mkl --with-blacs-libs=mkl --enable-slepc-linalg --with-scalpack-libs=mkl&lt;br /&gt;
&lt;br /&gt;
finally compile the code with:&lt;br /&gt;
 &lt;br /&gt;
 make core&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene&amp;lt;/span&amp;gt;: every time you compile or use Lumen , you have to load the Intel variables with the command: &#039;&#039;&#039;source /opt/intel/oneapi/setvars.sh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you have problems compiling PetSC and Slepc inside Lumen you can download them separately, configure and compile them and the link the libraries with Lumen.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;for PetSC:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Download last version, for example:&lt;br /&gt;
  wget https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-3.24.0.tar.gz&lt;br /&gt;
  tar zxvf petsc-3.24.0.tar.gz&lt;br /&gt;
  cd petsc-3.24.0&lt;br /&gt;
  export PETSC_DIR=$PWD&lt;br /&gt;
  export PETSC_ARCH=linux-opt&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;export INSTALL_DIR=/home/attacc/local_single&amp;lt;/span&amp;gt;   # where you want to install the libraries&lt;br /&gt;
  ./configure --prefix=${INSTALL_DIR} CC=mpiicx CXX=mpiicx FC=mpiifx --with-blas-lapack-dir=${MKLROOT} --with-scalapack-dir=${MKLROOT} --with-precision=single  --with-scalar-type=complex&lt;br /&gt;
  make  &lt;br /&gt;
  make install&lt;br /&gt;
&lt;br /&gt;
Notice that if you use Yambo_nl you have to compile the libraries in double-precision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;for the SlePC:&#039;&#039;&#039;&lt;br /&gt;
  wget https://slepc.upv.es/download/distrib/slepc-3.24.0.tar.gz&lt;br /&gt;
  tar zxvf slepc-3.24.0.tar.gz&lt;br /&gt;
  cd slepc-3.24.0/&lt;br /&gt;
  export SLEPC_DIR=$PWD&lt;br /&gt;
  ./configure --prefix=${INSTALL_DIR} &lt;br /&gt;
  make &lt;br /&gt;
  make install &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;and then use them in Lumen:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 ./configure CC=icx MPICC=mpiicx MPIFC=mpiifort MPIF77=mpiifort FC=ifx F77=ifx --enable-open-mp --enable-par-linalg --with-scalapack-libs=mkl  \&lt;br /&gt;
  --enable-slepc-linalg --with-petsc-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-slepc-path=&amp;quot;${INSTALL_DIR}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_on_Ubuntu/LinuxMint_with_Intel_compiler&amp;diff=871</id>
		<title>Install Lumen on Ubuntu/LinuxMint with Intel compiler</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Install_Lumen_on_Ubuntu/LinuxMint_with_Intel_compiler&amp;diff=871"/>
		<updated>2026-02-01T11:48:36Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Intel compiler are freely available on Linux machines.&amp;lt;br&amp;gt; &lt;br /&gt;
From the Intel oneAPI page, download and install:&amp;lt;br&amp;gt;&lt;br /&gt;
* [https://www.intel.com/content/www/us/en/developer/tools/oneapi/overview.html Intel OneAPI]&lt;br /&gt;
&lt;br /&gt;
Now that you have installed all packages necessary to compile yambo, you can setup the Intel environment.&lt;br /&gt;
If you use the bash/sh shell and you have a local installation just do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;source /&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;YOURHOME/intel/oneapi/setvars.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if you have an installed OneAPI as root do:&lt;br /&gt;
&amp;lt;code&amp;gt;source /opt/intel/oneapi/setvars.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now all intel compilers and libraries will be in your path, you are ready to install Yambo. &lt;br /&gt;
The Yambo configure automatically recognize BLAS, LAPACK and FFT from MKL, you have just to specify&lt;br /&gt;
to use MKL also for BLACS and SCALAPACK. &lt;br /&gt;
&lt;br /&gt;
 ./configure CC=icx MPICC=mpiicx MPIFC=mpiifx MPIF77=mpiifx --enable-open-mp --enable-par-linalg --with-scalapack-libs=mkl --with-blacs-libs=mkl --enable-slepc-linalg&lt;br /&gt;
 --with-blacs-libs=mkl --with-scalpack-libs=mkl&lt;br /&gt;
&lt;br /&gt;
finally compile the code with:&lt;br /&gt;
 &lt;br /&gt;
 make core&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;Nota bene&amp;lt;/span&amp;gt;: every time you compile or use Lumen , you have to load the Intel variables with the command: &#039;&#039;&#039;source /opt/intel/oneapi/setvars.sh&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you have problems compiling PetSC and Slepc inside Lumen you can download them separately, configure and compile them and the link the libraries with Yambo.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;for PetSC:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Download last version, for example:&lt;br /&gt;
  wget https://web.cels.anl.gov/projects/petsc/download/release-snapshots/petsc-3.24.0.tar.gz&lt;br /&gt;
  tar zxvf petsc-3.24.0.tar.gz&lt;br /&gt;
  cd petsc-3.24.0&lt;br /&gt;
  export PETSC_DIR=$PWD&lt;br /&gt;
  export PETSC_ARCH=linux-opt&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;export INSTALL_DIR=/home/attacc/local_single&amp;lt;/span&amp;gt;   # where you want to install the libraries&lt;br /&gt;
  ./configure --prefix=${INSTALL_DIR} CC=mpiicx CXX=mpiicx FC=mpiifx --with-blas-lapack-dir=${MKLROOT} --with-scalapack-dir=${MKLROOT} --with-precision=single  --with-scalar-type=complex&lt;br /&gt;
  make  &lt;br /&gt;
  make install&lt;br /&gt;
&lt;br /&gt;
Notice that if you use Yambo_nl you have to compile the libraries in double-precision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;for the SlePC:&#039;&#039;&#039;&lt;br /&gt;
  wget https://slepc.upv.es/download/distrib/slepc-3.24.0.tar.gz&lt;br /&gt;
  tar zxvf slepc-3.24.0.tar.gz&lt;br /&gt;
  cd slepc-3.24.0/&lt;br /&gt;
  export SLEPC_DIR=$PWD&lt;br /&gt;
  ./configure --prefix=${INSTALL_DIR} &lt;br /&gt;
  make &lt;br /&gt;
  make install &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;and then use them in Yambo:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 ./configure CC=icx MPICC=mpiicx MPIFC=mpiifort MPIF77=mpiifort FC=ifx F77=ifx --enable-open-mp --enable-par-linalg --with-scalapack-libs=mkl --with-blacs-libs=mkl \&lt;br /&gt;
  --enable-slepc-linalg --with-petsc-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-slepc-path=&amp;quot;${INSTALL_DIR}&amp;quot;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Main_Page&amp;diff=870</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Main_Page&amp;diff=870"/>
		<updated>2026-01-30T15:57:00Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;strong&amp;gt;Lumen wiki&amp;lt;/strong&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Installation]]&lt;br /&gt;
* [[Tutorials]]&amp;lt;nowiki/&amp;gt;&lt;br /&gt;
* [https://enccs.github.io/max-coe-workshop/day5-tutorials/ Yambo tutorials on Markdown]&lt;br /&gt;
* [[Lumen release notes|Lumen Releases]]&lt;br /&gt;
* [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy YamboPy]&lt;br /&gt;
* [[Configure library externally]] &lt;br /&gt;
* [https://www.lumen-code.org/doxygen/ Doxygen documentation]&lt;br /&gt;
* [[Internal wiki]]&lt;br /&gt;
* [[Test-suite]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=869</id>
		<title>Configure library externally</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=869"/>
		<updated>2026-01-30T14:27:09Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== In this page we explain how to configure HDF5 and NetCDFc and NetCDF-Fortran ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gfortran Installation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export INSTALL_DIR={your installation directory}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with gfortran:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx --enable-parallel CC=mpicc CPP=&amp;quot;mpicc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot;  FC=mpif90 --enable-build-mode=production&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with gfortran&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --without-pic --enable-static --disable-shared --disable-dap --enable-netcdf-4 CC=gcc CPP=&amp;quot;gcc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALLDIR}&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR} -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpif90 LDFLAGS=&amp;quot;-Wl,--copy-dt-needed-entries&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with gfortran&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --libdir=&amp;quot;${INSTALL_DIR}/lib&amp;quot; --without-pic --enable-static --disable-shared CC=gcc CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpif90 -E&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran&lt;br /&gt;
-I${INSTALLDIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -hdf5&amp;quot; F77=mpif90&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Intel ONEAPI Installation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export INSTALLDIR={your installation directory}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with intel:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/configure --prefix=${INSTALL_DIR} --enable-fortran --enable-parallel CC=mpiicx CPP=&amp;quot;mpiicx -E&amp;quot; FC=mpiifx --enable-build-mode=production --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with intel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --without-pic --enable-static --disable-shared --disable-dap --disable-libxml2 --enable-netcdf-4  CC=mpiicx CPP=&amp;quot;mpiicx -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpiifort CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALL_DIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib  -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpiifx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with intel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --libdir=/home/attacc/local_intel/lib --without-pic --enable-static --disable-shared CC=mpiicx CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpiicx -E&amp;quot; FC=mpiifx CPPFLAGS=&amp;quot;-DpgiFortran -I&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;${INSTALL_DIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran  -lhdf5_hl -lhdf5&amp;quot; F77=mpiifx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Linking libraries to Lumen&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/configure  --with-netcdf-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-netcdff-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-hdf5-path=&amp;quot;${INSTALL_DIR}&amp;quot;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=868</id>
		<title>Configure library externally</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=868"/>
		<updated>2026-01-30T14:26:24Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== In this page we explain how to configure HDF5 and NetCDFc and NetCDF-Fortran ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gfortran Installation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export INSTALL_DIR={your installation directory}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with gfortran:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=$INSTALL_DIR --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx --enable-parallel CC=mpicc CPP=&amp;quot;mpicc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot;  FC=mpif90 --enable-build-mode=production&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with gfortran&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --without-pic --enable-static --disable-shared --disable-dap --enable-netcdf-4 CC=gcc CPP=&amp;quot;gcc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALLDIR}&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR} -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpif90 LDFLAGS=&amp;quot;-Wl,--copy-dt-needed-entries&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with gfortran&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --libdir=&amp;quot;${INSTALL_DIR}/lib&amp;quot; --without-pic --enable-static --disable-shared CC=gcc CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpif90 -E&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran&lt;br /&gt;
-I${INSTALLDIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -hdf5&amp;quot; F77=mpif90&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Intel ONEAPI Installation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export INSTALLDIR={your installation directory}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with intel:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/configure --prefix=$INSTALL_DIR --enable-fortran --enable-parallel CC=mpiicx CPP=&amp;quot;mpiicx -E&amp;quot; FC=mpiifx --enable-build-mode=production --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with intel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=$INSTALL_DIR --without-pic --enable-static --disable-shared --disable-dap --disable-libxml2 --enable-netcdf-4  CC=mpiicx CPP=&amp;quot;mpiicx -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpiifort CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALL_DIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib  -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpiifx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with intel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=/home/attacc/local_intel/ --libdir=/home/attacc/local_intel/lib --without-pic --enable-static --disable-shared CC=mpiicx CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpiicx -E&amp;quot; FC=mpiifx CPPFLAGS=&amp;quot;-DpgiFortran -I&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;${INSTALL_DIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran  -lhdf5_hl -lhdf5&amp;quot; F77=mpiifx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Linking libraries to Lumen&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/configure  --with-netcdf-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-netcdff-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-hdf5-path=&amp;quot;${INSTALL_DIR}&amp;quot;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=867</id>
		<title>Configure library externally</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=867"/>
		<updated>2026-01-30T14:24:06Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== In this page we explain how to configure HDF5 and NetCDFc and NetCDF-Fortran ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gfortran Installation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export INSTALL_DIR={your installation directory}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with gfortran:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=$INSTALL_DIR --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx --enable-parallel CC=mpicc CPP=&amp;quot;mpicc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot;  FC=mpif90 --enable-build-mode=production&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with gfortran&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --without-pic --enable-static --disable-shared --disable-dap --enable-netcdf-4 CC=gcc CPP=&amp;quot;gcc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALLDIR}&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR} -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpif90 LDFLAGS=&amp;quot;-Wl,--copy-dt-needed-entries&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with gfortran&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=${INSTALL_DIR} --libdir=&amp;quot;${INSTALL_DIR}/lib&amp;quot; --without-pic --enable-static --disable-shared CC=gcc CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpif90 -E&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran&lt;br /&gt;
-I${INSTALLDIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -hdf5&amp;quot; F77=mpif90&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Intel ONEAPI Installation&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export INSTALLDIR={your installation directory}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with intel:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/configure --prefix=/home/attacc/local_intel/ --enable-fortran --enable-parallel CC=mpiicx CPP=&amp;quot;mpiicx -E&amp;quot; FC=mpiifx --enable-build-mode=production --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with intel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=/home/attacc/local_intel/ --without-pic --enable-static --disable-shared --disable-dap --disable-libxml2 --enable-netcdf-4  CC=mpiicx CPP=&amp;quot;mpiicx -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpiifort CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALL_DIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib  -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpiifx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with intel&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;./configure --prefix=/home/attacc/local_intel/ --libdir=/home/attacc/local_intel/lib --without-pic --enable-static --disable-shared CC=mpiicx CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpiicx -E&amp;quot; FC=mpiifx CPPFLAGS=&amp;quot;-DpgiFortran -I&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;${INSTALL_DIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALL_DIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran  -lhdf5_hl -lhdf5&amp;quot; F77=mpiifx&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Linking libraries to Lumen&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;/configure  --with-netcdf-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-netcdff-path=&amp;quot;${INSTALL_DIR}&amp;quot; --with-hdf5-path=&amp;quot;${INSTALL_DIR}&amp;quot;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=866</id>
		<title>Configure library externally</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Configure_library_externally&amp;diff=866"/>
		<updated>2026-01-30T14:15:06Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: Created page with &amp;quot;== In this page we explain how to configure HDF5 and NetCDFc and NetCDF-Fortran ==    Configuration of HDF5 1.14.6 with gfortran:  export INSTALLDIR={your installation directory}  ./configure --prefix=$INSTALDIR --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx --enable-parallel CC=mpicc CPP=&amp;quot;mpicc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot;  FC=mpif90 --enable-build-mode=production   Configure NetCDFC-4.9.0 with gfortran  ./configure --...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== In this page we explain how to configure HDF5 and NetCDFc and NetCDF-Fortran ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Configuration of HDF5 1.14.6 with gfortran:&lt;br /&gt;
&lt;br /&gt;
export INSTALLDIR={your installation directory}&lt;br /&gt;
&lt;br /&gt;
./configure --prefix=$INSTALDIR --enable-fortran --disable-shared --enable-static --without-pic --disable-cxx --enable-parallel CC=mpicc CPP=&amp;quot;mpicc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot;  FC=mpif90 --enable-build-mode=production &lt;br /&gt;
&lt;br /&gt;
Configure NetCDFC-4.9.0 with gfortran&lt;br /&gt;
&lt;br /&gt;
./configure --prefix=${INSTALLDIR} --without-pic --enable-static --disable-shared --disable-dap --enable-netcdf-4 CC=gcc CPP=&amp;quot;gcc -E&amp;quot; CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran -I${INSTALLDIR}&amp;quot; LIBS=&amp;quot;-L${INSTALLDIR} -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -lhdf5&amp;quot; F77=mpif90 LDFLAGS=&amp;quot;-Wl,--copy-dt-needed-entries&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Configure NetCDF-fortran 4.6.2 with gfortran&lt;br /&gt;
&lt;br /&gt;
./configure --prefix=${INSTALLDIR} --libdir=&amp;quot;${INSTALLDIR}/lib&amp;quot; --without-pic --enable-static --disable-shared CC=gcc CFLAGS=&amp;quot;-O2 -std=gnu99 -D_C_US -D_FORTRAN_US&amp;quot; CPP=&amp;quot;mpif90 -E&amp;quot; FC=mpif90 CPPFLAGS=&amp;quot;-DpgiFortran&lt;br /&gt;
-I${INSTALLDIR}/include&amp;quot; LIBS=&amp;quot;-L${INSTALLDIR}/lib/ -lnetcdf -lhdf5hl_fortran -lhdf5_fortran -lhdf5_hl -hdf5&amp;quot; F77=mpif90&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=863</id>
		<title>Shift current</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Shift_current&amp;diff=863"/>
		<updated>2026-01-29T14:56:18Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Analysis of the results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:Shift current.png|right|200px | Shift_current]]&lt;br /&gt;
== Introduction ==&lt;br /&gt;
In this tutorial we will show how to calculate Shift Current in bulk materials.&amp;lt;br&amp;gt;&lt;br /&gt;
We suppose you are already familiar with the non-linear response using the Yambo code.&lt;br /&gt;
If it is not the case please study the previous tutorials: &amp;lt;br&amp;gt;[[Linear response using Dynamical Berry Phase]] and [[Real time approach to non-linear response (SHG)]].&amp;lt;br&amp;gt;&lt;br /&gt;
This theoretical implementation of this tutorial is described in the paper  &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; , please cite it if you use it. &amp;lt;br&amp;gt;&lt;br /&gt;
The tutorial was created with the help of [https://www.linkedin.com/in/yuncheng-mao-8aba6279/ Yuncheng Mao].&lt;br /&gt;
&lt;br /&gt;
== Setup calculations ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will take as example the two dimensional GeS monolayer.&amp;lt;br&amp;gt;&lt;br /&gt;
DFT inputs can be downloaded here: [http://www.attaccalite.com/tutorials_yambo/GeS_DFT.tgz  GeS_DFT.tgz].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First of all run the setup, then remove symmetries along the &#039;&#039;&#039;y&#039;&#039;&#039; direction, as explained in the tutorial above.&lt;br /&gt;
&lt;br /&gt;
== Real-time setup and calculations ==&lt;br /&gt;
&lt;br /&gt;
In order to generate input file for shift current you do: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -u n -V par -F input.in&amp;lt;/span&amp;gt; &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 nloptics                         # [R] Non-linear spectroscopy&lt;br /&gt;
 NLogCPUs=0                       # [PARALLEL] Live-timing CPU`s (0 for all)&lt;br /&gt;
 PAR_def_mode= &amp;quot;balanced&amp;quot;         # [PARALLEL] Default distribution mode (&amp;quot;balanced&amp;quot;/&amp;quot;memory&amp;quot;/&amp;quot;workload&amp;quot;/&amp;quot;KQmemory&amp;quot;)&lt;br /&gt;
 NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;                       # [PARALLEL] CPUs for each role&lt;br /&gt;
 NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;quot;                     # [PARALLEL] CPUs roles (w,k)&lt;br /&gt;
 DIP_CPU= &amp;quot;&amp;quot;                      # [PARALLEL] CPUs for each role&lt;br /&gt;
 DIP_ROLEs= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs roles (k,c,v)&lt;br /&gt;
 OSCLL_CPU= &amp;quot;&amp;quot;                    # [PARALLEL] CPUs for each role&lt;br /&gt;
 OSCLL_ROLEs= &amp;quot;&amp;quot;                  # [PARALLEL] CPUs roles (k,b)&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 NL_Threads=0                     # [OPENMP/NL] Number of threads for nl-optics&lt;br /&gt;
 OSCLL_Threads=0                  # [OPENMP/X] Number of threads for Oscillators&lt;br /&gt;
 % NLBands&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;17 |  24 | &amp;lt;/span&amp;gt;                          # [NL] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 NLverbosity= &amp;quot;high&amp;quot;              # [NL] Verbosity level (low | high)&lt;br /&gt;
 NLtime=-1.000000           fs    # [NL] Simulation Time&lt;br /&gt;
 NLintegrator= &amp;quot;INVINT&amp;quot;           # [NL] Integrator (&amp;quot;EULEREXP/RK2/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&amp;quot;)&lt;br /&gt;
 NLCorrelation= &amp;quot;IPA&amp;quot;             # [NL] Correlation (&amp;quot;IPA/HARTREE/TDDFT/LRC/LRW/JGM/SEX/LSEX/LHF&amp;quot;)&lt;br /&gt;
 NLLrcAlpha= 0.000000             # [NL] Long Range Correction&lt;br /&gt;
 % NLEnRange&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1.000000 | 8.000000 &amp;lt;/span&amp;gt; |         eV    # [NL] Energy range (for loop on frequencies NLEnSteps/=0&lt;br /&gt;
 %&lt;br /&gt;
 NLEnSteps=  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;24     &amp;lt;/span&amp;gt;               # [NL] Energy steps for the loop on frequencies&lt;br /&gt;
 % NLrotaxis&lt;br /&gt;
  0.000000 | 0.000000 | 0.000000 |        # [NL] Rotation axis (for the loop on angles NLAngSteps/=0)&lt;br /&gt;
 %&lt;br /&gt;
 NLAngSteps=0                     # [NL] Angular steps (if NLAngSteps/=0 field versor will be ignored)&lt;br /&gt;
 NLDamping= 0.200000        eV    # [NL] Damping (or dephasing)&lt;br /&gt;
 RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative RADLifeTime=Phase_LifeTime)&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt;                    # [NL] Evaluate the current&lt;br /&gt;
 #FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field&lt;br /&gt;
 Field1_Freq= 0.100000      eV    # [RT Field1] Frequency&lt;br /&gt;
 Field1_Int=  1000.00       kWLm2 # [RT Field1] Intensity&lt;br /&gt;
 Field1_Width= 0.000000     fs    # [RT Field1] Width&lt;br /&gt;
 Field1_kind= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;SOFTSIN&amp;lt;/span&amp;gt;&amp;quot;           # [RT Field1] Kind(SIN|SOFTSIN| see more on src/modules/mod_fields.F)&lt;br /&gt;
 Field1_pol= &amp;quot;linear&amp;quot;             # [RT Field1] Pol(linear|circular)&lt;br /&gt;
 % Field1_Dir&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 0.000000 | 1.000000 | 0.000000 |   &amp;lt;/span&amp;gt;     # [RT Field1] Versor &lt;br /&gt;
 %&lt;br /&gt;
 Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time&lt;br /&gt;
&lt;br /&gt;
Notice that in this input we turned one the evaluation of current  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;EvalCurrent&amp;lt;/span&amp;gt; and force the parallelization on the frequencies, &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;NL_CPU= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;8 1&amp;lt;/span&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt; NL_ROLEs= &amp;quot;&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;w k&amp;lt;/span&amp;gt;&amp;lt;/code&amp;gt;&amp;quot;, that is much more efficient than the one on k-points.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Then you can run simulation by doing: &amp;lt;span style=&amp;quot;color:blue&amp;quot;&amp;gt;yambo_nl -F input.in&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Analysis of the results ==&lt;br /&gt;
&lt;br /&gt;
In order to analyze the result we use  Yambopy: [https://wiki.yambo-code.eu/wiki/index.php?title=First_steps_in_Yambopy YamboPy],&amp;lt;br&amp;gt; and the following script for the post-processing:&lt;br /&gt;
&lt;br /&gt;
 from yambopy import *&lt;br /&gt;
 from yambopy.nl.harmonic_analysis import Harmonic_Analysis&lt;br /&gt;
 from yambopy.units import fs2aut&lt;br /&gt;
 X_order=4&lt;br /&gt;
 NLDB=YamboNLDB()&lt;br /&gt;
 Harmonic_Analysis(NLDB,X_order=X_order,prn_Peff=True)&lt;br /&gt;
&lt;br /&gt;
This script will produce different file containing the response function of the current and polarization respect to the total field.&lt;br /&gt;
From the second order response of the current at zero frequency, file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0&amp;lt;/code&amp;gt;  we can extract the shift current coefficient along the &#039;y&#039; direction&lt;br /&gt;
that correspond to the 5th column of the file. In the file &amp;lt;code&amp;gt;o.YamboPy-Sigma_probe_order_0:&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
the first column ti the energy&lt;br /&gt;
&lt;br /&gt;
columns 2,3 are the imaginary and real part along x-direction&lt;br /&gt;
&lt;br /&gt;
columns 4,5 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
columns 6,7 are the imaginary and real part along y-direction&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that the imaginary part is zero within the numerical precision.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Hereafter we report the shift current spectrum compared with the results of Ibañez-Azpiroz et al. &amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:Sigma2.png|center| 800px | Shift current]]&lt;br /&gt;
&lt;br /&gt;
The python script to plot the results, the data from the Ibañez-Azpiroz paper can be downloaded here: [https://www.attaccalite.com/tutorials_yambo/GeS_plot.tgz GeS_plot].  &amp;lt;br&amp;gt;&lt;br /&gt;
In this example we used very few k-points, increasing the number of k-points bring the result very close to the one of Ibañez-Azpiroz, see also Supp. Mat. of Ref. &amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;&amp;lt;/ref&amp;gt; .&amp;lt;br&amp;gt;&lt;br /&gt;
Notice that we rescale the shift-currect for an effective thickness of 2.65 Angstrom, you can find all the rescaling factor in the python script.&lt;br /&gt;
&lt;br /&gt;
Correlation effects can be included in the SC response in the same way we do for other non-linear response functions, for more info look at the tutorial:&lt;br /&gt;
[https://wiki.yambo-code.eu/wiki/index.php?title=SHG_within_the_TD-aGW_level_(also_called_TD-HSEX,_TD-BSE) SHG within the TD-aGW level (also called TD-HSEX, TD-BSE)]&lt;br /&gt;
&lt;br /&gt;
== References == &lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;yuncheng&amp;quot;&amp;gt;Yuncheng Mao, Myrta Grüning, Ju Zhou, and Claudio Attaccalite, &#039;&#039;Shift current in 2D Janus Transition-Metal Dichalcogenides: the role of excitons&lt;br /&gt;
&#039;&#039;, [https://arxiv.org/abs/2506.16067 arXiv:2506.16067(2025)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Azpiroz&amp;quot;&amp;gt;Julen Ibañez-Azpiroz, Stepan S. Tsirkin, and Ivo Souza, &#039;&#039;Ab initio calculation of the shift photocurrent by Wannier interpolation&#039;&#039;, [https://doi.org/10.1103/PhysRevB.107.205204  Phys. Rev. B &#039;&#039;&#039;107&#039;&#039;&#039;, 205204 (2023)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=LiF&amp;diff=860</id>
		<title>LiF</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=LiF&amp;diff=860"/>
		<updated>2026-01-29T14:27:08Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* The Bethe-Salpeter equation, Excitons (yambo -o b -k sex -y h -V qp) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
= Prerequisites =&lt;br /&gt;
== The material ==&lt;br /&gt;
&lt;br /&gt;
[[File:LiF-crystal.jpg|x300px|frameless|LiF crystal]]&lt;br /&gt;
[[File:LiF_lif_structure.jpg|x300px|frameless|LiF structure]]&lt;br /&gt;
[[File:lif_rholf.png|x350px|frameless|Optical absorption of solid LiF. Dots: experiment. Continuous line: BSE. Dashed line: RPA-QP]]&lt;br /&gt;
&lt;br /&gt;
LiF is an isulator with a wide band-ga and the following characteristics:&lt;br /&gt;
* FCC lattice&lt;br /&gt;
* Two atoms per cell, Li and F (8 electrons) &lt;br /&gt;
* Lattice constant 7.61 [a.u.]&lt;br /&gt;
* Plane waves cutoff 40 Hartree (1800 RL vectors)&lt;br /&gt;
&lt;br /&gt;
In this tutorial we will use LiF to show the importance of excitonic effects in the optical properites of materials with weak screening.&lt;br /&gt;
We will start the TDDFT tutorial exactly where standard local approximations for f&amp;lt;sub&amp;gt;xc&amp;lt;/sub&amp;gt; (like ALDA) do not work at all. The optical spectrum of solid&lt;br /&gt;
[[LiF]] &amp;lt;ref name=&amp;quot;wikipedia/&amp;gt; is dominated by a strongly bound exciton (3 eV binding energy) &amp;lt;ref name=&amp;quot;Rohlfing&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Marini&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Adragna&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Sottile&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Reining&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Botti&amp;quot;/&amp;gt;&amp;lt;ref name=&amp;quot;Sangalli&amp;quot;/&amp;gt; and will immediately see that any independent particle approximation drastically fails to describe the complex structures that are observed experimentally.&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[Tutorials_download]] and download/unpack the [https://media.yambo-code.eu/educational/tutorials/files/LiF.tar.gz LiF.tar.gz]. &amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; Increase the number of bands in the NSCF DFT up to 50&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Computing the ground state properties with PWscf ==&lt;br /&gt;
&lt;br /&gt;
 $ cd YAMBO_TUTORIALS/LiF/PWSCF&lt;br /&gt;
 $ ls&lt;br /&gt;
 inputs	outputs  psps&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; inputs/scf.in &amp;gt; scf.out&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; inputs/nscf.in &amp;gt; nscf.out  &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_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;LiF.save&#039;&#039; directory:&lt;br /&gt;
 $ ls LiF.save&lt;br /&gt;
 charge-density.dat  data-file-schema.xml  F.LDA.cpi.UPF  Li.LDA.cpi.UPF  wfc10.dat  wfc1.dat  wfc2.dat	wfc3.dat  wfc4.dat  wfc5.dat  wfc6.dat	wfc7.dat  wfc8.dat  wfc9.dat&lt;br /&gt;
&lt;br /&gt;
== Conversion to Yambo format ==&lt;br /&gt;
The PWscf &#039;&#039;LiF.save&#039;&#039; output is converted to the Yambo format using the &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt; executable (pwscf to yambo), found in the yambo &#039;&#039;bin&#039;&#039; directory.&lt;br /&gt;
Enter &#039;&#039;LiF.save&#039;&#039; and launch &amp;lt;code&amp;gt;p2y&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
 $ cd LiF.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. &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 ../../Optics/YAMBO&lt;br /&gt;
 $ ls&lt;br /&gt;
 SAVE&lt;br /&gt;
&lt;br /&gt;
In the following we will describe in detail the different TDDFT related calculations. For each example you can find a link to the Input file with a brief explanation of the variables meaning.&lt;br /&gt;
&lt;br /&gt;
We will also use this first system to explain in detail some of the most relevant technical aspects of yambo.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Initialization (yambo -i -V RL) =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This section describes the standard initialization procedure. As this initialization is common to all yambo runs it will be described extensively only in this case.&lt;br /&gt;
&lt;br /&gt;
To run this example enter the &#039;&#039;YAMBO&#039;&#039; directory (where you have previously created the SAVE folder) and type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; localhost:&amp;gt;yambo -F Inputs/01_init -J 01_init&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
and you will see&lt;br /&gt;
&amp;lt;pre&amp;gt; &amp;lt;---&amp;gt; [01] Game Summary&lt;br /&gt;
 &amp;lt;---&amp;gt; [02] Input variables setup&lt;br /&gt;
 &amp;lt;---&amp;gt; RL-shells |                    | [000%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; RL-shells |####################| [100%] --(E) --(X)&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.01] K-grid lattice&lt;br /&gt;
 &amp;lt;---&amp;gt; [02.02] Input (E)nergies[ev] &amp;amp;amp; Occupations&lt;br /&gt;
 &amp;lt;---&amp;gt; [03] Transferred momenta grid: Indexes&lt;br /&gt;
 &amp;lt;---&amp;gt; [04] Game Over &amp;amp;amp; Game summary&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
If now you edit the &#039;&#039;r-01_setup&#039;&#039; you will find a lot of useless ([[File:LiF_smile.gif|60x23px]]) informations about your system like, the Fermi level&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;   [02.02] Input (E)nergies[ev] &amp;amp;amp; Occupations&lt;br /&gt;
  ========&lt;br /&gt;
 &lt;br /&gt;
  Fermi Energy[ev] - T[ev/K] :-0.241627  0.000100  1.160400&lt;br /&gt;
  Bands summary              : Full        Empty&lt;br /&gt;
                               0001-0004   0005-0050&lt;br /&gt;
  Indirect Gap  [ev][min-max]:  9.11330  14.79631&amp;lt;/pre&amp;gt;&lt;br /&gt;
confirming that, yes, our bulk LiF is a &#039;&#039;&#039;wide&#039;&#039;&#039; gap insulator. Then you can see the effect of using&lt;br /&gt;
&amp;lt;pre&amp;gt; MaxGvecs=  800           RL  # [INI] Max number of G-vectors planned to use&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
in the &#039;&#039;Inputs/01_init&#039;&#039; file. In the report file we notice that&lt;br /&gt;
&amp;lt;pre&amp;gt;  G-vectors             [RL space]: 1807&lt;br /&gt;
                   [wavefunctions]: 1807&amp;lt;/pre&amp;gt;&lt;br /&gt;
whereas the Reciprocal Space shells found by yambo are&lt;br /&gt;
&amp;lt;pre&amp;gt; G-vector (S)hells. Format: [Snn] G`s&lt;br /&gt;
  [S0030]:   773 [S0029]:   749 [S0028]:   725 [S0027]:   701 [S0026]:   645&lt;br /&gt;
  [S0025]:   609 [S0024]:   561 [S0023]:   537 [S0022]:   531 [S0021]:   459&lt;br /&gt;
  [S0020]:   411 [S0019]:   387 [S0018]:   339 [S0017]:   331 [S0016]:   307&lt;br /&gt;
  [S0015]:   283 [S0014]:   259 [S0013]:   229 [S0012]:   181 [S0011]:   169&lt;br /&gt;
  [S0010]:   137 [S0009]:   113 [S0008]:    89 [S0007]:    65 [S0006]:    59&lt;br /&gt;
  [S0005]:    51 [S0004]:    27 [S0003]:    15 [S0002]:     9 [S0001]:     1&amp;lt;/pre&amp;gt;&lt;br /&gt;
so that the highest number of RL vectors we can use is 773, lower than the charge number given by Abinit and different from the value for &#039;&#039;MaxGvecs&#039;&#039; we provided. This happens because yambo has calculated the Reciprocal Space shells up to 800 to find that the highest closed shell corresponds to 773 RL vectors. Note that, independently of the value you set for any variable that defines a dimension in the RL space, yambo redefines it, in order to match it to the nearest closed shell.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;02&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span id=&amp;quot;03&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Random-Phase approximation (yambo -o c) (yambo -o c -k hartree) (yambo -o c -k hartree -V qp) =&lt;br /&gt;
&lt;br /&gt;
The simplest approximation that can be used to calculate the absorption spectrum of LiF is the independent particle approximation. This is done in &#039;&#039;Inputs/02_RPA_no_LF&#039;&#039;, that is generated directly by &amp;amp;quot;yambo -o c&amp;amp;quot; command line without specifying an approximation for the kernel (in fact there is no kernel!), To run this example type&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; localhost:&amp;gt;yambo -F Inputs/02_RPA_no_LF -J 02_RPA_no_LF&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
The optional &#039;&#039;-J&#039;&#039; flag is used to label the output/report/log files.&lt;br /&gt;
In &#039;&#039;Inputs/03_RPA_LF&#039;&#039; we include a kernel in the Hartree approximation. This correspond to the Random-Phase-Approximation (RPA). The response function size is changed to 51 RL. This means including Local Field Effects corresponding to charge oscillations expanded up to the 51&amp;lt;sup&amp;gt;st&amp;lt;/sup&amp;gt; RL component. The converged value for &#039;&#039;NGsBlkXd&#039;&#039; shall be determined by doing several calculations with different values and checking the effect on the final physical result (the absorption spectrum, in this case).&lt;br /&gt;
&lt;br /&gt;
After having run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; localhost:&amp;gt;yambo -F Inputs/03_RPA_LF -J 03_RPA_LF&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
we can compare the result of our calculations with the experimental curve (that you find in the &#039;&#039;Experiment&#039;&#039; folder).&lt;br /&gt;
&lt;br /&gt;
[[File:LiF_02_03.png|512x384px&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
The comparison with the experiment clearly show that the RPA is not at all adequate in the case of LiF. We notice two main discrepancies between theory and experiment: the RPA absorption onset is too low and the shape lacks the sharp peak observed experimentally at around 12 eV. The onset position can be artificially corrected using a scissor operator (representing the QP gap correction) of 5.19 eV that simply opens rigidly the LDA gap. This is shown in &#039;&#039;Inputs/03_RPA_LF_QP&#039;&#039; with the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;% XfnQP_E&lt;br /&gt;
 5.190000 | 1.000000 | 1.000000 |      # [EXTQP Xd] E parameters (c/v)&lt;br /&gt;
%&amp;lt;/pre&amp;gt;&lt;br /&gt;
The resulting spectrum fits better with the experiment but now there seems to be an even more serious problem:&lt;br /&gt;
&lt;br /&gt;
[[File:LiF_03.png|512x384px]]&lt;br /&gt;
&lt;br /&gt;
there is an experimental peak well below the QP absorption onset:&lt;br /&gt;
&lt;br /&gt;
an [http://en.wikipedia.org/wiki/Exciton EXCITON!]&lt;br /&gt;
&lt;br /&gt;
[[File:LiF_exciton.jpg|160x202px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;04&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
= ALDA (yambo -o c -k alda) =&lt;br /&gt;
&lt;br /&gt;
Our first attempt to go beyond RPA is using TDDFT in the Adiabatic LDA approximation. Depending on the exchange-correlation(xc) functional used in the ground state calculation yambo will produce a corresponding xc-kernel. In this case, as reported by the &#039;&#039;a2y&#039;&#039; command we are using a Perdew Wang parametrization.&lt;br /&gt;
Generate input file with the command: &amp;lt;code&amp;gt; yambo -o c -k alda -F tdlda.in&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 chi                              # [R][CHI] Dyson equation for Chi.&lt;br /&gt;
 tddft                            # [R][K] Use TDDFT kernel&lt;br /&gt;
 #DegFix                        # Force the code to impose the energy levels to respect their degeneracy&lt;br /&gt;
 Chimod= &amp;quot;ALDA&amp;quot;                   # [X] IP/Hartree/ALDA/LRC/PF/BSfxc&lt;br /&gt;
 FxcGRLc= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;51 &amp;lt;/span&amp;gt;                RL    # [TDDFT] XC-kernel RL size&lt;br /&gt;
 NGsBlkXd= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;51 &amp;lt;/span&amp;gt;               RL    # [Xd] Response block size&lt;br /&gt;
 % QpntsRXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 1 | 1 | &amp;lt;/span&amp;gt;                    # [Xd] Transferred momenta&lt;br /&gt;
 %&lt;br /&gt;
 % BndsRnXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   1 | 10 | &amp;lt;/span&amp;gt;                  # [Xd] Polarization function bands&lt;br /&gt;
 %&lt;br /&gt;
 % EnRngeXd&lt;br /&gt;
 &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  7.50000 | 25.00000 | &amp;lt;/span&amp;gt;  eV  # [Xd] Energy range&lt;br /&gt;
 %&lt;br /&gt;
 % DmRngeXd&lt;br /&gt;
  0.100000 | 0.100000 |   eV  # [Xd] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 ETStpsXd= &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;300 &amp;lt;/span&amp;gt;               # [Xd] Total Energy steps&lt;br /&gt;
 % LongDrXd&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |      # [Xd] [cc] Electric Field&lt;br /&gt;
 %&lt;br /&gt;
&lt;br /&gt;
In this input we set to 51 RL (reciprocal lattice vectors) the size of the dielectric constant. This is also the number of RL vectors&lt;br /&gt;
used for the exchange correlation functional (FxcGRLc).&lt;br /&gt;
You can run the input with the command: &amp;lt;code&amp;gt;yambo -F tdlda.in&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output will be in the file &amp;lt;code&amp;gt;o.eps_q1_inv_alda_dyson&amp;lt;/code&amp;gt;, where the first column is the energy while the second and third are the imaginary&lt;br /&gt;
and real parts of the dielectric constant.  &lt;br /&gt;
&lt;br /&gt;
[[File:LiF_04.png|512x384px]]&lt;br /&gt;
&lt;br /&gt;
Unfortunately ALDA only slightly changes the RPA result. The situation will change in more isolated system (reduced dimensionality).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;05&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=The Statically screened Electron-electron interaction (yambo -X s) =&lt;br /&gt;
&lt;br /&gt;
As simple RPA and ALDA approximations have not described correctly the experimental spectrum we have to move towards more elaborate techniques like the Bethe-Salpeter (BS) equation.&lt;br /&gt;
&lt;br /&gt;
A key ingredient in the BS kernel is the electron-electron interaction commonly evaluated in the static approximation. The input file &#039;&#039;Inputs/05_W&#039;&#039; describes how to calculate it. The variables used in this input file have the same physical meaning of those used in the optical absorption calculation. The only difference is that, in general, the response function dimension obtained in the examples (03-04), gives an upper bound to the number of RL vectors needed here. This is because the size of response matrix in an RPA calculation defines also the size of the Hartree potential, whose short-range components are not screened. In the present case, instead, the electron-electron interaction is screened and, for this reason, the RL vectors needed are considerably smaller than in the RPA case. So let&#039;s type (no &#039;&#039;-J&#039;&#039; option here) ...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; localhost:&amp;gt;yambo -F Inputs/05_W &amp;lt;/pre&amp;gt;&lt;br /&gt;
... and after waiting for some minutes the result, that is the database SAVE/ndb.em1s. Do not use the &#039;&#039;-J&#039;&#039; option here as we will need to read this database in the next examples.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;06&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=The Bethe-Salpeter equation, Excitons (yambo -o b -k sex -y h -V qp) =&lt;br /&gt;
&lt;br /&gt;
The input file of BSE describes how to calculate an excitonic absorption spectrum, by solving the BS equation using the recursive Haydock Method. &lt;br /&gt;
The input file can be generated with the command above. Before running &#039;&#039;yambo&#039;&#039; we must have set the paramteter of the input file, in red the one we changed:&lt;br /&gt;
&lt;br /&gt;
 optics                           # [R] Linear Response optical properties&lt;br /&gt;
 bss                              # [R] BSE solver&lt;br /&gt;
 bse                              # [R][BSE] Bethe Salpeter Equation.&lt;br /&gt;
 dipoles                          # [R] Oscillator strenghts (or dipoles)&lt;br /&gt;
 #DegFix                        # Force the code to impose the energy levels to respect their degeneracy&lt;br /&gt;
 DIP_Threads=0                    # [OPENMP/X] Number of threads for dipoles&lt;br /&gt;
 X_Threads=0                      # [OPENMP/X] Number of threads for response functions&lt;br /&gt;
 K_Threads=0                      # [OPENMP/BSK] Number of threads for response functions&lt;br /&gt;
 BSKmod= &amp;quot;SEX&amp;quot;                    # [BSE] IP/Hartree/HF/ALDA/SEX/BSfxc&lt;br /&gt;
 BSEmod= &amp;quot;resonant&amp;quot;               # [BSE] resonant/retarded/coupling&lt;br /&gt;
 BSEdiskIO= &amp;quot;medium&amp;quot;              # [BSE] medium (restart possible only in corr.)|low (writes at the end)|none&lt;br /&gt;
 BSSmod= &amp;quot;h&amp;quot;                      # [BSS] (h)aydock/(d)iagonalization/(s)lepc/(i)nversion/(t)ddft`&lt;br /&gt;
 BSENGexx=  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 773&amp;lt;/span&amp;gt;            RL    # [BSK] Exchange components&lt;br /&gt;
 BSENGBlk=  51              RL    # [BSK] Screened interaction block size [if -1 uses all the G-vectors of W(q,G,Gp)]&lt;br /&gt;
 #WehCpl                        # [BSK] eh interaction included also in coupling&lt;br /&gt;
 KfnQP_DbGd_INTERP_mode= &amp;quot;NN&amp;quot;     # [EXTQP BSK BSS] Interpolation DbGd mode&lt;br /&gt;
 % KfnQP_E&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt; 5.800000 &amp;lt;/span&amp;gt; | 1.000000 | 1.000000 |        # [EXTQP BSK BSS] E parameters  (c/v) eV|adim|adim&lt;br /&gt;
 %&lt;br /&gt;
 % BSEQptR&lt;br /&gt;
  1 | 1 |                             # [BSK] Transferred momenta range&lt;br /&gt;
 %&lt;br /&gt;
 % BSEBands&lt;br /&gt;
  &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;   2 |  7 |  &amp;lt;/span&amp;gt;                         # [BSK] Bands range&lt;br /&gt;
 %&lt;br /&gt;
 % BEnRange&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.00000 | 20.00000 |   &amp;lt;/span&amp;gt;      eV    # [BSS] Energy range&lt;br /&gt;
 % &lt;br /&gt;
 %BDmRange&lt;br /&gt;
  0.100000 | 0.100000 |         eV    # [BSS] Damping range&lt;br /&gt;
 %&lt;br /&gt;
 BEnSteps= 100                    # [BSS] Energy steps&lt;br /&gt;
 % BLongDir&lt;br /&gt;
  1.000000 | 0.000000 | 0.000000 |        # [BSS] [cc] Electric Field versor&lt;br /&gt;
 %&lt;br /&gt;
 BSEprop= &amp;quot;abs&amp;quot;                   # [BSS] Can be any among abs/jdos/kerr/asymm/anHAll/magn/dich/photolum/esrt&lt;br /&gt;
 BSEdips= &amp;quot;none&amp;quot;                  # [BSS] Can be &amp;quot;trace/none&amp;quot; or &amp;quot;xy/xz/yz&amp;quot; to define off-diagonal rotation plane&lt;br /&gt;
 BSHayTrs=-0.020000               # [BSS] Relative [o/o] Haydock threshold. Strict(&amp;gt;0)/Average(&amp;lt;0) &lt;br /&gt;
&lt;br /&gt;
The line&lt;br /&gt;
&amp;lt;pre&amp;gt;% KfnQP_E&lt;br /&gt;
 5.80000 | 1.000000 | 1.000000 |      # [EXTQP BSK BSS] E parameters (c/v)&lt;br /&gt;
%&amp;lt;/pre&amp;gt;&lt;br /&gt;
applies a 5.8 eV scissor in order to open the LDA gap.&lt;br /&gt;
&amp;lt;pre&amp;gt;BSKmod= &amp;amp;quot;SEX&amp;amp;quot;                # [BSE] IP/Hartree/HF/ALDA/SEX&amp;lt;/pre&amp;gt;&lt;br /&gt;
Here we are using the screened exchange (SEX) approximation for the kernel that includes both exchange and correlation terms.&lt;br /&gt;
The line &lt;br /&gt;
 %BEnRange&lt;br /&gt;
   &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;  0.00000 | 20.00000 |   &amp;lt;/span&amp;gt;      eV    # [BSS] Energy range&lt;br /&gt;
  % &lt;br /&gt;
specify the energy range where we want to calculate the dielectric response.&lt;br /&gt;
The lines&lt;br /&gt;
&amp;lt;pre&amp;gt;% BSEBands&lt;br /&gt;
  2 |  7 |                   # [BSK] Bands range&lt;br /&gt;
%&lt;br /&gt;
BSENGBlk=  51            RL  # [BSK] Screened interaction block size&lt;br /&gt;
BSENGexx=  773           RL  # [BSK] Exchange components&amp;lt;/pre&amp;gt;&lt;br /&gt;
specify the range of bands to be used and the RL components for the screened interaction (51) (read from the ndb.em1s file) and for the Hartree term (773, the maximal available). &#039;&#039;&#039;Remember&#039;&#039;&#039; that the BS kernel is written in Bloch space and its size is given by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;BS kernel size = Valence Bands × Conduction Bands  × K-points in the whole BZ&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our case the size is 2304. The BS bands range must be converged with care trying to keep as a few bands as possible.&lt;br /&gt;
Running&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; localhost:&amp;gt;yambo -F Inputs/06_BSE -J 06_BSE&amp;lt;/pre&amp;gt;&lt;br /&gt;
will calculate the BS kernel and store in in the &#039;&#039;06_BSE&#039;&#039; folder. Before analyzing the BS absorption spectrum we can edit the log file &#039;&#039;l-06_BSE_optics_bse_bss&#039;&#039; to observe the on-the-fly live timing feature of yambo:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; [...]&lt;br /&gt;
  &amp;lt;---&amp;gt; BSK |                    | [000%] --(E) --(X)&lt;br /&gt;
 &amp;lt;05s&amp;gt; BSK |#                   | [007%] 05s(E) 01m-07s(X)&lt;br /&gt;
 &amp;lt;11s&amp;gt; BSK |###                 | [015%] 10s(E) 01m-06s(X)&lt;br /&gt;
 [...]&lt;br /&gt;
 &amp;lt;01m-02s&amp;gt; BSK |##################  | [093%] 01m-01s(E) 01m-06s(X)&lt;br /&gt;
 &amp;lt;01m-07s&amp;gt; BSK |####################| [100%] 01m-06s(E) 01m-06s(X)&lt;br /&gt;
 [...]&amp;lt;/pre&amp;gt;&lt;br /&gt;
The two numbers at the end of each line represents the elapsed time(E) and the expected time(X). The latter estimates the time needed to complete that particular section (the BS kernel construction in this case).&lt;br /&gt;
&lt;br /&gt;
Finally we can compare the resulting BS optical absorption with the experimental result. We see how strong is the excitonic effect, if compared to the RPA calculation. The BS equation is, then, able to describe the bound electron-hole state responsible for the peak observed experimentally below the QP gap.&lt;br /&gt;
&lt;br /&gt;
[[File:LiF_06.png|512x384px&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notice that in the input there is variable called &amp;lt;code&amp;gt;BSEdiskIO&amp;lt;/code&amp;gt;to tune the BSE-IO. If you have problem with IO on your cluster you can select &amp;quot;low&amp;quot; in this case the BSE matrix will be written only at the end of the calculation, restart will not be possible.&lt;br /&gt;
&lt;br /&gt;
You can also decide to store only the results: eigelvalues, eigenvectors or spectrum is you select &amp;lt;code&amp;gt;BSEdiskIO&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;=&amp;quot;none&amp;quot;&amp;lt;/code&amp;gt;&amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt;There is also the possibility to set it to &#039;high&#039; in this case restart will be possible also in the exchange part of the calculations.&lt;br /&gt;
&lt;br /&gt;
=A Bethe-Salpeter based F&amp;lt;sub&amp;gt;xc&amp;lt;/sub&amp;gt;(yambo -o c -k lrc -V qp) =&lt;br /&gt;
&lt;br /&gt;
As for TDDFT we might be a little bit disappointed at this stage as the only method that yields a reasonable absorption spectrum for LiF is based on MBPT. It is possible, however, to extract from the BS kernel a possible approximation for the xc-kernel. This approach is efficient, but is far too complicated, and requires the prior computation of the BS kernel. An alternative possibility is to use a simple Long Range Component model, as introduced in [[LiF#Reining|Reining]]. In this model, the yambo input file &#039;&#039;Inputs/07_LRC&#039;&#039; describes a model where&lt;br /&gt;
&lt;br /&gt;
[[File:LiF_PIC_LiF_equations-14.png|190x55px]]&lt;br /&gt;
with F&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;= &#039;&#039;LRC_alpha&#039;&#039;=-8.7.&lt;br /&gt;
&lt;br /&gt;
[[File:LiF_07.png|512x384px&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
We see from the previous figure that the agreement with the BS calculation is not very good. Nevertheless this simple model captures the presence of an exciton and works quite well for a large number of simple semiconductors, as show in [[LiF#silvana|Botti]]:&lt;br /&gt;
&lt;br /&gt;
[[File:F_silvana.png|371x352px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span id=&amp;quot;exercises&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Additional Exercises =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Calculate the absorption spectra like in section [[LiF#02|02]]-[[LiF#03|03]] increasing the polarization RL size, the polarization bands to find the converged values.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Plot the EELS spectrum obtained in section [[LiF#02|02]]-[[LiF#03|03]] and check the effect of increasing the polarization bands. Do a resonant only calculation (using the -V option) to see that the EELS cannot be described using only the resonant part of the response function.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&amp;lt;p&amp;gt;See the effect of using a denser BZ sampling grid running Abinit with, for example&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;ngkpt2  6 6 6&amp;lt;/pre&amp;gt;&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Repeat the [[LiF#06|BSE]] calculation increasing the bands.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Calculate the [[LiF#06|BSE]] spectrum using a diagonal only interaction.&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
&amp;lt;references&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;wikipedia&amp;quot;&amp;gt; [http://en.wikipedia.org/wiki/Lithium_fluoride| LiF on wikipedia]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Rohlfing&amp;quot;&amp;gt; M. Rohlfing, S. Louie, Phys. Rev. Lett. &#039;&#039;&#039;81&#039;&#039;&#039;, 2312 (2000)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Marini&amp;quot;&amp;gt; A. Marini, R. Del Sole, and A. Rubio, Phys. Rev. Lett., &#039;&#039;&#039;91&#039;&#039;&#039;, 256402 (2003)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Adragna&amp;quot;&amp;gt; G. Adragna, R. Del Sole, and A. Marini, Phys. Rev. B &#039;&#039;&#039;68&#039;&#039;&#039;, 165108 (2003)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Sottile&amp;quot;&amp;gt; F. Sottile, V. Olevano, and L. Reining, Phys. Rev. Lett. &#039;&#039;&#039;91&#039;&#039;&#039;, 056402 (2003)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Reining&amp;quot;&amp;gt;  Reining, V. Olevano, A. Rubio, and G. Onida, Phys. Rev. Lett. &#039;&#039;&#039;88&#039;&#039;&#039;, 066404 (2002)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Botti&amp;quot;&amp;gt;  S. Botti, Phys. Rev. B &#039;&#039;&#039;69&#039;&#039;&#039;, 155112 (2004)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;ref name=&amp;quot;Sangalli&amp;quot;&amp;gt; [https://doi.org/10.1103/PhysRevMaterials.5.083803 D. Sangalli, Phis. Rev. Mat. &#039;&#039;&#039;5&#039;&#039;&#039;, 083803 (2021)]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&amp;lt;/references&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=Bethe-Salpeter_solver:_SLEPC&amp;diff=859</id>
		<title>Bethe-Salpeter solver: SLEPC</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=Bethe-Salpeter_solver:_SLEPC&amp;diff=859"/>
		<updated>2026-01-29T14:16:49Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this module you learn how to obtain the optical absorption spectrum of bulk BN within the Bethe-Salpeter equation (BSE) framework for a previously calculated Bethe-Salpeter kernel. You will learn how to by-pass the diagonalization of the full two-particle Hamiltonian and only obtain eigenvalues and eigenvectors for a selected number of states, using the [https://slepc.upv.es SLEPc] solver.&amp;lt;ref&amp;gt;V. Hernandez, J.E. Roman and V. Vidal in &#039;&#039; ACM Transactions on Mathematical Software&#039;&#039;, &#039;&#039;&#039;31&#039;&#039;&#039; 315 (2005)&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Prerequisites==&lt;br /&gt;
[[File:Yambo-handbook-v5-p-21.png|thumb|Cheatsheet on SLEPc|150px]]&lt;br /&gt;
* You must first complete the [[Static screening]] and [[Bethe-Salpeter kernel]] modules in the [[Calculating optical spectra including excitonic effects: a step-by-step guide|step-by-step guide]]&lt;br /&gt;
* Optionally, in order to compare results with the diagonalization solver, you may first complete the [[Bethe-Salpeter solver: diagonalization]] module.&lt;br /&gt;
* Optionally, in order to better understand background, you may first complete the [[Bethe-Salpeter solver: Lanczos-Haydock]] module and the [[How to analyse excitons - CECAM 2021 school | How to analyse excitons]] module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You will need&#039;&#039;&#039;:&lt;br /&gt;
* The &amp;lt;code&amp;gt;SAVE&amp;lt;/code&amp;gt; databases for 3D hBN&lt;br /&gt;
* The &amp;lt;code&amp;gt;3D_BSE&amp;lt;/code&amp;gt; directory containing the databases from the [[Static screening]] and [[Bethe-Salpeter kernel]] modules&lt;br /&gt;
* The &amp;lt;code&amp;gt;yambo&amp;lt;/code&amp;gt; executable&lt;br /&gt;
* &amp;lt;code&amp;gt;gnuplot&amp;lt;/code&amp;gt; for plotting spectra&lt;br /&gt;
&lt;br /&gt;
==Choice of input parameters==&lt;br /&gt;
To use the SLEPc solver invoke yambo with &amp;quot;-y s&amp;quot; option in the command line:&lt;br /&gt;
&lt;br /&gt;
 $ yambo -F 03_3D_BSE_slepc_solver.in -y s -V qp -J 3D_BSE&lt;br /&gt;
The input is open in the editor. The input variables to be changed are &lt;br /&gt;
 % [[Variables#BEnRange|BEnRange]]&lt;br /&gt;
   2.00000 | 8.00000 | eV    &lt;br /&gt;
 %&lt;br /&gt;
 [[Variables#BEnSteps|BEnSteps]]= 200      &lt;br /&gt;
 % [[Variables#BDmRange|BDmRange]]&lt;br /&gt;
   0.10000 |  0.10000 | eV    &lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#BLongDir|BLongDir]]&lt;br /&gt;
  1.000000 | 1.000000 | 0.000000 | &lt;br /&gt;
 %&lt;br /&gt;
 % [[Variables#KfnQP_E|KfnQP_E]] &lt;br /&gt;
  1.440000 | 1.000000 | 1.000000 |&lt;br /&gt;
 %&lt;br /&gt;
as for the diagonalization and Haydock solvers, while the additional parameters&lt;br /&gt;
 [[Variables#BSSNEig|BSSNEig]]= 4&lt;br /&gt;
 [[Variables#BSSEnTarget|BSSEnTarget]]= 2.00 eV          &lt;br /&gt;
define the number of states to look for and the energy around which to look, respectively. &lt;br /&gt;
In our case, we know that the optical absorption onset is &amp;gt;4 eV, so by setting &amp;lt;code&amp;gt;BSSEnTarget=2.00 eV&amp;lt;/code&amp;gt; we will capture the lowest-energy &amp;lt;code&amp;gt;BSSNEig&amp;lt;/code&amp;gt; states of the absorption spectrum.&lt;br /&gt;
We set &amp;lt;code&amp;gt;BSSNEig=4&amp;lt;/code&amp;gt; since we know from the tutorial on [[How to analyse excitons - CECAM 2021 school | how to analyse excitons]] that the first peak in the hBN spectrum is comprised of states 3 and 4:&lt;br /&gt;
 $ ls o-3D_BSE.exc_qpt1_E_sorted&lt;br /&gt;
&lt;br /&gt;
 #    E [ev]             Strength           Index&lt;br /&gt;
 #&lt;br /&gt;
     3.53959870        0.575763806E-6      1.00000000&lt;br /&gt;
     3.53977442        0.104714145E-4      2.00000000&lt;br /&gt;
     3.58167791        0.482294828         3.00000000&lt;br /&gt;
     3.58199883         1.00000000         4.00000000&lt;br /&gt;
     3.70031905        0.913734333E-8      5.00000000&lt;br /&gt;
     3.71410418        0.229000130E-8      6.00000000&lt;br /&gt;
        ...                ...                ...&lt;br /&gt;
     4.24574852        0.303127885         12.0000000&lt;br /&gt;
     4.24597263        0.125847101         13.0000000&lt;br /&gt;
        ...                ...                ...&lt;br /&gt;
     4.49848938        0.813002646         20.0000000&lt;br /&gt;
     4.49882555        0.353004009         21.0000000&lt;br /&gt;
&lt;br /&gt;
Therefore we are trying to describe just the dominant feature in the spectrum.&lt;br /&gt;
&lt;br /&gt;
There is also an additional parameter defining the maximum number of iterations:&lt;br /&gt;
 BSSSlepcMaxIt=0&lt;br /&gt;
If we keep this equal to zero, the code will use an internally defined value.&lt;br /&gt;
&lt;br /&gt;
==Bethe-Salpeter solver runlevel==&lt;br /&gt;
Invoke yambo to run the calculation:&lt;br /&gt;
 $ yambo -F 03_3D_BSE_slepc_solver.in -J &amp;quot;3D_BSE-NEig4,3D_BSE&amp;quot;  &lt;br /&gt;
This outputs the following log:&lt;br /&gt;
 ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [03] BSE solver(s) @q1&lt;br /&gt;
 &amp;lt;---&amp;gt; [03.01] Slepc Solver @q1&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Slower alogorithm but BSE matrix distributed over MPI tasks&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Approach                          : Krylov-Schur&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Extraction method                 : ritz&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Number of requested eigenvalues   :   4&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Criterion is target energy        :  2.000000 [eV]&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Stopping condition tolerance      :  0.100000E-5&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Stopping condition max iterations : -2&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Iteration #1 - converged States 0 - error :  0.013375  0.000000&lt;br /&gt;
        ...&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Iteration #8 - converged States 0 - error :  0.229377E-5   0.00000&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Iteration #9 - converged States 3 - error :  0.726125E-7  0.121157E-5&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Iteration #10 - converged States 5 - error :  0.247454E-7  0.712303E-5&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Number of iterations              :  10&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Number of eigenvalues        [NEV]:   4&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Max. subspace size of solver [NCV]:  19&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Max. allowed dim             [MPD]:  19&lt;br /&gt;
 &amp;lt;---&amp;gt; [SLEPC] Number of converged states        :   5&lt;br /&gt;
 ...&lt;br /&gt;
As you can see, the requested eigenvalues were converged. You may notice some advanced information (Approach, Extraction method, Stopping condition tolerance, etc). These are all controllable with specific input variables (see the yambo cheatsheet for more information), but in practice you don&#039;t usually need to worry about them.&lt;br /&gt;
&lt;br /&gt;
If you now check inside the folder &amp;lt;code&amp;gt;3D_BSE-NEig4&amp;lt;/code&amp;gt;, you will see that a database &amp;lt;code&amp;gt;ndb.BS_diago_Q1&amp;lt;/code&amp;gt; has been produced, like in the full diagonalization case. This will allow postprocessing and analysis of the requested excitons with &amp;lt;code&amp;gt;ypp&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
We can plot the spectrum from the o-* file and compare with the result from diagonalization:&lt;br /&gt;
 $gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
  plot &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:2 w l lc rgb &#039;black&#039; t &#039;Diagonalization&#039;, &#039;o-3D_BSE-NEig4.eps_q1_slepc_bse&#039; u 1:2 w l lw 2 lc rgb &#039;blue&#039; t &#039;Slepc 4 states&#039;&lt;br /&gt;
[[File:03 bse slepc 4.png|none|600px]]&lt;br /&gt;
As expected, by requesting the first 4 states we are able to reproduce the first and strongest absorption peak.&lt;br /&gt;
&lt;br /&gt;
==Including more peaks==&lt;br /&gt;
We now want to also include the second and third bright peaks in the calculations. From the &amp;lt;code&amp;gt;*E_sorted&amp;lt;/code&amp;gt; file, we know that the second bright peak corresponds to states 12 and 13.&lt;br /&gt;
Change therefore the input variable:&lt;br /&gt;
 [[Variables#BSSNEig|BSSNEig]]= 13          &lt;br /&gt;
and repeat the calculation&lt;br /&gt;
 $ yambo -F 03_3D_BSE_slepc_solver.in -J &amp;quot;3D_BSE-NEig13,3D_BSE&amp;quot;  &lt;br /&gt;
&lt;br /&gt;
As you can see from the plot below, we now capture the second peak as well, though it lacks the enhancement due to the low-energy shoulder of the adjacent third peak. In order to include the third peak change again the input variable:&lt;br /&gt;
 [[Variables#BSSNEig|BSSNEig]]= 21          &lt;br /&gt;
and again repeat the calculation&lt;br /&gt;
 $ yambo -F 03_3D_BSE_slepc_solver.in -J &amp;quot;3D_BSE-NEig21,3D_BSE&amp;quot;  &lt;br /&gt;
&lt;br /&gt;
By plotting these results:&lt;br /&gt;
 $ gnuplot&lt;br /&gt;
 ...&lt;br /&gt;
 plot &#039;o-3D_BSE.eps_q1_diago_bse&#039; u 1:2 w l lc rgb &#039;black&#039; t &#039;Diagonalization&#039;, &#039;o-3D_BSE-NEig4.eps_q1_slepc_bse&#039; u 1:2 w l lw 2 lc rgb &#039;blue&#039; t &#039;Slepc 4 states&#039;, &#039;o-3D_BSE-NEig13.eps_q1_slepc_bse&#039; u 1:2 w l lw 2 lc rgb &#039;red&#039;  t &#039;Slepc 13 states&#039;, &#039;o-3D_BSE-NEig21.eps_q1_slepc_bse&#039; u 1:2 w l lw 2 lc rgb &#039;orange&#039; t &#039;Slepc 21 states&#039;&lt;br /&gt;
[[File:03 bse slepc 21.png|none|600px]]&lt;br /&gt;
We see that we obtain an accurate description of the relevant part of the absorption spectrum of bulk hBN by just including 21 states. The diagonalization solver needs 432 states instead, because this is the size of the two-particle Hamiltonian in our calculation (keep in mind that this is far from being numerically converged, and the correct absorption spectrum looks quite different).&lt;br /&gt;
&lt;br /&gt;
In a real calculation for a large system, when full diagonalization is not an option, you will typically first obtain the full absorption spectrum using the Lanczos-Haydock solver, then switch to the SLEPc to focus on the exciton states relevant to your analysis, while using the previously obtained full spectrum as a reference as we did in this tutorial.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
From this tutorial you&#039;ve learned:&lt;br /&gt;
* How to compute the optical spectrum by using the SLEPc solver within the Bethe-Salpeter equation framework&lt;br /&gt;
* How to correctly describe a subset of the excitonic eigenvalues and eigenvectors without diagonalizing the full two-particle Hamiltonian.&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
&lt;br /&gt;
* Previous module: [[Bethe-Salpeter kernel]]&lt;br /&gt;
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: diagonalization | diagonalization]] &lt;br /&gt;
* Alternative Bethe-Salpeter equation solver: [[Bethe-Salpeter solver: Lanczos-Haydock|Haydock]]&lt;br /&gt;
* Back to [[Calculating optical spectra including excitonic effects: a step-by-step guide]] tutorial&lt;br /&gt;
&lt;br /&gt;
==References==&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=File:03_bse_slepc_4.png&amp;diff=858</id>
		<title>File:03 bse slepc 4.png</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=File:03_bse_slepc_4.png&amp;diff=858"/>
		<updated>2026-01-29T14:16:11Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=File:03_bse_slepc_21.png&amp;diff=857</id>
		<title>File:03 bse slepc 21.png</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=File:03_bse_slepc_21.png&amp;diff=857"/>
		<updated>2026-01-29T14:16:01Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=BSE_solvers_overview&amp;diff=856</id>
		<title>BSE solvers overview</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=BSE_solvers_overview&amp;diff=856"/>
		<updated>2026-01-29T14:14:38Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial explores the options available in Yambo for the numerical solution of the Bethe-Salpeter equation. Before running this tutorial, you should have carried out the tutorial &#039;&#039;&#039;[[Calculating optical spectra including excitonic effects: a step-by-step guide]]&#039;&#039;&#039;. We will use the same example system (bulk hBN). The various options correspond to different numerical methods for solving (large) eigenvalue problems. The numerical methods are not covered in this tutorial and the interested user is directed to the references.&lt;br /&gt;
&lt;br /&gt;
After completion of this tutorial, you are expected to recognize which solver to use depending on the system, computational load and desired output. Also, for each of the solver, you should be able to choose the values for the key input parameters. &lt;br /&gt;
&lt;br /&gt;
Three main solvers are available in Yambo:&lt;br /&gt;
__TOC__&lt;br /&gt;
===Full diagonalization solver (-y d)===&lt;br /&gt;
Diagonalization of the full Hamiltonian using the standard LAPACK library.  &lt;br /&gt;
&lt;br /&gt;
This solver outputs the macroscopic dielectric function over a range of energies chosen by the user. It also calculates all exciton energies and composition in terms of electron-hole pairs. Upon user&#039;s choice, the latter is stored on disk for use in postprocessing for exciton analysis and plotting as seen in the tutorial &#039;&#039;&#039;[[How to analyse excitons - CECAM 2021 school|How to analyse excitons]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Unfortunately, the computational cost of full diagonalization is cubic in the number of electron-hole pairs so this solver can be used for small system only (few light atoms per unit cell).   &lt;br /&gt;
 &lt;br /&gt;
You should have already carried out the  &#039;&#039;&#039;[[Bethe-Salpeter solver: diagonalization]]&#039;&#039;&#039;. If you wish, you can run again this part and then &#039;&#039;&#039;return to this tutorial&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Lanczos-Haydock solver (-y h)===&lt;br /&gt;
Subspace iterative [https://en.wikipedia.org/wiki/Lanczos_algorithm | Lanczos algorithm] which by-pass diagonalization with the Haydock approach&amp;lt;ref&amp;gt;R. Haydock, in&lt;br /&gt;
 &#039;&#039;Solid State Phys.&#039;&#039;, &#039;&#039;&#039;35&#039;&#039;&#039; 215 (1980) edited by H. Ehrenfest, F. Seitz, and D. Turnbull, Academic Press&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This solver outputs the macroscopic dielectric function over a range of energies chosen by the user. It can be applied to medium-large systems as it is substantially cheaper than the full diagonalization (quadratic with the number of electron-hole pairs). However, this approach &#039;&#039;does not provide&#039;&#039; the individual exciton energies and composition in terms of electron-hole pairs.&lt;br /&gt;
&lt;br /&gt;
Follow the link to &#039;&#039;&#039;[[Bethe-Salpeter solver: Lanczos-Haydock]]&#039;&#039;&#039; then  &#039;&#039;&#039;return to this tutorial&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This solver is compatible with the double-grid, see tutorial: [[Fast convergence of dielectric constant with double grid]].&lt;br /&gt;
&lt;br /&gt;
===SLEPc solver (-y s) ===&lt;br /&gt;
Subspace iterative algorithm using the [https://slepc.upv.es SLEPc library]&amp;lt;ref&amp;gt;V. Hernandez, J.E. Roman and V. Vidal in &#039;&#039; ACM Transactions on Mathematical Software&#039;&#039;, &#039;&#039;&#039;31&#039;&#039;&#039; 315 (2005)&amp;lt;/ref&amp;gt; (SLEPC solver).&lt;br /&gt;
&lt;br /&gt;
This solver outputs the individual exciton energies and composition about an energy value chosen by the user. It can be applied to medium-large systems but does not provide the overall spectrum. This solver is typically used after obtaining the spectra from the Lanczos-Haydock solver to either analyze a specific peak or getting the energy and composition of a few low-lying excitons. It can be used for large-medium systems. The computational cost grows with the number of excitons one asks to compute.  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Optional:&#039;&#039;&#039;&lt;br /&gt;
Advanced users can recompile Yambo with the &#039;&#039;--enable-slepc-linalg&#039;&#039; option if they hadn&#039;t done so. &lt;br /&gt;
If/Once you have a Yambo version compiled with the SLEPc, or you have the Virtual Machine or the Docker (with the yambo-gcc_openmp_petsc [[CECAM VIRTUAL 2021| container]]), follow the link to &#039;&#039;&#039;[[Bethe-Salpeter solver: SLEPC]]&#039;&#039;&#039; then  &#039;&#039;&#039;return to this tutorial&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===INVERSION solver (-y i) ===&lt;br /&gt;
This solver is not used anymore, it was used in an old implementation of the double-grid see Ref.&amp;lt;ref&amp;gt;David Kammerlander, Silvana Botti, Miguel A. L Marques, Andrea Marini, and Claudio Attaccalite, Phys. Rev. B 86, 125203 (2012) &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
To summarise, the output (dielectric function, exciton energies and composition) and cost of the three solvers are summarized in this table.&lt;br /&gt;
&lt;br /&gt;
[[File:Solver.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Navigate==&lt;br /&gt;
* Back to [[BSE tutorial on hBN]] module&lt;br /&gt;
* Back to [[Tutorials]] main page&lt;br /&gt;
&lt;br /&gt;
=References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=BSE_solvers_overview&amp;diff=855</id>
		<title>BSE solvers overview</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=BSE_solvers_overview&amp;diff=855"/>
		<updated>2026-01-29T14:14:12Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This tutorial explores the options available in Yambo for the numerical solution of the Bethe-Salpeter equation. Before running this tutorial, you should have carried out the tutorial &#039;&#039;&#039;[[Calculating optical spectra including excitonic effects: a step-by-step guide]]&#039;&#039;&#039;. We will use the same example system (bulk hBN). The various options correspond to different numerical methods for solving (large) eigenvalue problems. The numerical methods are not covered in this tutorial and the interested user is directed to the references.&lt;br /&gt;
&lt;br /&gt;
After completion of this tutorial, you are expected to recognize which solver to use depending on the system, computational load and desired output. Also, for each of the solver, you should be able to choose the values for the key input parameters. &lt;br /&gt;
&lt;br /&gt;
Three main solvers are available in Yambo:&lt;br /&gt;
__TOC__&lt;br /&gt;
===Full diagonalization solver (-y d)===&lt;br /&gt;
Diagonalization of the full Hamiltonian using the standard LAPACK library.  &lt;br /&gt;
&lt;br /&gt;
This solver outputs the macroscopic dielectric function over a range of energies chosen by the user. It also calculates all exciton energies and composition in terms of electron-hole pairs. Upon user&#039;s choice, the latter is stored on disk for use in postprocessing for exciton analysis and plotting as seen in the tutorial &#039;&#039;&#039;[[How to analyse excitons - CECAM 2021 school|How to analyse excitons]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Unfortunately, the computational cost of full diagonalization is cubic in the number of electron-hole pairs so this solver can be used for small system only (few light atoms per unit cell).   &lt;br /&gt;
 &lt;br /&gt;
You should have already carried out the  &#039;&#039;&#039;[[Bethe-Salpeter solver: diagonalization]]&#039;&#039;&#039;. If you wish, you can run again this part and then &#039;&#039;&#039;return to this tutorial&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Lanczos-Haydock solver (-y h)===&lt;br /&gt;
Subspace iterative [https://en.wikipedia.org/wiki/Lanczos_algorithm | Lanczos algorithm] which by-pass diagonalization with the Haydock approach&amp;lt;ref&amp;gt;R. Haydock, in&lt;br /&gt;
 &#039;&#039;Solid State Phys.&#039;&#039;, &#039;&#039;&#039;35&#039;&#039;&#039; 215 (1980) edited by H. Ehrenfest, F. Seitz, and D. Turnbull, Academic Press&amp;lt;/ref&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
This solver outputs the macroscopic dielectric function over a range of energies chosen by the user. It can be applied to medium-large systems as it is substantially cheaper than the full diagonalization (quadratic with the number of electron-hole pairs). However, this approach &#039;&#039;does not provide&#039;&#039; the individual exciton energies and composition in terms of electron-hole pairs.&lt;br /&gt;
&lt;br /&gt;
Follow the link to &#039;&#039;&#039;[[Bethe-Salpeter solver: Lanczos-Haydock]]&#039;&#039;&#039; then  &#039;&#039;&#039;return to this tutorial&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This solver is compatible with the double-grid, see tutorial: [[Fast convergence of dielectric constant with double grid]].&lt;br /&gt;
&lt;br /&gt;
===SLEPc solver (-y s) ===&lt;br /&gt;
Subspace iterative algorithm using the [https://slepc.upv.es SLEPc library]&amp;lt;ref&amp;gt;V. Hernandez, J.E. Roman and V. Vidal in &#039;&#039; ACM Transactions on Mathematical Software&#039;&#039;, &#039;&#039;&#039;31&#039;&#039;&#039; 315 (2005)&amp;lt;/ref&amp;gt; (SLEPC solver).&lt;br /&gt;
&lt;br /&gt;
This solver outputs the individual exciton energies and composition about an energy value chosen by the user. It can be applied to medium-large systems but does not provide the overall spectrum. This solver is typically used after obtaining the spectra from the Lanczos-Haydock solver to either analyze a specific peak or getting the energy and composition of a few low-lying excitons. It can be used for large-medium systems. The computational cost grows with the number of excitons one asks to compute.  &lt;br /&gt;
 &lt;br /&gt;
===INVERSION solver (-y i) ===&lt;br /&gt;
This solver is not used anymore, it was used in an old implementation of the double-grid see Ref.&amp;lt;ref&amp;gt;David Kammerlander, Silvana Botti, Miguel A. L Marques, Andrea Marini, and Claudio Attaccalite, Phys. Rev. B 86, 125203 (2012) &amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Optional:&#039;&#039;&#039;&lt;br /&gt;
Advanced users can recompile Yambo with the &#039;&#039;--enable-slepc-linalg&#039;&#039; option if they hadn&#039;t done so. &lt;br /&gt;
If/Once you have a Yambo version compiled with the SLEPc, or you have the Virtual Machine or the Docker (with the yambo-gcc_openmp_petsc [[CECAM VIRTUAL 2021| container]]), follow the link to &#039;&#039;&#039;[[Bethe-Salpeter solver: SLEPC]]&#039;&#039;&#039; then  &#039;&#039;&#039;return to this tutorial&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
To summarise, the output (dielectric function, exciton energies and composition) and cost of the three solvers are summarized in this table.&lt;br /&gt;
&lt;br /&gt;
[[File:Solver.png|Yambo tutorial image]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Navigate==&lt;br /&gt;
* Back to [[BSE tutorial on hBN]] module&lt;br /&gt;
* Back to [[Tutorials]] main page&lt;br /&gt;
&lt;br /&gt;
=References =&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
	<entry>
		<id>https://www.lumen-code.org/wiki/index.php?title=File:BSE1-Eq5.png&amp;diff=854</id>
		<title>File:BSE1-Eq5.png</title>
		<link rel="alternate" type="text/html" href="https://www.lumen-code.org/wiki/index.php?title=File:BSE1-Eq5.png&amp;diff=854"/>
		<updated>2026-01-29T14:10:55Z</updated>

		<summary type="html">&lt;p&gt;Wikiadmin: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
	</entry>
</feed>