*3.3. SOC Estimation Process for LiFePO4 Battery*

Step 1. Data input. Input the test data of the LiFePO4 battery, including the working current sampling data *IL*(*k*), terminal voltage *UL*(*k*), battery capacity of 13 Ah, parameter model identification results, and sampling period *T* = 0.1 s.

Step 2. Algorithm initialization. Initialize the battery state vector *x*<sup>0</sup> = [*SOC*(0), 0, 0], ⎡ 10−<sup>6</sup> 0 0 ⎤

estimation error covariance matrix *P*<sup>0</sup> = ⎣ 0 10−<sup>6</sup> 0 0 0 10−<sup>6</sup> ⎦, process noise covariance

matrix *Q*<sup>0</sup> = ⎡ ⎣ 10−<sup>6</sup> 0 0 0 10−<sup>6</sup> 0 0 0 10−<sup>6</sup> ⎤ ⎦, and observation noise covariance matrix *R*<sup>0</sup> = 0.05.

Step 3. Calculate the prior estimate of the state variable and the predicted covariance matrix. Firstly, according to Equation (10), calculate the state transition matrix *Ak* = *diag*[1,*e* −*T τp*1(*k*) ,*e* −*T τp*2(*k*) ] and the systeminputmatrix *Bk* = [<sup>−</sup> *<sup>T</sup> Q*<sup>0</sup> , *Rp*1(1 − *e* −*T τp*1(*k*) ), *Rp*2(1 − *e* −*T τp*2(*k*) )] T using the model parameters at time *k*. Secondly, substitute the state vector *x*<sup>k</sup> = [*SOC*(*k*), *Up*1(*k*), *Up*2(*k*)] and the operating current *I*(*k*) at *k* time into Equation (20) to calculate the prior estimate value *x*ˆ*k*+1/*<sup>k</sup>* of the state variable. Finally, calculate the predicted error covariance matrix *Pk*+1/*<sup>k</sup>* according to Equation (21).

Step 4. Calculating the Kalman gain matrix. Firstly, the nonlinear observation equation is linearized based on Equation (8), and the Jacobian matrix *Gk* of the observation equation is calculated, as given in equation (33). Secondly, the Jacobian matrix *Gk*, the predicted error covariance matrix *Pk*+1/*k*, and the observation noise matrix *Rk* are substituted into Equation (22) to calculate the Kalman gain matrix *Kk*.

$$\mathbf{G}\_{k} = [\frac{\partial \mathcal{U}\_{\rm OC}[\rm SOC] - I \mathcal{R}\_{0}}{\partial \rm SOC}|\_{k'} \frac{\partial - \mathcal{U}\_{p1}}{\mathcal{U}\_{p1}}|\_{k'} \frac{\partial - \mathcal{U}\_{p2}}{\mathcal{U}\_{p2}}|\_{k}] = [\frac{\partial \mathcal{U}\_{\rm OC}[\rm SOC]}{\partial \rm SOC}|\_{k'} - 1\_{\prime} - 1] \tag{34}$$

Step 5. Calculating the optimal estimated value of the state vector and updating the error covariance matrix. Based on Equation (34), the observation value, i.e., the estimated value *UL*(*k*) of the battery terminal voltage at *k* time, is calculated. Then, Equation (23) is used to calculate the optimal estimated value *<sup>x</sup>*ˆ*k*+1/*k*+<sup>1</sup> = [*SOC*(*<sup>k</sup>* <sup>+</sup> <sup>1</sup>), *Up*1(*<sup>k</sup>* <sup>+</sup> <sup>1</sup>), *Up*2(*<sup>k</sup>* <sup>+</sup> <sup>1</sup>)]*<sup>T</sup>* of the state vector, where *SOC*(*k* + 1) is the *SOC* value estimated by AEKF at (*k* + 1) time. Finally, Equation (13) is used to update the error covariance matrix *Pk*+1/*k*.

Step 6. Updating the noise covariance matrix. The process noise covariance matrix *Qk* and the observation noise covariance matrix *R*(*k*) are calculated based on Equations (24) and (25). Steps 2 to 6 are repeated recursively to estimate the SOC value at each moment.

#### *3.4. Comparison and Analysis of SOC Estimation Results between EKF and AEKF Algorithms*

To compare and analyze the performance of EKF and AEKF algorithms for SOC estimation of lithium iron phosphate batteries, a comparative study is conducted on SOC estimation based on the second-order equivalent circuit parameter model. Through battery charge–discharge testing, the corresponding relationship between battery OCV and SOC can be obtained through fitting. A 13 Ah-rated capacity and 3.2 V-rated voltage LiFePO4 battery is selected for HPPC testing to obtain its SOC and OCV data. The testing procedure involved discharging at 1 C for 10 s, resting for 40 s, and then charging at 0.75 C for 10 s. After resting for 45 min for every 10% drop in SOC, the OCV is measured, followed by another cycle of testing until the SOC of the battery reached 0.06, which is considered as

the end of the discharge. Under the global discharge, the battery terminal voltage *UL*, the output current *IL*, and the real values of SOC are shown in Figures 2 and 3, respectively.

**Figure 2.** The waveform of terminal voltage *UL* and the output current *IL*.

**Figure 3.** The waveform of real values of SOC.

Figures 4 and 5, respectively, show the SOC estimation results and estimation errors under the EKF and AEKF algorithms. From Figures 4 and 5, it can be seen that compared with the EKF algorithm, the AEKF algorithm can converge to the vicinity of the true value more quickly. The convergence time of the EKF algorithm and the AEKF algorithm is 532.8 s and 124.5 s, respectively. The SOC estimation accuracy of the AEKF algorithm is higher than that of the EKF algorithm. Experimental results show that the AEKF algorithm has a better SOC estimation convergence speed and accuracy.

**Figure 4.** The SOC estimating results with EKF and AEKF.

**Figure 5.** The SOC estimating errors with EKF and AEKF.

The specific statistical characteristics of SOC estimation errors under EKF and AEKF algorithms are shown in Table 1 (absolute error, AE; relative error, RE; mean absolute error, MAE; mean relative error, MRE), and the relevant features are calculated based on the converged results. From Table 1, it can be seen that the SOC estimation accuracy of the AEKF algorithm is better than that of the EKF algorithm, with a maximum absolute error (MaxAE) of 11.9% and a maximum relative error (MaxRE) of 152.6%, which occurs at the end of discharge. And the MAE of the SOC estimation is 8.8%, and the MRE of the SOC estimation is 25.4% with the AEKF algorithm, which is lower than that with the EKF. It can also be seen from Table 1 that the errors of both EKF and AEKF algorithms gradually increase. Therefore, the adaptive noise covariance matrix updating method of the AEKF algorithm can reduce SOC estimation errors. However, the SOC estimation precision is still large, which cannot meet the actual use needs of the battery energy management system. And, further optimization of the SOC estimation algorithm is needed.


**Table 1.** SOC estimation error under the EKF algorithm and AEKF algorithm.

#### **4. SOC Estimation Method Based on FFRLS-AFKF**

The FFRLS-AEKF joint estimation algorithm uses the SOC value estimated using the AEKF algorithm to replace the estimated value of the ampere-hour integration method in the FFRLS algorithm to improve the battery equivalent circuit parameters identification accuracy. The identified model parameters are substituted into the AEKF algorithm to recursively estimate the SOC and improve the accuracy of the AEKF algorithm. Then, the estimated SOC value is fed back to FFRLS, and through positive feedback, the SOC estimation accuracy is finally improved. The specific calculation process is shown in Figure 6.

Step 1. Initialize the FFRLS algorithm and the AEKF algorithm, where SOC(0) is obtained by the open-circuit voltage method.

Step 2. Obtain the model parameters at *k* time through the FFRLS algorithm, substitute them into the AEKF algorithm, construct the corresponding transfer matrix and input matrix, and obtain the SOC at (*k* + 1) time.

Step 3. Substitute the SOC at (*k* + 1) time into the OCV-SOC relationship formula, and then use the FFRLS algorithm to obtain the model parameters at (*k* + 1) time.

Step 4. Update the transfer matrix and input matrix in the AEKF algorithm to obtain the SOC of the next time step; repeat steps 2 to step 4 and recursively obtain the SOC at each time step. The specific calculation process is shown in the diagram.

**Figure 6.** FFRLS + AEKF processes.

#### **5. Experimental Results**

The experimental parameters setting is the same as in Section 3.2. The structure of the battery pack used in the experiment is first parallel and then series. The batteries used are all new, and the working temperature is 25 ◦C. According to the method in Section 2.3, the battery parameters *R*0, *Rp*1, *Cp*1, *Rp*2, and *Cp*<sup>2</sup> can be identified at 25 ◦C, and the identification results are in Table 2. Four single cells form a parallel unit, and ten parallel units, a total of forty battery cells form a series battery pack. The parallel unit is composed of ten parallel units, and a total of forty battery cells are composed of series battery packs. The model of the battery is IFP9380, the rated capacity is 15 Ah, the nominal voltage is 3.2 V, the operating voltage range is 2.0–3.65 V, and the maximum discharge current is 2.00 A. The main control chip of the switching circuit selects STM32F103VB8T6 battery voltage measurement using the battery management chip LTC6811. The measurement error is less than 1 mV, and the sampling frequency is greater than 3 kHz. The sampling of the circuit

current uses a shunt, and the sampling error is less than 0.1%. The experimental platform is shown in Figure 7.

**Table 2.** The identification results.


(**c**)

**Figure 7.** Experimental platform of battery charge and discharge. (**a**) Control board physical diagram. (**b**) DC power supply charging. (**c**) Battery pack interface diagram.

Figures 8 and 9 show the SOC estimation results and errors using the AEKF and FFRLS-AEKF algorithms, respectively. From Figures 6 and 7, it can be seen that the estimation results with the FFRLS-AEKF algorithm are closer to the true values, and the SOC estimation

errors with the FFRLS-AEKF algorithm are smaller than with the AEKF algorithm. The estimation errors of the AEKF and FFRLS-AEKF algorithms are shown in Table 3. It can be seen from Table 3 that the maximum absolute error of the joint estimation algorithm is 4.97%, and the error is controlled within 5%. As the battery operating time increases, the SOC estimation accuracy continuously converges to the vicinity of the true value, with the average absolute error decreasing to 2.5%. The experimental results show that the FFRLS-AEKF joint estimation algorithm has good convergence performance and high estimation accuracy, verifying that the proposed method is correct and feasible. Therefore, the SOC estimation performances with EKF, AEKF, and FFRLS-AEKF are shown in Table 4.

**Figure 8.** The SOC estimating results of the FFRLS-AEKF and AEKF.

**Figure 9.** The SOC estimating errors of the FFRLS-AEKF and AEKF.



**Table 4.** The SOC estimation performances with EKF, AEKF, and FFRLS-AEKF.


#### **6. Conclusions**

The working principle of FFRLS for battery parameter identification is analyzed. The second-order equivalent circuit state discretization equation based on the AEKF algorithm is established, and the steps of the battery SOC estimation method based on AEKF are discussed and simulated. The simulation results show that it has the disadvantages of low steady-state accuracy and slow convergence rate. To improve SOC estimation precision, combining the advantages of high precision and adaptability of FFRLS and AEKF, a joint SOC estimation method based on FFRLS-AEKF is proposed and experimented with. The experimental results show that the FFRLS-AEKF algorithm can have higher SOC estimation and faster accuracy convergence speed, verifying that the proposed method is correct and feasible.

In the actual use of the battery pack, it is often necessary to combine the battery cells in series and parallel to provide sufficient capacity and voltage level. However, in the process of series and parallel grouping of the battery pack, there will be problems such as more complex model parameters and difficult data sampling. Therefore, the next step in this research field needs to consider the influence of physical parameters such as the small number of sampling points, incomplete sampling data, and contact resistance on the accuracy of the battery model. The establishment of a perfect equivalent model of the battery pack is the focus of the next step in this research.

**Author Contributions:** Conceptualization, Y.X.; methodology, Z.Y.; software, L.H.; validation, Y.X., Z.Y. and L.S.; formal analysis, L.H.; investigation, L.H.; resources, Z.Y.; data curation, Y.X.; writing original draft preparation, L.H.; writing—review and editing, Y.X.; visualization, Z.Y.; supervision, L.H.; project administration, L.S.; funding acquisition, Y.J. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research was funded by the National Natural Science Foundation of China (Grant No. 51507183 and 51877212).

**Data Availability Statement:** The data that support the findings of this study are available from the corresponding author upon reasonable request.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**


**Disclaimer/Publisher's Note:** The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

**Ge He 1, Zhijie Wang 1,\*, Hengke Ma <sup>1</sup> and Xianli Zhou <sup>2</sup>**


**Abstract:** Because the new energy is intermittent and uncertain, it has an influence on the system's output power stability. A hydrogen energy storage system is added to the system to create a wind, light, and hydrogen integrated energy system, which increases the utilization rate of renewable energy while encouraging the consumption of renewable energy and lowering the rate of abandoning wind and light. Considering the system's comprehensive operation cost economy, power fluctuation, and power shortage as the goal, considering the relationship between power generation and load, assigning charging and discharging commands to storage batteries and hydrogen energy storage, and constructing a model for optimal capacity allocation of wind–hydrogen microgrid system. The optimal configuration model of the wind, solar, and hydrogen microgrid system capacity is constructed. A particle swarm optimization with dynamic adjustment of inertial weight (IDW-PSO) is proposed to solve the optimal allocation scheme of the model in order to achieve the optimal allocation of energy storage capacity in a wind–hydrogen storage microgrid. Finally, a microgrid system in Beijing is taken as an example for simulation and solution, and the results demonstrate that the proposed approach has the characteristics to optimize the economy and improve the capacity of renewable energy consumption, realize the inhibition of the fluctuations of power, reduce system power shortage, and accelerate the convergence speed.

**Keywords:** independent microgrid system; wind and solar complementary power generation; hydrogen energy storage; IDW-PSO; capacity configuration
