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
- 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.
- 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.
- 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
- 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.
- 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.
- 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.
- 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 |
FillTensors() | This applies only for the full matrix mode. see footnote (*1) | Function |
Note: the index i is the layer index according to the layer input table. ([0] := substrate, [1] := first layer after substrate)
(*1)Before the script is executed the optical 3×3 tensors are filled with default values given by the parameters in the layer list. That means in compound mode, that the tensor is filled with the contents of delta, beta, deltam and betam at the appropriate tensor entries. In element mode, the scattering tensor is filled with the contents of f1, f2, f1m and f2m. Any change to delta, beta, deltam, betam in compound mode or f1, f2, f1m, f2m in element mode in the script is therefore meaningless. But if these parameters are changed, the tensor can be renewed by executing the “FillTensors()” function.
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 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 these 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];