cellpy.utils.ocv_rlx
#
Module Contents#
Classes#
Object for performing fitting of multiple cycles. |
|
Class for fitting open circuit relaxation data. |
Functions#
|
Fits the OCV steps in CellpyCell object c. |
|
Select points from the ocvrlx steps. |
- class MultiCycleOcvFit(cellpydata, cycles, circuits=3)[source]#
Object for performing fitting of multiple cycles.
- Remarks:
This is only tested for OCV relaxation data for half-cells in anode mode where the OCV relaxation is performed according to the standard protocol implemented at IFE in the battery development group.
If you want to use this for other data or protocols, please report an issue on the GitHub page.
Object for performing fitting of multiple cycles.
- Parameters:
cellpydata –
CellpyCell-object
cycles (list) – cycles to fit.
circuits (int) – number of circuits to use in fitting.
- get_best_fit_parameters_translated() list [source]#
Returns the parameters in ‘real units’ for the best fit.
- get_best_fit_parameters_translated_grouped() dict [source]#
Returns the parameters as a dictionary of the ‘real units’ for the best fit.
- plot_summary_translated()[source]#
Convenience function for plotting the summary of the fit (translated)
- class OcvFit(circuits=None, direction=None, zero_current=0.1, zero_voltage=0.05)[source]#
Bases:
object
Class for fitting open circuit relaxation data.
The model is a sum of exponentials and a constant offset (Ohmic resistance). The number of exponentials is set by the number of circuits. The model is:
v(t) = v0 + R0 + sum(wi * exp(-t/tau_i)) where v0 is the OCV, wi is the weight of the exponential tau_i is the time constant of the exponential and R0 is the Ohmic resistance.
r is found by calculating v0 / i_start –> err(r)= err(v0) + err(i_start). c is found from using tau / r –> err(c) = err(r) + err(tau).
The fit is performed by using lmfit.
- data#
The data to be fitted.
- Type:
cellpydata-object
- time#
Time measured during relaxation (extracted from data if provided).
- Type:
list
- voltage#
Time measured during relaxation (extracted from data if provided).
- Type:
list
- steps#
Step information (if data is provided).
- Type:
str
- circuits#
The number of circuits to be fitted.
- Type:
int
- weights#
The weights of the different circuits.
- Type:
list
- zero_current#
Last current observed before turning the current off.
- Type:
float
- zero_voltage#
Last voltage observed before turning the current off.
- Type:
float
- model#
The model used for fitting.
- Type:
lmfit-object
- params#
The parameters used for fitting.
- Type:
lmfit-object
- result#
The result of the fitting.
- Type:
lmfit-object
- best_fit_data#
The best fit data [x, y_measured, y_fitted].
- Type:
list
- best_fit_parameters#
The best fit parameters.
- Type:
dict
- Remarks:
This class does not take advantage of the cellpydata-object. It is primarily used for fitting data that does not originate from cellpy, but it can also be used for fitting cellpy-data.
If you have cellpy-data, you should use the MultiCycleOcvFit class instead.
Initializes the class.
- Parameters:
circuits (int) – The number of circuits to be fitted (including R0).
direction (str) – The direction of the relaxation (up or down).
zero_current (float) – Last current observed before turning the current off.
zero_voltage (float) – Last voltage observed before turning the current off.
- run_fit()[source]#
Performing fit of the OCV steps in the cycles set by set_cycles() from the data set by set_data()
r is found by calculating v0 / i_start –> err(r)= err(v0) + err(i_start).
c is found from using tau / r –> err(c) = err(r) + err(tau).
The resulting best fit parameters are stored in self.result for the given cycles.
- Returns:
None
- set_cellpydata(cellpydata, cycle)[source]#
Convenience method for setting the data from a cellpydata-object. :param cellpydata: data object from cellreader :type cellpydata: CellpyCell :param cycle: cycle number to get from CellpyCell object :type cycle: int
- Remarks:
You need to set the direction before calling this method if you don’t want to use the default direction (up).
- Returns:
None
- fit(c, direction='up', circuits=3, cycles=None, return_fit_object=False)[source]#
Fits the OCV steps in CellpyCell object c.
- Parameters:
c – CellpyCell object
direction – direction of the OCV steps (‘up’ or ‘down’)
circuits – number of circuits to use (first is IR, rest is RC) in the fitting (min=1, max=4)
cycles – list of cycles to fit (if None, all cycles will be used)
return_fit_object – if True, returns the MultiCycleOcvFit instance.
- Returns:
pd.DataFrame with the fitted parameters for each cycle if return_fit_object=False, else MultiCycleOcvFit instance
- select_ocv_points(cellpydata, cycles=None, cell_label=None, include_times=True, selection_method='martin', number_of_points=5, interval=10, relative_voltage=False, report_times=False, direction='both')[source]#
Select points from the ocvrlx steps.
- Parameters:
cellpydata –
CellpyData-object
cycles – list of cycle numbers to process (optional)
cell_label (str) – optional, will be added to the frame if given
include_times (bool) – include additional information including times.
selection_method ('martin' | 'fixed_times') – criteria for selecting points (‘martin’: select first and last, and then last/2, last/2/2 etc. until you have reached the wanted number of points; ‘fixed_times’: select first, and then same interval between each subsequent point).
number_of_points – number of points you want.
interval – interval between each point (in use only for methods where interval makes sense). If it is a list, then number_of_points will be calculated as len(interval) + 1 (and override the set number_of_points).
relative_voltage – set to True if you would like the voltage to be relative to the voltage before starting the ocv rlx step. Defaults to False. Remark that for the initial rxl step (when you just have put your cell on the tester) does not have any prior voltage. The relative voltage will then be versus the first measurement point.
report_times – also report the ocv rlx total time if True (defaults to False)
direction ("up", "down" or "both") – select “up” if you would like to process only the ocv rlx steps where the voltage is relaxing upwards and vice versa. Defaults to “both”.
- Returns:
pandas.DataFrame
(and anotherpandas.DataFrame
if return_times is True)