User Tools

Site Tools


documentation:script

This is an old revision of the document!


The script window uses the scripting language LUA (see: http://www.lua.org/ or http://de.wikipedia.org/wiki/Lua) and therefore provides a large function pool (mathematical functions, control structures etc.).

The script in the register “BeforeCalculation” is executed when

  1. The script is executed manually. Either in the menu in the main window or the execute button in the script window. The altered variables are written back to the graphical user interface. Error Messages and Debug Messages appear in the Debug Window. The script is executed even if the script function is disabled.
  2. A const-energy reflectivity calculation is performed. The script is executed only one time before the simulation starts. The altered variables are not written back to the graphical user interface. Error messages as well as debug messages are suppressed.
  3. Plotting the optical profiles as function of z. The script is executed only one time before the simulation starts. The altered variables are not written back to the graphical user interface. Error messages as well as debug messages are suppressed
  4. An energy scan calculation is performed (the same holds for the map calculation). The script is executed individually for every data point. The altered variables are not written back to the graphical user interface. Error messages as well as debug messages are suppressed.
  5. Plotting the scattering factors f1 and f2 as function of energy. The script is executed individually for every data point. The altered variables are not written back to the graphical user interface. Error messages as well as debug messages are suppressed.
  6. Plotting delta and beta as function of energy. The script is executed individually for every data point. The altered variables are not written back to the graphical user interface. Error messages as well as debug messages are suppressed.
  7. Plotting deltam and betam as function of energy. The script is executed individually for every data point. The altered variables are not written back to the graphical user interface. Error messages as well as debug messages are suppressed.

The script execution can be disabled in the preferences window. If the option “Initial optical constants from database” is enabled the script is executed after the optical constants are set.

Currently defined common variables
Variable Description Type
thickness[i] Thickness of layer i Array of Decimals
delta[i] Optical constant delta for layer i Array of Decimals
beta[i] Optical constant beta for layer i Array of Decimals
sigma[i] RMS roughness of layer i Array of Decimals
deltam[i] Δδ – magnetic change of δ of layer i Array of Decimals
betam[i] Δβ – magnetic change of β of layer i Array of Decimals
density[i] density in g/cm³ of layer i Array of Decimals
gauss_delta[i] Optical constant δ for Gaussian i Array of Decimals
gauss_delta[i] Optical constant δ for Gaussian i Array of Decimals
gauss_variance[i] Variance of Gaussian i Array of Decimals
gauss_z[i] Position z of Gaussian i Array of Decimals
exx_r[i] real part of dielectric tensor Array of Decimals
exx_i[i] imaginary part of dielectric tensor Array of Decimals
exy_r[i] real part of dielectric tensor Array of Decimals
exy_i[i] imaginary part of dielectric tensor Array of Decimals
exz_r[i] real part of dielectric tensor Array of Decimals
exz_i[i] imaginary part of dielectric tensor Array of Decimals
eyx_r[i] real part of dielectric tensor Array of Decimals
eyx_i[i] imaginary part of dielectric tensor Array of Decimals
eyy_r[i] real part of dielectric tensor Array of Decimals
eyy_i[i] imaginary part of dielectric tensor Array of Decimals
eyz_r[i] real part of dielectric tensor Array of Decimals
eyz_i[i] imaginary part of dielectric tensor Array of Decimals
ezx_r[i] real part of dielectric tensor Array of Decimals
ezx_i[i] imaginary part of dielectric tensor Array of Decimals
ezy_r[i] real part of dielectric tensor Array of Decimals
ezy_i[i] imaginary part of dielectric tensor Array of Decimals
ezz_r[i] real part of dielectric tensor Array of Decimals
ezz_i[i] imaginary part of dielectric tensor Array of Decimals
par[i] parameter which can be fitted Array of Decimals
energy Energy Decimal
resolution Resolution Decimal
epsilon Epsilon Decimal
write(…) writes to the debug window (see Lua documentation) Function
print(…) writes to the debug window (see Lua documentation) Function
SetDeltaBeta(i, energy) set delta and beta of layer i to tabulated values at a specific energy Function

Note: the index i is the layer index according to the layer input table. ([0] := substrate, [1] := first layer after substrate)

Currently defined element specific variables

The functions are accessed by putting the element label before the function.
Example:

-- element Lanthanum 
La:getf1()
La:getf2()
La:setf1(1.3)
Variable Description Type included since
getf1() get value of scattering factor f1 Function
getf2() get value of scattering factor f2 Function
setf1(x) set value of scattering factor f1 Function
setf2(x) set value of scattering factor f2 Function
getf1m() get value of scattering factor f1 Function V2.2
getf2m() get value of scattering factor f2 Function V2.2
setf1m(x) set value of scattering factor f1 Function V2.2
setf2m(x) set value of scattering factor f2 Function V2.2
getsigma(i) get roughness of layer i Function
setsigma(i, x) set roughness of layer i Function
getthickness(i) get thickness of layer i Function
setthickness(i, x) set thickness of layer i Function
getdensity(i) get density of layer i Function
setdensity(i, x) set density of layer i Function
setf(energy) set f1, f2, f1m and f2m to tabulated values at a specific energy Function

The index i is the layer index according to the layer input table. ([0] := substrate, [1] := first layer after substrate)

Currently defined variables but unsupported

Following commands are not officially supported. Use this commands in the register “Default”.

Variable Description Type
ShowMatrixEigenvalues ??? Function
ShowEScanEigenvalues(i) ??? Function
GetError() Get the error of the current state Function
CalculateReflectivity() Calculate the reflectivitz Function
CalculateDicReflectivity() not working Function
CalculateEnergyscan() not working Function
solution_qz[i] qz-values after calculation Array of Decimals
solution_R[i] reflectivity-values after calculation Array of Decimals
solution_Rp[i] reflectivity-values after calculation Array of Decimals
solution_Rm[i] reflectivity-values after calculation Array of Decimals
solution_energy[i] energy-values after calculation Array of Decimals
nlayers ??? Number of layers Integer
Examples

Imagine you want to fit a multilayer sample where every second layer has the same thickness…select thickness[1] for fitting (on the layer input table) and then define the following script in the script window:

for i = 3, 7, 2 do
thickness[i] = thickness[1]
end

…the script window defines the thickness[3], [5] and [7] to be equal to [1]. Another example could be a hardcoded constraint of the roughness like:

sigma[3] = sigma[1];
sigma[5] = sigma[1];
sigma[7] = sigma[6];
documentation/script.1412724692.txt.gz · Last modified: 2014/10/07 23:31 by macke

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki