A parameter adaptive method for state of charge estimation of lithium-ion batteries with an improved extended Kalman filter

An accurate state of charge (SOC) estimation in battery management systems (BMS) is of crucial importance to guarantee the safe and effective operation of automotive batteries. However, the BMS consistently suffers from inaccuracy of SOC estimation. Herein, we propose a SOC estimation approach with both high accuracy and robustness based on an improved extended Kalman filter (IEKF). An equivalent circuit model is established, and the simulated annealing-particle swarm optimization (SA-PSO) algorithm is used for offline parameter identification. Furthermore, improvements have been made with noise adaptation, a fading filter and a linear-nonlinear filtering based on the traditional EKF method, and rigorous mathematical proof has been carried out accordingly. To deal with model mismatch, online parameter identification is achieved by a dual Kalman filter. Finally, various experiments are performed to validate the proposed IEKF. Experimental results show that the IEKF algorithm can reduce the error to 2.94% under dynamic stress test conditions, and robustness analysis is verified with noise interference, hence demonstrating its practicability for extending to state estimation of battery packs applied in real-world operating conditions.

, the ohmic resistance R o and a RC network. R p and C p are the polarization resistance and capacitance respectively. U L is the terminal voltage, I L is the current (assumed positive for charge, negative for discharge). U p describes the polarization voltage over the RC network.
For Eq. (1) and Eq. (2), a Laplace transform is used to establish a state-space equation for the Thevenin ECM, shown as Eq. (3): where T s is the sampling interval, w k is the processing noise.
The systematic observation equation is shown in Eq. (4): where: v k is the observation noise.
For the established state-space model, the parameters to be identified consist of C p , R o and R p . Classical methods for parameter identification are divided into offline and online methods. Since the parameters of the battery are greatly affected by the SOC, state of health (SOH) (representing the battery remaining life) as well as temperature and charging/discharging current, it is difficult to obtain accuracy parameters if relying on interpolated values which were acquired from simple offline parameter identification tests. Therefore, in this article, online parameter identification is applied to obtain better precision of the battery parameters, which is called DKF as shown in "IEKF and parameter adaptation". To speed up the fitting process, a SA-PSO method has been developed for offline parameter identification, which can be used as the initial value of online estimation and implemented for model correction.
Offline parameter identification. Although online parameter identification can effectively improve the accuracy of the ECMs, the algorithm used will degenerate if initialization of parameters deviates too much from the true value, and result in a lower convergence speed because the parameters correction relies on observation values. Therefore, a SA-PSO method has been adopted for identifying the parameters offline as the initial value of online identification.
The SA algorithm originates from the industrial annealing process and has been applied for various scenarios 22 . For each feasible solution generated, the value of the fitness function (marked as f(x)) is calculated and the optimal solution is selected according to the Metropolis principle which is a type of resampling method. In this article, the new state will be generated by a normal distribution. When the system status varies from x 0 to x, there is a probability: where P is the probability of the new state being acceptable; E is the energy of system, which can be abstract as the fitness function and T is the annealing temperature. In this article, we use the root mean squared error (RMSE) between the simulated voltage and the real voltage as the fitness function.
If E x0 < E x , the new status will be accepted; otherwise, the new status will be discarded by the probability: During each annealing temperature, L times iteration will be executed. After the iterative process is completed, T will be updated as Eq. (7) the maximum posteriori estimation proposed where K is the annealing rate. The performance of SA is significantly influenced by the annealing rate and a fully slow annealing is appreciated for the best solution searching. Therefore, K is 0.99 in this article. The SA algorithm can search the global-best solution; however, the capability of a global search relies on a sufficiently high temperature initialization and a sufficiently slow cooling process. Therefore, the SA algorithm converges slowly, but can be optimize by coupling this with an intelligent optimization method 23 .
The PSO algorithm belongs to the group intelligent optimization methods and is derived from the study of bird predation behaviors. PSO, including its implement, has been widely used for parameter identification 24,25 . In the PSO algorithm, each potential solution can be abstracted as a particle in state-space with each particle having a position and velocity. All particles simultaneously search for the individual-best solution and group-best solution in the given state-space. The position-speed update equation is shown as Eq. (8).
(2) where ω is the inertia weight; c 1 and c 2 are learning factors; r 1 and r 2 are random numbers between 0 and 1; v is the velocity of particle; x is the current solution; p is the individual-best solution and g is the group-best solution.
In this article, we assume that c 1 = c 2 = 1.5, and ω = 0.8. The position can thus be updated by Eq. (9): The PSO algorithm has a high convergence speed, but it is intended to converge to a local-best solution.
To optimize the SA algorithm and the PSO algorithm, a coupled SA-PSO algorithm is proposed to speed up convergence speed and avoid the algorithm falling into local optimum. The specific implementation manner can thus be depicted as follows: Step 1: set the initial annealing temperature, and perform a Monte Carlo search at each temperature to find the global equilibrium status.
Step 2: when each particle is iteratively updated in the particle swarm algorithm, the Metropolis criterion is adopted to accept the new particle status.
Step 3: loop at each annealing temperature until the number of iterations reaches the maximum or a satisfactory convergence is achieved.
Using this method, the algorithm not only avoids local optimum, but also guarantees the Monte Carlo simulation process of the annealing algorithm to ensure the ability to search the global parameter space. The SA-PSO algorithm can be depicted as Fig. 2.
Pulse discharge experiments were carried out to validate the algorithm. The experiment results are shown in Fig. 3a. According to Eq. (2), the system has zero-input in the voltage rebound phase, which can be used to fit R p and C p values, and the voltage step at the end of the pulse discharge can be used to fit R o . The offline parameter identification fitting results are shown in the Fig. 3b. Moreover, the error bars of Ro and Rp are presented as Fig. 3c,d, which are demonstrated based on the multi-times simulation results. Considering the error analysis based on error bars, the adopted models generally predict the battery characteristics and can be applied for states estimation.

IEKF and parameter adaptation
Traditional EKF. The classical Kalman filter performs poorly in state estimation problems when dealing with nonlinear systems. The main cause is that there are nonlinear integral equations when the state and observers update. Based on Bayesian filtering theory, nonlinear systems that satisfy Markov characteristics can be depicted as Eq. (10): www.nature.com/scientificreports/ where p is the probability of state transfer, and x is the system state, and z is the system observation.
The priori information (one-step prediction equation) can be defined as Eq. (11) and state updating equation as Eq. (12): p(z k |z k−1 ) is maximum likelihood function. Equation (11) and Eq. (12) represent the prediction and updating process respectively. The classical linear Kalman filter has difficulty in calculating Eq. (11) and Eq. (13) precisely. Therefore, some improvement is needed to improve the algorithm performance. Here, a Taylor series expansion of the nonlinear equations is used to achieve linearization, which is called EKF. The EKF has first-order polynomial precision, for which it discards the quadratic term and high order terms (Table 1). For the nonlinear system described in Eq. (14):  Extended Kalman filter can be summarized as Table 2.
The linearization process can be expressed as follows: Improved EKF. Although the EKF improves the ability of the algorithm to cope with nonlinear systems, more improvements are needed for complex system state tracking problems in practical applications. For realworld battery pack, the system noise is often non-Gaussian, such as the constant deviation of the current and voltage sensor, especially for large capacity battery packs. Additionally, the characteristics are strongly coupled with battery capacity degradation, ambient temperature and dynamic working conditions, affecting the accuracy and robustness of the SOC estimation. Therefore, some optimization is adopted to improve the EKF algorithm to impair the influences of the factors mentioned.
Adaptive noise. For the Kalman filter, signal noise can be separated into process noise and environmental noise. The process noise characterizes the reliability of the proposed model, and the environmental noise often originates from errors caused by the sensor and environmental disturbance during the actual measurement. Both noises have great impacts on the performance of the filtering system, mainly affecting the convergence and accuracy of the system 26 . For a converged Kalman filter, the system is considered to be converged to a stable value at an infinite moment as shown in Eq. (15) According to the covariance matrix updating the EKF, the Kalman Gain converges to a constant value along with the convergent covariance matrix. Therefore, the Kalman filter will degrade to a low-pass filter, and the Kalman Gain is only determined by system noise, which affects the precision.
On the other hand, the process noise influences convergence speed of the system. The existence of noise can assist the system to gradually converge to the true value when there is a deviation, and the convergence speed depends on the amplitude of the noise. In real operating conditions, it is generally expected that there is (14) x

Prediction module
where:

Updating module
Kalman gain www.nature.com/scientificreports/ a larger noise in the initial stage of filtering to enhance the influence of correcting initial value deviation and enhancing the convergence speed of the filtering. However, when the filter is stabilized, it is ideal for the noise to be attenuated for higher accuracy. Therefore, it is of great practical significance to achieve adaptive system noise 27 . The adaptive noise can be effectively implemented with observation. The demand of data storage for recursive process is small, and with the low dimensions of the matrix A, B, C, the adaptive algorithm has obvious advantage for calculation. The adaptive algorithm based on the maximum posteriori estimation proposed for discrete systems can be characterized as Eq. (16) and (17) 28 : where Fading filter. The fading filter is a method to enhance the system's ability for utilizing observation measurement to optimize divergence phenomenon when filtering. Due to the rounding error when calculating with computers, the covariance matrix may not be positive during the iterative process, leading to the filtering system oscillating or diverging. In addition, when the system model is severely mismatched, the correction of the system can only be achieved with observation. Therefore, enhancing the observation proportion when updating the status can improve the stability and robustness of the algorithm.
Classical EKF algorithms assume that the total filtering time domain is N, for the arbitrary time k in the time domain, thus we have: Take s as the fading factor, and multiply both sides of the Eq. (19) by s -(N-k) : Note: Then Eq. (19) can be expressed as Eq. (22): Equation (18) can be replaced by Eq. (22) to optimize the covariance matrix updating, and the covariance matrix has been enlarged by s times compared with the original equation which reveals that the utilization ability for measurement has been enhanced.
The fading factor of Eq. (22) can select a constant larger than 1, and can also be adaptively updated according to the degree of system model mismatch Moreover, the error bars].
Linear-nonlinear filter. When the EKF is improved by using several solutions shown as "IEKF and parameter adaptation", the cost of calculation needed for the algorithm obviously increases, making it difficult to realize fast estimation. Therefore, the linear-nonlinear (L-N) filter is used for solving the issues that the algorithm is too complex.
Noting that the first-order ECM has the following characteristics: 1. State update process is a linear process.
2. Observation process is non-linear process.
The nonlinear proportion is concentrated in the observation process. Therefore, it is considered that the state update portion is separately processed from the observation portion. Classical Kalman filtering has higher precision when dealing with linear systems accompany little amount of calculation. However, while the EKF can response to nonlinear systems, the accuracy is similar to that of classical Kalman filtering when tackling linear systems, whereas a lot of computing power is wasted. Therefore, for the special linear-nonlinear system mentioned above, the L-N filter is used to solve the problem. The classical Kalman filter method is adopted for www.nature.com/scientificreports/ the status updating process, and the EKF is applied for the observation process, which effectively reduces the calculation amount required by the algorithm without affecting the accuracy of estimation.

Summarization.
In "IEKF and parameter adaptation", several solutions are introduced for dealing with the filtering noise and divergence problems. The L-N filter method is used to reduce the amount of calculation. The IEKF algorithm adopted can be described as Table 3: Parameter adaptation. The EKF algorithm can only track the system and depending on the observations for correction. Therefore, the EKF algorithm will degenerate into an information filter with a lower convergence rate. Furthermore, improving the model accuracy or timely modifying the model to adapt the system has higher significance for improving the convergence speed and robustness. Online parameter identification is the main means for fitting the model to real systems. The parameters of the first-order ECM include R o , R p , C p . R p and C p and represents the battery polarization effects, used for simulating the long-term and dynamic characteristics that affect the system. Therefore, the above parameters need to be implemented in the online identification process.
The online parameter identification method can be equivalent to the application of a Dual Kalman filter (DKF) 29 . Therefore, establishing a state space model for the parameters to be identified can effectively articulate how the parameter online identification works.
Since the variation of battery parameters is usually slow during degradation, we assume that the battery parameters do not change during an iterative process. Then the state space is rewritten as Eq. (25): This state space model has interesting features. Firstly, the state update matrix is a unit matrix, which has good positive definiteness and low computational complexity. Additionally, the observation equation of the system is the same as the battery equivalent circuit model. The observed voltage value and the polarization characteristic is affected accordingly. Therefore, the online parameter identification needs to be fed back to the prediction and update process in the ECM. Meanwhile, the SOC estimation result will affect the ability to correct the parameters which depending on observation. The adaptive parameter process is shown in Fig. 4. Considering the influence factors for filter algorithms, the selected parameters are presented in Table 4. Although the Gaussian noise is Table 3. Improved EKF algorithm. www.nature.com/scientificreports/ expected for ideal systems, the constant initialization is provided for predicting the non-Gaussian battery system and online parameter identification contributes to the adaptive optimizations.

Workbench and experiment.
To verify the validity of the algorithm, an experimental workbench is established as shown in Fig. 5, with the details illustrated in Table 5.    www.nature.com/scientificreports/ The experiment was verified on a BYD 130 Ah lithium-ion battery, and its specifications are shown in Table 6. The experimental results for conditions are used to verify the effectiveness and robustness of the algorithm and the verification test of this paper, including constant current test, pulse discharge test, and dynamic stress test (DST). All tests are carried out in an ambient temperature of 25 ℃.

Results and validation
Algorium validation. The effectiveness of the proposed algorithm is compared to the classical EKF algorithm. Two characteristics are introduced to evaluate the algorithm, which are the maximum error (ME) and RMSE. The definitions are shown as Eqs. (26) and (27).
The real SOC can be calculated from the measurement by using the AHC based on high precision test equipment. Compared with simulation results, the experimental results show that ME of IEKF can be reduced to 1.43% under 1C constant current discharge conditions, which is better than the 1.93% for the EKF algorithm. The RMSE of IEKF is 1.0193 × 10 -3 . Under the DST condition, the ME of IEKF slightly rises to 2.94%, and the RMSE is 2.4028 × 10 -4 . The ME of EKF rises to 6.72%. The results are shown in Table 7, which illustrate that IEKF is superior to EKF. Moreover, considering the invalidation of ECMs under low SOC ranges, the proposed method contributes to compensate the enlarged error, and the results are presented in Fig. 6b. The relatively fitted curve demonstrates the effectiveness on the correction for ECMs applying low SOC ranges.
The online identification results of the model parameters can be verified according to the voltage matching degree. The results of the model matching during the DST are shown in Figs. 6, and 7.
The voltage curves show that the accuracy of the system model can be improved after using the parameter adaptive algorithm. As shown in Fig. 6d, the simulated voltage curve based on IEKF is rather similar with the real one compared against others. The results can be attributed to the effective adaptive parameter identification, and the effective correction also contributes to the result.
As shown in Fig. 8, the method is validated under low-temperature condition. The test is carried out at − 10 ℃ and 0.2 ℃ discharging until reaching cutoff voltage of 2.5 V. The maximum error under − 10 ℃ is 2.27%, indicating a satisfactory precision based on IEKF method.
Considering the various battery types operating on electric vehicles, the lithium iron phosphate (LFP) battery is selected as another typical example to validate the effectiveness of proposed method. Herein, a 1.5 AH LFP battery is operated at 1C discharging test and 25 ℃. The model of used battery is LR1865EH, and the tested result is presented in Fig. 9. The maximum error applying proposed method is under 3%, indicating the potential application of the proposed method for various battery types.  www.nature.com/scientificreports/ Validation of convergence. The convergence of the algorithm can describe the ability of the filtering system to converge back to the true value when the system has seriously deviated. The quantification can be expressed as the time needed for the system to converge back to the true value. Table 8 depicts the ability of system convergence under different degrees of deviation. Due to the use of the fading filter and adaptive noise, the convergence speed is significantly increased compared to the classical EKF algorithm. Furthermore, Fig. 10 illustrates the results of convergence when there is a 20% absolute deviation during SOC initialization.

Analysis of robustness.
Robustness of the algorithm can be characterized as the ability to maintain true values when the system is disturbed. Since the state monitoring capability of the EV battery pack is limited in actual working conditions, the accumulated error caused by the current sensor is difficult to eliminate. Therefore, if the system samples contain the deviation and variance of the real current, the IEKF algorithm can trace    www.nature.com/scientificreports/ the true value. Benefiting from the noise adaptive method, the IEKF algorithm has better robustness than the AHC. In addition to the accuracy of the current sensor, the battery capacity (estimated SOC) is also greatly affected. The capacity is affected by many factors such as the ambient temperature and degradation of capacity. Table 9 lists the capacity test results of the batteries used in this paper at different ambient temperatures. It can be found in Table 9 that the nominal capacity of the battery is significantly different at various temperatures. Therefore, it is difficult to ensure that the battery capacity obtained by the AHC method is accurate for the actual usage of the battery pack. As a result, the algorithm robustness analysis should consider the battery capacity deviation problem.
Simulations of different capacities when calculating SOC under DST conditions are carried out. The results of capacity deviation and noise interference of the sensor are shown in Fig. 11. According to Fig. 11 and Table 10, the IEKF can tackle the mismatched capacity well compared to the AHC, by evaluating the error at the end of discharge, which indicates that IEKF has better robustness if the parameters of system are mismatched.
Analysis of calculation efficiency. BMSs in EVs are always responsible for important tasks such as state monitoring, system protection, charging control and communicating with other electrical systems. Considering the limited computing ability of embedded systems in EVs, the calculation efficiency of the online algorithm is crucial. Therefore, we simulate the algorithm in MATLAB and verify the computational efficiency within the time span of the simulation. The results are shown in Table 11. Compared to traditional EKF, the IEKF with online parameter and L-N filter has similar calculation efficiency. The IEKF with online parameter and L-N filter is much more efficient than IEKF where the parameters are relying on central difference method.

Conclusion
An IEKF associated with online parameter identification is used to investigate the SOC estimation of LIBs for automotive applications. The algorithm highlights the fact that the model parameters and system noises need to be adapted to the inaccurate current/voltage measurement or other various environment noise interference. Simulations show excellent agreement with experimental data under different working conditions, and the maximum error is found to be 2.94% under DST conditions. Furthermore, the robustness and convergence are analyzed, showing that the IEKF has better performance than traditional EKF. Noise interference is random and chaotic under practical operating conditions, which will affect the actual capacity of the cell and increase the difficulty of state estimation. The simulation results show that the maximum error of AHC for SOC estimation in distorted temperature is 16.54%, while the error of IEKF method is only 1.19%. Additionally, when there is a sensor error, AHC integrity has a significant deviation in the estimation due to its weak robustness, while the IEKF has much better accuracy. Moreover, simulation results show that IEKF has a higher convergence speed when dealing with mismatching initialization.
Although the proposed modelling framework and experiment only considers a single cell, the proposed algorithm can also be applied to further evaluate battery packs under varying operating conditions. In the future, temperature prediction and state of health estimation will also be considered in modelling and experimental work to further improve the method (Supplementary Information).