optimpv.RateEqfits package
Submodules
optimpv.RateEqfits.Pumps module
Pump pulse generation for transient experiments
- optimpv.RateEqfits.Pumps.gaussian_pulse_norm(t, tpulse, width)[source]
Returns a gaussian pulse
- Parameters:
t (1-D sequence of floats) – t time axis (unit: s)
tpulse (float) – tpulse center of the pulse (unit: s)
width (float) – width of the pulse (unit: s)
- Returns:
Vector containing the gaussian pulse
- Return type:
1-D sequence of floats
- optimpv.RateEqfits.Pumps.gaussian_pump(t, fpu, pulse_width, P, t0, background=0, G_frac=1)[source]
Gaussian pump pulse
- Parameters:
t (ndarray of shape (n,)) – array of time values in seconds
fpu (float) – pump frequency in Hz
pulse_width (float) – width of the pump pulse in seconds
P (float) – total volume density of generated photons m^-3
t0 (float) – center of the pulse in seconds
background (float, optional) – background volume density of generated photons, by default 0
G_frac (float, optional) – scaling for the power of the pulse, by default 1
- Returns:
density of generated photons m^-3 at each time point
- Return type:
ndarray of shape (n,)
- optimpv.RateEqfits.Pumps.get_flux_density(Power, wavelength, fpu, Area, alpha)[source]
From the measured power, repetition rate and area, get photons/m2 and approximate photons/m3 per pulse
- Parameters:
Power (float) – total CW power of pulse in W
wavelength (float) – excitation wavelength in m
fpu (float) – repetition rate in Hz
Area (float) – effective pump area in m^-2
alpha (float) – penetration depth in m
- Returns:
flux (float) – flux in photons m^-2
density (float) – average volume density in photons m^-3
- optimpv.RateEqfits.Pumps.initial_carrier_density(t, fpu, N0, background=0, G_frac=1)[source]
Initial carrier density
- Parameters:
t (ndarray of shape (n,)) – array of time values in seconds
fpu (float) – pump frequency in Hz
N0 (float) – initial carrier density in m^-3
background (float, optional) – background carrier density, by default 0
G_frac (float, optional) – scaling for the power of the pulse, by default 1
- Returns:
initial carrier density in m^-3
- Return type:
ndarray of shape (n,)
- optimpv.RateEqfits.Pumps.square_pump(t, fpu, pulse_width, P, t0=0, background=0, G_frac=1)[source]
Square pump pulse
- Parameters:
t (ndarray of shape (n,)) – array of time values in seconds
fpu (float) – pump frequency in Hz
pulse_width (float) – width of the pump pulse in seconds
P (float) – total volume density of generated photons m^-3
t0 (float, optional) – time shift of the pump pulse, by default 0
background (float, optional) – background volume density of generated photons, by default 0
G_frac (float, optional) – scaling for the power of the pulse, by default 1
- Returns:
density of generated photons m^-3 at each time point
- Return type:
ndarray of shape (n,)
optimpv.RateEqfits.RateEqAgent module
Provides general functionality for Agent objects for Rate Equation simulations
- class optimpv.RateEqfits.RateEqAgent.RateEqAgent(params, X, y, model=<function BT_model>, pump_model=<function initial_carrier_density>, pump_args={}, exp_format='trPL', fixed_model_args={}, metric='mse', loss='linear', threshold=100, minimize=True, yerr=None, weight=None, tracking_metric=None, tracking_loss=None, tracking_exp_format=None, tracking_X=None, tracking_y=None, tracking_weight=None, name='RateEq', equilibrate=True, detection_limit=None, **kwargs)[source]
Bases:
BaseAgent
Agent object for fitting rate equation models. Available models are:
Bimolecular-Trapping (BT)
Bimolecular-Trapping-detrapping (BTD)
see optimpv.RateEqfits.RateEqModel.py for more details about the available models
- Parameters:
params (list of Fitparam() objects) – List of Fitparam() objects.
X (array-like) – 1-D or 2-D array containing the voltage (1st column) and if specified the Gfrac (2nd column) values.
y (array-like) – 1-D array containing the current values.
pump_model (function, optional) – Function to get the generated carrier density profile, by default initial_carrier_density.
pump_args (dict, optional) – Arguments for the pump_model function, by default {}.
exp_format (str or list of str, optional) – Format of the experimental data, cane be [‘trPL’,’TAS’,’trMC’], by default ‘trPL’.
exp_format_agrs (dict, optional) – Arguments dependent on the exp_format function, by default {}.
metric (str or list of str, optional) – Metric to evaluate the model, see optimpv.general.calc_metric for options, by default ‘mse’.
loss (str or list of str, optional) – Loss function to use, see optimpv.general.loss_function for options, by default ‘linear’.
threshold (int or list of int, optional) – Threshold value for the loss function used when doing multi-objective optimization, by default 100.
minimize (bool or list of bool, optional) – If True then minimize the loss function, if False then maximize the loss function (note that if running a fit minize should be True), by default True.
yerr (array-like or list of array-like, optional) – Errors in the current values, by default None.
weight (array-like or list of array-like, optional) – Weights used for fitting if weight is None and yerr is not None, then weight = 1/yerr**2, by default None.
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_X (array-like or list of array-like, optional) – X values for tracking metrics, by default None.
tracking_y (array-like or list of array-like, optional) – y values for tracking metrics, by default None.
tracking_weight (array-like or list of array-like, optional) – Weights for tracking metrics, by default None.
name (str, optional) – Name of the agent, by default ‘RateEq’.
**kwargs (dict) – Additional keyword arguments.
- reformat_data(df, X, parameters, exp_format='trPL')[source]
Reformat the data to the experimental format
- Parameters:
df (DataFrame) – DataFrame containing the simulation results.
X (array-like) – 1-D or 2-D array containing the voltage (1st column) and if specified the Gfrac (2nd column) values.
parameters (dict) – Dictionary of parameter names and values.
exp_format (str, optional) – Format of the experimental data, cane be [‘trPL’,’TAS’,’trMC’], by default ‘trPL’.
- Returns:
DataFrame containing the simulation results in the experimental format.
- Return type:
DataFrame
- run(parameters, X=None, exp_format='trPL')[source]
Run the diode model and calculate the loss function
- Parameters:
parameters (dict) – Dictionary of parameter names and values.
- Returns:
Array containing the current values.
- Return type:
array-like
optimpv.RateEqfits.RateEqModel module
Rate equation models for charge carrier dynamics in semiconductors
- optimpv.RateEqfits.RateEqModel.BTD_model(parameters, t, Gpulse, t_span, N0=0, G_frac=1, equilibrate=True, eq_limit=0.01, maxcount=1000.0, solver_func='odeint', output_trap_dens=False, **kwargs)[source]
Solve the bimolecular trapping and detrapping equation :
dn/dt = G - k_trap * n * (N_t_bulk - n_t) - k_direct * n * (p + N_A) dn_t/dt = k_trap * n * (N_t_bulk - n_t) - k_detrap * n_t * (p + N_A) dp/dt = G - k_detrap * n_t * (p + N_A) - k_direct * n * (p + N_A)
Based on the beautiful work of:
Péan, Emmanuel V. and Dimitrov, Stoichko and De Castro, Catherine S. and Davies, Matthew L., Phys. Chem. Chem. Phys., 2020,22, 28345-28358, http://dx.doi.org/10.1039/D0CP04950F
- Parameters:
parameters (dict) –
dictionary containing the parameters of the model it must contain ‘k_trap’, ‘k_direct’, ‘k_detrap’, ‘N_t_bulk’ and ‘N_A’.
- k_trapfloat
Trapping rate constant in m^3 s^-1
- k_directfloat
Bimolecular/direct recombination rate constant in m^3 s^-1
- k_detrapfloat
Detrapping rate constant in m^3 s^-1
- N_t_bulkfloat
Bulk trap density in m^-3
- N_Afloat
Ionized p-doping concentration in m^-3
t (ndarray of shape (n,)) – time values in s
Gpulse (ndarray of shape (n,)) – array of values of the charge carrier generation rate m^-3 s^-1
t_span (ndarray of shape (n,), optional) – time values for the pulse time step in case it is different from t, by default None
N0 (float, optional) – initial values of the electron, trapped electron and hole concentrations in m^-3, by default 0
G_frac (float, optional) – fraction of the generation rate that is absorbed, by default 1
equilibrate (bool, optional) – whether to equilibrate the system, by default True
eq_limit (float, optional) – limit for the relative change of the last time point to the previous one to consider the system in equilibrium, by default 1e-2
maxcount (int, optional) – maximum number of iterations to reach equilibrium, by default 1e3
solver_func (str, optional) – solver function to use can be [‘odeint’,’solve_ivp’], by default ‘odeint’
output_trap_dens (bool, optional) – whether to output the trapped electron concentration, by default False
kwargs (dict) –
additional keyword arguments for the solver function
- ’method’str, optional
method to use for the solver, by default ‘RK45’
- ’rtol’float, optional
relative tolerance, by default 1e-3
- Returns:
ndarray of shape (n,) – electron concentration in m^-3
ndarray of shape (n,) – hole concentration in m^-3
ndarray of shape (n,) – if output_trap_dens is True then we also output trapped electron concentration in m^-3
- optimpv.RateEqfits.RateEqModel.BT_model(parameters, t, Gpulse, t_span, N0=0, G_frac=1, equilibrate=True, eq_limit=0.01, maxcount=1000.0, solver_func='solve_ivp', **kwargs)[source]
Solve the bimolecular trapping equation :
dn/dt = G - k_trap * n - k_direct * n^2
Based on the beautiful work of:
Péan, Emmanuel V. and Dimitrov, Stoichko and De Castro, Catherine S. and Davies, Matthew L., Phys. Chem. Chem. Phys., 2020,22, 28345-28358, http://dx.doi.org/10.1039/D0CP04950F
- Parameters:
parameters (dict) –
- dictionary containing the parameters of the model it must contain ‘k_trap’ and ‘k_direct’.
- ’k_trap’float
trapping rate constant in s^-1
- ’k_direct’float
Bimolecular/direct recombination rate constant in m^-3 s^-1
t (ndarray of shape (n,)) – array of time values
G (ndarray of shape (n,)) – array of values of the charge carrier generation rate m^-3 s^-1
t_span (ndarray of shape (n,), optional) – array of time values for the pulse time step in case it is different from t, by default None
N0 (float, optional) – initial value of the charge carrier density, by default 0
G_frac (float, optional) – fraction of the generation rate that is absorbed, by default 1
equilibrate (bool, optional) – make sure equilibrium is reached?, by default True
eq_limit (float, optional) – relative change of the last time point to the previous one, by default 1e-2
maxcount (int, optional) – maximum number of iterations to reach equilibrium, by default 1e3
solver_func (str, optional) – solver function to use can be [‘odeint’,’solve_ivp’], by default ‘solve_ivp’
kwargs (dict) –
- additional keyword arguments for the solver function
- ’method’str, optional
method to use for the solver, by default ‘RK45’
- ’rtol’float, optional
relative tolerance, by default 1e-3
- Returns:
array of values of the charge carrier density m^-3
- Return type:
ndarray of shape (n,)
- optimpv.RateEqfits.RateEqModel.DBTD_model(parameters, t, Gpulse, t_span, N0=0, G_frac=1, equilibrate=True, eq_limit=0.01, maxcount=1000.0, output_integrated_values=True, **kwargs)[source]
Solve the diffusion bimolecular trapping and detrapping model including diffusion.
The rate equation and model used here are based on the work by [Kober-Czerny et al. 2025](https://doi.org/10.1103/PRXEnergy.4.013001) see the [paper](https://doi.org/10.1103/PRXEnergy.4.013001) for more details or the [GitHub repository](https://github.com/manuelkoberczerny/assessing-TRPL-with-bayesian-inference_and-MCMC).
- Parameters:
parameters (dict) –
dictionary containing the parameters of the model it must contain ‘k_trap’, ‘k_direct’, ‘k_detrap’, ‘N_t_bulk’ and ‘N_A’.
- k_directfloat
Bimolecular/direct recombination rate constant in m^3 s^-1
- k_deepfloat
Deep trap rate constant in s^-1
- k_cfloat
Capture rate constant in s^-1
- k_efloat
Electron emission rate constant in s^-1
- S_frontfloat
Front surface recombination velocity in m s^-1
- S_backfloat
Back surface recombination velocity in m s^-1
- N_Afloat
Acceptor doping density in m^-3
- Lfloat
Length of the device in m
- alphafloat
Absorption coefficient in m^-1
- mufloat
Mobility in m^2 V^-1 s^-1
- Tfloat
Temperature in K, by default 300
t (ndarray of shape (n,)) – time values in s
Gpulse (ndarray of shape (n,)) – array of values of the charge carrier generation rate m^-3 s^-1
t_span (ndarray of shape (n,), optional) – time values for the pulse time step in case it is different from t, by default None
N0 (float, optional) – initial values of the electron, trapped electron and hole concentrations in m^-3, by default 0
G_frac (float, optional) – fraction of the generation rate that is absorbed, by default 1
equilibrate (bool, optional) – whether to equilibrate the system, by default True
eq_limit (float, optional) – limit for the relative change of the last time point to the previous one to consider the system in equilibrium, by default 1e-2
maxcount (int, optional) – maximum number of iterations to reach equilibrium, by default 1e3
output_integrated_values (bool, optional) – whether to output the integrated values, by default True
kwargs (dict) –
- additional keyword arguments for the solver function
- ’grid_size’int, optional
size of the grid for the spatial discretization, by default 100
- Returns:
list or ndarray – The integrated values of the electron density versus time and space. Each element of the list corresponds to a specific time point and contains the electron density values at different spatial positions.
list or ndarray – The integrated values of the hole density versus time and space. Each element of the list corresponds to a specific time point and contains the hole density values at different spatial positions.
- Raises:
ValueError – If the parameters are not valid.
- optimpv.RateEqfits.RateEqModel.DBTD_multi_trap(parameters, t, Gpulse, t_span, N0=0, G_frac=1, equilibrate=True, eq_limit=0.01, maxcount=1000.0, output_integrated_values=True, **kwargs)[source]
Solve the bimolecular, multi-trap trapping and detrapping model including diffusion. This implementation is based on the work by [M. Simmonds](https://github.com/MaximSimmonds-HZB/MAPI-FAPI-fitting).
Note: This needs to be tested further, I think there are some issues regarding the stability of the solver and whether the diffusion part was implemented properly.
- Parameters:
parameters (dict) –
dictionary containing the parameters of the model it must contain ‘k_trap’, ‘k_direct’, ‘k_detrap’, ‘N_t_bulk’ and ‘N_A’.
- k_directfloat
Bimolecular/direct recombination rate constant in m^3 s^-1
- N_t_bulkfloat
Bulk trap density (can be multiple) in m^-3
- C_nfloat
Electron capture coefficient (can be multiple) in m^3 s^-1
- C_pfloat
Hole capture coefficient (can be multiple) in m^3 s^-1
- E_t_bulkfloat
Relative trap depth in the bandgap (can be multiple) in eV
- Lfloat
Length of the device in m
- alphafloat
Absorption coefficient in m^-1
- mu_nfloat
Electron mobility in m^2 V^-1 s^-1
- mu_pfloat
Hole mobility in m^2 V^-1 s^-1
- N_cfloat
Effective density of states of the conduction band in m^-3
- N_vfloat
Effective density of states of the valence band in m^-3
- Egfloat
Bandgap energy in eV
- Tfloat
Temperature in K
t (ndarray of shape (n,)) – time values in s
Gpulse (ndarray of shape (n,)) – array of values of the charge carrier generation rate m^-3 s^-1
t_span (ndarray of shape (n,), optional) – time values for the pulse time step in case it is different from t, by default None
N0 (float, optional) – initial values of the electron, trapped electron and hole concentrations in m^-3, by default 0
G_frac (float, optional) – fraction of the generation rate that is absorbed, by default 1
equilibrate (bool, optional) – whether to equilibrate the system, by default True
eq_limit (float, optional) – limit for the relative change of the last time point to the previous one to consider the system in equilibrium, by default 1e-2
maxcount (int, optional) – maximum number of iterations to reach equilibrium, by default 1e3
output_integrated_values (bool, optional) – whether to output the integrated values, by default True
kwargs (dict) –
additional keyword arguments for the solver function
- ’method’str, optional
method to use for the solver, by default ‘Radau’
- ’rtol’float, optional
relative tolerance, by default 1e-3
- ’atol’float, optional
absolute tolerance, by default 1e-6
- ’grid_size’int, optional
size of the grid for the spatial discretization, by default 100
- ’dimensionless’bool, optional
whether to use dimensionless variables, by default False
- ’timeout’float, optional
maximum time to wait for the solver to finish, by default 120
- Returns:
list or ndarray – The integrated values of the electron density versus time and space. Each element of the list corresponds to a specific time point and contains the electron density values at different spatial positions.
list or ndarray – The integrated values of the hole density versus time and space. Each element of the list corresponds to a specific time point and contains the hole density values at different spatial positions.
- Raises:
ValueError – If the parameters are not valid.