Linear response using Dynamical Berry Phase: Difference between revisions

From The Yambo Project
Jump to navigation Jump to search
No edit summary
 
(59 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[File:Lresp.png|thumb|200px]]
The tutorial on linear response from real-time Schödinger equation is divided in 8 steps:<br />
The tutorial on linear response from real-time Schödinger equation is divided in 8 steps:<br />
<br />
<br />
'''1) DFT calculations'''<br />
== DFT calculations==
In Lumen (and Yambo) all quantities are written in a basis of the Kohn-Sham(KS) eigenvalues and eigenvectors. In order to generate this basis we use a DFT code in plane wave as [http://www.abinit.org/ Abinit] or [http://www.quantum-espresso.org/ QuantumEspresso](QE).<br />
In Yambo all quantities are written in a basis of the Kohn-Sham(KS) eigenvalues and eigenvectors. In order to generate this basis we use a DFT code in plane wave as [http://www.abinit.org/ Abinit] or [http://www.quantum-espresso.org/ QuantumEspresso](QE).<br />
In this example we will consider a single later of hexagonal boron nitrite (hBN), the input files available here ([[tutorials/BNsheetDFT.tgz|QE_inputs]] or [[tutorials/BN_abinit.tgz|ABINIT_inputs]]). The first input file is a self-consistent(SCF) calculation that is used to generate the density of the system. The second input file is a non-self consistent(NSCF) calculation to diagonalize the KS Hamiltonian, that depends from the density of the first run, on for a given number of bands and k-points. Notice that parameters in the NSCF calculation determine the number of k-points and the maximum number of bands that can be used in Lumen. Run these calculation with the command:<br />
In this example we will consider a single later of hexagonal boron nitrite (hBN), the input files available here ([http://www.attaccalite.com/lumen/tutorials/BNsheetDFT.tgz QE_inputs] or [http://www.attaccalite.com/lumen/tutorials/BN_abinit.tgz ABINIT_inputs]). The first input file is a self-consistent(SCF) calculation that is used to generate the density of the system. The second input file is a non-self consistent(NSCF) calculation to diagonalize the KS Hamiltonian, that depends from the density of the first run, on for a given number of bands and k-points. Notice that parameters in the NSCF calculation determine the number of k-points and the maximum number of bands that can be used in Lumen. Run these calculation with the command:<br />
<br />
 
for QuantumEspresso:<br />
for QuantumEspresso:


<pre>pw.x -inp BNsheet.scf.in  &gt; output_scf
<pre>pw.x -inp BNsheet.scf.in  &gt; output_scf
pw.x -inp BNsheet.nscf.in &gt; output_nscf</pre>
pw.x -inp BNsheet.nscf.in &gt; output_nscf</pre>
<br />
for Abinit:
for Abinit:<br />


<pre>abinit &lt; hBN.files &gt; output_hBN</pre>
<pre>abinit &lt; hBN.files &gt; output_hBN</pre>
<br />
 
Notice that in the NSCF file of QuantumEspresso we use the flag <code>force_symmorphic=.true.</code> to exclude the non-symmorphic symmetries that are not supported by Lumen(Yambo), in Abinit the same option is activated by the flag <code>symmorphi 0</code>.<br />
Notice that in the NSCF file of QuantumEspresso we use the flag <code>force_symmorphic=.true.</code> to exclude the non-symmorphic symmetries that are not supported by Yambo, in Abinit the same option is activated by the flag <code>symmorphi 0</code>.
<br />
 
'''2) Import the wave-functions'''<br />
==Import the wave-functions==
If you used QuantumEspresso go in the folder <code>bn.save</code>, in the ABINIT case all file are already in the main folder. Then import the wave-function with the command<br />
If you used QuantumEspresso go in the folder <code>bn.save</code>, in the ABINIT case all file are already in the main folder. Then import the wave-function with the command<br />
<br />
for QuantumEspresso:
for QuantumEspresso:<br />
p2y
for Abinit:
a2y -F hbn_out_DS2_KSS
 
==Setup==
Generate the setup input file with the command <code>yambo_nl -i -V RL -F setup.in</code>, then run <code>yambo_nl -F setup.in</code>.<br> You can reduce the number of G-vectors in the setup in such a way to speed up calculations. I advise to reduce G-vector to 1000 (about 50% the initial ones).<br />


<pre>p2y</pre>
==Reduce symmetries==
<br />
Since in real-time simulation we introduce a finite electric field in the Hamiltonian, the number of the symmetries of the original system is reduced due to the presence of this field. Using the tool <code>ypp -y</code> to generate the input file:
for Abinit:<br />


<pre>a2y -F hbn_out_DS2_KSS</pre>
fixsyms                      # [R] Reduce Symmetries
<br />
% Efield1
<br />
0.00    | <span style="color:red>1.00 </span>   | 0.00    |        # First external Electric Field
'''4) Setup'''<br />
%
Generate the setup input file with the command <code>yambo_nl -i -V RL -F setup.in</code>, then run <code>yambo_nl -F setup.in</code>. You can reduce the number of G-vectors in the setup in such a way to speed up calculations. I advise to reduce G-vector to 1000 (about 50% the initial ones).<br />
% Efield2
<br />
  0.00    | 0.00    | 0.00    |        # Additional external Electric Field
'''5) Reduce symmetries'''<br />
%
Since in real-time simulation we introduce a finite electric field in the Hamiltonian, the number of the symmetries of the original system is reduced due to the presence of this field. Using the tool <code>ypp -y</code> to generate the input file:<br />
#RmAllSymm                  # Remove all symmetries
<br />
<span style="color:red>RmTimeRev </span>                 # Remove Time Reversal


<pre>fixsyms                      # [R] Reduce Symmetries
% Efield1
0.00    | 1.00    | 0.00    |        # First external Electric Field
%
% Efield2
0.00    | 0.00    | 0.00    |        # Additional external Electric Field
%
#RmAllSymm                  # Remove all symmetries
RmTimeRev                  # Remove Time Reversal</pre>
<br />
<br />
Set the external field in the <code>y</code> direction and uncomment the Time Reversal flag, as shown in red above. Run <code>ypp</code> and it will create a new folder called <code>FixSymm</code> with the reduced symmetries wave-functions.<br />
Set the external field in the <code>y</code> direction and uncomment the Time Reversal flag, as shown in red above. Run <code>ypp</code> and it will create a new folder called <code>FixSymm</code> with the reduced symmetries wave-functions.<br />
<br />
 
'''6) Setup again'''<br />
==Setup again==
Go in the <code>FixSymm</code> directory and run the setup again <code>yambo_nl -F ../setup.in</code>. Now everything is ready for the real-time simulations!<br />
Go in the <code>FixSymm</code> directory and run the setup again <code>yambo_nl -F ../setup.in</code>. Now everything is ready for the real-time simulations!<br />
<br />
'''7) Real-time dynamics'''<br />
In order to calculate linear-response in real-time we will perturb the system with a delta function in time external field. Use the command <code>yambo_nl -u -F input_lr.in</code> to generate the input:<br />
<br />


<pre>nlinear                      # [R NL] Non-linear optics
== Real-time dynamics==
NL_Threads= 1                # [OPENMP/NL] Number of threads for nl-optics
In order to calculate linear-response in real-time we will perturb the system with a delta function in time external field. Use the command <code>yambo_nl -u p -F input_lr.in</code> to generate the input:
% NLBands
 
  3 |  6 |                   # [NL] Bands
nlinear                      # [R NL] Non-linear optics
%
NL_Threads= 1                # [OPENMP/NL] Number of threads for nl-optics
NLstep=   0.0100       fs    # [NL] Real Time step length
% NLBands
NLtime=55.000000      fs    # [NL] Simulation Time
  <span style="color:red">3 |  6 |   </span>                # [NL] Bands
NLverbosity= &quot;high&quot;          # [NL] Verbosity level (low | high)
%
NLintegrator= &quot;INVINT&quot;      # [NL] Integrator (&quot;EULEREXP/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&quot;)
NLstep= <span style="color:red"> 0.0100 </span>    fs    # [NL] Real Time step length
NLCorrelation= &quot;IPA&quot;        # [NL] Correlation (&quot;IPA/HARTREE/TDDFT/LRC/JGM/SEX/HF&quot;)
NLtime=55.000000      fs    # [NL] Simulation Time
NLLrcAlpha= 0.000000        # [NL] Long Range Correction
NLintegrator= &quot;INVINT&quot;      # [NL] Integrator (&quot;EULEREXP/RK4/RK2EXP/HEUN/INVINT/CRANKNIC&quot;)
% NLEnRange
NLCorrelation= &quot;IPA&quot;        # [NL] Correlation (&quot;IPA/HARTREE/TDDFT/LRC/JGM/SEX/HF&quot;)
  0.200000 | 8.000000 | eV    # [NL] Energy range
NLLrcAlpha= 0.000000        # [NL] Long Range Correction
%
NLDamping= 0.000000   eV    # [NL] Damping
NLEnSteps= 1                 # [NL] Energy steps
RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative Yambo sets it equal to Phase_LifeTime in NL)
NLDamping= 0.000000    eV    # [NL] Damping
#EvalCurrent                  # [NL] Evaluate the current
% ExtF_Dir
#FrPolPerdic                  # [DIP] Force periodicity of polarization respect to the external field
  0.000000 | 1.000000 | 0.000000 |        # [NL ExtF] Versor
% Field1_Freq
%
  0.100000 | 0.100000 |        eV    # [RT Field1] Frequency
ExtF_kind= &quot;DELTA&quot;        # [NL ExtF] Kind(SIN|SOFTSIN|RES|ANTIRES|GAUSS|DELTA|QSSIN)
%
  Field1_NFreqs= 1                 # [RT Field1] Frequency
Field1_Int=  1000.00      kWLm2 # [RT Field1] Intensity
Field1_Width= 0.000000     fs    # [RT Field1] Width
Field1_kind=  <span style="color:red"> "DELTA"  </span>        # [RT Field1] Kind(SIN|COS|RES|ANTIRES|GAUSS|DELTA|QSSIN)
Field1_pol= "linear"            # [RT Field1] Pol(linear|circular)
% Field1_Dir
  <span style="color:red"> 0.000000 | 1.000000 | 0.000000 |</span>        # [RT Field1] Versor
%
Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time
 


            </pre>
         
The standard input of Lumen is thought for non-linear response so we have to change some parameters in order to calculate the linear response. Set the field direction along y, the field type to DELTA, the length of the simulation to 55 fs, number of bands from 3 to 6 dephasing to zero and the number of energy steps to one, as shown above in red.<br />
The standard input of Lumen is thought for non-linear response so we have to change some parameters in order to calculate the linear response. Set the field direction along y, the field type to DELTA, the length of the simulation to 55 fs, number of bands from 3 to 6 dephasing to zero and the number of energy steps to one, as shown above in red.<br />
We set the verbosity to &quot;high&quot; in such a way to print real-time output files.<br />
We set the verbosity to &quot;high&quot; in such a way to print real-time output files.<br />
We set the differential equation integrator to INVINT that is faster bul less accurate than the default(see PRB '''88''', 235113). This integrator is ok in case of independent partcicles but I advise you to use CRANKNIC integrator when correlation effects are present. Now run <code>yambo_nl -F input_lr.in</code><br />
We set the differential equation integrator to INVINT that is faster bul less accurate than the default(see PRB '''88''', 235113). This integrator is ok in case of independent partcicles but I advise you to use CRANKNIC integrator when correlation effects are present. Now run <code>yambo_nl -F input_lr.in</code><br />
The code will produce different files: <code>o.polarization_F1</code> that contains the polarization, <code>o.external_potential_F1</code> the external field we used, and finally <code>r_optics_nloptics</code> a report with all information about the simulation. If you plot the third column of <code>o.polarization_F1</code> versus the first one (time variable) you will get the time-dependent polarization along the y direction:
The code will produce different files: <code>o.polarization_F1</code> that contains the polarization, <code>o.external_potential_F1</code> the external field we used, and finally <code>r_optics_nloptics</code> a report with all information about the simulation. If you plot the third column of <code>o.polarization_F1</code> versus the first one (time variable) you will get the time-dependent polarization along the y direction:
<br />
[[File:Polarization hbn.png|center]]
[[File:images/polarization_hbn.png]]
 
<br />
==Analyze the results==
<br />
'''8) Analyze the results'''<br />
Now we can use <code>ypp_nl -u</code> to analyze the results:<br />
Now we can use <code>ypp_nl -u</code> to analyze the results:<br />
nonlinear                    # [R] NonLinear Optics Post-Processing
Xorder= 1                    # Max order of the response functions
% TimeRange
-1.000000 |-1.000000 | fs    # Time-window where processing is done
%
ETStpsRt= 200                # Total Energy steps
% EnRngeRt
  0.00000 | <span style="color:red">10.00000 </span>| eV    # Energy range
%
DampMode= <span style="color:red">&quot;LORENTZIAN&quot; </span>            # Damping type ( NONE | LORENTZIAN | GAUSSIAN )
DampFactor=  <span style="color:red">0.10000 </span>  eV    # Damping parameter
where we set a Lorentzian smearing corresponding to 0.1 eV. Notice that due to the finite time of our simulation a smearing is always necessary to Fourier transform the result. Then we run <code>ypp_nl</code> and obtain the following files: the dielectric constant along the field direction <code>o.YPP-eps_along_E</code>, the EELS along the same direction <code>o.YPP-eels_along_E</code>, and the damped polarization <code>o.YPP-damped_polarization</code>.<br />
Now we can plot the dielectric constant and compare it with linear response:
[[File:BN eps.png|center|1000px]]
<br />
<br />
The input for the linear response can be downloaded [http://www.attaccalite.com/lumen/tutorials/linear_optics_BNsheet.in here]. Notice that in a real-time simulation we obtain directly the <math> \chi(\omega) = \frac{P(\omega)}{E(\omega)} </math> that is related to the dielectric constant from the relation <math>\epsilon(\omega) = 1 + 4 \pi \chi(\omega) </math><br />
==Analysis of the results using YamboPy==
'''This part works only with Yambo 5.3 or the last version available on Github:''' [https://github.com/yambo-code/yambo https://github.com/yambo-code/yambo]
<br>
<br>
Starting from Yambo 5.3 the analysis of real-time simulation can performed using [https://github.com/yambo-code/yambopy YamboPy]  code.<br> Here we suppose that you already installed it otherwise you can follow this webpage [https://www.yambo-code.eu/wiki/index.php/Setting_up_Yambo#Setting_up_Yambopy Setting up YamboPy].<br>
In order to analyze the real-time results, go in the folder where you ran the simulation, and in the python shell type:
import numpy as np
from yambopy import *
from yambopy.plot  import *
NLDB=YamboNLDB()
pol =NLDB.Polarization[0]
time=NLDB.IO_TIME_points
t_initial=NLDB.Efield[0]["initial_time"]
in this way you read all the Non-linear databases. If your runs are in a different folder then the 'SAVE' one you can specify it using the command:
NLDB=YamboNLDB(calc='MYJOB')
now in the array <code>pol</code> you have all the polarization for all laser frequencies in the three Cartesian directions, while the variable <code>time</code> contains all the time series of your simulation, and <code>t_intital</code> is the time when the external field is turned on. <br>
We can now apply a damping function to the polarization before Fourier transform it by doing:
pol_damped=np.empty_like(pol)
for i_d in range(3):
    pol_damped[i_d,:]=damp_it(pol[i_d,:],time,t_initial,damp_type='LORENTZIAN',damp_factor=0.1/ha2ev)
now we can plot the damped polarization with the command
Plot_Pol_or_Curr(time=time, pol=pol_damped, xlim=[0,55], save_file='polarization.pdf')
you will get the damped polarization in the three Cartesian directions:
[[File:Pol yambopy.png|center]]


<pre>nonlinear                    # [R] NonLinear Optics Post-Processing
Now we can Fourier transform it to get the dielectric constant as explained in the previous section:
Xorder= 1                    # Max order of the response functions
% TimeRange
Linear_Response(time=time,pol=pol_damped,efield=NLDB.Efield[0],plot=False,plot_file='eps.pdf')
-1.000000 |-1.000000 | fs    # Time-window where processing is done
%
ETStpsRt= 200                # Total Energy steps
% EnRngeRt
  0.00000 | 10.00000 | eV    # Energy range
%
DampMode= &quot;LORENTZIAN&quot;            # Damping type ( NONE | LORENTZIAN | GAUSSIAN )
DampFactor= 0.10000  eV    # Damping parameter


            </pre>
here the result:
where we set a lorentzian smearing corresponding to 0.1 eV. Notice that due to the finite time of our simulation a smearing is always necessary to Fourier transform the result. Then we run <code>ypp_nl</code> and obtain the following files: the dielectric constant along the field direction <code>o.YPP-eps_along_E</code>, the EELS along the same direction <code>o.YPP-eels_along_E</code>, and the damped polarization <code>o.YPP-damped_polarization</code>.<br />
[[File:Eps yambopi nl.png|center]]
Now we can plot the dielectric constant and compare it with linear response:
[[File:images/BN_eps.png]]
<br />
The input for the linear response can be downloaded [[tutorials/linear_optics_BNsheet.in|here]]. Notice that in a real-time simulation we obtain directly the <span class="math-inline">\( \chi(\omega) = \frac{P(\omega)}{E(\omega)} \)</span> that is realted to the dielectric constant from the relation $$\epsilon(\omega) = 1 + 4 \pi \chi(\omega) $$<br />
<br />
<br />

Latest revision as of 10:08, 14 November 2023

Lresp.png

The tutorial on linear response from real-time Schödinger equation is divided in 8 steps:

DFT calculations

In Yambo all quantities are written in a basis of the Kohn-Sham(KS) eigenvalues and eigenvectors. In order to generate this basis we use a DFT code in plane wave as Abinit or QuantumEspresso(QE).
In this example we will consider a single later of hexagonal boron nitrite (hBN), the input files available here (QE_inputs or ABINIT_inputs). The first input file is a self-consistent(SCF) calculation that is used to generate the density of the system. The second input file is a non-self consistent(NSCF) calculation to diagonalize the KS Hamiltonian, that depends from the density of the first run, on for a given number of bands and k-points. Notice that parameters in the NSCF calculation determine the number of k-points and the maximum number of bands that can be used in Lumen. Run these calculation with the command:

for QuantumEspresso:

pw.x -inp BNsheet.scf.in  > output_scf
pw.x -inp BNsheet.nscf.in > output_nscf

for Abinit:

abinit < hBN.files > output_hBN

Notice that in the NSCF file of QuantumEspresso we use the flag force_symmorphic=.true. to exclude the non-symmorphic symmetries that are not supported by Yambo, in Abinit the same option is activated by the flag symmorphi 0.

Import the wave-functions

If you used QuantumEspresso go in the folder bn.save, in the ABINIT case all file are already in the main folder. Then import the wave-function with the command
for QuantumEspresso:

p2y

for Abinit:

a2y -F hbn_out_DS2_KSS

Setup

Generate the setup input file with the command yambo_nl -i -V RL -F setup.in, then run yambo_nl -F setup.in.
You can reduce the number of G-vectors in the setup in such a way to speed up calculations. I advise to reduce G-vector to 1000 (about 50% the initial ones).

Reduce symmetries

Since in real-time simulation we introduce a finite electric field in the Hamiltonian, the number of the symmetries of the original system is reduced due to the presence of this field. Using the tool ypp -y to generate the input file:

fixsyms                      # [R] Reduce Symmetries
% Efield1
0.00     | 1.00     | 0.00     |        # First external Electric Field
%
% Efield2
 0.00     | 0.00     | 0.00     |        # Additional external Electric Field
%
#RmAllSymm                   # Remove all symmetries
RmTimeRev                   # Remove Time Reversal

Set the external field in the y direction and uncomment the Time Reversal flag, as shown in red above. Run ypp and it will create a new folder called FixSymm with the reduced symmetries wave-functions.

Setup again

Go in the FixSymm directory and run the setup again yambo_nl -F ../setup.in. Now everything is ready for the real-time simulations!

Real-time dynamics

In order to calculate linear-response in real-time we will perturb the system with a delta function in time external field. Use the command yambo_nl -u p -F input_lr.in to generate the input:

nlinear                      # [R NL] Non-linear optics
NL_Threads= 1                # [OPENMP/NL] Number of threads for nl-optics
% NLBands
  3 |  6 |                   # [NL] Bands
%
NLstep=   0.0100       fs    # [NL] Real Time step length
NLtime=55.000000      fs    # [NL] Simulation Time
NLintegrator= "INVINT"       # [NL] Integrator ("EULEREXP/RK4/RK2EXP/HEUN/INVINT/CRANKNIC")
NLCorrelation= "IPA"         # [NL] Correlation ("IPA/HARTREE/TDDFT/LRC/JGM/SEX/HF")
NLLrcAlpha= 0.000000         # [NL] Long Range Correction
NLDamping=  0.000000   eV    # [NL] Damping
RADLifeTime=-1.000000      fs    # [RT] Radiative life-time (if negative Yambo sets it equal to Phase_LifeTime in NL)
#EvalCurrent                   # [NL] Evaluate the current
#FrPolPerdic                   # [DIP] Force periodicity of polarization respect to the external field
% Field1_Freq
 0.100000 | 0.100000 |         eV    # [RT Field1] Frequency
%
Field1_NFreqs= 1                 # [RT Field1] Frequency
Field1_Int=  1000.00       kWLm2 # [RT Field1] Intensity
Field1_Width= 0.000000     fs    # [RT Field1] Width
Field1_kind=   "DELTA"           # [RT Field1] Kind(SIN|COS|RES|ANTIRES|GAUSS|DELTA|QSSIN)
Field1_pol= "linear"             # [RT Field1] Pol(linear|circular)
% Field1_Dir
   0.000000 | 1.000000 | 0.000000 |        # [RT Field1] Versor
%
Field1_Tstart= 0.010000    fs    # [RT Field1] Initial Time


The standard input of Lumen is thought for non-linear response so we have to change some parameters in order to calculate the linear response. Set the field direction along y, the field type to DELTA, the length of the simulation to 55 fs, number of bands from 3 to 6 dephasing to zero and the number of energy steps to one, as shown above in red.
We set the verbosity to "high" in such a way to print real-time output files.
We set the differential equation integrator to INVINT that is faster bul less accurate than the default(see PRB 88, 235113). This integrator is ok in case of independent partcicles but I advise you to use CRANKNIC integrator when correlation effects are present. Now run yambo_nl -F input_lr.in
The code will produce different files: o.polarization_F1 that contains the polarization, o.external_potential_F1 the external field we used, and finally r_optics_nloptics a report with all information about the simulation. If you plot the third column of o.polarization_F1 versus the first one (time variable) you will get the time-dependent polarization along the y direction:

Polarization hbn.png

Analyze the results

Now we can use ypp_nl -u to analyze the results:

nonlinear                    # [R] NonLinear Optics Post-Processing
Xorder= 1                    # Max order of the response functions
% TimeRange 
-1.000000 |-1.000000 | fs    # Time-window where processing is done
%
ETStpsRt= 200                # Total Energy steps
% EnRngeRt
  0.00000 | 10.00000 | eV    # Energy range
%
DampMode= "LORENTZIAN"             # Damping type ( NONE | LORENTZIAN | GAUSSIAN )
DampFactor=  0.10000   eV    # Damping parameter

where we set a Lorentzian smearing corresponding to 0.1 eV. Notice that due to the finite time of our simulation a smearing is always necessary to Fourier transform the result. Then we run ypp_nl and obtain the following files: the dielectric constant along the field direction o.YPP-eps_along_E, the EELS along the same direction o.YPP-eels_along_E, and the damped polarization o.YPP-damped_polarization.
Now we can plot the dielectric constant and compare it with linear response:

BN eps.png


The input for the linear response can be downloaded here. Notice that in a real-time simulation we obtain directly the [math]\displaystyle{ \chi(\omega) = \frac{P(\omega)}{E(\omega)} }[/math] that is related to the dielectric constant from the relation [math]\displaystyle{ \epsilon(\omega) = 1 + 4 \pi \chi(\omega) }[/math]

Analysis of the results using YamboPy

This part works only with Yambo 5.3 or the last version available on Github: https://github.com/yambo-code/yambo

Starting from Yambo 5.3 the analysis of real-time simulation can performed using YamboPy code.
Here we suppose that you already installed it otherwise you can follow this webpage Setting up YamboPy.
In order to analyze the real-time results, go in the folder where you ran the simulation, and in the python shell type:

import numpy as np
from yambopy import *
from yambopy.plot  import *

NLDB=YamboNLDB()

pol =NLDB.Polarization[0]
time=NLDB.IO_TIME_points
t_initial=NLDB.Efield[0]["initial_time"]

in this way you read all the Non-linear databases. If your runs are in a different folder then the 'SAVE' one you can specify it using the command:

NLDB=YamboNLDB(calc='MYJOB')

now in the array pol you have all the polarization for all laser frequencies in the three Cartesian directions, while the variable time contains all the time series of your simulation, and t_intital is the time when the external field is turned on.
We can now apply a damping function to the polarization before Fourier transform it by doing:

pol_damped=np.empty_like(pol)
for i_d in range(3):
   pol_damped[i_d,:]=damp_it(pol[i_d,:],time,t_initial,damp_type='LORENTZIAN',damp_factor=0.1/ha2ev)

now we can plot the damped polarization with the command

Plot_Pol_or_Curr(time=time, pol=pol_damped, xlim=[0,55], save_file='polarization.pdf')

you will get the damped polarization in the three Cartesian directions:

Pol yambopy.png

Now we can Fourier transform it to get the dielectric constant as explained in the previous section:

Linear_Response(time=time,pol=pol_damped,efield=NLDB.Efield[0],plot=False,plot_file='eps.pdf')

here the result:

Eps yambopi nl.png