Core functions¶
Create stack¶
-
CTMM_EXPORT ctmm_stack ctmm_create_stack(unsigned int nlyrs, double vwl, double t_in)
Initialises a new stack.
The stack should be deallocated with ctmm_free_stack(stack).
- Return
ctmm_stack with initialised arrays and matricies.
- Parameters
nlyrs
: Number of layers in stack.vwl
: Vacuum wavelength of illuminating light (metres).t_in
: Angle of incidence (radians).
Free stack¶
-
CTMM_EXPORT void ctmm_free_stack(ctmm_stack stack)
Frees memory allocated upon stack creation.
- Parameters
stack
:
Set refractive index¶
-
CTMM_EXPORT void ctmm_set_ind(ctmm_stack stack, unsigned int lyr_n, double x, double y)
Sets the refractive index of layer lyr_n to (x + y*i).
- Parameters
stack
: ctmm_stack to set index in.lyr_n
: Layer number to set the index of.x
: Real component of refractive index.y
: Imaginary component of refractive index.
Get refractive index¶
-
CTMM_EXPORT ctmm_complex ctmm_get_ind(ctmm_stack stack, unsigned int lyr_n)
Returns the refractive index of layer lyr_n to (x + y*i).
- Parameters
stack
: ctmm_stack to get index from.lyr_n
: Layer number to get the index of.
Set layer thickness¶
-
CTMM_EXPORT void ctmm_set_d(ctmm_stack stack, unsigned int lyr_n, double d)
Sets the thickness of layer lyr_n to d.
- Parameters
stack
: ctmm_stack to set thickness in.lyr_n
: Layer number to set the index of.d
: Thickness of layer lyr_n.
Get layer thickness¶
-
CTMM_EXPORT double ctmm_get_d(ctmm_stack stack, unsigned int lyr_n)
Returns the thickness of layer lyr_n.
- Parameters
stack
: ctmm_stack to get thickness from.lyr_n
: Layer number to get the index of.
Get vacuum wavelength¶
-
CTMM_EXPORT double ctmm_get_vwl(ctmm_stack stack)
Returns the vacuum wavelength used by stack.
- Parameters
stack
: ctmm_stack to get vwl from.
Get angle of incidence¶
-
CTMM_EXPORT double ctmm_get_t_in(ctmm_stack stack)
Returns the angle of incidence used by stack.
- Parameters
stack
: ctmm_stack to get t_in from.
Get number of layers¶
-
CTMM_EXPORT unsigned int ctmm_get_nlyrs(ctmm_stack stack)
Returns the number of layers in stack.
- Parameters
stack
: ctmm_stack to get nlyrs from.
Get stack matrix pointer¶
-
CTMM_EXPORT ctmm_matrix* ctmm_get_matrix(ctmm_stack stack)
Returns a pointer to the first element of the stack matrix.
- Parameters
stack
: ctmm_stack to get matrix from.
Evaluate stack¶
-
CTMM_EXPORT void ctmm_evaluate(ctmm_stack stack)
Calculate the stack transfer matrix.
- Parameters
stack
:
Calculate ampltiude reflectivity and transmission coefficients¶
-
CTMM_EXPORT void ctmm_rtc(ctmm_stack stack, ctmm_complex * coefs)
calculates fresnel coefficients of stack
- Parameters
coefs
: pointer to length 4 ctnn_complex array to hold coefficients ordered [r_p, t_p, r_s, t_s].stack
: pointer to stack struct
Calculate power reflectivity and transmission coefficients¶
-
CTMM_EXPORT void ctmm_rts(ctmm_stack stack, double * coefs)
Calculates power reflectivities and transmissions.
Reflectivity and transmission coefficients are calculated for both S and P polarised light. The calculated coefficients are stored in the ‘coefs’ array. The stack matrix must have already been evaluated.
This function may return incorrect results if the first or final layer in the stack is absorbing (that is, have a non-zero imaginary component of the refractive index).
- Parameters
coefs
: Array of coefficients ordered [rP, tP, rS, tS].stack
: Stack struct.
Calculate power coefficients and phase changes¶
-
CTMM_EXPORT void ctmm_rtps(ctmm_stack stack, double * coefs)
Calculates power and phase reflectivities and transmissions.
Reflectivity and transmission coefficients and phases are calculated for both S and P polarised light. The calculated coefficients are stored in the ‘coefs’ array. The stack matrix must have already been evaluated.
This function may return incorrect results if the first or final layer in the stack is absorbing (that is, have a non-zero imaginary component of the refractive index).
- Parameters
coefs
: Pointer to length 8 array of coefficients ordered [rP, tP, rS, tS, prP, ptP, prS, ptS].stack
: Stack struct.