# CreateResonantSpectra

CreateResonantSpectra($O_1$,$O_2$,$O_3$,$O_4$,$\psi$) calculates $$\langle \psi | O_3^{\dagger} \frac{1}{(\omega_1 - \mathrm{i} \Gamma_1/2 + E_0^{(1)} - O_1^{\dagger})} O_4^{\dagger} \frac{1}{(\omega_2 + \mathrm{i} \Gamma_2/2 + E_0^{(2)} - O_2)} O_4\frac{1}{(\omega_1 + \mathrm{i} \Gamma_1/2 + E_0^{(1)} - O_1)} O_3 | \psi \rangle,$$ with $E_0^{(i)} = \langle \psi | O_i | \psi \rangle$. The spectrum is returned as a spectrum object.

## Input

• $O_1$ : Operator
• $O_2$ : Operator
• $O_3$ : Operator
• $O_4$ : Operator
• $\psi$ : Wavefunction
• Possible options are:
• “NTri1” Positive integer specifying the number of states in the Krylov basis of $O_1$. (Standard value 200)
• “NTri2” Positive integer specifying the number of states in the Krylov basis of $O_2$. (Standard value 200)
• “epsilon” Positive real defining the smallest absolute value considered different than zero. (Standard value 1.49E-8)
• “restrictions1” A list of restrictions defining restrictions on configurations and occupations included for $O_1$ . Allows one to do restricted active space calculations. Note that the action of $O_3$ and $O_4$ are not restricted and all excitations they can make are included.
• “restrictions2” A list of restrictions defining restrictions on configurations and occupations included for $O_2$ . Allows one to do restricted active space calculations. Note that the action of $O_3$ and $O_4$ are not restricted and all excitations they can make are included.
• “Emin1” Real value defining the minimum energy in the spectra (Standard value determined such that the spectrum fits into the range)
• “Emax1” Real value defining the maximum energy in the spectra (Standard value determined such that the spectrum fits into the range)
• “NE1” Positive integer defining the number of points in the spectrum. (Standard value 1000)
• “Gamma1” Positive real defining the full width half maximum Lorenzian broadening. (Standard value 10*(Emax1-Emin1)/NE1)
• “Emin2” Real value defining the minimum energy in the spectra (Standard value determined such that the spectrum fits into the range)
• “Emax2” Real value defining the maximum energy in the spectra (Standard value determined such that the spectrum fits into the range)
• “NE2” Positive integer defining the number of points in the spectrum. (Standard value 1000)
• “Gamma2” Positive real defining the full width half maximum Lorenzian broadening. (Standard value 10*(Emax2-Emin2)/NE2)

## Output

• G : Spectrum object.

In the case that $O_3$ ($\{O_3^a, O_3^b\}$) , $O_4$ ($\{O_4^{\alpha}, O_4^{\beta}, O_4^{\gamma}\}$) and $\psi$ ($\{\psi_1,\psi_2,\psi_3\}$) are given as tables the order of spectra returned is:

$\{$ $I_1^{a,\alpha}(E_0)$, $I_1^{a,\alpha}(E_1)$, $\dots$, $I_1^{a,\alpha}(E_{N_E})$, $I_1^{a,\beta}(E_0)$, $I_1^{a,\beta}(E_1)$, $\dots$, $I_1^{a,\beta}(E_{N_E})$, $I_1^{a,\gamma}(E_0)$, $I_1^{a,\gamma}(E_1)$, $\dots$, $I_1^{a,\gamma}(E_{N_E})$,

$I_1^{b,\alpha}(E_0)$, $I_1^{b,\alpha}(E_1)$, $\dots$, $I_1^{b,\alpha}(E_{N_E})$, $I_1^{b,\beta}(E_0)$, $I_1^{b,\beta}(E_1)$, $\dots$, $I_1^{b,\beta}(E_{N_E})$, $I_1^{b,\gamma}(E_0)$, $I_1^{b,\gamma}(E_1)$, $\dots$, $I_1^{b,\gamma}(E_{N_E})$,

$I_2^{a,\alpha}(E_0)$, $I_2^{a,\alpha}(E_1)$, $\dots$, $I_2^{a,\alpha}(E_{N_E})$, $I_2^{a,\beta}(E_0)$, $I_2^{a,\beta}(E_1)$, $\dots$, $I_2^{a,\beta}(E_{N_E})$, $I_2^{a,\gamma}(E_0)$, $I_2^{a,\gamma}(E_1)$, $\dots$, $I_2^{a,\gamma}(E_{N_E})$,

$I_2^{b,\alpha}(E_0)$, $I_2^{b,\alpha}(E_1)$, $\dots$, $I_2^{b,\alpha}(E_{N_E})$, $I_2^{b,\beta}(E_0)$, $I_2^{b,\beta}(E_1)$, $\dots$, $I_2^{b,\beta}(E_{N_E})$, $I_2^{b,\gamma}(E_0)$, $I_2^{b,\gamma}(E_1)$, $\dots$, $I_2^{b,\gamma}(E_{N_E})$,

$I_3^{a,\alpha}(E_0)$, $I_3^{a,\alpha}(E_1)$, $\dots$, $I_3^{a,\alpha}(E_{N_E})$, $I_3^{a,\beta}(E_0)$, $I_3^{a,\beta}(E_1)$, $\dots$, $I_3^{a,\beta}(E_{N_E})$, $I_3^{a,\gamma}(E_0)$, $I_3^{a,\gamma}(E_1)$, $\dots$, $I_3^{a,\gamma}(E_{N_E})$,

$I_3^{b,\alpha}(E_0)$, $I_3^{b,\alpha}(E_1)$, $\dots$, $I_3^{b,\alpha}(E_{N_E})$, $I_3^{b,\beta}(E_0)$, $I_3^{b,\beta}(E_1)$, $\dots$, $I_3^{b,\beta}(E_{N_E})$, $I_3^{b,\gamma}(E_0)$, $I_3^{b,\gamma}(E_1)$, $\dots$, $I_3^{b,\gamma}(E_{N_E})$ $\}$

where the alphabetic, greek and numeral indices refer to $O_3$, $O_4$ and $\psi$.

## Example

Calculates the resonant spectra for some toy Hamiltonian and transition operators.

### Input

CreateResonantSpectra.Quanty
dofile("../definitions.Quanty")
-- define an Hamiltonian (in this case a magnetic field of 6 tesla in the z direction)
H1 = 6 * EnergyUnits.Tesla.value * (2*OppSz + OppLz)
-- define a second Hamiltonian (in this case a magnetic field of 6 tesla in the z direction)
H2 = 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)
T1 = 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
-- define a feritale operator to be able to calculate resonant spectroscopy
T2 = (2*OppSy + OppLy)

-- calculate < psigrd | T1^dag 1/(w1-i*G1/2+E0-H1^dag) T2^dag 1/(w2+i*G2/2+E0-H2) T2 1/(w1+i*G1/2+E0-H1) T1 | psigrd >
--   with E0 = <psigrd | H | psigrd >
spec = CreateResonantSpectra(H1, H2, T1, T2, psigrd, {{"NE1",2} , {"NE2",10}})

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

### Result

CreateResonantSpectra.out
Start of LanczosTriDiagonalizeKrylovRR
#Spectra: 3
Emin______Emax      -2.192128838174913E-04  1.516839581805201E-03 -2.192128838174913E-04  1.516839581805201E-03 -2.192128838174913E-04  1.516839581805201E-03
EminPole__EmaxPole  -4.261691575999300E-05  1.372168543003309E-03 -3.252606517456513E-19  1.103426565393108E-03 -7.454184501560037E-05  1.231092634560993E-03
dE________Gamma      1.736052465622692E-04  8.680262328113460E-04  1.736052465622692E-04  8.680262328113460E-04  1.736052465622692E-04  8.680262328113460E-04
Energy               Re[0]                  Im[0]                  Re[1]                  Im[1]                  Re[2]                  Im[2]
-2.192128838175E-04 -4.567517681416985E+03 -5.543001799870324E+03 -6.525966405714727E+03 -7.880181085715437E+03 -9.384459417866910E+03 -1.130970660619754E+04
-4.560763725522E-05 -3.049277280510574E+03 -6.941998645128027E+03 -4.378985928344880E+03 -9.870966283781299E+03 -6.310071944361847E+03 -1.416835749667363E+04
1.279976093070E-04 -1.110398821142657E+03 -6.912151183558704E+03 -1.635935503976258E+03 -9.839344445259658E+03 -2.381205186729950E+03 -1.413028103055951E+04
3.016028558693E-04 -2.339718928433063E+02 -6.040288069886097E+03 -3.980926728647760E+02 -8.619719098196922E+03 -6.087166968383502E+02 -1.239320326724325E+04
4.752081024316E-04 -2.390678249447761E+02 -5.634601111286659E+03 -4.035726414751845E+02 -8.068711266115147E+03 -6.128411970706163E+02 -1.161934969943266E+04
6.488133489939E-04 -2.524732347767481E+02 -6.001004351733182E+03 -4.060760193483442E+02 -8.614860860968134E+03 -6.011480856818257E+02 -1.241731791050131E+04
8.224185955561E-04  3.679380250879433E+02 -6.833308993933237E+03  5.040215977236442E+02 -9.811795868961692E+03  7.258932025733963E+02 -1.413634888162722E+04
9.960238421184E-04  2.021779007891823E+03 -7.375129604228581E+03  2.886102637616710E+03 -1.058171170957882E+04  4.159362152701476E+03 -1.523242665463819E+04
1.169629088681E-03  4.003817796524420E+03 -6.533443251521155E+03  5.730077171546568E+03 -9.369302108441347E+03  8.248266324697368E+03 -1.348088402875583E+04
1.343234335243E-03  4.923590725326930E+03 -4.801398097101529E+03  7.048863360389564E+03 -6.883831893729633E+03  1.014238202103176E+04 -9.903347380254836E+03
1.516839581805E-03  4.881130744512203E+03 -3.318203623750060E+03  6.988195901103923E+03 -4.756658494950744E+03  1.005361328477628E+04 -6.843031437448207E+03