**1. Introduction**

In recent years, the lithium-ion battery has proven to be an ideal safety battery for hybrid electric vehicles, with high discharge power, environmental protection, low pollution, and long life [1–19]. Some details about its features, modelling, and hybrid combinations with different power sources in a fuel cell electric vehicle (FCEV) and power distribution controlled and optimized by an energy managemen<sup>t</sup> system (EMS) are shown in Part 1 [20]. It is worth mentioning that the battery SOC is an essential internal parameter that is continuously monitored by a battery managemen<sup>t</sup> system (BMS) to prevent dangerous situations and improves battery performance. The Li-ion battery as a direct energy supply and its SOC have a significant impact on the HEV's performance. Besides, the amount of SOC is crucial for safe operation of the Li-ion battery and its prolongation of life, so an accurate estimate of the SOC has an important theoretical significance and application value [1,2,5,6].

Typically, for calculation based on the coulomb counting method, the SOC is "tracking according to the discharging current" [5,6,12]. In the absence of a measurement sensor, the SOC cannot be measured directly; thus, its estimation using a Kalman filter technique is required [5].

Typically, the Kalman filter SOC estimators are model based, so both battery models—the linear RC equivalent electrical circuit (ECM) and the nonlinear Simscape generic model developed and analyzed in Part 1 [20] are beneficial for designing and implementing a high accuracy SOC estimator [1–10,12–19]. For better documentation and information for the reader, the diagrams of both models represented in Part 1 [20] are taken over and repeated in Appendix A.1, Figure A1a–c. The Li-ion battery is an essential component of the battery managemen<sup>t</sup> system (BMS) that plays an important role for improving the battery performance [2,5,6,12]. More details on the definition, the role, the main components (hardware and software) and the multitask functions can be found in [2,5]. Motivated by the results obtained in Part 1 [20], this article focuses on the design and implementation of three real-time SOC estimators on a MATLAB R2020a simulation environment. The remaining sections of this paper are structured as follows. Section 2 makes a presentation of state of the art of Li-ion battery SOC estimation Kalman filter techniques. Section 3 describes three of the most suitable SOC estimators in HEV applications and for each estimator shows the MATLAB simulation results. Section 4 analyses, for each SOC estimator, the SOC accuracy, convergence speed and robustness performance using six statistical criteria, defined in Part 1 [20]. Section 5 highlights the authors' contributions to this research paper.

### **2. State of the Art of Li-Ion Battery SOC Estimation Kalman Filter Techniques**

The most popular nowadays, Kalman filter (KF) is the "optimum state estimator and intelligent tool for a linear system", beneficial for estimating the Li-ion battery dynamic states and parameters [8].

Its "predictor–corrector" structure, more precisely the "self-correcting" nature, is the most attractive feature of the KF algorithm when the system is running, which helps to "tolerate large variations" in the estimated SOC values, as mentioned in [6]. Besides, it can significantly improve the "accuracy and robustness of battery SOC estimation", as well as the filtering of noise that realistically occurs in the measurement output dataset and the battery model process. The accuracy, response speed convergence, robustness, and noise filtration, in the proposed case study, are approached in some detail in Sections 4.1–4.5. The values of statistical criteria from Tables 1 and A1, Tables A2–A4 analyzed in Section 4.5, play an essential role in the analysis of SOC estimation performance for all three SOC estimators and both models of the Li-ion battery. It is worth mentioning that all the Kalman filter state estimators played a crucial role in the last six decades, reforming the whole theory of automatic control systems, both theoretically and in terms of applicability. A combination of the KF state estimator and the Ah Coulomb counting method can be used to "compensate for the non-ideal factors that can prolong the operation of the battery" [6]. However, there are situations when some Li-ion battery models have a dynamic that is "extremely nonlinear" and therefore "the linearization error may occur due to the lack of precision in the extension of the first series Taylor series in extremely nonlinear conditions" [5]. The simplicity of the SOC EKF estimator design and real-time MATLAB implementation is among two main features that motivated many researchers to apply it to a variety of Li-ion battery models, as in [2,3,6–9]. A new state of the art analysis on Li-ion BMSs is presented in [12], which includes a brief overview presentation of the most common adaptive filtration techniques for SOC estimation reported in the literature. Similarly, in [6], the authors present an interesting state of the art study on SOC estimation of the Li-ion battery for electric vehicles, in which an entire subsection examines all existing adaptive SOC filtration estimation techniques reported in the literature. A brief review on SOC estimating techniques related to Li-based batteries can be found in [13]. In [14], a new approach, the dual EKF SOC estimator of first-order RC ECM Li-ion battery model state and parameters, is well documented. The SOC simulations resulting from research paper [14] reveal excellent accuracy for SOC estimation.


**Table 1.** Statistical criteria—state of charge (SOC) estimators (default value SOCini = 0.7).

First place: 1; second place: 2; third place: 3.

Still, the robustness of the algorithm in [14] is lacking; it is strengthened in our research for five different scenarios and two battery models. Besides this, six performance analysis criteria are defined and used to assess the accuracy and robustness of SOCs. On the other hand, the authors of [14], in a new frame of a fault detection and isolation (FDI) approach, develop an SOC AEKF estimator for a Li-ion battery. A rigorous analysis of fault estimation performance, injected into BMS current and voltage sensor, showed a high accuracy and robustness to a 20% initial initialization of SOC error for an urban dynamometer driving schedule (UDDS) driving cycle profile test. The SOC accuracy and robustness performance are comparable to those obtained in our research for 30% initialization SOC error (scenario R1 for both battery models and each SOC estimator) and for an FTP-75 driving cycle profile test that includes the UDDS in the first 1379 s. Of course, to analyze the impact of each fault on the SOC estimation performance it was beneficial to see the fault SOC estimated values. An AEKF fading (AFEKF) approach is proposed in [15] for the accuracy of Li-ion battery SOC estimation and the convergence rate, which can reduce the SOC estimation error to less than 2%. The AFEKF SOC estimator performs better in terms of accuracy, robustness and convergence speed for a 20% initialization SOC error, but in our research similar performances are obtained at the initialization of 30% and 50% SOC errors (scenario R1), and also in combination with capacity degradation (scenario R2), noise level change (scenario R3) and the effects of temperature on the internal resistance of the battery (scenario R4). The result of the MATLAB simulations reveals that the AEKF SOC estimator works successfully in all five scenarios, especially for the Simscape model.

A similar situation is reported in the literature, in reference [16], where the authors investigate an RC ECM Li-ion battery model, and the SOC accuracy performance and robustness are analyzed for 20% initialization of SOC error. The SOC estimated error of the AEKF SOC estimator is more significant than 2% during the steady-state for a considerable window length *t* ∈ (800, 2200) *s* of SOC residual [16] compared to the AEKF SOC estimator used in our research for which the SOC estimated error is 0.32% for third order resistor capacitor (3RC) equivalent circuit model (ECM), if a 20% initialization SOC error (SOCini = 50%) is under investigation. For performance comparison purposes, Figure 1 shows a complete picture of Li-ion battery AEKF SOC, i.e., accuracy and robustness performance, for a 20% initialization SOC error, such as is reported in several references in the literature. Typically, in our research, for MATLAB simulations, 30% and 50% initialization of SOC errors, in combination with different scenarios, are under consideration.

**Figure 1.** The Li-ion battery adaptive extended Kalman filter (AEKF) SOC and robustness performance for an initializing 20% SOC error (SOCini = 50%; SOCini for advanced vehicle simulator ADVISOR and battery model is 70%) (**a**) Li-ion battery model SOC (blue), ADVISOR SOC estimate (green), AEKF SOC (red); (**b**) SOC residual error AEKF vs ADVISOR SOC estimate; (**c**) SOC residual error AEKF vs battery model; (**d**) AEKF open-circuit voltage (OCV) vs battery model OCV (true value); (**e**) AEKF battery terminal output voltage vs battery model terminal output voltage (true value).

For a similar RC ECM battery model, reference [17] shows the SOC accuracy and robustness of the AEKF SOC estimator for a UDDS current profile test, and 20% initialization SOC error. The simulation results in [17] reveal that the estimated SOC error reaches, during the UDDS driving cycle test, even 5%. In reference [18], based on an RC ECM model, an adaptive Kalman filter (AKF) is implemented and the SOC is set for initialization to SOCini = 76% and SOCini = 81%, compared to the default value SOCini = 80%. During the driving cycle the SOC errors reach 5% for first case and 4% for the second case. The selective results reported in the literature, highlighted in this paragraph, are significant for demonstrating the effectiveness of all three Kalman filter SOC estimators. In conclusion, comparing the simulation results obtained in our research work with those reported in the literature and mentioned above, it can be affirmed that the proposed SOC estimators and both models of Li-ion batteries are very efficient and work very well. The AEKF SOC estimator was chosen as a baseline because its results have a slight superiority compared to the other two competitors, namely the AUKF and PFE SOC estimators. AEKF proved to be a strong competitor compared to many other SOC estimators reported in the literature. In general, it can be said with confidence that the SOC AEKF estimator adopted in the present research with a correct design and with the parameters established at appropriate optimal values has better results than those found in the literature. Fundamental work related to the unscented Kalman filter (UKF) estimator is outlined in [7], which provides a strong theoretical background. Moreover, a particle filter estimator (FPE) is used to estimate the states, estimating the "probability density function" of a nonlinear dynamics of the Li-ion battery model, using a Monte-Carlo simulation technique, such as is developed in [11].

### **3. Li-Ion Battery SOC—Adaptive and Particle Filter Estimators**

In this section, an overview of two Kalman filter SOC estimators with adaptive function is provided, namely a linearized adaptive Kalman filter (AEKF) [5,6,15–19] and an unscented adaptive Kalman filter (AUKF). A successful implementation of both SOC estimators is performed on the software platform MATLAB R2020a, which estimates the SOC of a Li-ion SAFT battery with a rated capacity of 6 Ah and a nominal voltage of 3.6 V. Both SOC estimators under investigation are model based; thus, a dynamic state space representation model of the Li-ion battery is required in order to develop a simulation model for the emulation of nonlinear battery behavior [5,6]. In the case study, the set of equations that describe both models developed in Part 1 [20] is used, namely a 3RC ECM Li-ion battery model and a Li-ion battery Simscape model.

### *3.1. Adaptive Extended Kalman Filter (AEKF) Overview Presentation*

The AEKF SOC estimator is a standard EKF, such as those developed in [2,5,6,15–19], with improved performance by using a memory fading factor [16] or adaptive correction of process and measurement noise covariances [6]. In [5], the SOC AEKF estimator combines both memory fading and noise correction. Encouraged by the preliminary results obtained in [5], the current research paper implements the same version of the AEKF SOC estimator adapted for each of the Li-ion battery models under investigation, namely the 3RC ECM and Simscape models. In the following are underlined only some interesting implementation aspects related to the AEKF estimation algorithm. The AEKF algorithm can improve SOC estimation performance by using "a fading memory factor to increase the adaptiveness for the modelling errors and the uncertainty of Li-ion battery SOC estimation, as well as to give more credibility to the measurements" [19]. It is based on the linearized models of the Li-ion battery described in the previous section. An excellent feature of the AEKF SOC estimator is that it is easy to implement in real time, due to its "recursive predictor–corrector structure that allows the time and measurement updates at each iteration" [5,19].

The tuning parameters of the AEKF SOC estimator are the following: *Q*(0) and *<sup>R</sup>*(0), *P*<sup>ˆ</sup>(0) = *<sup>P</sup>*<sup>ˆ</sup>(0|0), the fading factor α and the window length L, obtained by a "trial and error" procedure based on the designer's empirical experience.

For simulation purposes, to test the e ffectiveness of the AEKF SOC estimator, the Kalman filter estimator parameters are set up for an FTP = 75 driving cycle profile test to the following set of values, *Q*(0) = 5 × <sup>10</sup>−4, *R*(0) = 0.4 × <sup>10</sup>−4, ∝ = 0.9, *P*<sup>ˆ</sup>(0) = <sup>10</sup>−10, *L* = 100 samples for the Simscape battery model, and a second set of values *Q*(0) = *diag*([*qw qw qw qwSOC*]), *qw* = 2 × <sup>10</sup>−3, *qwSOC* = 0.5, *R*(0) = 0.02, ∝ = 0.9, *P*<sup>ˆ</sup>(0) = <sup>10</sup>−10, *L* = 80 samples for the 3RC ECM Li-ion battery model.

The MATLAB simulation results for an FTP-75 driving cycle current profile test are shown for all three SOC estimators, adapted for each Li-ion battery model described in the previous section and for the following five main scenarios, defined as:


Li-ion battery model) to changes in ambient temperature (T0 = 293.15 K, equivalent to 20 ◦C), as is shown in Part 1 [20], p. 12 for thermal model.

The MATLAB simulation results are depicted in the main part of the manuscript and in Appendix A.1, and the statistical criteria values are given in Appendix A.2, Table A4.

For each SOC estimator, these abbreviations of the five scenarios in the following text inserted into the manuscript are used to avoid repeating the words.

3.1.1. MATLAB Simulation Results for 3RC ECM Battery Model—Accuracy and Robustness Scenarios

• Scenario R0. The MATLAB simulation results for this scenario are shown in Appendix A.1, Figure A12a–c, and the statistical criteria values are given in Table 1.

Performance analysis:


Performance analysis:


Performance analysis:


Performance analysis:


Performance analysis:


**Figure 2.** Robustness to simultaneous changes, SOCini = 1, Qnom = 4.2 Ah (ageing effects); (**a**) AEKF SOC value versus battery model true value; (**b**) SOC residual.

**Figure 3.** Robustness to simultaneous changes, SOCini = 0.2, and output temperature profile changes; (**a**) AEKF SOC value versus battery model true value; (**b**) SOC residual.

3.1.2. MATLAB Implementation and Simulation Results for Simulink Simscape Battery Model—Accuracy and Robustness Scenarios

• Scenario R0. The MATLAB simulation results for this scenario are depicted in Appendix A.1, Figure A15a–c, and the statistical criteria values are given in Table 1.

Performance analysis:


Performance analysis:


Performance analysis:



Performance analysis:


Performance analysis:


**Figure 4.** Robustness to simultaneous changes, SOCini = 1, Qnom = 4.2 Ah (ageing effects); (**a**) AEKF SOC value versus battery model true value; (**b**) SOC residual.

**Figure 5.** Robustness to simultaneous changes, SOCini = 0.2, and output temperature profile changes; (**a**) AEKF SOC value versus battery model true value; (**b**) SOC residual.

Roughly, based on the MATLAB simulation results of the AEKF SOC performance obtained for each model, both the 3RC ECM and Simscape models, it seems that the AEKF SOC estimator works better in all five scenarios based on the Simscape model.

*3.2. Adaptive Unscented Kalman Filter (AUKF)*

The AUKF SOC estimator [4,6,8,9] is an extremely precise algorithm, suitable for nonlinear dynamics of Li-ion battery models, compared to the AEKF SOC estimator [5,6,15–19], which only deals with models that have a linearized dynamic, so the calculation of Jacobian matrices is required, which is time consuming.

In the following, the steps of a general formulation of the AUKF SOC estimator that can be easily adapted to each model under investigation are presented briefly.

A standard UKF estimator is today one of the most popular estimators for states and nonlinear process parameters reported in the literature [7,12]. The AUKF SOC estimator adopted for the current research paper has the same steps as in [6]; our contribution is the adaptation of the algorithm to both the proposed Li-ion battery models, described in the previous section, and the parameter adjustment procedure for achieving an excellent accuracy for SOC.

UAKF SOC estimator algorithm steps [5,6]:

[UAKF1]. Write the battery model equations in discrete time state space representation.


*xk*+1 = *f*(*xk* , *uk*) + *qw*,*k*. *yk* = *g*(*xk* , *xk*) + *rv*,*k*. [UAKF2]. Initialization. For *k* = 0, let: *x*ˆ + 0 = *<sup>E</sup>*[*<sup>x</sup>*0] denotes the mean of initial value (predicted value). *P*<sup>+</sup> *x*ˆ,0 = *E*[ *x*0 − *x*ˆ + 0 *x*0 − *x*ˆ + 0 *T* is the state covariance matrix (predicted state). [UAKF3]. Computation.

3.1 Generate sigma points and weighting coe fficients at time *k* − 1, *k* = [1, ∞]

*X*0 = *X*ˆ *k*−1 is the mean of the state at time *k* − 1. *Xi k*−1 = *X*ˆ *k*−1 + (*n* + <sup>λ</sup>)*Pk*−<sup>1</sup> *i* , *i* = 0, *n* represent the sigma points. *Xj k*−1 = *X*ˆ *k*−1 + (*n* + <sup>λ</sup>)*Pk*−<sup>1</sup> *j*−*<sup>n</sup>* , *j* = *n* + 1, 2*n* are the sigma points.*W*(0) *m* = λ *n*+λ − mean weights. *W*(0) *c* = λ *n*+λ + 1 − α<sup>2</sup> + β denote the covariance weights. *W*(*i*) *m* = *W*(*i*) *c* = λ <sup>2</sup>(*n*+<sup>λ</sup>) are the mean and covariance weights. [UAKF4]. Prediction phase (Forecast): For *k* = [1, *<sup>n</sup>*], compute:

4.1 State estimate time update:

*Xi k*|*k*−1 = *f X*<sup>ˆ</sup>*<sup>i</sup> k*|*k*−1 , *uk* is the prediction state vector (passing sigma points through function f (.,.)). *<sup>x</sup>*<sup>ˆ</sup>*k*−<sup>1</sup> = <sup>2</sup>*n i*=0 *W*(*i*) *m Xi k*|*k*−1 designates the state estimate at time *k* − 1. *P*− *<sup>x</sup>*,*k*|*k*−1 = <sup>2</sup>*n i*=0 *W*(*i*) *c* [*Xi k*|*k*−1 − *<sup>x</sup>*<sup>ˆ</sup>*k*−<sup>1</sup>] *Xi k*|*k*−1 − *<sup>x</sup>*<sup>ˆ</sup>*k*−<sup>1</sup> *T* denotes the prediction covariance matrix. *Yi k*|*k*−1 = *g X*<sup>ˆ</sup>*<sup>i</sup> k*|*k*−1 , *uk* are the output sigma points (passing sigma points through output function g(.,.)). *y*<sup>ˆ</sup>*k*−<sup>1</sup>=<sup>2</sup>*n W*(*i*) *Yi* isthemeanestimate.

 *i*=0 *m k*|*k*−1 output [UAKF5]. Correction update phase (analysis): 5.1 Update the covariance output matrix and cross-covariance matrix.

$$\begin{aligned} P\_{y,k} &= \sum\_{i=0}^{2n} \mathcal{W}\_{\mathbf{c}}^{(i)} [\mathbf{Y}\_{k|\mathbf{k}-1}^{i} - \hat{\mathcal{y}}\_{k-1}] \Big[ \mathbf{Y}\_{k|\mathbf{k}-1}^{i} - \hat{\mathcal{y}}\_{k-1} \Big]^{T} . \\ P\_{xy,k} &= \sum\_{i=0}^{2n} \mathcal{W}\_{\mathbf{c}}^{(i)} [\widetilde{X}\_{k|\mathbf{k}-1}^{i} - \hat{\mathcal{x}}\_{k-1}] \Big[ \mathbf{Y}\_{k|\mathbf{k}-1}^{i} - \hat{\mathcal{y}}\_{k-1} \Big]^{T} \text{ is the cross-covariance x-y.} . \end{aligned}$$

5.2 Compute the Kalman filter gain:

$$
\mathbb{K}\_k = P\_{xy,k} P\_{y,k}^{-1}.
$$

5.3 State estimate update:

$$\mathfrak{a}\_{k} = \mathfrak{a}\_{k|k-1} + \mathcal{K}\_{k}(\mathfrak{y}\_{k} - \mathfrak{y}\_{k|k-1}) \cdot$$

5.4 State covariance matrix estimate update:

*Pk* = *P*−*<sup>x</sup>*,*k*|*k*−1 − *KkPy*,*k<sup>K</sup>Tk* . [UAKF 6]. Correction measurement covariance matrices of noises:

6.1 Compute the output error:

> ε*k* = *yk* − *g*(*x*<sup>ˆ</sup>*k*, *uk*).

6.2 Compute the adjustment coefficient:

> *ck* = 1*L ki*=*k*−*L*+<sup>1</sup> <sup>ε</sup>*k*ε*k<sup>T</sup>* L is the window length (number of samples inside the window).

6.3 Compute the covariance matrix of process noise:

$$q\_{w,k} = K\_k c\_k K\_k{}^T.$$

6.4 Compute the covariance matrix of the measurement noise:

 $r\_{\upsilon,k} = c\_k + \sum\_{i=0}^{2n} \mathcal{W}\_c^{(i)} [Y\_{k|k-1}^i - y\_k + c\_k] \left[ Y\_{k|k-1}^i - y\_k + c\_k \right]^T.$  For a better understanding of this algorithm. reference

For a better understanding of this algorithm, references [6–9] provide an excellent source of documentation.

The following two sets of tuned parameter values are used in MATLAB simulations for this algorithm:


3.2.1. MATLAB Implementation and Simulation Results for 3RC ECM Battery Model-AUKF SOC Estimator Accuracy and Robustness Scenarios

•Scenario R0. The MATLAB simulation results are shown in Appendix A.1, Figure A18a–c, and the statistical criteria values are given in Table 1.

Performance analysis:


• Scenario R1. The MATLAB simulations result are shown in Appendix A.1, Figure A19a,b, and the statistical criteria values are given in Appendix A.2, Table A1.

Performance analysis:


Performance analysis:


Performance analysis:


Performance analysis:


**Figure 6.** Robustness to simultaneous changes, SOCini = 1, Qnom = 4.2 Ah (ageing effects); (**a**) AUKF SOC value versus battery model true value; (**b**) SOC residual.

**Figure 7.** Robustness to simultaneous changes, SOCini = 0.2, and output temperature profile changes; (**a**) AUKF SOC value versus battery model true value; (**b**) SOC residual.

3.2.2. MATLAB Implementation and Simulation Results for Simulink Simscape Battery Model—AUKF SOC Estimator Accuracy and Robustness Scenarios

• Scenario R0. The MATLAB simulation results for this scenario are shown in Appendix A.1, Figure A21a–c, and the statistical criteria values are given in Table 1.

Performance analysis:


Performance analysis:


Performance analysis:


Performance analysis:


Performance analysis:


**Figure 8.** Robustness to simultaneous changes, SOCini = 1, Qnom = 4.2 Ah (ageing effects); (**a**) AUKF SOC value versus battery model true value; (**b**) SOC residual.

**Figure 9.** Robustness to simultaneous changes, SOCini = 0.2, and output temperature profile changes; (**a**) AUKF SOC value versus battery model true value; (**b**) SOC residual.

In general, based on the MATLAB simulation results of AUKF SOC performance obtained for each model, it is relevant that the AUKF SOC estimator works well in four scenarios. The simulations from the second scenario (R2) reveal that AUKF is more sensitive to the effects of ageing in both models, so it is difficult to distinguish at this stage. The values of the statistical criteria can provide sufficient information to make a correct delimitation.
