Main Content

Estimate Equivalent Circuit Lithium-Ion Battery Data

The workflow steps estimate data for an equivalent circuit lithium-ion polymer (LiPo) battery. The steps use numerical optimization techniques to determine the number of recommended RC pairs, provide initial estimates for the battery model circuit parameters, and estimate parameters to fit a model to experimental pulse discharge data. The results provide the open circuit voltage, series resistance, and RC pair parameter data.

Step 1: Load and Preprocess Data

Data Format and Requirements

The workflow supports pulse discharge sequences from 100% to 0% state-of-charge (SOC). The data requirements include:

  • Time series consisting of current and voltage from an experimental pulse discharge. For each experimental data set, the temperature is constant. The sample rate should be a minimum of 1 Hz, with an ideal rate at 10 Hz.

  • Voltage accuracy within ±5 mV, ideally within ±1 mV.

  • Current accuracy within ±100 mA, ideally within 10 mA.

  • Temperature accuracy within ±1 °C, ideally within ±1 °C.

  • Change in SOC for each pulse should not be greater than 5%.

  • Data collection at high or low SOC might need modification to ensure safety.

  • Sufficient relaxation time after each pulse to ensure battery approaches steady-state voltage.

Load and Preprocess Data

Load and preprocess time series discharge voltage and current data for a lithium-ion polymer (LiPo) battery.

First, create a PulseSequence object.

psObj = Battery.PulseSequence;
disp(psObj);
  PulseSequence with properties:

                 Data: [0×5 double]
            ModelName: ''
             MetaData: [1×1 Battery.MetaData]
             Capacity: 1
           CapacityAh: 2.7778e-04
            NumPulses: 0
             TestType: 'none'
                 Time: [0×1 double]
              Voltage: [0×1 double]
              Current: [0×1 double]
               Charge: [0×1 double]
             ChargeAh: [0×1 double]
                  SOC: [0×1 double]
           Parameters: [1×0 Battery.Parameters]
    ParametersHistory: [1×0 Battery.Parameters]
              idxEdge: []
              idxLoad: []
             idxRelax: []
                Pulse: [0×1 Battery.Pulse]

Specify the file name and load the raw data.

FileName = 'Synthetic_LiPo_PulseDischarge.mat';
[time,voltage,current] = Battery.loadDataFromMatFile(FileName);

Add the data to the PulseSequence.

psObj.addData(time,voltage,current);

Review the pulse sequence data.

Pulse Sequence Data

psObj.plot();

Figure contains 3 axes objects. Axes object 1 with ylabel Voltage contains an object of type line. Axes object 2 with ylabel Current (A) contains an object of type line. Axes object 3 with xlabel Time (hours), ylabel SOC contains an object of type line.

Break up the data into Battery.Pulse objects by creating the objects within the PulseSequence. This creates a parameter object with look-up tables that are the correct size.

psObj.createPulses(...
    'CurrentOnThreshold',0.1,... %minimum current magnitude to identify pulse events
    'NumRCBranches',3,... %how many RC pairs in the model
    'RCBranchesUse2TimeConstants',false,... %do RC pairs have different time constant for discharge and rest?
    'PreBufferSamples',10,... %how many samples to include before the current pulse starts
    'PostBufferSamples',15); %how many samples to include after the next pulse starts

Specify the model that matches the number of RC branches and time constants.

psObj.ModelName = 'BatteryEstim3RC_PTBS';

Plot the identified pulses in the data.

Pulse Identification

psObj.plotIdentifiedPulses();

Figure contains 3 axes objects. Axes object 1 with ylabel Voltage contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Voltage, Pairs surround load, Pairs surround relaxation. Axes object 2 with ylabel Current (A) contains 3 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with xlabel Time (hours), ylabel SOC contains 3 objects of type line. One or more of the lines displays its values using only markers

To exclude pulses, use this code.

% psObj.removePulses(indexToRemove);
% psObj.plotIdentifiedPulses();

Step 2: Determine the Number of RC Pairs

Determine the number of RC pairs. Too many pairs can over-fit the data. Too few pairs increases the fit error. If you decide to change the number of pairs, you rerun createPulses and change the NumRCBranches to the new value.

Determine the number of necessary time constants (TC) for estimation.

PulsesToTest = [1 floor(psObj.NumPulses/2), psObj.NumPulses-1];
psObj.Pulse(PulsesToTest).compareRelaxationTau();

Figure contains 4 axes objects. Axes object 1 with title TC Comparison, Pulse 1 of 3, ylabel voltage (V) contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent 1 TC, 2 TC, 3 TC, 4 TC, 5 TC. Axes object 2 with title First 60 seconds contains 6 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with xlabel time (s), ylabel residual (mV) contains 5 objects of type line. Axes object 4 with xlabel time (s) contains 5 objects of type line.

Figure contains 4 axes objects. Axes object 1 with title TC Comparison, Pulse 2 of 3, ylabel voltage (V) contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent 1 TC, 2 TC, 3 TC, 4 TC, 5 TC. Axes object 2 with title First 60 seconds contains 6 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with xlabel time (s), ylabel residual (mV) contains 5 objects of type line. Axes object 4 with xlabel time (s) contains 5 objects of type line.

Figure contains 4 axes objects. Axes object 1 with title TC Comparison, Pulse 3 of 3, ylabel voltage (V) contains 6 objects of type line. One or more of the lines displays its values using only markers These objects represent 1 TC, 2 TC, 3 TC, 4 TC, 5 TC. Axes object 2 with title First 60 seconds contains 6 objects of type line. One or more of the lines displays its values using only markers Axes object 3 with xlabel time (s), ylabel residual (mV) contains 5 objects of type line. Axes object 4 with xlabel time (s) contains 5 objects of type line.

Step 3: Estimate Parameters

Estimate the parameters. First, set parameter values. Only update parameters once. Updating the parameters changes the history.

Params = psObj.Parameters;

Params.Tx(1,:,:) = 5;
Params.Tx(2,:,:) = 50;
Params.Tx(3,:,:) = 200;

Params.TxMin(1,:,:) = 1;
Params.TxMax(1,:,:) = 50;

Params.TxMin(2,:,:) = 20;
Params.TxMax(2,:,:) = 1000;

Params.TxMin(3,:,:) = 100;
Params.TxMax(3,:,:) = 3500; %don't set this bigger than the relaxation time available

Update the parameters.

psObj.Parameters = Params;

Estimate the initial Em and R0 values. Plot the results.

psObj.estimateInitialEmR0(...
    'SetEmConstraints',false,... %Update EmMin or EmMax values based on what we learn here
    'EstimateEm',true,... %Keep this on to perform Em estimates
    'EstimateR0',true); %Keep this on to perform R0 estimates

Parameter Tables

psObj.plotLatestParameters();

Figure Parameter Tables contains 8 axes objects and another object of type subplottext. Axes object 1 with title E indexOf m baseline, ylabel Volts contains an object of type line. Axes object 2 with title tau indexOf 1 baseline, ylabel seconds contains an object of type line. Axes object 3 with title tau indexOf 2 baseline, ylabel seconds contains an object of type line. Axes object 4 with title tau indexOf 3 baseline, ylabel seconds contains an object of type line. Axes object 5 with title R indexOf 0 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 6 with title R indexOf 1 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 7 with title R indexOf 2 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 8 with title R indexOf 3 baseline, xlabel SOC, ylabel Ohms contains an object of type line.

Get the initial Tx (Tau) values. This step performs curve fitting on the pulse relaxation to estimate the RC time constant at each SOC.

psObj.estimateInitialTau(...
    'UpdateEndingEm',false,... %Keep this on to update Em estimates at the end of relaxations, based on the curve fit
    'ShowPlots',true,... %Set this true if you want to see plots while this runs
    'ReusePlotFigure',true,... %Set this true to overwrite the plots in the same figure
    'UseLoadData',false,... %Set this true if you want to estimate Time constants from the load part of the pulse, instead of relaxation
    'PlotDelay',0.5); %Set this to add delay so you can see the plots 

Figure contains an axes object. The axes object with title Exponential fit 26 of 26, xlabel time (s), ylabel voltage contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Data, Fit.

Plot the results.

Parameter Tables

psObj.plotLatestParameters();

Figure Parameter Tables contains 8 axes objects and another object of type subplottext. Axes object 1 with title E indexOf m baseline, ylabel Volts contains an object of type line. Axes object 2 with title tau indexOf 1 baseline, ylabel seconds contains an object of type line. Axes object 3 with title tau indexOf 2 baseline, ylabel seconds contains an object of type line. Axes object 4 with title tau indexOf 3 baseline, ylabel seconds contains an object of type line. Axes object 5 with title R indexOf 0 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 6 with title R indexOf 1 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 7 with title R indexOf 2 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 8 with title R indexOf 3 baseline, xlabel SOC, ylabel Ohms contains an object of type line.

Simulation Results

psObj.plotSimulationResults(); 

Figure contains 2 axes objects. Axes object 1 with xlabel Time (hours), ylabel Volts contains 2 objects of type line. These objects represent data, simulation. Axes object 2 with xlabel Mean and Max Residual Voltage 12.3816 to 581.3743, ylabel mV contains 2 objects of type line.

Get initial Em and Rx values using a linear system approach - pulse by pulse. This step takes the data for each pulse and treats it as a linear system. It fits the Rx values for each RC branch. Optionally, you can allow it to adjust the Em and R0 values, and if these are adjusted, you also have the option whether to retain the optimized values of these or to discard them.

psObj.estimateInitialEmRx(...
    'IgnoreRelaxation',false,... %Set this true if you want to ignore the relaxation periods during this step
    'ShowPlots',true,...  %Set this true if you want to see plots while this runs
    'ShowBeforePlots',true,... %Set this true if you want to see the 'before' value on the plots
    'PlotDelay',0.5,... %Set this to add delay so you can see the plots 
    'EstimateEm',true,... %Set this true to allow the optimizer to change Em further in this step
    'RetainEm',true,... %Set this true keep any changes made to Em in this step
    'EstimateR0',true,... %Set this true to allow the optimizer to change R0 further in this step
    'RetainR0',true); %Set this true keep any changes made to R0 in this step

Figure contains an axes object. The axes object with title Linear fit 26 of 26, xlabel time (s), ylabel voltage contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Data, Before Fit, After Fit.

Plot the results.

Parameter Tables

psObj.plotLatestParameters();

Figure Parameter Tables contains 8 axes objects and another object of type subplottext. Axes object 1 with title E indexOf m baseline, ylabel Volts contains an object of type line. Axes object 2 with title tau indexOf 1 baseline, ylabel seconds contains an object of type line. Axes object 3 with title tau indexOf 2 baseline, ylabel seconds contains an object of type line. Axes object 4 with title tau indexOf 3 baseline, ylabel seconds contains an object of type line. Axes object 5 with title R indexOf 0 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 6 with title R indexOf 1 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 7 with title R indexOf 2 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 8 with title R indexOf 3 baseline, xlabel SOC, ylabel Ohms contains an object of type line.

Simulation Results

psObj.plotSimulationResults(); 

Figure contains 2 axes objects. Axes object 1 with xlabel Time (hours), ylabel Volts contains 2 objects of type line. These objects represent data, simulation. Axes object 2 with xlabel Mean and Max Residual Voltage 6.722 to 310.7349, ylabel mV contains 2 objects of type line.

Perform design optimization estimation.

SDOOptimizeOptions = sdo.OptimizeOptions(...
    'OptimizedModel',psObj.ModelName,...
    'Method','lsqnonlin',...
    'UseParallel','always');

SDOOptimizeOptions.MethodOptions.Display = 'final';

psObj.estimateParameters(...
    'CarryParamToNextPulse',true,... %Set this true to use the final parameter values from the prior pulse and SOC as initial values for the next pulse and SOC
    'SDOOptimizeOptions',SDOOptimizeOptions,... %Specify the SDO options object
    'ShowPlots',true,... %Set this true if you want to see plots while this runs
    'EstimateEm',true,... %Set this true to allow the optimizer to change Em further in this step
    'RetainEm',true,... %Set this true keep any changes made to Em in this step
    'EstimateR0',true,... %Set this true to allow the optimizer to change R0 further in this step
    'RetainR0',true); %Set this true keep any changes made to R0 in this step
Local minimum possible.
lsqnonlin stopped because the size of the current step is less than
the value of the step size tolerance.

<stopping criteria details>

Estimation completed in 940.84 seconds.

Figure contains 2 axes objects. Axes object 1 with title SDO Estimation 26 of 26, ylabel voltage (V) contains 3 objects of type line. One or more of the lines displays its values using only markers These objects represent Data, Before (Mean Residual = 33.15 mV), After (Mean Residual = 6.19 mV). Axes object 2 with xlabel time (s), ylabel residual (mV) contains 2 objects of type line.

Plot the results.

Parameter Tables

psObj.plotLatestParameters();

Figure Parameter Tables contains 8 axes objects and another object of type subplottext. Axes object 1 with title E indexOf m baseline, ylabel Volts contains an object of type line. Axes object 2 with title tau indexOf 1 baseline, ylabel seconds contains an object of type line. Axes object 3 with title tau indexOf 2 baseline, ylabel seconds contains an object of type line. Axes object 4 with title tau indexOf 3 baseline, ylabel seconds contains an object of type line. Axes object 5 with title R indexOf 0 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 6 with title R indexOf 1 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 7 with title R indexOf 2 baseline, xlabel SOC, ylabel Ohms contains an object of type line. Axes object 8 with title R indexOf 3 baseline, xlabel SOC, ylabel Ohms contains an object of type line.

Simulation Results

psObj.plotSimulationResults(); 

Figure contains 2 axes objects. Axes object 1 with xlabel Time (hours), ylabel Volts contains 2 objects of type line. These objects represent data, simulation. Axes object 2 with xlabel Mean and Max Residual Voltage 7.5271 to 322.3215, ylabel mV contains 2 objects of type line.

Copyright 2023 The Matharninorks, Inc.