# Identify Supercapacitor Parameter

This example shows how to identify the parameters of a supercapacitor. Instead of collecting voltage and current waveforms from a real supercapacitor, this example generates voltage and current waveforms by running a simulation of a supercapacitor using known parameter values. Then the example applies a parameter identification methodology [1] to the waveforms.

To assess the accuracy of the methodology, this example compares the identified parameters to the known parameter values. The example also shows how to further refine the parameter values using the Parameter Estimation app in the Simulink® Design Optimization™ toolbox.

To empirically identify the parameters of an actual supercapacitor, you can:

Collect voltage and current waveforms from the supercapacitor.

Identify parameter values using the waveform data and the methodology in [1].

To identify the parameters of a modeled supercapacitor, this example:

Generates voltage and current waveforms by simulating a model using known values for supercapacitor parameters.

Identifies supercapacitor parameter values using the generated waveform data and the methodology in [1].

Configures and simulates the supercapacitor using the identified supercapacitor parameter values.

To learn how the approach works for a real supercapacitor, evaluate the accuracy of the identification methodology by comparing:

The data you generate using known parameter values and the data you generate using identified parameter values.

The known parameter values and identified parameter values.

If the accuracy is not sufficient, use the Parameter Estimator app from Simulink Design Optimization to improve it. Use the identified parameter values as the starting values for the optimization.

### Generate Data

Generate voltage and current waveforms by configuring and simulating a model using known values for the fixed resistances, fixed capacitances, and voltage-dependent capacitor gain parameters of the supercapacitor. Model the input current, configure the physical characteristics and the self-discharge resistance of the supercapacitor using realistic values.

```
modelName = 'SupercapacitorFromData';
open_system(modelName);
```

Configure the supercapacitor using known parameter values.

SupercapacitorFromDataParameterConfiguration;

Observe the supercapacitor behavior during three distinct phases:

Charge with constant current

Charge redistribution from immediate to delayed branch

Charge redistribution from immediate and delayed branches to long-term branch

sim(modelName)

### Perform Parameter Identification

Using the waveform data from the simulation, apply the methodology described in [1].

#### Identify Immediate Branch Parameters

During the first stage of the identification, a fully discharged supercapacitor is charged with constant current. The method assumes that the immediate branch stores all the initial charge because the time constant for the branch is relatively small.

To calculate the immediate branch parameters, you take measurements of the charge characteristic. Once the charging current reaches the steady-state at $${t}_{1}=20{e}^{-3}s$$, measure $${v}_{1}$$ and then calculate the fixed resistance of the immediate branch by using this equation:

$${R}_{i}=\frac{{v}_{1}}{{i}_{1}}$$

where:

$${t}_{1}$$ is the time at parameter identification event $$n=1$$in seconds.

$${v}_{1}$$ is the terminal voltage at $${t}_{1}$$ in volts.

$${i}_{1}$$ is the charging current at $${t}_{1}$$ in amperes.

$${R}_{i}$$ is the fixed resistance of immediate branch in ohm.

Once voltage increases from $${v}_{1}$$ by approximately $$50{e}^{-3}V$$, measure $${t}_{2}$$ and $${v}_{2}$$ and then calculate the fixed capacitance of the immediate branch by using this equation:

$${C}_{i0}={i}_{1}\frac{{t}_{2}-{t}_{1}}{{v}_{2}-{v}_{1}}$$

where:

$${t}_{2}$$ is the time at parameter identification event $$n=2$$ in seconds.

$${v}_{2}$$ is the terminal voltage at $${t}_{2}$$ in volts.

$${C}_{i0}$$ is the fixed capacitance of immediate branch in farads.

Once the voltage reaches rated voltage, measure $${v}_{3}$$ and $${t}_{3}$$, and turn off the charging current. After $$20{e}^{-3}s$$, once charging current reaches steady-state value of $$0A$$ measure $${t}_{4}$$ and $${v}_{4}$$ and then calculate the voltage-dependent capacitance coefficient by using this equation:

$${t}_{4}={t}_{3}+20{e}^{-3}$$

$${C}_{i1}=\frac{2}{{v}_{4}}(\frac{{i}_{1}({t}_{4}-{t}_{1})}{{v}_{4}}-{C}_{i0})$$

where:

$${t}_{3}$$ is the time at parameter identification event $$n=3$$ in seconds.

$${v}_{3}$$ is the terminal voltage at $${t}_{3}$$ in volts.

$${t}_{4}$$ is the time at parameter identification event $$n=4$$ in seconds.

$${v}_{4}$$ is the terminal voltage at $${t}_{4}$$ in volts.

$${C}_{i1}$$ is the voltage-dependent capacitance coefficient in farads per volt.

To perform these calculations, run this script:

SupercapacitorFromDataParameterImmediateIdentification;

#### Identify Delayed Branch Parameters

During the second stage of the identification, the charge redistributes from the immediate branch to the delayed branch.

To calculate the delayed branch parameters, measure the hold charge characteristics.

Once the voltage decreases from $${v}_{4}$$ by approximately $$50{e}^{-3}V$$, measure $${t}_{5}$$ and $${v}_{5}$$ and then calculate the delayed branch resistance by using these equations:

$$\Delta v={v}_{4}-{v}_{5}$$

$${V}_{ci}={v}_{4}-\frac{\Delta V}{2}$$

$${C}_{diff}={C}_{i0}+{C}_{i1}{V}_{ci}$$

$${R}_{d}=\frac{({v}_{4}-\frac{\Delta V}{2})({t}_{5}-{t}_{4})}{{C}_{diff}\Delta V}$$

where:

$${t}_{5}$$ is the time at parameter identification event $$n=5$$ in seconds.

$${v}_{5}$$ is the terminal voltage at $${t}_{5}$$ in volts.

$${V}_{ci}$$ is the voltage at which the total immediate capacitance is to be calculated in volts.

$${C}_{diff}$$ is the total immediate capacitance at $${V}_{ci}$$ in farads.

$${R}_{d}$$ is the delayed branch resistance in ohms.

Wait 300 seconds, measure $${t}_{6}$$ and $${v}_{6}$$ and then calculate the delayed branch capacitance by using these equations:

$${Q}_{total}={i}_{1}({t}_{4}-{t}_{1})$$

$${C}_{d}=\frac{{Q}_{total}}{{v}_{6}}-({C}_{i0}+\frac{{C}_{i1}}{2}{v}_{6})$$

where:

$${t}_{6}$$ is the time at parameter identification event $$n=6$$ in seconds.

$${v}_{6}$$ is the terminal voltage at $${t}_{6}$$ in volts.

$${Q}_{total}$$ is the total charge supplied to the supercapacitor in coulombs.

$${C}_{d}$$ is the delayed branch capacitance in farads.

To perform these calculations, run this script:

SupercapacitorFromDataParameterDelayedIdentification;

#### Identify Long-Term Branch Parameters

During the third and final stage of the identification, the charge redistributes from the immediate and delayed branches to the long-term branch.

To calculate the long-term branch parameters, measure the hold charge characteristics.

Once the voltage decreases from $${v}_{6}$$ by approximately $$50{e}^{-3}V$$, measure $${t}_{7}$$ and $${v}_{7}$$ and then calculate the long-term branch resistance by using these equations:

$$\Delta v={v}_{6}-{v}_{7}$$

$${R}_{l}=\frac{({v}_{6}-\frac{\Delta V}{2})(t7-{t}_{6})}{{C}_{diff}\Delta V}$$

where:

$${t}_{7}$$ is the time at parameter identification event $$n=7$$ in seconds.

$${v}_{7}$$ is the terminal voltage at $${t}_{7}$$ in volts.

$${R}_{l}$$ is the long-term branch resistance in ohms.

After 30 minutes from the start of the charging/discharging process, measure $${t}_{8}$$ and $${v}_{8}$$ and then calculate the long-term branch capacitance by using this equation:

$${C}_{l}=\frac{{Q}_{total}}{{v}_{8}}-({C}_{i0}+\frac{{C}_{i1}}{2}{v}_{8})-{C}_{d}$$

where:

$${t}_{8}$$ is the time at parameter identification event $$n=8$$ in seconds.

$${v}_{8}$$ is the terminal voltage at $${t}_{8}$$ in volts.

$${C}_{l}$$ is the long-term branch capacitance in farads.

To perform these calculations, run this script:

SupercapacitorFromDataParameterLongTermIdentification;

#### Collate Time and Voltage Data

Collate the time and voltage data for each parameter identification event in a MATLAB® table:

DataTable = table((1:8)',... [t1 t2 t3 t4 t5 t6 t7 t8]',... [v1 v2 v3 v4 v5 v6 v7 v8]',... 'VariableNames',{'Event','Time','Voltage'})

`DataTable=`*8×3 table*
Event Time Voltage
_____ _______ ________
1 0.02 0.071799
2 0.51803 0.1218
3 40 2.2717
4 40.02 2.2019
5 56.675 2.1519
6 356.67 1.8473
7 499.28 1.7973
8 1800 1.5865

SupercapacitorFromDataPlotVoltage;

#### Evaluate Accuracy of Identified Parameters

Configure and simulate the model using the identified supercapacitor parameters. Then, to evaluate the accuracy of the identified parameter values, compare the waveform output to the data that you generate by running a simulation that uses known parameters.

SupercapacitorFromDataParameterSimulateIdentifiedParameters;

### Optimize Parameters Using Parameter Estimation App

To perform the optimization of the supercapacitor parameters, you must have the Simulink Design Optimization toolbox installed.

If the traces are not similar enough to meet requirements, then the identified parameter values can serve as initial parameter values for the Parameter Estimator app from Simulink Design Optimization.

To optimize the super capacitor parameters, at the MATLAB Command Window, enter:

```
spetool('SupercapacitorSDOParameterEstimatorSession');
```

### Display Optimization Results

Display the parameter trajectory created using the **Sum Squared Error** cost function and **Nonlinear least squares** optimization method.

`openfig('SupercapacitorSDOParameterEstimatorResults');`

### Results from Real-Time Simulation

This model has been tested on a Speedgoat Performance real-time target machine with an Intel® 3.5 GHz i7 multi-core CPU. This model can run in real time with a step size of 50 microseconds.

### References

[1] Zubieta, L. and R. Bonert. "Characterization of Double-Layer Capacitors for Power Electronics Applications." IEEE Transactions on Industry Applications, Vol. 36, No. 1, 2000, pp. 199-205.