SOE Estimator (Adaptive Kalman Filter)
State of energy and terminal resistance estimator with adaptive Kalman filter
Since R2023b
Libraries:
Simscape /
Battery /
BMS /
Estimators
Description
The SOE Estimator (Adaptive Kalman Filter) block implements an estimator that calculates the state of energy (SOE) and terminal resistance of a battery by using the Kalman filter algorithms. The terminal resistance, R0 is a state of the estimator.
The SOE is the ratio of the remaining energy Eremain to the total energy Etotal:
This block supports single-precision and double-precision floating-point simulation.
Note
To enable single-precision floating-point simulation, the data type of all inputs and
parameters, except for the Sample time (-1 for inherited)
parameter, must be single
.
For continuous-time simulation, set the Filter type parameter to
Extended Kalman-Bucy filter
or Unscented
Kalman-Bucy filter
.
Note
Continuous-time implementation of this block works only in a double-precision floating-point simulation. If you provide single-precision floating-point parameters and inputs, this block casts them to double-precision floating-point values to prevent errors.
For discrete-time simulation, set the Filter type parameter to
Extended Kalman filter
or Unscented Kalman
filter
and the Sample time (-1 for inherited)
parameter to a positive value or -1
.
Equations
These figures show the equivalent circuit for a battery with one-time-constant dynamics and two time-constant dynamics, respectively:
The equations for the equivalent circuit with the terminal resistance R0 as an additional state and with two time-constant dynamics are:
where
SOE is the state of energy.
i is the current.
V0 is the no-load voltage.
Vt is the terminal voltage.
Enom is the nominal cell energy capacity.
R1 is the first polarization resistance.
C1 is the parallel RC capacitance.
T is the temperature.
R0 is the terminal resistance.
V1 is the polarization voltage over the first RC network.
V2 is the polarization voltage over the second RC network.
A time constant τ1 for the first parallel section relates the first polarization resistance R1 and the first parallel RC capacitance C1 using the relationship
A time constant τ2 for the second parallel section relates the second polarization resistance R2 and the second parallel RC capacitance C2 using the relationship
For the Kalman filter algorithms, the block uses these state, input, and output vectors:
If you set the Charge dynamics parameter to Two
time-constant dynamics
, for the Kalman filter algorithms, the
block uses these state, input, and output vectors:
Then the block rewrites the equations for the equivalent circuit as a standard nonlinear state space system:
The linearized model is
where:
This diagram shows the structure of the extended Kalman filter (EKF):
For a battery SOE estimation technique with a one-time-constant model, the block uses this linearized model:
You can modify three parameters of the Kalman filter: the covariance of the measurement noise R, the initial state error covariance P0, and the covariance of the process noise Q. Set R to the square of the error from the equipment you used to test the battery cell.
The EKF algorithm comprises these phases:
Initialization
— State estimate at time step 0 using measurements at time step 0.
— State estimation error covariance matrix at time step 0 using measurements at time step 0.
Prediction
Project the states ahead (a priori):
Project the error covariance ahead:
where Q is the covariance of the process noise.
Correction
Compute the Kalman gain:
where R is the covariance of the measurement noise.
Update the estimate with the measurement y(k) (a posteriori):
Update the error covariance:
This diagram shows the structure of the extended Kalman-Bucy filter (EKBF):
The EKBF is the continuous-time variant of the Kalman filter.
In continuous time, the EKBF couples the prediction and correction steps.
Initialization
— State estimate at time t0.
— State estimation error covariance matrix at time t0.
Prediction-Correction EKBF algorithm
where:
This diagram shows the structure of the unscented Kalman filter (UKF):
The EKF locally approximates nonlinear functions with the linear equations obtained from the Taylor expansion by using only the first term of the expansion. In a highly nonlinear system, these solutions are not very accurate.
The UKF uses nonlinear transformations on a set of sigma points that the algorithm chooses deterministically. This technique is called unscented transformation. The mean and the covariance matrix of the transformed points are accurate to the second order of the Taylor series expansion.
The algorithm first generates a set of state values called sigma points. These sigma points capture the mean and covariance of the state estimates. The algorithm uses each of the sigma points as an input to the state transition and measurement functions to get a new set of transformed state points. Then, the algorithm uses the mean and covariance of the transformed points to obtain state estimates and state estimation error covariance.
The UKF algorithm follows these steps:
Initialization
— State estimate at time step 0 using measurements at time step 0.
— State estimation error covariance matrix at time step 0 using measurements at time step 0.
Generate sigma points and calculate the mean weight and covariance weight for each point.
Choose the sigma points x(i)(k|k)
where:
n is the dimension of the state vector, x.
describes the distance between the sigma point and the mean point. In a normal distribution, β = 2 and κ = 0.
is the ith row or column of . The block calculates the matrix square root by using numerically efficient and stable methods such as the Cholesky decomposition.
Perform first estimation of the system state matrix:
Perform first estimation of the covariance matrix of the state variables:
Estimate the measured variables:
Estimate the covariance of the measurement (Py) and covariance between the measurement and the state (Pxy):
Compute the Kalman filter gain:
Perform the second update of the state matrix and of the covariance of the state variables:
This diagram illustrates the overall structure of the unscented Kalman-Bucy filter (UKBF):
The derived continuous-time filtering equations of the UKBF are similar to the EKBF equations.
The stochastic differential equations corresponding to the UKF in continuous time are:
where
is the sigma-point matrix.
The general UKBF equations can run into issues related to finite numerical precision of computer arithmetic. Because the UKF uses matrix square roots in its sigma points, the square-root UKBF algorithm obtains the square-root version of the UKBF by formulating the filter as a differential equation for the sigma points. The equations for the square-root UKBF are:
where
is the sigma-point matrix.
is a function that returns the lower diagonal part of the argument.
is the ith column of the argument matrix.
This matrix implementation is not always the most computationally efficient implementation of the square-root UKBF. You can use these equations to alternatively compute the matrix expressions:
where
Ports
Input
Output
Parameters
References
[1] Yujie Wang, Chenbin Zhang, Zonghai Chen. Model-based State-of-energy Estimation of Lithium-ion Batteries in Electric Vehicles. Energy Procedia, Volume 88, 2016, Pages 998-1004.
[2] S. Munisamy, D. J. Auger, A. Fotouhi, B. Hawkes and E. Kappos, State of energy estimation in electric propulsion systems with lithium-sulfur batteries. Online Conference, 2020, pp. 788-795.
[3] R. Van der Merwe and E. A. Wan, The square-root unscented Kalman filter for state and parameter-estimation. 2001 IEEE International Conference on Acoustics, Speech, and Signal Processing. Proceedings (Cat. No.01CH37221), 2001, pp. 3461-3464 vol.6, doi: 10.1109/ICASSP.2001.940586.
[4] M. S. Grewal and A. P. Andrews, Kalman Filtering, Theory and Practice Using MATLAB. New York: Wiley Intersci., 2001.
[5] S. Sarkka, On Unscented Kalman Filtering for State Estimation of Continuous-Time Nonlinear Systems. IEEE Transactions on Automatic Control, vol. 52, no. 9, pp. 1631-1641, Sept. 2007, doi: 10.1109/TAC.2007.904453.