# CreateSpectra

CreateSpectra($O_1$,$O_2$,$\psi$) calculates $$\langle \psi | O_2^{\dagger} \frac{1}{(\omega + \mathrm{i} \Gamma/2 + E_0 - O_1)} O_2 | \psi \rangle,$$ with $E_0 = \langle \psi | O_1 | \psi \rangle$ and returns the result as a spectrum object and as a tri-diagonal matrix. $O_1$ and $O_2$ are allowed to be tables of operators or tables of wavefunctions. CreateSpectra can take a fourth element specifying options.

## Input

• $O_1$ : Operator
• $O_2$ : Operator or a list of operators
• $\psi$ : Wavefunction or a list of Wavefunctions
• Possible options are:
• “NTri” Positive integer specifying the number of states in the Krylov basis. (Default value 200)
• “epsilon” Positive real defining the smallest absolute value considered different than zero. (Default value 1.49E-8)
• “restrictions” A list of restrictions defining restrictions on configurations and occupations included. Allows one to do restricted active space calculations
• “Emin” Real value defining the minimum energy in the spectra (Default value determined such that the spectrum fits into the range
• “Emax” Real value defining the maximum energy in the spectra (Default value determined such that the spectrum fits into the range
• “NE” Positive integer defining the number of points in the spectrum. (Default value 1000)
• “Gamma” Positive real defining the full width half maximum Lorenzian broadening. (Default value 10*(Emax-Emin)/NE)
• “Tensor” Bolean defining if off diagonal elements are calculated or not. (Default false)

## Output

• G : Spectrum object. In the case that both a list of operators $\{O_2^a,O_2^b\}$ as well as a list of Wavefunctions $\{\psi_1,\psi_2,\psi_3\}$ is given the output order first the Wavefunctions and then the operators, i.e. $\{I_1^a,I_2^a,I_3^a,I_1^b,I_2^b,I_3^b\}$ with $a$ and $b$ referring to the index of the operators and $1,2,3$ to the index of the Wavefunctions.
• T : List representing a tri-diagonal matrix, whose resolvent is the spectral function

## Example

description text

### Input

CreateSpectra.Quanty
dofile("../definitions.Quanty")
-- define an Hamiltonian (in this case a magnetic field of 6 tesla in the z direction)
H = 6 * EnergyUnits.Tesla.value * (2*OppSz + OppLz)
-- define a transition operator (in this case a pulsed magnetic field of 20 tesla in the x direction)
T = 20 * EnergyUnits.Tesla.value * (2*OppSx + OppLx)
-- define a ground-state (in this case a p electron with spin and angular momentum down)
psigrd = psim1dn

-- calculate < psigrd | T^dag 1/(w-H+i*G/2+E0) T | psigrd >
--   with E0 = <psigrd | H | psigrd >
-- spectri is optional
spec, spectri = CreateSpectra(H, T, psigrd,{{"NE",20}})

-- the real and imaginary part on a fixed energy grid
print(spec)

-- the spectrum represented as a continued fraction
-- spectri contains {a,b,E0}
-- and the spectrum is a[1] + b[1]^2 / (w + E0 + i G/2 - a[2] - b[2]^2 / (w + E0 + i G/2 - a[3] - b[3]^2 / ... ))
print(spectri)

### Result

CreateSpectra.out
#Spectra: 1
Emin______Emax       3.038900445581886E-04  7.380186796413151E-04
EminPole__EmaxPole   3.473029080665012E-04  6.946058161330025E-04
dE________Gamma      2.170643175415633E-05  2.170643175415633E-04
Energy               Re[0]                  Im[0]
3.038900445582E-04 -5.313499244491392E-03 -6.207216396406420E-03
3.255964763123E-04 -4.530120135703289E-03 -6.919966484421555E-03
3.473029080665E-04 -3.515600809214091E-03 -7.272899174061652E-03
3.690093398207E-04 -2.517203983251221E-03 -7.171656631527070E-03
3.907157715748E-04 -1.782244773628827E-03 -6.719544484357337E-03
4.124222033290E-04 -1.413455673284595E-03 -6.131215006631856E-03
4.341286350831E-04 -1.372258888529464E-03 -5.591509432157396E-03
4.558350668373E-04 -1.564713253998241E-03 -5.201614330859017E-03
4.775414985914E-04 -1.902890978987316E-03 -5.000149700104968E-03
4.992479303456E-04 -2.322043353835751E-03 -4.998296710798989E-03
5.209543620998E-04 -2.774954571317865E-03 -5.203039821220997E-03
5.426607938539E-04 -3.219375361758718E-03 -5.628003383025635E-03
5.643672256081E-04 -3.603346747444065E-03 -6.295735047500588E-03
5.860736573622E-04 -3.848348813887564E-03 -7.231512606316196E-03
6.077800891164E-04 -3.831631961478373E-03 -8.442956473257584E-03
6.294865208705E-04 -3.379188728845951E-03 -9.875468445796350E-03
6.511929526247E-04 -2.302467572417779E-03 -1.134374714025916E-02
6.728993843788E-04 -5.224385625615705E-04 -1.249103108669947E-02
6.946058161330E-04  1.757800404607050E-03 -1.289786046880420E-02
7.163122478872E-04  4.046100622038835E-03 -1.236518601314671E-02
7.380186796413E-04  5.850339581477893E-03 -1.108758309628370E-02

{ { { 0 , -0.00081037345215517 , -0.00092614108817734 } ,
{ 0.0014178581849128 , 0.00016372016094642 } ,
mu = 0 ,
name = Matrix ,
type = Tri } }