Spectra

The Spectra object stores complex spectra as created by the functions CreateSpectra or CreateResonantSpectra. The spectra are stored as complex functions on a discrete mesh. The object furthermore contains several additional information such as the integral.

Shared code for examples

In order to run the examples for the different functions, properties and methods of the object spectra we define a set of functions specific to spectra. These functions must be loaded before any of the examples provided later on will work. The code creates three spectra stored in the variable G

  1. a spectrum with 9 peaks at energy 1 to 9 in steps of 1 and intensity 0.12 to 0.92.
  2. a spectrum with 4 peaks at energy 2 to 8 in steps of 2 and intensity 0.22 to 0.82.
  3. a spectrum with 5 peaks at energy 1 to 9 in steps of 2 and intensity 0.12 to 0.92.

The actual code in Quanty is:

definitions.Quanty
NF = 9
NB = 0
T1 = NewOperator("Create", NF, {0,1,2,3,4,5,6,7,8},{0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9})
T2 = NewOperator("Create", NF, {0,1,2,3,4,5,6,7,8},{0.0,0.2,0.0,0.4,0.0,0.6,0.0,0.8,0.0})
T3 = NewOperator("Create", NF, {0,1,2,3,4,5,6,7,8},{0.1,0.0,0.3,0.0,0.5,0.0,0.7,0.0,0.9})
H = NewOperator("Number", NF, {0,1,2,3,4,5,6,7,8}, {0,1,2,3,4,5,6,7,8}, {1,2,3,4,5,6,7,8,9})
psi = NewWavefunction(NF,NB,{{"000000000",1}})
G = CreateSpectra(H, {T1,T2,T3}, psi, {{"Emin",-1}, {"Emax",11}, {"Gamma",0.1}})
gnuplotHead = [[
set autoscale
set xtic auto
set ytic auto
set style line  1 lt 1 lw 1 lc rgb "#000000"
set style line  2 lt 1 lw 1 lc rgb "#FF0000"
set style line  3 lt 1 lw 1 lc rgb "#00FF00"
set style line  4 lt 1 lw 1 lc rgb "#0000FF"
set style line  5 lt 1 lw 3 lc rgb "#808080"
set style line  6 lt 1 lw 3 lc rgb "#00FFFF"
set style line  7 lt 1 lw 3 lc rgb "#FF00FF"
set style line  8 lt 1 lw 3 lc rgb "#FFFF00"
set xlabel "Energy (arb. units)" font "Times-Roman,12"
set ylabel "Intensity (arb. units)" font "Times-Roman,12"
set size 1.0, 0.3
set terminal postscript portrait enhanced color  "Times-Roman" 8
]]

The code above does not create output. We can save the spectra G to file and use gnuplot to plot the spectra with the example below.

Example.Quanty
dofile("definitions.Quanty")
G.Print({{"file","Spectra.dat"}})
gnuplotScript = gnuplotHead .. [[
set output "Spectra.ps"
plot "Spectra.dat"  using 1:(-$3  ) title 'T1' with lines ls  1,\
     "Spectra.dat"  using 1:(-$5+4) title 'T2' with lines ls  2,\
     "Spectra.dat"  using 1:(-$7+8) title 'T3' with lines ls  3
]]
file = io.open("Spectra.gnuplot", "w")
file:write(gnuplotScript)
file:close()
-- call gnuplot to execute the script
os.execute("gnuplot Spectra.gnuplot")
os.execute("convert -density 1024 Spectra.ps -resize 1024 Spectra.png")

The resulting picture is:

Table of contents

Print/export