Joint Estimation of SOC of Lithium Battery Based on Dual Kalman Filter

: In order to improve the estimation accuracy of the state of charge (SOC) of electric vehicle power batteries, a dual Kalman ﬁlter method based on the online identiﬁcation of model parameters is proposed to estimate the state of charge in lithium-ion batteries. Here, we build the ﬁrst-order equivalent circuit model of lithium-ion batteries and derive its online identiﬁcation model based on extended Kalman (EKF). Considering that the noise value in the EKF algorithm is difﬁcult to select through experiments to achieve the best ﬁltering effect, this paper combines an improved particle swarm optimization algorithm (IPSO) with EKF to realize online model parameter identiﬁcation. At the same time, the EKF ﬁltering method derived from the state space equation is also used in SOC estimation. It constitutes a dual Kalman ﬁlter method for online identiﬁcation of model parameters and SOC estimation. The experimental and simulation results show that the IPSO–EKF algorithm can adaptively adjust the noise value according to the complex operating conditions of electric vehicles. Compared with the EKF algorithm, our algorithm can identify battery model parameters more accurately. The dual Kalman ﬁlter method composed of the IPSO–EKF algorithm and EKF applied to SOC estimation achieved a higher accuracy in the ﬁnal algorithm veriﬁcation.


Introduction
The state of charge (SOC) in a battery represents how much power is stored inside the battery. It is one of the important states of the battery and is an important basis for the vehicle's control system to formulate an efficient energy distribution strategy [1,2]. Therefore, accurate estimation of the battery SOC is of great significance to prolong its service life, to improve vehicle performance, and to reduce costs.
From the perspective of engineering application, the common battery SOC estimation methods mainly include the ampere-hour integration method, the open circuit voltage method, and methods based on a battery equivalent circuit model [3]. The ampere-hour integral method is simple to calculate, but it has high requirements for the accuracy of the initial value, is easy to produce cumulative errors during the estimation process, and cannot be self-corrected [4][5][6][7]. The open-circuit voltage of the open-circuit voltage method needs to be obtained by standing the battery up completely, which is not suitable for direct application in real vehicles and is generally used in conjunction with the ampere-hour integration method [8,9]. The method based on the battery equivalent circuit model uses electronic components such as capacitors and resistors to form an electrical model that can reflect the charging and discharging characteristics of the battery, to then identify the model parameters with the relevant test data of the battery, and to finally select an algorithm to estimate SOC [10]. Whether the model parameters can be accurately identified directly affects the accuracy of the SOC estimation. The current research methods of parameter identification mainly include offline and online identification. For the offline identification, the least square method (LS) is mostly used, which applies the voltage response characteristics of constant current pulse discharge [11]. Luo et al. [12] used a simulated annealing algorithm that does not require initial parameters, has a fast convergence rate, and can obtain a global optimum to identify parameters. However, the battery's operating conditions are complicated, where the current and voltage change frequently during the driving process, and as the operating temperature changes, the number of charge and discharge cycles increases and the battery model parameters also change. Therefore, the offline method cannot identify the battery model parameters under working conditions in real time.
The online identification methods are divided into intelligent algorithms and modelbased filtering algorithms. The first subclass, intelligent algorithms, includes artificial neural network (ANN) [13] and the fuzzy logic algorithm [14], the accuracy of which depends on the comprehensiveness and accuracy of the training data. In the second subclass, Extend Kalman filter (EKF) can modify the prior estimation based on the measurement information at the current time to obtain the optimal state estimation for the purpose of minimizing the mean variance [15,16]. Wang et al. [17] proposed a recursive least squares-extended Kalman filter (RLS-EKF) algorithm, which used the recursive least squares method to achieve online parameter identification and then was combined with the extended Kalman filter to estimate the battery SOC. Partovibakhsh et al. [18] used an adaptive extended Kalman filter (AEKF) and the recursive least square method to estimate the open-circuit voltage (OCV) and then estimated the battery SOC through the SOC-OCV relationship. The experimental results showed that this method has a certain improvement effect. The key point of EKF lies in the selection of system noise and measurement noise covariance, which are contradictory to each other: the greater the former, the greater the gain, which improves the dynamic performance of the system but increases the uncertainty of the system [19]. However, the increase in the latter makes the gain smaller, so the transient response performance of the system decreases and the filter is unable to modify the state variables in time. Therefore, how to select noise to achieve a dynamic balance in the system is the focus of this paper.
In this paper, the first-order RC equivalent circuit model of a ternary lithium battery is established, and EKF is used to identify the model parameters online. In order to reasonably determine the system noise and the measured noise covariance in the EKF algorithm, the improved particle swarm optimization algorithm (IPSO) is adopted for noise optimization. In addition, the IPSO-EKF algorithm is combined with EKF to form a dual extend Kalman filter (DEKF), which updates the battery model parameters and state in each cycle to realize the real-time joint estimation of the battery SOC.

Establish the Equivalent Circuit Model of the Battery
The battery equivalent circuit models mainly include Rint, Thevenin, and PNGV. A ternary lithium battery with a nominal capacity of 10 Ah is chosen as the experimental object, for which the voltage limits are 4.2 V and 2.75 V, respectively. Considering the battery type, model accuracy, and cost [20][21][22], the Thevenin model with a first-order resistance-capacitance (RC) circuit model shown in Figure 1 is adopted in this paper.
Processes 2021, 9, x FOR PEER REVIEW 2 of 11 methods of parameter identification mainly include offline and online identification. For the offline identification, the least square method (LS) is mostly used, which applies the voltage response characteristics of constant current pulse discharge [11]. Luo et al. [12] used a simulated annealing algorithm that does not require initial parameters, has a fast convergence rate, and can obtain a global optimum to identify parameters. However, the battery's operating conditions are complicated, where the current and voltage change frequently during the driving process, and as the operating temperature changes, the number of charge and discharge cycles increases and the battery model parameters also change. Therefore, the offline method cannot identify the battery model parameters under working conditions in real time.
The online identification methods are divided into intelligent algorithms and modelbased filtering algorithms. The first subclass, intelligent algorithms, includes artificial neural network (ANN) [13] and the fuzzy logic algorithm [14], the accuracy of which depends on the comprehensiveness and accuracy of the training data. In the second subclass, Extend Kalman filter (EKF) can modify the prior estimation based on the measurement information at the current time to obtain the optimal state estimation for the purpose of minimizing the mean variance [15,16]. Wang et al. [17] proposed a recursive least squaresextended Kalman filter (RLS-EKF) algorithm, which used the recursive least squares method to achieve online parameter identification and then was combined with the extended Kalman filter to estimate the battery SOC. Partovibakhsh et al. [18] used an adaptive extended Kalman filter (AEKF) and the recursive least square method to estimate the open-circuit voltage (OCV) and then estimated the battery SOC through the SOC-OCV relationship. The experimental results showed that this method has a certain improvement effect. The key point of EKF lies in the selection of system noise and measurement noise covariance, which are contradictory to each other: the greater the former, the greater the gain, which improves the dynamic performance of the system but increases the uncertainty of the system [19]. However, the increase in the latter makes the gain smaller, so the transient response performance of the system decreases and the filter is unable to modify the state variables in time. Therefore, how to select noise to achieve a dynamic balance in the system is the focus of this paper.
In this paper, the first-order RC equivalent circuit model of a ternary lithium battery is established, and EKF is used to identify the model parameters online. In order to reasonably determine the system noise and the measured noise covariance in the EKF algorithm, the improved particle swarm optimization algorithm (IPSO) is adopted for noise optimization. In addition, the IPSO-EKF algorithm is combined with EKF to form a dual extend Kalman filter (DEKF), which updates the battery model parameters and state in each cycle to realize the real-time joint estimation of the battery SOC.

Establish the Equivalent Circuit Model of the Battery
The battery equivalent circuit models mainly include Rint, Thevenin, and PNGV. A ternary lithium battery with a nominal capacity of 10 Ah is chosen as the experimental object, for which the voltage limits are 4.2 V and 2.75 V, respectively. Considering the battery type, model accuracy, and cost [20][21][22], the Thevenin model with a first-order resistance-capacitance (RC) circuit model shown in Figure 1 is adopted in this paper.  I is the operating current, and the charging direction is the positive direction of the current; R 1 is the polarization internal resistance; C 1 is the polarization capacitance; U 1 is the polarization ring terminal voltage; and U t is the battery terminal voltage [23].
According to Kirchhoff's voltage law and Kirchhoff's current law, the electrical relationship of the equivalent circuit model can be obtained as follows: .

EKF Algorithm
The Kalman filter is the optimal state estimator for a linear system, but due to the nonlinearity of the battery system, direct use of the Kalman filter algorithm for parameter or state estimation produces a large error, so we use the extended Kalman algorithm (EKF) to linearize the nonlinear function by first-order Taylor-series expansion.
The nonlinear discrete-time system is modeled as follows: where f (•) is a nonlinear state transition function and g(•) is a nonlinear measurement function. w k and v k are zero-mean white Gaussian stochastic processes with covariance matrixes Q k and R k , respectively. u k and y k are system input and output, respectively. Then, f (•) and g(•) are linearized by first-order Taylor-series expansion when x k =x k , where 'ˆ'represents a posterior estimate, so we have the linear system: Here, Based on the above system, EKF filtering recursion is performed as follows: Initialization: Computation:

Online Identification Model Based on EKF
When EKF is used for the online identification of battery model parameters, the firstorder RC equivalent circuit model of a ternary lithium battery is first transformed into the state space form as shown in Equation (3). The derivation process is as follows: The state vector x k , the parameters of the model to be estimated can be approximately regarded as unchanged in a short time interval because the changes of factors affecting the model parameters such as battery SOC and temperature can be ignored in a very short time interval [24]. On this premise, the recursive expression of I 1 is derived from the relationship between ∆U 1 , ∆I 1 , and R 1 within the sampling interval T = 1 s: where τ = R 1 C 1 .
The nonlinear discrete-time state space equation as shown in Equation (2) can be obtained:  where x k = [U oc,k , R 0,k , R 1,k , C 1,k, I 1,k ]; I k and U t,k are system input and output at time index k, respectively; Q k = diag ([a 11 , a 22 , a 33 , a 44 , a 55 ]); R k = diag(m); a 11 , a 22 , a 33 , a 44 , and a 55 are the main diagonal elements of the noise covariance matrix Q k ; and m is the main diagonal element of the measured noise covariance matrix R k . At each time step, f (•) and g(•) are linearized by a first-order Taylor-series expansion.

Optimizing Noise Matrix Based on IPSO
The particle swarm optimization (PSO) algorithm was developed to simulate the movement of bird flock predation. The particles X i = (x i1 , x i2 , . . . , x iD ) in the D-dimensional space have two attributes: position and velocity, which represent the direction and speed of movement, respectively. Each particle's positional coordinates represent the candidate solution of the problem. The positions and velocities are adjusted, and the function is evaluated with the new coordinates at each time step [25]. P_best represents the optimal solution searched by each particle individually, and g_best is the global optimal solution Processes 2021, 9, 1412 5 of 10 that is the best p_best at each iteration. For each generation, the velocity and position of the jth dimension (1 ≤ j ≤ D) are updated, as Equation (13) shows: where w is the inertia weight factor, c 1 and c 2 are acceleration factors, and r 1 and r 2 are random constants with values ranging from 0 to 1. In this paper, since the optimization object is a noise matrix, then X i = [a 11 , a 22 , a 33 , a 44 , a 55 , m].
The focus of the PSO is on the setting of the evaluation function. The optimization of the noise matrix in the EKF algorithm using PSO is to improve the accuracy of battery parameter identification, which is reflected by the error between the predicted and the actual terminal voltage: the smaller the error, the higher the accuracy. Therefore, the evaluation function is set to the following: where N is the length of the data vector, k is the sampling time, and U t is the measured terminal voltage.Û t is the terminal voltage estimated by EKF using the optimized noise value for identification at time k. According to the model, the terminal voltage recursion relationship is as follows:Û Then,Û t,k = θ 1,k U t,k−1 + θ 2,k I k + θ 3,k I k−1 + θ 4,k where θ 4,k = U OC, k − U oc,k−1 θ 1,k The defect of the PSO is that it is easy to fall into the local best state. Therefore, the key to improving the PSO algorithm is to promote continuous update of the local and global optimal positions in order to jump out of the local best position and to continue to search for a better solution. Based on this, the weight factor w is set to linearly decrease with the number of iterations in the range of [0.95, 0.2], thereby expanding the early search ability and increasing the convergence speed in the later period.

Identification Based on IPSO-EKF
Identification of the model parameters based on IPSO-EKF is first to use IPSO to optimize the noise matrix of EKF according to the current working condition in order to reduce the terminal voltage error at every moment; then, EKF uses the updated noise value for filtering; and the model parameter vector x k online are identified at last. The specific algorithm process is as follows: Step 1: set the initial values

EKF
x 0 = [4.18, 0.10, 0.10, 1000, 0]. After several times of algorithm debugging, the value range of the main diagonal element of Q k is set to 0~10 −4 , and the value range of the main diagonal element of R k is set to 0~1.

IPSO
Processes 2021, 9, 1412 6 of 10 The size of the population is 200. The maximum number of iterations is 30. Every particle is initialized with random positions and velocities, and a function is evaluated to obtain the initial p_best and g_best using the particle's positional coordinates as input values [26].
Step 2: Determine whether the maximum number of iterations is reached; if so, jump directly to Step 4.
Step 3: Evaluate the function to determine whether the update conditions of velocity and position are met. If so, update p_best and g_best at the same time; otherwise, execute the next step.
Step 4: Assign the positional coordinates of g_best found in Step 3 to the noise covariance matrix Q k , R k .
Step 5: Use the EKF algorithm to identify the parameter value online with the current and voltage at the current moment, and then, return to Step 3 to perform the IPSO optimization at the next moment.

Comprehensive Battery Model
Derived from Equation (1), the model discrete equation is as follows: On this basis, it is combined with the ampere-hour integration method to obtain a comprehensive model for estimating battery SOC, which takes U 1 and SOC as the system state, and I and U t as the system input and output, respectively, and is transformed into the form of Equation (3). Then, where η is the charge and discharge efficiency, which can be obtained through the charge and discharge test. SOC (0) is the SOC value under the current OCV by linear interpolation using the SOC-OCV relationship obtained from the experiment.

SOC Estimation Based on IPSO-DEKF
The basic idea of IPSO-DEKF to estimate the battery SOC is to update the state and measured equations in the EKF algorithm used for SOC estimation using model parameter values identified by IPSO-EKF with the current input and then to perform the time and measurement update process to estimate the SOC value at the next moment. The schematic diagram is shown in Figure 2.

SOC Estimation Based on IPSO-DEKF
The basic idea of IPSO-DEKF to estimate the battery SOC is to update the state and measured equations in the EKF algorithm used for SOC estimation using model parameter values identified by IPSO-EKF with the current input and then to perform the time and measurement update process to estimate the SOC value at the next moment. The schematic diagram is shown in Figure 2.

Test and Simulation Analysis
The technical parameters of the lithium-ion battery selected in this article are as follows: rated capacity 10 Ah, rated cell voltage 3.7 V, charge cutoff voltage 4.2 V, and discharge cutoff voltage 2.75 V.
First, the static capacity test (SCT) is carried out three times on the ternary lithium battery, and the average value of the three measured capacities is taken as the test capacity of 9.964 Ah. Then, the dynamic stress test (DST) is performed after standard charging of the battery. Each configuration file is a series of constant power discharge/charge steps with a duration of 360 s. The specific test process refers to the electric vehicle battery experiment manual. A total of 26 cycles are performed in this test, and the sampling interval time is T s = 1 s. The current and voltage of the DST working condition are imported into the IPSO-EKF and EKF algorithms. The parameter identification results of the IPSO-EKF are shown in Figure 3: Processes 2021, 9, x FOR PEER REVIEW 8 of 11

Test and Simulation Analysis
The technical parameters of the lithium-ion battery selected in this article are as follows: rated capacity 10 Ah, rated cell voltage 3.7 V, charge cutoff voltage 4.2 V, and discharge cutoff voltage 2.75 V.
First, the static capacity test (SCT) is carried out three times on the ternary lithium battery, and the average value of the three measured capacities is taken as the test capacity of 9.964 Ah. Then, the dynamic stress test (DST) is performed after standard charging of the battery. Each configuration file is a series of constant power discharge/charge steps with a duration of 360 s. The specific test process refers to the electric vehicle battery experiment manual. A total of 26 cycles are performed in this test, and the sampling interval time is Ts = 1 s. The current and voltage of the DST working condition are imported into the IPSO-EKF and EKF algorithms. The parameter identification results of the IPSO-EKF are shown in Figure 3: First, as Figure 3a shows, both EKF and IPSO-EKF can track the test value well in the identification of OCV, which is not very different from the test value, but the lowest OCV values that IPSO-EKF and EKF can track are 3.59 V and 3.61 V, and the corresponding SOC are 0.255 and 0.283, respectively. The minimum SOC under test is 0.250; therefore, in the tracking of OCV, IPSO-EKF is closer to the test value. In the identification results of the other three parameters, it is obvious that there are large differences between the IPSO-EKF and EKF from Figure 3b to Figure 3d. The waveforms of the results identified by the First, as Figure 3a shows, both EKF and IPSO-EKF can track the test value well in the identification of OCV, which is not very different from the test value, but the lowest OCV values that IPSO-EKF and EKF can track are 3.59 V and 3.61 V, and the corresponding SOC are 0.255 and 0.283, respectively. The minimum SOC under test is 0.250; therefore, in the tracking of OCV, IPSO-EKF is closer to the test value. In the identification results of the other three parameters, it is obvious that there are large differences between the IPSO-EKF and EKF from Figure 3b to Figure 3d. The waveforms of the results identified by the two methods are roughly the same: the moments when the highest and the lowest peak appear are the same. However, there is a large gap between each peak and trough position. It can be seen that the peak value of IPSO-EKF is higher than EKF, and the valley value is lower than EKF, especially in the R 1 and τ, and the comparison of the accuracy of the two methods is reflected in the terminal voltage tracking. Then, the identification results of R 1 and τ jitter violently and even appear to have negative values in about 50-70 s, which is caused by the battery's internal reaction being more violent under complex working conditions, indicating that the EKF algorithm is affected by the working conditions and is not stable at the initial stage, making the identified results inaccurate, which is not conducive to the subsequent SOC state estimation, while IPSO-EKF can adjust the noise value according to the working conditions to adapt to the dynamic changes in the battery under complex working conditions. Therefore, the identified results do not have such meaningless parameters and maintain a good stability.
The parameters identified by the two algorithms are brought into Equation (18) to obtain the estimated terminal voltages at the same time, which are shown in Figure 4a. We subsequently verified the parameter estimation accuracy by comparing the predicted voltage with the measured voltage, and the absolute errors between them of two algorithms are shown in Figure 4b.
Processes 2021, 9, x FOR PEER REVIEW 9 of 11 the two methods is reflected in the terminal voltage tracking. Then, the identification results of R1 and τ jitter violently and even appear to have negative values in about 50-70 s, which is caused by the battery's internal reaction being more violent under complex working conditions, indicating that the EKF algorithm is affected by the working conditions and is not stable at the initial stage, making the identified results inaccurate, which is not conducive to the subsequent SOC state estimation, while IPSO-EKF can adjust the noise value according to the working conditions to adapt to the dynamic changes in the battery under complex working conditions. Therefore, the identified results do not have such meaningless parameters and maintain a good stability. The parameters identified by the two algorithms are brought into Equation (18) to obtain the estimated terminal voltages at the same time, which are shown in Figure 4a. We subsequently verified the parameter estimation accuracy by comparing the predicted voltage with the measured voltage, and the absolute errors between them of two algorithms are shown in Figure 4b.  As Figure 4a shows, the terminal voltage tracked by the EKF fluctuates greatly during the period when R1 and τ appear to be negative values, and the oscillation phenomenon occurs. It can also can be seen that the maximum error of the terminal voltage is at this moment, which is up to 2.45 V. As the inaccurate parameters identified by the EKF cause a large error in the estimated terminal voltage during this period, EKF is greatly affected by the working conditions and it is prone to identification distortion in the early stage under complex working conditions. Compared with EKF, the parameter values identified by IPSO-EKF have no abnormal fluctuations, so the estimated terminal voltage is relatively stable, with the maximum error of 0.128 V. In terms of parameter accuracy, it can be seen from Figure 4b that the terminal voltage error estimated by IPSO-EKF is smaller than that of EKF at every moment, among which the average error of EKF is 0.025 V and that of IPSO-EKF is 0.006 V, indicating that the model parameter values identified by IPSO-EKF are more accurate.
The IPSO-EKF and EKF are combined to form a dual Kalman filter to estimate SOC, where the true value of SOC is obtained by ampere-hour integration. The comparison of As Figure 4a shows, the terminal voltage tracked by the EKF fluctuates greatly during the period when R 1 and τ appear to be negative values, and the oscillation phenomenon occurs. It can also can be seen that the maximum error of the terminal voltage is at this moment, which is up to 2.45 V. As the inaccurate parameters identified by the EKF cause a large error in the estimated terminal voltage during this period, EKF is greatly affected by the working conditions and it is prone to identification distortion in the early stage under complex working conditions. Compared with EKF, the parameter values identified by IPSO-EKF have no abnormal fluctuations, so the estimated terminal voltage is relatively stable, with the maximum error of 0.128 V. In terms of parameter accuracy, it can be seen from Figure 4b that the terminal voltage error estimated by IPSO-EKF is smaller than that of EKF at every moment, among which the average error of EKF is 0.025 V and that of IPSO-EKF is 0.006 V, indicating that the model parameter values identified by IPSO-EKF are more accurate.
The IPSO-EKF and EKF are combined to form a dual Kalman filter to estimate SOC, where the true value of SOC is obtained by ampere-hour integration. The comparison of experiments is shown in Figure 5. From the SOC change graph on the left, the algorithm's SOC estimation value follows the test value very well. Looking specifically at the SOC estimation error on the right, the SOC estimation error is extremely small, the maximum SOC estimation error is 0.51%, and the average estimation error is 0.24%.

Conclusions
In this paper, based on the first-order RC equivalent circuit model, an online identification parameter model based on EKF is derived. For the problem that the noise value in the EKF algorithm is difficult to determine, it is proposed to combine it with the IPSO algorithm to adjust the noise value adaptively according to the current working conditions for the purpose of reducing terminal voltage error. The results show that IPSO-EKF can better track the OCV and maintain a good stability in the identification of other three parameters without the occurrence of meaningless parameter results by comparing with EKF. Moreover, the terminal voltage error using parameter values identified by IPSO-EKF is smaller, indicating that the accuracy of IPSO-EKF identification model parameters is higher. Then, a method of combining IPSO-EKF and EKF to form a double Kalman filter to estimate SOC is proposed, of which the result shows that the IPSO-DEKF algorithm can accurately track SOC.