Units

Maxwell's equations are scale-invariant. However the program is intended to run in the microscopic scale. To be consistent use for:

coordinates, lengths Angstrom (1e-10 m) eV (Electronvolt)

Command list

Incidence light

`quad.light.SetthetaPhi(number, number)`

```1. argument: angle theta in degrees
2. argument: angle phi in degrees
return value: none
Desc: Set the incoming light direction in spherical coordinates. The angle theta must be between 90° and 180°! Otherwise, the light doesn't hit the sample from the top.```

`quad.light.SetEnergy(number)`

```1. argument: energy in ev
return value: none
Desc: Energy of incoming light in eV```

`quad.light.SetPolarization (string)`

```1. argument:
"S" : Sigma polarization (perpendicular to the scattering plane)
"P" : Pi polarization (parallel to the scattering plane)
"L" : Left circular polarization
"R" : Right circular polarization
Desc: Defines the polarization of the incoming light dependent in relation to the HK=0,0 scattering plane. ```

`quad.light.SetPolarization (string, number)`

```1. argument:
"S" : Sigma polarization (perpendicular to the scattering plane)
"P" : Pi polarization (parallel to the scattering plane)
"L" : Left circular polarization
"R" : Right circular polarization
2. argument: Defines index of outgoing beam to define the scattering plane
Desc: Defines the polarization of the incoming light dependent on the defined scattering plane. ```

`quad.light.GetKVector()`

``` return value: Vec3
Desc: Returns the current wavevector of the incoming light
```

`quad.light.Setfilter(string)`

```1. argument:
"N" : none polarization filter (default)
"S" : Sigma polarization filter (perpendicular to the scattering plane)
"P" : Pi polarization filter (parallel to the scattering plane)
"L" : Left circular polarization filter
"R" : Right circular polarization filter
Desc: Defines the polarization filter of the outgoing light.```

Main Functions

`quad.Scatter()`

```return value: nothing
Desc: Calculates the scattering matrices for the whole layer structure. It depends on almost all parameters given earlier and executes the main routine.```

Atom creation

`quad.atom.NewScatteringFactorAtom(number, number)`

```1. argument: real part of scattering factor (f1)
2. argument: imaginary part of scattering factor (f2)
return value: atom type
Desc: Generates a energy-independent atom type```

`quad.atom.NewAtom(string)`

```1. argument: short element name like "Ti" for Titanium
return value: atom type
Desc: tries to find name.ff in order to load the scattering factor files or uses the internal database.```

`quad.atom.NewAtom(string, q)`

```1. argument: short element name like "Ti" for Titanium
2. argument: defines the scattering for a certain momentum transfer q [Unit: A^-1]
return value: atom type
Desc: tries to find name.ff in order to load the scattering factor files or uses the internal database.```

`quad.atom.NewMagneticAtom(number, number, number, number, number, number)`

```1. argument: real part of scattering factor (f1)
2. argument: imagninary part of scattering factor (f2)
3. argument: real part of magnetic scattering factor (f1m)
4. argument: imagninary part of magnetic scattering factor (f2m)
5. argument: direction of magnetiztion (theta angle in degrees)
6. argument: direction of magnetization (phi angle in degrees)
return value: atom type
Desc: Generates a energy-independent atom type with magnetic contributions```

`quad.atom.NewScatteringFactorFileAtom(string)`

```1. argument: filename of tabulated scattering factors
return value: atom type
Desc: Generates a energy-dependent atom type```

`quad.atom.NewScatteringTensorFileAtom(string)`

```1. argument: filename of tabulated scattering tensors
return value: atom type
Desc: Generates a energy-dependent atom type```

Reciprocal lattice

`quad.rl.Set(vec2, vec2, Decimal number)`

``` 1. Argument: First unit cell vector in-plane
2. Argument: Second unit cell vector in-plane
3. Argument: unit cell length in z-direction. This argument is necessary to define the l-value in the function SetThetaHKL
Desc: Sets the lattice parameters in 2D. Adds the mandatory reciprocal lattice vector (H,K)=(0,0)
return value: nothing```

`quad.rl.b1()` `quad.rl.b2()` `quad.rl.b3()`

``` return value: Vec3
Desc: Returns the three reciprocal lattice vectors.```

`quad.rl.GetN()`

``` return value: integer
Desc: return the number of reciprocal lattice vectors calculated.```

`quad.rl.AddReciprocalLatticeVector(number, number)`

``` 1. Argument: Miller indice H of the reciprocal lattice vector
2. Argument: Miller indice K of the reciprocal lattice vector
return value: nothing
Desc: Adds a reciprocal lattice vector HK to the list of vector, which have to be calculated```

`quad.rl.SetRadius(number)`

``` 1. Argument: Radius in the reciprocal lattice space
return value: nothing
Desc: Renews the list of reciprocal lattice vectors with a list of all reciprocal lattice vector withing the radius
```

Slab Settings

`quad.slabs.AddSlabs(number, number)`

``` 1. Argument: number of slabs to create
2. Argument: thickness of each slab
return value: nothing```

`quad.slabs.AddAtom(number, atom type, Vec3)`

``` 1. Argument: add to the slab with index i
2. Argument: the variable with the atom type
3. Argument: Position of the atom inside the slab
return value: nothing```

`quad.slabs.SetStructure(string)`

``` Desc: Describes the final film structure. These are basically comma seperated slab indices or variables defined in slabs.DefineCrystal
Additionally it allows to place brackets and repetitions
Examples:  "0,1"
"100*(0,1)"
"100*(1,2), 0"
"100*(0,1), 100000*(2)"
"100*( 2*(0,1), 2*(3,4) )"
"Crys1, Crys2" (if "Crys1" and "Crys2" were defined with slabs.CreateCrystal or the other functions)
return value: nothing
```

`quad.slabs.CreateCrystal(string, string)`

``` 1. argument: Variable name of this structure. Allowed signs: 'a'-'z', 'A'-'Z', '_', and '0'-'9' if it is not the first sign
2. argument: Crystal definition like in the function slabs.SetStructure
return value: nothing
Desc: Defines a seperate crystal which can be used in the function slabs.SetStructure```

`quad.slabs.CreateHom(string, string)`

``` 1. argument: Variable name of this structure. Allowed signs: 'a'-'z', 'A'-'Z', '_', and '0'-'9' if it is not the first sign
2. argument: Crystal definition like in the function slabs.SetStructure
return value: nothing
Desc: Defines a slab of an unordered crystal. The crystal is reduced to a continuum with the correct optical constants```

`quad.slabs.CreateInterface(string, string, string, number, number)`

``` 1. argument: Variable name of this structure. Allowed signs: 'a'-'z', 'A'-'Z', '_', and '0'-'9' if it is not the first sign
2. argument: Crystal definition of the top crystal like in the function slabs.SetStructure
3. argument: Crystal definition of the bottom crystal like in the function slabs.SetStructure
4. argument: Total thickness of this interface with unordered crystal. The interface will be in the center of this slab.
5. argument: Discretization of this interface. (around 3*thickness/sigma)
6. argument: Roughness sigma in Angstrom
return value: nothing
Desc: Defines a slab with two unordered crystal and a rough interface. ```

General Functions

`quad.PrintStatus()`

` return value: nothing`

`quad.GetReflectedIntensity(number)`

` return value: Decimal Number`

`quad.GetTransmittedIntensity(number)`

` return value: Decimal Number`

`quad.GetReflectedKVector(number)`

`  return value: Vec3`

`quad.GetTransmittedKVector(number)`

`  return value: Vec3`

`quad.SetThetaHKL(integer h, integer k, Decimal number l)`

```return value: integer (-1 if error)
Desc: Calculates the angle theta for a fixed phi angle and given hkl triple. Variable l can be non-integer. Returns the index of the reciprocal lattice vector.
a negative number of l means transmission whereas a positive number means reflection. The calculated angle theta is automatically set in the variable light.theta```

`quad.SetMultipleScattering(type)`

```return value: nothing
valid values:
MS.KINEMATIC:   Kinematical scattering (independent scatterers and independent light)
MS.NONE:   No multiple scattering is calculated (enable light absorbtion and refraction)
MS.LAYER:  Interlayer multiple scattering is enabled
MS.INTERATOMIC: Interlayer as well as interatomic multiple scattering is enabled (not supported yet)```

`quad.SetNumericAccuracy(type)` (not supported yet)

```valid values:
NUM.FLOAT: The decimals numbers are defined as 4 byte floating point numbers
NUM.DOUBLE: The decimals numbers are defined as 8 byte floating point numbers
NUM.LONGDOUBLE: The decimals numbers are defined as 10 byte floating point numbers. (Architecture dependent)
NUM.QUAD: The decimals numbers are defined as 16 byte floating point numbers```

`quad.SetMatrixAccuracy(type)`

```valid values:
M.DIAGONAL: Neglect off-diagonal terms of the matrices. Very fast but leads to separate scattering channels.
M.FULL: Use Full Matrix-Matrix-Multiplications
M.BLAS: Like M.FULL but use of BLAS-libraries to increase performance of matrix-matrix-multiplication (not working yet)```

Queue functions for Parallelization

`quad.queue.Add()`

`  Desc: Add current light configuration to queue`

`quad.queue.Run()`

`  Desc: Execute the current queue parallelized`

`quad.queue.Activate(integer)`

```  Variable1: Index in the queue beginning from zero
Desc: Activates a result of the queue.```

`quad.queue.GetN()`

`  return value: Number of entries in the queue`

`quad.queue.Clear()`

` Desc: Clears the queue (Bug: Memory is not freed)`

Fitting functions

`quad.fit.AddVariable(number, number, number, number)`

```1. argument: initial value for number
2. argument: stepsize of 1.arguement in first iteration . If unsure choose 0.1*initial_value. The value must not be zero!
3. argument: lower boundary for variable
4. argument: upper boundary for variable```

`quad.fit.SetErrorFunction(function)`

```1. argument: Lua function which should return an error
Desc: The function receives a list of parameters (array of numbers), and should return an error (number)```

`quad.fit.Iterate(number)`

`1. argument: Number of simplex iterations to perform`