Transfer-matrix method

There are three distinct uses of the ray-tracing code: to create redistribution matrices for the matrix framework, to generate lookup tables which are used by the ray-tracer, and to define and calculate structures which are treated in their entirety using TMM(so the matrix framework is not used). The function TMM is used to create redistribution matrices, while the class tmm_structure is used to define structures for ray-tracing. The function make_TMM_lookuptable generates lookup tables for the ray-tracer.

rayflare.transfer_matrix_method.tmm.TMM(layers, incidence, transmission, surf_name, options, structpath, coherent=True, coherency_list=None, prof_layers=None, front_or_rear='front', save=True, overwrite=False)

Function which takes a layer stack and creates an angular redistribution matrix.

Parameters:
  • layers – A list with one or more layers.

  • incidence – incidence medium

  • transmission – transmission medium

  • surf_name – name of the surface (to save/load the matrices generated).

  • options – a list of options

  • structpath – file path where matrices will be stored or loaded from

  • coherent – whether the layer stack is coherent. If None, it is assumed to be fully coherent. Boolean, default True.

  • coherency_list – a list with the same number of entries as the layers, either ‘c’ for a coherent layer or ‘i’ for an incoherent layer

  • prof_layers – layers for which the absorption profile should be calculated (if None, do not calculate absorption profile at all)

  • front_or_rear – a string, either ‘front’ or ‘rear’; front incidence on the stack, from the incidence medium, or rear incidence on the stack, from the transmission medium.

  • save – whether to save the matrices to file. Boolean, default True.

  • overwrite – whether to overwrite existing saved matrices. Boolean, default False.

Returns:

Number of returns depends on whether absorption profiles are being calculated; the first two items are always returned, the final one only if a profile is being calcualted.

  • fullmat: the R/T redistribution matrix at each wavelength, indexed as (wavelength, angle_bin_out, angle_bin_in)

  • A_mat: the absorption redistribution matrix (total absorption per layer), indexed as (wavelength, layer_out, angle_bin_in)

  • allres: xarray dataset storing the absorption profile data

class rayflare.transfer_matrix_method.tmm.tmm_structure(layer_stack, incidence=None, transmission=None, no_back_reflection=False)

Set up structure for TMM calculations.

Parameters:
  • stack – an OptiStack or SolarCell object.

  • incidence – incidence medium (Solcore material)

  • transmission – transmission medium/substrate (Solcore material)

  • no_back_reflection – whether to suppress reflections at the interface between the final material in the stack and the substrate (default False)

build_coh_list(options)
calculate(options, profile=False, layers=None, dist=None)

Calculates the reflected, absorbed and transmitted intensity of the structure for the wavelengths and angles defined.

Parameters:
  • options

    options for the calculation. The key entries are:

    • wavelength: Wavelengths (in m) in which calculate the data. An array.

    • theta_in: Angle (in radians) of the incident light.

    • pol: Polarisation of the light: ‘s’, ‘p’ or ‘u’.

    • coherent: If the light is coherent or not. If not, a coherency list must be added.

    • coherency_list: A list indicating in which layers light should be treated as coherent (‘c’) and in which incoherent (‘i’). It needs as many elements as layers in the structure.

  • profile – whether or not to calculate the absorption profile

  • layers – indices of the layers in which to calculate the absorption profile. Layer 0 is the incidence medium.

Returns:

A dictionary with the R, A and T at the specified wavelengths and angle.

calculate_profile(options, layers=None)
set_widths(new_widths)
rayflare.transfer_matrix_method.lookup_table.make_TMM_lookuptable(layers, incidence, transmission, surf_name, options, structpath, coherent=True, coherency_list=None, prof_layers=None, sides=None, overwrite=False)

Takes a layer stack and calculates and stores lookup tables for use with the ray-tracer.

Parameters:
  • layers – a list of layers. These can be Solcore ‘Layer’ objects, or any other layer format accepted by the Solcore class ‘OptiStack’.

  • incidence – semi-incidence medium. Should be an instance of a Solcore material object

  • transmission – semi-infinite transmission medium. Should be an instance of a Solcore material object

  • surf_name – name of the surfaces, for storing the lookup table (string).

  • options – dictionary or State object containing user options

  • structpath – file path where matrices will be stored or loaded from

  • coherent – boolean. True if all the layers in the stack (excluding the semi-infinite incidence and transmission medium) are coherent, False otherwise. Default True.

  • coherency_list – list. List of ‘c’ (coherent) and ‘i’ (incoherent) for each layer excluding incidence and transmission media. Only needs to be provided if coherent = False. Default = None

  • prof_layers – Indices of the layers in which the parameters relating to the absorption profile should be calculated and stored. Layer 0 is the incidence medium.

  • sides – List of which sides of incidence should all parameters be calculated for; 1 indicates incidence from the front and -1 is rear incidence. Default = [1, -1]

  • overwrite – boolean. If True, existing saved lookup tables will be overwritten. Default = False.

Returns:

xarray Dataset with the R, A, T and (if relevant) absorption profile coefficients for each wavelength, angle, polarization, side of incidence.