optimpv.TransferMatrix package

Submodules

optimpv.TransferMatrix.TransferMatrixAgent module

Provides general functionality for Agent objects for transfer matrix simulations

class optimpv.TransferMatrix.TransferMatrixAgent.TransferMatrixAgent(params, y=None, layers=None, thicknesses=None, activeLayer=None, lambda_min=3.5e-07, lambda_max=8e-07, lambda_step=1e-09, x_step=1e-09, mat_dir=None, spectrum=None, photopic_file=None, exp_format='Jsc', metric=None, loss=None, threshold=10, minimize=False, tracking_metric=None, tracking_loss=None, tracking_exp_format=None, tracking_y=None, compare_type='linear', name='TM')[source]

Bases: BaseAgent

Initialize the TransferMatrixAgent

Parameters:
  • params (dict) – Dictionary of parameters.

  • y (array-like, optional) – Experimental data, by default None.

  • layers (list, optional) – List of material names in the stack, by default None. Note that these names will be used to find the refractive index files in the mat_dir. The filenames must be in the form of ‘nk_materialname.txt’.

  • thicknesses (list, optional) – List of thicknesses of the layers in the stack in meters, by default None.

  • lambda_min (float, optional) – Start wavelength in m, by default 350e-9.

  • lambda_max (float, optional) – Stop wavelength in m, by default 800e-9.

  • lambda_step (float, optional) – Wavelength step in m, by default 1e-9.

  • x_step (float, optional) – Step size for the x position in the stack in m, by default 1e-9.

  • activeLayer (int, optional) – Index of the active layer in the stack, i.e. the layer where the generation profile will be calculated. Counting starts at 0, by default None.

  • spectrum (string, optional) – Name of the file that contains the spectrum, by default None.

  • mat_dir (string, optional) – Path to the directory where the refractive index files and the spectrum file are located, by default None.

  • photopic_file (string, optional) – Name of the file that contains the photopic response (must be in the same directory as the refractive index files), by default None.

  • exp_format (str or list, optional) – Expected format of the output, by default ‘Jsc’.

  • metric (str or list, optional) – Metric to be used for optimization, by default None.

  • loss (str or list, optional) – Loss function to be used for optimization, by default None.

  • threshold (int, float or list, optional) – Threshold value for the loss function, by default 10.

  • minimize (bool or list, optional) – Whether to minimize the loss function, by default False.

  • tracking_metric (str or list of str, optional) – Additional metrics to track and report in run_Ax output, by default None.

  • tracking_loss (str or list of str, optional) – Loss functions to apply to tracking metrics, by default None.

  • tracking_exp_format (str or list of str, optional) – Experimental formats for tracking metrics, by default None.

  • tracking_y (array-like or list of array-like, optional) – y values for tracking metrics, by default None.

  • compare_type (str, optional) – Type of comparison to use for metrics, by default ‘linear’. Options: ‘linear’, ‘log’, ‘normalized’, ‘normalized_log’, ‘sqrt’.

  • name (str, optional) – Name of the agent, by default ‘TM’.

Raises:

ValueError – If any of the required parameters are not defined or if there is a mismatch in the lengths of metric, loss, threshold, minimize, and exp_format.

run(parameters)[source]

Run the transfer matrix model and calculate the Jsc, AVT and LUE

Parameters:

parameters (dict) – Dictionary of parameter names and values.

Returns:

  • Jsc (float) – Short circuit current density in A/m^2.

  • AVT (float) – Average visible transmittance.

  • LUE (float) – Light utilization efficiency.

run_Ax(parameters)[source]

Run the transfer matrix model and calculate the loss function

Parameters:

parameters (dict) – Dictionary of parameter names and values.

Returns:

Dictionary of loss functions.

Return type:

dict

target_metric(y, yfit=None, metric_name=None)[source]

Calculates the target metric based on the metric, loss, threshold and minimize values

Parameters:
  • y (array-like) – 1-D array containing the current values.

  • yfit (array-like) – 1-D array containing the fitted current values.

  • metric_name (str) – Metric to evaluate the model, see optimpv.general.calc_metric for options.

Returns:

Target metric value.

Return type:

float

optimpv.TransferMatrix.TransferMatrixModel module

Transfer Matrix Model

optimpv.TransferMatrix.TransferMatrixModel.I_mat(n1, n2)[source]

calculate the interface matrix

Parameters:
  • n1 (float) – refractive index of the first material

  • n2 (float) – refractive index of the second material

Returns:

ret – interface matrix

Return type:

array

optimpv.TransferMatrix.TransferMatrixModel.L_mat(n, d, l)[source]

calculate the propagation matrix

Parameters:
  • n (array) – complex refractive index of the material

  • d (float) – thickness of the material

  • l (float) – wavelength

Returns:

L – propagation matrix

Return type:

array

optimpv.TransferMatrix.TransferMatrixModel.TMM(parameters, layers, thicknesses, lambda_min, lambda_max, lambda_step, x_step, activeLayer, spectrum, mat_dir, photopic_file=None)[source]

Calculate the Jsc, AVT or LUE for a multilayer stack

Parameters:
  • parameters (dict) – dictionary of parameters note that all parameters must be in the form of ‘d_i’ or ‘nk_i’ where i is the index of the layer and the everything must be in SI units.

  • layers (list) – list of material names in the stack. Note that this names will be used to find the refractive index files in the mat_dir. The filenames must be in the form of ‘nk_materialname.txt’

  • thicknesses (list) – list of thicknesses of the layers in the stack in meters

  • lambda_min (float) – start wavelength in m

  • lambda_max (float) – stop wavelength in m

  • lambda_step (float) – wavelength step in m

  • x_step (float) – step size for the x position in the stack in m

  • activeLayer (int) – index of the active layer in the stack, i.e. the layer where the generation profile will be calculated. Counting starts at 0.

  • spectrum (string) – name of file that contains the spectrum.

  • mat_dir (string) – path to the directory where the refractive index files and the spectrum file are located.

  • photopic_file (string, optional) – name of the file that contains the photopic response (must be in the same directory as the refractive index files), by default None

Returns:

  • Jsc (float) – Short circuit current

  • AVT (float) – Average visible transmittance

  • LUE (float) – Light utilization efficiency

Raises:
  • ValueError – Wrong indices for the thicknesses

  • ValueError – Wrong indices for the complex refractive index

  • ValueError – Wavelengths out of range for the layer

  • ValueError – photopic_file must be defined to calculate AVT or LUE

optimpv.TransferMatrix.TransferMatrixModel.get_ntotal(matName, lambdas, mat_dir)[source]

get the complex refractive index of a material from a file

Parameters:
  • matName (string) – name of the material in the matdata folder

  • lambdas (list) – list of wavelengths in nm

Returns:

ntotal – list of complex refractive index values

Return type:

list

optimpv.TransferMatrix.TransferMatrixModel.openFile(fname)[source]

opens files and returns a list split at each new line

Parameters:

fname (string) – path to the file

Returns:

fd – list of lines in the file

Return type:

list

Raises:

ValueError – Target is not a readable file

Module contents