Differences
This shows you the differences between two versions of the page.
documentation:language_reference:objects:spectra:start [2016/09/25 23:02] – created Maurits W. Haverkort | documentation:language_reference:objects:spectra:start [2016/10/10 09:41] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== 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// | ||
+ | - a spectrum with 9 peaks at energy 1 to 9 in steps of 1 and intensity 0.1< | ||
+ | - a spectrum with 4 peaks at energy 2 to 8 in steps of 2 and intensity 0.2< | ||
+ | - a spectrum with 5 peaks at energy 1 to 9 in steps of 2 and intensity 0.1< | ||
+ | |||
+ | The actual code in Quanty is: | ||
+ | ### | ||
+ | |||
+ | <code Quanty definitions.Quanty> | ||
+ | NF = 9 | ||
+ | NB = 0 | ||
+ | T1 = NewOperator(" | ||
+ | T2 = NewOperator(" | ||
+ | T3 = NewOperator(" | ||
+ | H = NewOperator(" | ||
+ | psi = NewWavefunction(NF, | ||
+ | G = CreateSpectra(H, | ||
+ | gnuplotHead = [[ | ||
+ | set autoscale | ||
+ | set xtic auto | ||
+ | set ytic auto | ||
+ | set style line 1 lt 1 lw 1 lc rgb "# | ||
+ | set style line 2 lt 1 lw 1 lc rgb "# | ||
+ | set style line 3 lt 1 lw 1 lc rgb "# | ||
+ | set style line 4 lt 1 lw 1 lc rgb "# | ||
+ | set style line 5 lt 1 lw 3 lc rgb "# | ||
+ | set style line 6 lt 1 lw 3 lc rgb "# | ||
+ | set style line 7 lt 1 lw 3 lc rgb "# | ||
+ | set style line 8 lt 1 lw 3 lc rgb "# | ||
+ | set xlabel " | ||
+ | set ylabel " | ||
+ | set size 1.0, 0.3 | ||
+ | set terminal postscript portrait enhanced color " | ||
+ | ]] | ||
+ | </ | ||
+ | |||
+ | ### | ||
+ | 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. | ||
+ | ### | ||
+ | |||
+ | <code Quanty Example.Quanty> | ||
+ | dofile(" | ||
+ | G.Print({{" | ||
+ | gnuplotScript = gnuplotHead .. [[ | ||
+ | set output " | ||
+ | plot " | ||
+ | " | ||
+ | " | ||
+ | ]] | ||
+ | file = io.open(" | ||
+ | file: | ||
+ | file: | ||
+ | -- call gnuplot to execute the script | ||
+ | os.execute(" | ||
+ | os.execute(" | ||
+ | </ | ||
+ | |||
+ | ### | ||
+ | The resulting picture is: | ||
+ | ### | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===== Table of contents ===== | ||
+ | {{indexmenu> |