|
|
不要命的自行车 · 使用近似与精确kNN实现向量检索-检索分析服 ...· 2 月前 · |
|
|
重感情的水桶 · 解决浏览器 require is not ...· 1 年前 · |
|
|
光明磊落的高山 · 一个文科生从零到进入大厂的感悟(3小时掌握一 ...· 2 年前 · |
|
|
路过的茴香 · pySCENIC转录因子分析 - 简书· 2 年前 · |
|
|
拉风的海龟 · DllImport 自动选择x64或x86 ...· 2 年前 · |
|
|
痴情的煎饼
8 月前 |
Libraries:
Simscape /
Battery /
BMS /
Estimators
The SOC Estimator (Kalman Filter) block implements an estimator that calculates the state of charge (SOC) of a battery by using the Kalman filter algorithms.
The SOC is the ratio of the released capacity C releasable to the rated capacity C rated . Manufacturers provide the value of the rated capacity of each battery, which represents the maximum amount of charge in the battery:
This block supports single-precision and double-precision floating-point simulation.
Note
To enable inherited 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
.
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 two time-constant dynamics are:
where
SOC is the state of charge.
i is the current.
V 0 is the no-load voltage.
V t is the terminal voltage.
AH is the ampere-hour rating.
R 1 is the first polarization resistance.
C 1 is the first parallel RC capacitance.
R 2 is the second polarization resistance.
C 2 is the second parallel RC capacitance.
T is the temperature.
V 1 is the polarization voltage over the first RC network.
V 2 is the polarization voltage over the second RC network.
A time constant τ 1 for the first parallel section relates the first polarization resistance R 1 and the first parallel RC capacitance C 1 using the relationship
A time constant τ 2 for the second parallel section relates the second polarization resistance R 2 and the second parallel RC capacitance C 2 using the relationship
For the Kalman filter algorithms, the block uses this state and these process and observation functions:
If you set the
Charge dynamics
parameter to
Two
time-constant dynamics
, for the Kalman filter algorithms, the
block uses this state and these process and observation functions:
This diagram shows the structure of the extended Kalman filter (EKF):
The EKF technique relies on a linearization at every time step to approximate the nonlinear system. To linearize the system at every time step, the algorithm computes these Jacobians online:
The EKF is a discrete-time algorithm. After the discretization, the Jacobians for the SOC estimation of the battery are:
where T S is the sample time and V OC is the open-circuit voltage.
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
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 prediction and correction steps are coupled.
Initialization
— State estimate at time t 0 .
— State estimation error covariance matrix at time t 0 .
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 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
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 i th 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 ( P y ) and covariance between the measurement and the state ( P xy ):
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.
Because the UKF uses matrix square roots in its sigma points, the 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 i th column of the argument matrix.
Explores different techniques to estimate the state of charge (SOC) of a battery, including the Kalman filter algorithm and the Coulomb counting method. The Kalman filter is an estimation algorithm that infers the state of a linear dynamic system from incomplete and noisy measurements. This example illustrates the effectiveness of the Kalman filter in dynamically estimating the SOC of a battery, even when starting with inaccurate initial conditions and when the measurements are noisy. The SOC of a battery measures the current capacity of the battery in relation to its maximum capacity.
Estimate the state of charge (SOC) of lithium iron phosphate (LFP) batteries by using the Coulomb Counting method with error correction. The Coulomb counting method is implemented at 1 second sample time. To correct the estimate of the Coulomb counting method, the example implements an extended Kalman filter with a sampling time of 10 seconds. The initial SOC of the battery is equal to 0.4. The estimator uses an initial condition for the SOC equal to 0.6. The LFP battery keeps charging and discharging for six hours. The estimator converges to the real value of the SOC in approximately half an hour and then follows the real SOC value.
Estimate the battery state of charge (SOC) by using a Kalman filter. The initial SOC of the battery is equal to 0.5. The estimator uses an initial condition for the SOC equal to 0.8. The battery keeps charging and discharging for 6 hours. The extended Kalman filter estimator converges to the real value of the SOC in less than 10 minutes and then follows the real SOC value. To use a different Kalman filter implementation, in the SOC Estimator (Kalman Filter) block, set the Filter type parameter to the desired value.
Cyclically charge and discharge a battery module while estimating the state of charge (SOC) of the three parallel assemblies of the module over time. This example uses the SOC estimation to switch between the charging and discharging profiles. For the estimation, the Kalman filter uses an initial SOC estimation and the voltage, current, and temperature of the parallel assemblies. The model estimates the temperature of the parallel assemblies from the average of the cell temperatures of each parallel assembly.
Battery current, in ampere, specified as a scalar for a single cell or a vector for multiple cells. To specify this input as a vector of cell currents, select the Specify Current input as cell current(s) parameter.
Cell voltage, in volt, specified as a scalar for a single cell or a vector for multiple cells. The size of this input port must be equal to the size of the CellTemperature and InitialSOC input ports.
Cell temperature, specified as a scalar for a single cell or a vector for multiple cells. The size of this input port must be equal to the size of the CellVoltage and InitialSOC input ports.
Initial state of charge, specified as a scalar or vector of entries in the range [0, 1]. The size of this input port must be equal to the size of the CellVoltage and CellTemperature input ports.
State of charge of the battery, returned as a scalar or a vector. The size of this output port is equal to the size of the CellVoltage , CellTemperature , and InitialSOC input ports.
Since R2023b
Option to specify the value of the Current input port as a vector of cell currents. If you select this parameter, the value at the Current input port can be a scalar or a vector of size equal to the size of the block inputs.
Type of Kalman filter that this block uses to estimate the battery state of charge.
Coefficient that controls the spread of the sigma points. The block uses this parameter in its implementation of the equations for the unscented Kalman filter and the unscented Kalman-Bucy filter.
To enable this parameter, set
Filter type
to
Unscented Kalman filter
or
Unscented Kalman-Bucy filter
.
Coefficient related to the distribution. The block uses this parameter in its implementation of the unscented Kalman filter and the unscented Kalman-Bucy filter.
To enable this parameter, set
Filter type
to
Unscented Kalman filter
or
Unscented Kalman-Bucy filter
.
Coefficient that controls the spread of the sigma points. The block uses this parameter in its implementation of the equations for the unscented Kalman filter and the unscented Kalman-Bucy filter.
To enable this parameter, set
Filter type
to
Unscented Kalman filter
or
Unscented Kalman-Bucy filter
.
2
-by-
2
covariance matrix of the noise in the
states.
Covariance of the noise in the measurements.
2
-by-
2
covariance matrix of the
initial state error. This parameter defines the deviation in the
initialization of the state.
Time between consecutive block executions. During execution, the block produces outputs and, if appropriate, updates its internal state. For more information, see What Is Sample Time? and Specify Sample Time .
For inherited discrete-time operation, specify this parameter as
-1
. For discrete-time operation, specify this
parameter as a positive integer. For continuous-time operation, specify
this parameter as
0
.
If this block is in a masked subsystem or a variant subsystem that supports switching between continuous operation and discrete operation, promote the sample time parameter. Promoting the sample time parameter ensures correct switching between the continuous and discrete implementations of the block. For more information, see Promote Block Parameters on a Mask .
To enable this parameter, set
Filter type
to
Extended Kalman filter
or
Unscented Kalman filter
.
Since R2024a
Option to model the battery charge dynamics. This parameter determines the number of parallel RC sections in the equivalent circuit:
One time-constant dynamics
— The equivalent circuit
contains one parallel RC section. Specify the polarization resistance and the
time constant using the
First polarization resistance, R1(SOC,T),
(ohm)
and
First time constant, tau1(SOC,T),
(s)
parameters.
Two time-constant dynamics
— The equivalent circuit
contains two parallel RC sections. Specify the polarization resistances and the
time constants using the
First polarization resistance, R1(SOC,T),
(ohm)
,
First time constant, tau1(SOC,T),
(s)
,
Second polarization resistance, R2(SOC,T),
(ohm)
, and
Second time constant, tau2(SOC,T),
(s)
parameters.
Vector of the state of charge breakpoints defining the points at which you specify lookup data. The entries of this vector must be in strictly ascending order. The block calculates the state of charge value with respect to the nominal battery capacity specified in the Cell capacity, AH (A*Hr) parameter. The SOC is the ratio of the available battery charge q battery and the nominal battery capacity q nom (T,n) . You must make sure that, for each temperature value, an SOC of 1 represents the battery charge capacity for the corresponding element of the Cell capacity, AH (A*Hr) parameter when you model a fresh battery with a number of cycles N equal to 1 and δ AH (n = 1, T fade ) equal to 0:.
Vector of temperature breakpoints defining the points at which you specify lookup data. This vector must be strictly ascending and greater than 0 K. The physical unit of this parameter must be the same as the physical unit of the CellTemperature input port.
Lookup data for series resistance of the battery at the specified SOC and temperature breakpoints.
Lookup data, in ohm, for the first parallel RC resistance at the specified SOC and temperature breakpoints. The number of rows of this matrix is equal to the size of the Vector of state-of-charge values, SOC (-) parameter. The number of columns of this matrix is equal to the size of the Vector of temperatures, T parameter.
Lookup data, in second, for the first parallel RC time constant at the specified SOC and temperature breakpoints. The number of rows of this matrix is equal to the size of the Vector of state-of-charge values, SOC (-) parameter. The number of columns of this matrix is equal to the size of the Vector of temperatures, T parameter.
Since R2024a
Lookup data, in ohm, for the second parallel RC resistance at the specified SOC and temperature breakpoints. The number of rows of this matrix is equal to the size of the Vector of state-of-charge values, SOC (-) parameter. The number of columns of this matrix is equal to the size of the Vector of temperatures, T parameter.
To enable this parameter, set
Charge dynamics
to
Two time-constant dynamics
.
Since R2024a
Lookup data, in second, for the second parallel RC time constant at the specified SOC and temperature breakpoints. The number of rows of this matrix is equal to the size of the Vector of state-of-charge values, SOC (-) parameter. The number of columns of this matrix is equal to the size of the Vector of temperatures, T parameter.
To enable this parameter, set
Charge dynamics
to
Two time-constant dynamics
.
Lookup data, in volt, for open-circuit voltages across the fundamental battery model at the specified SOC. The number of rows of this matrix is equal to the size of the Vector of state-of-charge values, SOC (-) parameter. The number of columns of this matrix is equal to the size of the Vector of temperatures, T parameter.
Cell capacity of the battery, in ampere-hour. The block calculates the state of charge by dividing the accumulated charge by this value. The block calculates the accumulated charge by integrating the battery current.
Since R2025a
Option to choose the data type for the block algorithm, specified as one of these values:
Inherit: auto
— You can simulate the block in
both
single
and
double
precision. You must explicitly provide the inputs and parameters as either
single
or
double
.
double
— The block algorithm casts all inputs
and parameters to
double
data type.
single
— The block algorithm casts all inputs
and parameters to
single
data type.
<data type expression>
— The block
algorithm casts all inputs and parameters to the data type object you
specify.
Click the
Show data type assistant
button
to display the
Data Type Assistant
, which helps you set the data type attributes. For more information, see
Specify Data Types Using Data Type Assistant
and
Control Data Types of Signals
.
[1] Grewal, Mohinder S., and Angus P. Andrews. Kalman Filtering: Theory and Practice Using MATLAB. New York: Wiley Intersci., 2001.
[2] Van der Merwe, R., 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), vol. 6, IEEE, 2001, pp. 3461–64.
[3] Sarkka, Simo 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.
[4] Huria, Tarun, et al. Simplified Extended Kalman Filter Observer for SOC Estimation of Commercial Power-Oriented LFP Lithium Battery Cells. 2013, pp. 2013-01–1544.
You can now easily switch between single-precision and double-precision floating-point simulation of the block algorithm by using the Algorithm data type parameter.
You can now estimate the battery SOC by using equivalent models with two time-constant charge dynamics.
To select an equivalent model with two time-constant charge dynamics, set the
Charge dynamics
parameter to
Two time-constant dynamics
and specify the values of the new
Second polarization resistance, R2(SOC,T), (ohm)
and
Second time constant, tau2(SOC,T), (s)
parameters.
You can now specify the value of the Current input port as a vector of cell currents.
To enable a vectorized input, select the Specify Current input as cell current(s) parameter. If you select this parameter, the Current input port must have the same size as the other inputs and represents individual cell currents.
SOC Estimator (Adaptive Kalman Filter) | SOC Estimator (Coulomb Counting) | SOC Estimator (Coulomb Counting, Variable Capacity) | SOH Estimator
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.