optimpv.DDfits package
Subpackages
- optimpv.DDfits.old package
- Submodules
- optimpv.DDfits.old.CVAgent module
- optimpv.DDfits.old.HysteresisAgent module
- optimpv.DDfits.old.IMPSAgent module
- optimpv.DDfits.old.ImpedanceAgent module
- optimpv.DDfits.old.JVAgent module
- optimpv.DDfits.old.SIMsalabimAgent module
SIMsalabimAgent
SIMsalabimAgent.ambi_param_transform()
SIMsalabimAgent.check_duplicated_parameters()
SIMsalabimAgent.convert_parameter_to_basename()
SIMsalabimAgent.energy_level_offsets()
SIMsalabimAgent.get_SIMsalabim_clean_cmd()
SIMsalabimAgent.is_inputFile()
SIMsalabimAgent.package_SIMsalabim_files()
SIMsalabimAgent.prepare_cmd_pars()
- Module contents
Submodules
optimpv.DDfits.CVAgent module
CVAgent class for steady-state CV simulations
- class optimpv.DDfits.CVAgent.CVAgent(params, X, y, session_path, Vmin=0.5, Vmax=1.0, V_step=0.1, freq=10000.0, G_frac=1, del_V=0.01, simulation_setup=None, exp_format='CV', 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='CV', **kwargs)[source]
Bases:
SIMsalabimAgent
CVAgent class for Capacitance-Voltage simulations with SIMsalabim
- Parameters:
params (list of Fitparam() objects) – List of Fitparam() objects.
X (array-like) – 1-D or 2-D array containing the voltage values.
y (array-like) – 1-D array containing the current values.
session_path (str) – Path to the session directory.
Vmin (float, optional) – minimum voltage, by default 0.
Vmax (float, optional) – maximum voltage, by default 1.2.
V_step (float, optional) – Voltage difference, determines at which voltages the capacitance is determined, by default 0.1.
freq (float, optional) – Frequency of the CV measurement [Hz], by default 1e4.
G_frac (float, optional) – Fractional light intensity, by default 1.
del_V (float, optional) – Voltage step for the impedance simulation, by default 0.01.
simulation_setup (str, optional) – Path to the simulation setup file, if None then use the default file ‘simulation_setup.txt’in the session_path directory, by default None.
exp_format (str or list of str, optional) – Format of the CV data, possible values are: ‘CV’, ‘MottSchottky’, by default ‘CV’.
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 ‘CV’.
**kwargs (dict) – Additional keyword arguments.
- reformat_CV_data(df, X, exp_format='CV')[source]
Reformat the data depending on the exp_format and X values Also interpolates the data if the simulation did not return the same points as the experimental data (i.e. if some points did not converge)
- Parameters:
df (dataframe) – Dataframe with the CV dara from run_CV_simulation function.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘CV’.
- Returns:
Tuple with the reformatted Xfit and yfit values.
- Return type:
tuple
- Raises:
ValueError – If the exp_format is not valid.
- run(parameters, X=None, exp_format='CV')[source]
Run the simulation with the parameters and return an array with the simulated values in the format specified by exp_format (default is ‘Cf’)
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘Cf’.
- Returns:
1-D array with the simulated current values.
- Return type:
array-like
- run_Ax(parameters)[source]
Function to run the simulation with the parameters and return the target metric value for Ax optimization
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dictionary with the target metric value.
- Return type:
dict
- run_CV_simulation(parameters)[source]
Run the simulation with the parameters and return the simulated values
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dataframe with the simulated CV values.
- Return type:
dataframe
- target_metric(y, yfit, metric_name, X=None, Xfit=None, weight=None)[source]
Calculate the target metric depending on self.metric
- Parameters:
y (array-like) – 1-D array containing the target values.
yfit (array-like) – 1-D array containing the fitted values.
metric_name (str) – Metric to evaluate the model, see optimpv.general.calc_metric for options.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
Xfit (array-like, optional) – 1-D array containing the x axis values, by default None.
weight (array-like, optional) – 1-D array containing the weights, by default None.
- Returns:
Target metric value.
- Return type:
float
optimpv.DDfits.HysteresisAgent module
HysteresisAgent class for transient hysteresis JV simulations
- class optimpv.DDfits.HysteresisAgent.HysteresisAgent(params, X, y, session_path, Vmin=0, Vmax=1.2, scan_speed=0.1, steps=100, direction=1, G_frac=1, simulation_setup=None, exp_format='JV', 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='Hyst', **kwargs)[source]
Bases:
SIMsalabimAgent
HysteresisAgent class for JV hysteresis simulations with SIMsalabim
- Parameters:
params (list of Fitparam() objects) – List of Fitparam() objects.
X (array-like) – 1-D or 2-D array containing the voltage values.
y (array-like) – 1-D array containing the current values.
session_path (str) – Path to the session directory.
Vmin (float, optional) – minimum voltage, by default 0.
Vmax (float, optional) – maximum voltage, by default 1.2.
scan_speed (float, optional) – Voltage scan speed [V/s], by default 0.1.
steps (int, optional) – Number of time steps, by default 100.
direction (integer, optional) – Perform a forward-backward (1) or backward-forward scan (-1), by default 1.
G_frac (float, optional) – Fractional light intensity, by default 1.
simulation_setup (str, optional) – Path to the simulation setup file, if None then use the default file ‘simulation_setup.txt’in the session_path directory, by default None.
exp_format (str or list of str, optional) – Format of the hysteresis data, possible values are: ‘JV’, by default ‘JV’.
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 ‘Hyst’.
**kwargs (dict) – Additional keyword arguments.
- reformat_hysteresis_data(df, X, exp_format='JV')[source]
Reformat the data depending on the exp_format and X values Also interpolates the data if the simulation did not return the same points as the experimental data (i.e. if some points did not converge)
- Parameters:
df (dataframe) – Dataframe with the hysteresis dara from run_hysteresis_simulation function.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘JV’.
- Returns:
Tuple with the reformatted Xfit and yfit values.
- Return type:
tuple
- Raises:
ValueError – If the exp_format is not valid.
- run(parameters, X=None, exp_format='JV')[source]
Run the simulation with the parameters and return an array with the simulated values in the format specified by exp_format (default is ‘Cf’)
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘Cf’.
- Returns:
1-D array with the simulated current values.
- Return type:
array-like
- run_Ax(parameters)[source]
Function to run the simulation with the parameters and return the target metric value for Ax optimization
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dictionary with the target metric value.
- Return type:
dict
- run_hysteresis_simulation(parameters)[source]
Run the simulation with the parameters and return the simulated values
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dataframe with the simulated hysteresis values.
- Return type:
dataframe
- target_metric(y, yfit, metric_name, X=None, Xfit=None, weight=None)[source]
Calculate the target metric depending on self.metric
- Parameters:
y (array-like) – 1-D array containing the target values.
yfit (array-like) – 1-D array containing the fitted values.
metric_name (str) – Metric to evaluate the model, see optimpv.general.calc_metric for options.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
Xfit (array-like, optional) – 1-D array containing the x axis values, by default None.
weight (array-like, optional) – 1-D array containing the weights, by default None.
- Returns:
Target metric value.
- Return type:
float
optimpv.DDfits.IMPSAgent module
IMPSAgent class for steady-state IMPS simulations
- class optimpv.DDfits.IMPSAgent.IMPSAgent(params, X, y, session_path, f_min, f_max, f_steps=30, V=0, G_frac=1, GStep=0.05, simulation_setup=None, exp_format='ImY', 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='IMPS', **kwargs)[source]
Bases:
SIMsalabimAgent
IMPSAgent class for IMPS simulations with SIMsalabim
- Parameters:
params (list of Fitparam() objects) – List of Fitparam() objects.
X (array-like) – 1-D or 2-D array containing the voltage values.
y (array-like) – 1-D array containing the current values.
session_path (str) – Path to the session directory.
f_min (float) – Minimum frequency for the IMPS simulation in Hz.
f_max (float) – Maximum frequency for the IMPS simulation in Hz.
f_steps (float, optional) – Number of frequency steps for the IMPS simulation (log spaced), by default 30.
V (float, optional) – Voltage value for the simulation, by default 0.
G_frac (float, optional) – Fractional light intensity, by default 1.
GStep (float, optional) – Applied generation rate increase at t=0, by default 0.05.
simulation_setup (str, optional) – Path to the simulation setup file, if None then use the default file ‘simulation_setup.txt’in the session_path directory, by default None.
exp_format (str, optional) – Format of the IMPS data, possible values are: ‘ReY’, ‘ImY’, ‘ColeCole’, by default ‘ImY’.
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 ‘IMPS’.
**kwargs (dict) – Additional keyword arguments.
- reformat_IMPS_data(df, X, exp_format='IMPS')[source]
Reformat the data depending on the exp_format and X values Also interpolates the data if the simulation did not return the same points as the experimental data (i.e. if some points did not converge)
- Parameters:
df (dataframe) – Dataframe with the IMPS dara from run_IMPS_simulation function.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘IMPS’.
- Returns:
Tuple with the reformatted Xfit and yfit values.
- Return type:
tuple
- Raises:
ValueError – If the exp_format is not valid.
- run(parameters, X=None, exp_format='ImY')[source]
Run the simulation with the parameters and return an array with the simulated values in the format specified by exp_format (default is ‘Cf’)
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘Cf’.
- Returns:
1-D array with the simulated current values.
- Return type:
array-like
- run_Ax(parameters)[source]
Function to run the simulation with the parameters and return the target metric value for Ax optimization
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dictionary with the target metric value and any tracking metrics.
- Return type:
dict
- run_IMPS_simulation(parameters)[source]
Run the simulation with the parameters and return the simulated values
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dataframe with the simulated IMPS values.
- Return type:
dataframe
- target_metric(y, yfit, metric_name, X=None, Xfit=None, sample_weight=None)[source]
Calculate the target metric depending on self.metric
- Parameters:
y (array-like) – 1-D array containing the target values.
yfit (array-like) – 1-D array containing the fitted values.
metric_name (str) – Metric to evaluate the model, see optimpv.general.calc_metric for options.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
Xfit (array-like, optional) – 1-D array containing the x axis values, by default None.
sample_weight (array-like, optional) – 1-D array containing the weights, by default None.
- Returns:
Target metric value.
- Return type:
float
optimpv.DDfits.ImpedanceAgent module
ImpedanceAgent class for impedance simulations
- class optimpv.DDfits.ImpedanceAgent.ImpedanceAgent(params, X, y, session_path, f_min, f_max, f_steps, V_0, G_frac=1, del_V=0.01, simulation_setup=None, exp_format=['Cf'], 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='Imp', **kwargs)[source]
Bases:
SIMsalabimAgent
ImpedanceAgent class for impedance simulations with SIMsalabim
- 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.
session_path (str) – Path to the session directory.
f_min (float) – Minimum frequency for the impedance simulation.
f_max (float) – Maximum frequency for the impedance simulation.
f_steps (int) – Number of frequency steps for the impedance simulation.
V_0 (float) – Initial voltage for the impedance simulation.
G_frac (float, optional) – Fractional light intensity, by default 1.
del_V (float, optional) – Voltage step for the impedance simulation, by default 0.01.
simulation_setup (str, optional) – Path to the simulation setup file, if None then use the default file ‘simulation_setup.txt’in the session_path directory, by default None.
exp_format (str or list of str, optional) – Format of the impedance data, possible values are: ‘Cf’, ‘Gf’, ‘Nyquist’, ‘BodeImZ’, ‘BodeReZ’, ‘Bode’, by default ‘Cf’.
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 ‘Imp’.
**kwargs (dict) – Additional keyword arguments.
- reformat_impedance_data(df, X, exp_format='Cf')[source]
Reformat the data depending on the exp_format and X values Also interpolates the data if the simulation did not return the same points as the experimental data (i.e. if some points did not converge)
- Parameters:
df (dataframe) – Dataframe with the impedance dara from run_impedance_simulation function.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘Cf’.
- Returns:
Tuple with the reformatted Xfit and yfit values.
- Return type:
tuple
- Raises:
ValueError – If the exp_format is not valid.
- run(parameters, X=None, exp_format='Cf')[source]
Run the simulation with the parameters and return an array with the simulated values in the format specified by exp_format (default is ‘Cf’)
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
exp_format (str, optional) – Format of the experimental data, by default ‘Cf’.
- Returns:
1-D array with the simulated current values.
- Return type:
array-like
- run_Ax(parameters)[source]
Function to run the simulation with the parameters and return the target metric value for Ax optimization
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dictionary with the target metric value and any tracking metrics.
- Return type:
dict
- run_impedance_simulation(parameters)[source]
Run the simulation with the parameters and return the simulated values
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dataframe with the simulated impedance values.
- Return type:
dataframe
- target_metric(y, yfit, metric_name, X=None, Xfit=None, sample_weight=None)[source]
Calculate the target metric depending on self.metric
- Parameters:
y (array-like) – 1-D array containing the target values.
yfit (array-like) – 1-D array containing the fitted values.
metric_name (str) – Metric to evaluate the model, see optimpv.general.calc_metric for options.
X (array-like, optional) – 1-D array containing the x axis values, by default None.
Xfit (array-like, optional) – 1-D array containing the x axis values, by default None.
sample_weight (array-like, optional) – 1-D array containing the weights, by default None.
- Returns:
Target metric value.
- Return type:
float
optimpv.DDfits.JVAgent module
JVAgent class for steady-state JV simulations
- class optimpv.DDfits.JVAgent.JVAgent(params, X, y, session_path, simulation_setup=None, exp_format=['JV'], 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='JV', **kwargs)[source]
Bases:
SIMsalabimAgent
JVAgent class for steady-state JV simulations with SIMsalabim
- 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.
session_path (str) – Path to the session directory.
simulation_setup (str, optional) – Path to the simulation setup file, if None then use the default file ‘simulation_setup.txt’in the session_path directory, by default None.
exp_format (str or list of str, optional) – Format of the experimental data, by default ‘JV’.
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 ‘JV’.
**kwargs (dict) – Additional keyword arguments.
- reformat_JV_data(df, X, exp_format='JV')[source]
Reformat the data depending on the exp_format and X values Also interpolates the data if the simulation did not return the same points as the experimental data (i.e. if some points did not converge)
- Parameters:
df (dataframe) – Dataframe with the JV data from run_JV function.
X (array-like) – 1-D or 2-D array containing the voltage (1st column) and if specified the Gfrac (2nd column) values.
exp_format (str, optional) – Format of the experimental data, by default ‘JV’
- Returns:
Tuple with the reformatted Xfit and yfit values.
- Return type:
tuple
- Raises:
ValueError – If the exp_format is not ‘JV’
- run(parameters, X=None, exp_format='JV')[source]
Run the simulation with the parameters and return an array with the simulated values in the format specified by exp_format (default is ‘JV’)
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
X (array-like, optional) – 1-D or 2-D array containing the voltage (1st column) and if specified the Gfrac (2nd column) values, it must match the X values used for the specified exp_format, by default None
exp_format (str, optional) – Format of the experimental data, by default ‘JV’
- Returns:
1-D array with the simulated current values.
- Return type:
array-like
- run_Ax(parameters)[source]
Function to run the simulation with the parameters and return the target metric value for Ax optimization
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dictionary with the target metric value and any tracking metrics.
- Return type:
dict
- run_JV(parameters)[source]
Run the simulation with the parameters and return the simulated values
- Parameters:
parameters (dict) – Dictionary with the parameter names and values.
- Returns:
Dataframe with the simulated JV data.
- Return type:
dataframe
- target_metric(y, yfit, metric_name, X=None, Xfit=None, weight=None)[source]
Calculate the target metric depending on self.metric
- 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.
X (array-like, optional) – 1-D or 2-D array containing the voltage (1st column) and if specified the Gfrac (2nd column) values, by default None.
Xfit (array-like, optional) – 1-D or 2-D array containing the voltage (1st column) and if specified the Gfrac (2nd column) values, by default None.
weight (array-like, optional) – Weights used for fitting, by default None.
- Returns:
Target metric value.
- Return type:
float
optimpv.DDfits.SIMsalabimAgent module
Provides general functionality for Agent objects for SIMsalabim simulations
- class optimpv.DDfits.SIMsalabimAgent.SIMsalabimAgent[source]
Bases:
BaseAgent
Provides general functionality for Agent objects for SIMsalabim simulations
- Gamma_pre_reset(cmd_pars, custom_pars)[source]
Prepare the Langevin pre-factor parameters for the SIMsalabim simulation but use it to calculate k_direct instead of passing preLangevin to SIMsalabim.
- Parameters:
cmd_pars (list of dict) – list of dictionaries with the following form {‘par’: string, ‘val’: string}
custom_pars (list of dict) – list of dictionaries with the following form {‘par’: string, ‘val’: string}
- Returns:
list of dictionaries with the following form {‘par’: string, ‘val’: string}
- Return type:
list of dict
- ambi_param_transform(param, value, cmd_pars, no_transform=False)[source]
Transform the ambipolar parameters to the SIMsalabim format example: mu_ions -> mu_anion and mu_cation N_ions -> N_anion and N_cation mu_np -> mu_n and mu_p C_np_bulk -> C_n_bulk and C_p_bulk C_np_int -> C_n_int and C_p_int
- Parameters:
param (Fitparam() object) – Fitparam() object
value (float) – value of the parameter
cmd_pars (list of dict) – list of dictionaries with the following form {‘par’: string, ‘val’: string}
- Returns:
list of dictionaries with the following form {‘par’: string, ‘val’: string}
- Return type:
list of dict
- check_duplicated_parameters(cmd_pars)[source]
Check if there are duplicated parameters in the cmd_pars
- Parameters:
cmd_pars (list of dict) – list of dictionaries with the following form {‘par’: string, ‘val’: string}
- Raises:
ValueError – There are duplicated parameters in the cmd_pars
- convert_parameter_to_basename(name, value)[source]
Convert the parameter value to its basename if it is a file
- Parameters:
name (str) – parameter name
value (str or float or int) – parameter value
- Returns:
parameter value in its basename
- Return type:
str
- energy_level_offsets(custom_pars, clean_pars)[source]
Convert the energy level offsets to the SIMsalabim format energy levels
- Parameters:
custom_pars (list of dict) – list of dictionaries these contain all the parameters that are not explicitely in the SIMsalabim format and not in the ambipolar format (see ambi_param_transform). The dictionaries are of the form {‘par’: string, ‘val’: string}
clean_pars (list of dict) – list of dictionaries these contain all the parameters that are explicitely in the SIMsalabim format. The dictionaries are of the form {‘par’: string, ‘val’: string}
- Returns:
list of dictionaries these contain all the parameters converted to the SIMsalabim format. The dictionaries are of the form {‘par’: string, ‘val’: string}
- Return type:
list of dict
- Raises:
ValueError – Energy level offset between conduction bands must be defined from right to left
ValueError – Energy level offset between valence bands must be defined from left to right
ValueError – The offset of the work function of the left electrode with respect to the conduction band must be negative
ValueError – The offset of the work function of the left electrode with respect to the valence band must be positive
ValueError – The offset of the work function of the right electrode with respect to the conduction band must be negative
ValueError – The offset of the work function of the right electrode with respect to the valence band must be positive
- get_SIMsalabim_clean_cmd(parameters, sim_type='simss')[source]
Get the command line arguments for the SIMsalabim simulation with properly formatted parameters
- Parameters:
parameters (dict or list of Fitparam() objects) – dictionary of parameter names and values or list of Fitparam() objects
sim_type (str, optional) – type of simulation (‘simss’ or ‘zimt’), by default ‘simss’
- Returns:
command line arguments for the SIMsalabim simulation
- Return type:
str
- get_SIMsalabim_clean_cmd_pars(parameters)[source]
Get the clean cmd_pars list for the SIMsalabim simulation with properly formatted parameters
- Parameters:
parameters (dict or list of Fitparam() objects) – dictionary of parameter names and values or list of Fitparam() objects
- Returns:
list of dictionaries containing the parameters that have a direct match in the SIMsalabim parameter files with the following form {‘par’: string, ‘val’: string}
- Return type:
list of dict
- Raises:
ValueError – Parameter name is not defined in the SIMsalabim parameter files. Please check the parameter names.
ValueError – Parameter name is defined in both the parameters and cmd_pars. Please remove one of them.
UserWarning – Parameter name is not defined in the SIMsalabim parameter files. Please check the parameter names. The optimization will proceed but the parameter will not be used by SIMsalabim.
- is_inputFile(name, value)[source]
Check if the parameter is an input file
- Parameters:
name (str) – parameter name
value (str or float or int) – parameter value
- Returns:
True if the parameter is an input file, False otherwise
- Return type:
bool
- package_SIMsalabim_files(parameters, sim_type, save_path=None)[source]
Package the SIMsalabim files for the simulation
- Parameters:
parameters (dict or list of Fitparam() objects) – dictionary of parameter names and values or list of Fitparam() objects
sim_type (str) – type of simulation (‘simss’ or ‘zimt’)
save_path (str, optional) – path to save the simulation files, if None, it will be saved in the session_path/tmp_results, by default None
- Raises:
ValueError – if sim_type is not ‘simss’ or ‘zimt’
- prepare_cmd_pars(parameters, custom_pars, clean_pars, VarNames)[source]
Prepare the cmd_pars for the SIMsalabim simulation
- Parameters:
parameters (dict) – dictionary of parameter names and values
custom_pars (list of dict) – list of dictionaries containing the custom parameters that do not have a direct match in the SIMsalabim parameter files with the following form {‘par’: string, ‘val’: string}
clean_pars (list of dict) – list of dictionaries containing the parameters that have a direct match in the SIMsalabim parameter files with the following form {‘par’: string, ‘val’: string}
VarNames (list of str) – list of parameter names
- Returns:
list of dict – list of dictionaries containing the custom parameters that do not have a direct match in the SIMsalabim parameter files with the following form {‘par’: string, ‘val’: string}
list of dict – list of dictionaries containing the parameters that have a direct match in the SIMsalabim parameter files with the following form {‘par’: string, ‘val’: string}
list of str – list of parameter names
- Raises:
ValueError – If the parameter name is not in the self.params list
ValueError – If the parameter name is in both the parameters and cmd_pars