*3.1.1 ECM hybrid and combined Li-ion battery models structures: Training phase and battery terminal voltage accuracy*

A specific MATLAB function *anfis*(*trainingData)* that has as argument the *TrainingData* generates a single-output Sugeno fuzzy inference system (FIS) and tunes the system parameters using the specified input-output training data. The FIS object is automatically generated using the grid partitioning method. The training algorithm uses a combination of the least-squares and back propagation gradient descent methods to model the training data. Also, the same MATLAB function could have a second argument called *options* with the syntax *anfis* (*trainingData*, *options*) and tunes an FIS using the specified trainingData and options. Using this syntax, the user can select an initial FIS object to tune, validate the data to prevent overfitting to training data, the training algorithm options, and display training progress information. In the last two decades, an impressive amount of research was done by researchers, developers, and implementers in the artificial intelligence field to develop a robust theoretical background on neural network architectures, fuzzy logic design, and ANFIS modeling approach, as well as to create the most suitable algorithms and techniques to be implemented in an extensive palette of applications [14, 18]. The following summarizes some of the key lines of MATLAB code that are much easier for MATLAB readers and users to understand a quick implementation of the online generation of the ANFIS model based exclusively on the input-output measurement data set suggested in [14]. The MATLAB implementation steps required to generate an ANFIS plant/process model, the actions that guide the reader/implementer are:

Step 1: Set up the driving cycle profile for Li-ion battery as input u, and the battery SOC (y1) and terminal voltage (y2) as battery outputs; The Li-ion battery input– output measurements data set will be collected from a 3RC ECM original battery model given by Eq. (1)–Eq. (7) from previous section through several extensive simulations conducted on MATLAB platform.

Step 2: Generate the ANFIS model grid partition method–based options using the specific MATLAB function:

options = genfisOptions('GridPartition')

options. NumMembershipFunctions = 5 or greater than this

Step 3: Construct the FIS input attached to the battery SOC and terminal voltage

in\_fis1 = genfis (u, y1, options)

in\_fis2 = genfis (u, y2, options)

Step 3: Select for training the ANFIS model options

options = anfisOptions.

options. InitialFIS1 = in\_fis1

options. InitialFIS2 = in\_fis2

options. EpochNumber = 20 or greater to get a reasonable accuracy

Step 4: Construct the FIS output attached to the battery SOC and terminal voltage out\_fis1 = anfis ([u y1], options)

out\_fis2 = anfis ([u y2], options)

Step 5: Plot the input-output measurements data set versus input-output of both ANFIS models

plot (u, y1, u, evalfis (u, out\_fis1))

plot (u, y2, u, evalfis (u, out\_fis2))

legend ('trainingData','ANFIS Output').

The previous steps must be adapted to generate both ANFIS models of the Rint-3RC ECM dynamic part and the OCV(SOC) nonlinear function. The MATLAB simulation results are depicted in Figure. **Figure 14a** presents the ANFIS Rint-3RC ECM dynamic part model output and voltage training data set measurements, and **Figure 14b** shows only the ANFIS model output. The impact on battery terminal voltage accuracy using the ANFIS -ECM model compared with ARX -ECM developed in the last Section 2.1.4 is shown in **Figure 14c**. The accuracy of ANFIS -ECM model is revealed in **Figure 14d**, which presents the battery terminal voltage residual.

Also, for building some interesting Li-ion SAFT battery structures, an ANFIS model is developed for OCV(SOC) nonlinear function block in **Figure 15a** for training data phase, and in **Figure 15b** for OCV(SOC) ANFIS output model. Both ANFIS models are based on a repeated UDDS driving cycles input current profile for almost 5 hours to assure a large interval of input-output data set measurements for SOC, OCV, and battery dynamic part voltage. The impact of OCV(SOC) ANFIS block on battery terminal voltage accuracy based on 3RC ECM is revealed in **Figure 15c** and **d**. In **Figure 15c** it is very difficult to distinguish between ECM battery terminal voltage graph and the second one ECM Li-ion battery terminal voltage that integrates the

## *Investigations of Using an Intelligent ANFIS Modeling Approach for a Li-Ion Battery… DOI: http://dx.doi.org/10.5772/intechopen.105529*

#### **Figure 14.**

*(a) ANFIS ECM dynamic part model output and voltage training data set measurements; (b) Rint-3RC ECM dynamic part ANFIS model yd. circuit output; (c) terminal battery voltage Vbat with Rint-3RC ECM dynamic part ANFIS model (ANFIS-ECM); (d) terminal voltage residual error.*

OCV(SOC) block ANFIS model due to the high ANFIS OCV(SOC) model block accuracy. The reader can have a better insight on the battery terminal voltage accuracy in **Figure 15d** that reveals a very small battery terminal voltage residual error compared with the ARX ECM dynamic part battery model terminal voltage shown in previous **Figure 14d**.

Let us discuss why the ANFIS battery integrated model is the most suitable to build hybrid integrated battery Li-ion structures in terms of high accuracy.

An exciting hybrid battery Li-ion structure can incorporate into the ARX ECM dynamic part model and an ANFIS OCV(SOC) nonlinear block model. The MATLAB simulations result of the Li-ion battery hybrid structure is presented in **Figure 16a** and **b**.

A rigorous analysis of MATLAB simulation results from **Figure 15c** and **d** shows a high battery terminal voltage accuracy compared with the battery hybrid structure, as can be seen in **Figure 16a** and **b**.

The last combined battery structure consists of two ANFIS models, the first one for Rint-3RC ECM active battery part and the second one that replaces the Li-ion SAFT ECM SUN OCV(SOC) nonlinear block with an ANFIS model block. The MATLAB simulation results are depicted in the **Figure 17a** and **b**.

#### **Figure 15.**

*(a) OCV = f(SOC) ANFIS model versus OCV measurements; (b) OCV = f(SOC) ANFIS model; (d) ECM Li-ion SAFT battery terminal voltage versus ECM-OCV(SOC) ANFIS model (Rint-3RC -ANFIS) terminal battery voltage; (e) ECM Li-ion SAFT battery terminal voltage residual error versus ECM-OCV(SOC) ANFIS model (Rint-3RC – ANFIS) integrated structure.*

#### **Figure 16.**

*(a). ECM Li-ion SAFT hybrid structure – ARX Rint-3RC dynamic part and ANFIS OCV (SOC) nonlinear block model (ARX-ANFIS; (b) Li-ion SAFT battery terminal residual voltage error for hybrid structure.*

The voltage accuracy performance revealed by simulation results from **Figure 17a** and **b** seems to be better than the previous hybrid ARX and ANFIS battery structure. Still, it is slightly inferior compared with the design that integrates only the ANFIS model for SOC(OCV) nonlinear battery block.

*Investigations of Using an Intelligent ANFIS Modeling Approach for a Li-Ion Battery… DOI: http://dx.doi.org/10.5772/intechopen.105529*

#### **Figure 17.**

*(a) ECM Li-ion SAFT battery terminal voltage versus ECM ANFIS combined structure terminal voltage; (b) ECM Li-ion SAFT battery terminal residual voltage error for ECM ANFIS combined structure.*
