Adaptive Online State of Charge Estimation of EVs Lithium-Ion Batteries with Deep Recurrent Neural Networks

: The State of Charge (SOC) estimation is a signiﬁcant issue for safe performance and the lifespan of Lithium-ion (Li-ion) batteries. In this paper, a Robust Adaptive Online Long Short-Term Memory (RoLSTM) method is proposed to extract SOC estimation for Li-ion Batteries in Electric Vehicles (EVs). This real-time, as its name suggests, method is based on a Recurrent Neural Network (RNN) containing Long Short-Term Memory (LSTM) units and using the Robust and Adaptive online gradient learning method (RoAdam) for optimization. In the proposed architecture, one sequential model is deﬁned for each of the three inputs: voltage, current, and temperature of the battery. Therefore, the three networks work in parallel. With this approach, the number of LSTM units are reduced. Using this suggested method, one is not dependent on precise battery models and can avoid complicated mathematical methods. In addition, unlike the traditional recursive neural network where content is re-written at any time, the LSTM network can decide on preserving the current memory through the proposed gateways. In that case, it can easily transfer this information over long paths to receive and maintain long-term dependencies. Using real databases, the experiment results illustrate the better performance of RoLSTM applied to SOC estimation of Li-Ion batteries in comparison with a neural network modeling and unscented Kalman ﬁlter method that have been used thus far.


Introduction
For over 100 years, automobiles have been used for transportation of humans, goods, etc. and, in this way, reformed traveling around the world. Exploring of rural areas and going on a road trip across the country were made possible using wheels. However, the engine vehicles cause many environmental damages as well [1]. According to the World Health Organization (WHO), in 2000, fuel vehicles produce 34% of nitrogen dioxide discharged into the environment. They, additionally, generate 51% of the carbon monoxide, 10% of the particulate, and 33% of the carbon dioxide, in the United States only [2]. Reacting with humidity in the air, nitrogen dioxide makes nitric acid, which causes severe decay of metals. It also causes thick fog and drastically reduces field of view. This molecule also has a critical negative footprint on plant growth and a greenhouse effect. Carbon monoxide (CO) is a harmful gas that provokes migraines, dizziness, and respiratory disease. High enough CO levels may induce unconsciousness or death. Lastly, carbon dioxide is a major contributor to temperature rise worldwide. As a result, nowadays, using electric vehicles (EVs) as an alternative to diesel-and petrol-powered cars is highly regarded. In this context, a high-tech battery is a crucial element for EVs.
Various types of batteries, such as nickel-cadmium, lithium, and acid, are used as the dominant power source in EVs [3]. Among them, Li-ion batteries are the most popular due to their specific characteristics, e.g., high energy density, self-discharge, charging speed, low maintenance, and long-life cycle. The correct charging of Li-ion batteries improves their performance and extends their lifespan. This correct charging is performed using the Battery Management System (BMS), which controls the discharging [4]. One of the significant issues of BMS is the SOC estimation of the battery [5]. SOC is the amount of charge that is stored in the battery at each moment. To date, various methods have been introduced for SOC estimation, which are separated into two main categories: direct and indirect methods [6,7]. When considering direct methods, an equation is used to estimate SOC, determined by the battery's physical properties such as current, voltage, and battery temperature. A popular direct method is Coulomb Counting (CC) estimation described in detail by Lashway et al. [8]. Many published studies contributed in the development of the Open Circuit Voltage (OCV) method for the SOC estimation (e.g., [1,9]). Electrochemical Impedance Spectroscopy (EIS) is another direct method to estimate SOC [10]. Indirect methods, on the other hand, do not use a specific equation, rather they employ a model for the battery or mapping of system specification. One of the model-based methods is Electrical Circuit Model (ECM) [11]. Another type of indirect methods are the adaptive-filter based algorithms such as Kalman filter (KF, EKF, UKF, and AEKF) [12][13][14], Recursive Least Square algorithm (RLS), and the H infinity algorithm (H∞) [7,15,16]. Artificial Intelligent methods are also a category of indirect methods, which in recent years have been used for the SOC estimation, including Fuzzy Logic (FL) [17][18][19], Neural Networks (NN) [20][21][22][23][24], and deep learning methods [25][26][27][28][29].
Deep learning (also known as deep structured learning or dynastic learning) is a class of machine learning with multiple layers for extracting a higher level of features, and is based on work-specific algorithms. Most modern deep learning models are based on artificial neural networks. However, they may include predicate or hidden variables in generating models such as nodes in deep belief networks and deep Boltzmann machines. Recurrent Neural Networks (RNNs) are a type of deep learning method created in the 1980s [30] yet widely used only in the last few years. These types of neural networks are beneficial for serial or sequencing data. Theoretically, RNNs should have the ability to use previous data for estimation of any future one. In practice, however, this is not the case. Expanding the sequence, typical RNNs are unable to learn the information. This is why the use of RNNs was stopped for a while until outstanding results were obtained using the long-and short-term memory units in neural networks, namely Long Short-Term Memory (LSTM). Unlike traditional RNNs, LSTMs can deal with long sequences, using a designed mechanism.
LSTM, in fact, emerged in 1995 to improve RNNs in dealing with sequential data, and solving the problem of the disappeared gradient phenomenon [31]. Sepp Hochreiter et al. [31] explained that "long-term memory" in LSTM refers to acquired weights and "short-term memory" is internal cellular states. The major change in this network is replacing the hidden layer of the RNN with a block called the LSTM block and its most incredible feature is the ability to learn long-term dependencies that are not possible using RNNs [32].
In this paper, a new deep learning method for estimating SOC is investigated. In this method, instead of one LSTM for inputs, three of them are used in parallel, and, consequently, the number of LSTM units is reduced. In addition, to optimize the LSTM network, a robust and adaptive online optimization method is utilized. This optimization is an improvement of Adam method which is called Robust Adam (RoAdam). RoAdam can be adaptively tuned against a doubtful outlier. The weights and biases could be tuned online with a strategy of adaptive optimization to have a high-performance network. Since batteries have a nonlinear function and a complex electrochemical model, the SOC estimation function is also nonlinear and depends on the charge and discharge currents and temperature. Hence, finding a method that does not depend on the model is essential. This paper is organized as follows. The LSTM Structure is described briefly in Section 2. Section 3 explains SOC estimation with the RoLSTM method. Section 4 is the discussion of the results for this implementation. Finally, Section 5 summarizes the study main achievements.

Long Short-Term Memory Structure
In RNN, each neuron or processing unit can manage its internal state or memory to maintain the previous input information. This feature is critical in many applications related to serial data. The main idea behind this type of architecture is the exploitation of this series structure. The name of this neural network is derived from the fact that these types of networks operate recursively. An operation is performed for each element of a sequence (word, sentence, etc.), and its output depends on the current input and previous operations. It means the output at time t is achieved by combining the output network at t − 1 with the new network input at time t. These cycles permit the existence of information from one step to the next step. In other words, these types of networks have a loop within themselves, which they can pass information through the input of neurons.
The structure of RNN is shown in Figure 1, where the black square represents the time delay at each time step. Looking at the chain formed after opening this computational graph, how the network works is completely understandable. Now, this is an architecture that can receive different inputs x t and generate o t outputs at each time step. It also contains a memory state h t that maintains the information about what happened on the network until the time (t). W 1 , W 2 , and W 3 in Figure 1 indicate the weights of input neuron, recurrent neuron, and output layer, respectively. All RNNs are in the form of repetitive sequences of neural network modules (units). In standard RNNs, these repeatable modules have a simple structure: for example, they only contain a hyperbolic tangent (tanh) layer. However, in LSTM, four layers communicate in a special structure instead of only one layer. Figure 2 indicates the architecture of LSTM block. In this figure, x t is the input and h t is the output of the LSTM unit at time t, and h t−1 is the output of previous LSTM block. The initial phase in the LSTM is deciding what information should be discarded from the cell state. This decision is made by a sigmoid (σ) layer, shown in Equation (1), called the forget gate layer ( f t ). The next step is to decide what new information have to save in the cell state. This decision contains two parts. First, a sigmoid layer called the input gate (i t ) decides which values will be updated with Equation (2). The next step represents in Equation (3), is a tanh layer that makes the vector of values called memory cell (C t ) that could be added to the state cell. By combining those two steps, the state cell (h t ) within the next step can be updated. Finally, it must be determined what information to be transmitted to the output (O t ). This output is based on the state cell that passes via a specified filter. The formulas for these models are expressed as below.
where the initial values of C t and h t are C 0 = 0 and h 0 = 0, respectively. W f , W i , W g , and W o are, respectively, the weights of forget gate, input gate, memory cell, and output gates, while b f , b i , b g , and b o are their associated biases. The gate activation function and the output activation function are shown by σ and tanh, which define in Equations (6) and (7), respectively.

Robust and Adaptive Online LSTM for SOC Estimation
In this inquiry, a RoLSTM model is used for the SOC estimation of a Li-ion battery with voltage (V), current (I), and temperature (T) as input variables and the SOC of the battery as output. The structure of this method is depicted in Figure 3. Three LSTM networks are used for the inputs. In fact, each input variable contains two hidden layers with 128 and 8 LSTM units, respectively, which they are working in parallel. The concatenation of these layers is realized to calculate the output with a dense layer, which is a linear operation that relates every input to every output with the following equation: where W and b are defined, respectively, as the weight matrices and biases of full connected layers. The input datasets for the LSTM layer should be three-dimensional (3D), which are defined as "(Samples, Time steps, Features)". Samples indicate the number of sequences, Time steps symbolize the number of observations in each sample, and Features represent the number of features for each element in the samples. The voltage, current, and temperature are the input vectors. In the preprocessing step, the input datasets must be converted to a 3D array for use as an input of the RoLSTM and normalized in the range [−1, 1] as: In (3), the minimum and maximum values of input vector x are shown by x min and x max , respectively. In addition, max equals 1 and min is −1. To scale the testing dataset, the maximum and minimum values of training inputs must be used. To train the LSTM and update the weights and biases in the network for SOC estimation, the Robust and Adaptive online optimization algorithm (RoAdam) is used [33]. RoAdam is dependent on gradient and the squared gradient. The equations of RoAdam are described in (10). The training step size is η = 0.0005; β 1 = 0.9, β 2 = 0.999, and β 3 = 0.999 are exponential decay rates; W t is the weights vector of the model in time step t; and = 10 −8 is a constant. The initial values of the first moment of the gradients, m t , and the second moment of the gradients, v t , are zero. r t is defined as a relative prediction error term of the loss function.
L is the loss function that is calculated considering (11): where n is the number of data point, while SOC t andŜOC t are, respectively, actual and predicted values of state of charge at time step t. To guarantee the stability of the relative prediction error, a threshold is intended for r t . Then, r t is changed as (12).
where k = 0.1 and K = 10 are the lower and upper thresholds, respectively. To implement this method and the mathematics operation, tensorflow framework is used. The flowchart of this program is depicted in Figure 4.

Battery Specification and Experimental Conditions
This method was applied on two different battery databases. The first database is related to the Panasonic 18650PF Li-ion battery which is used in some Tesla Electrical Vehicles. This database is collected by McMaster University in Ontario (Canada) [34]. The second one concerns the A123 LifePO4 Li-ion battery collecting by the Center for Advanced Life Cycle Engineering (CALCE) at University of Maryland [35]. The battery parameters are listed in Table 1.
The discharge datasets are realized from 10 different standard drive cycles e.g. Los Angeles 92 (LA92), Supplemental Federal Test Procedure Driving Schedule (US06), the Highway Fuel Economy Test (HWFET), and the Urban Dynamometer Driving Schedule (UDDS), with a variety of current steps and temperatures. Figure 5 presents the drive cycle power profiles of the Panasonic NCR18650PF cell for different drive cycles. The negative power is the discharge power and the positive power is the charge power.  The A123 battery is a lithium iron phosphate battery (LiFePO 4 battery). LiFePO 4 batteries are a type of li-ion batteries being used in EVs and Electric bikes. Table 2 represents the specification of A123 battery.  [36]. The measured current and voltage for DST profile are shown in Figure 6. In this study, the Mean Absolute Error (MAE), the Root Mean Square Error (RMSE), and the Maximum Error (MAX) were used to evaluate the performance of the suggested network for SOC estimation. Equations (13)- (15), respectively, were used to calculate the MAE, RMSE, and MAX.
where SOC t andŜOC t are the measured value and the estimated value at time step t, respectively, while n is the number of data points in the sequence.

Results for the Panasonic 18650PF
The existing data of all ten cycles at different ambient are more than 8 million data. They are categorized into two groups, training and validation data. To train the system, a random dataset containing the mixed eight drive cycles in different ambient temperature was used. The validation was applied to the remaining two cycles. In most cases, the length of the dataset for one drive cycle is more than 100,000 time steps. In reality, to implement a RoLSTM network with an n-step size equal to this length sequence, more than three GPUs are needed. Therefore, in this paper, the optimal values of n-step is chosen 500. The time required for training system with three Tesla V100 GPU is about 8 h. For testing the system, two categories with fixed and varying ambient temperatures were used. The current and voltage of the testing dataset are shown in Figure 7. The results of SOC estimation and SOC error for a dataset of mixed drive cycles with fixed ambient temperature at 0 and 25 • C and varying ambient temperature are described in Figures 8 and 9, respectively.    Table 3 details the MAE, RMSE and MAX error metrics, at 0, 10, and 25 • C for RNN [25], GRU-RNN [25], LSRM-RNN [26], and RoLSTM. Looking at these values for each temperature, one can see that all are decreased when RoLSTM method is applied. When varying temperature is considered, the RMSE of RoLSTM is equal to 1.8%, while the same error using LSTM-RNN [26] method is calculated as 2.08%. In the next step, this model was tested for the dataset of A123 Li f ePO 4 battery at different ambient temperatures from −10 to 50 • C, which were prepared based on DST and FUDS tests and datasets collected based on the low current voltage test.
The SOC estimation obtained based on DST and FUDS tests in the variant temperature are illustrated in Figure 10. Figure 11 presents the SOC error, which is defined as the difference between the SOC measurement and the SOC estimation with this model. As can be seen in these figures, the SOC estimate achieved by the RoLSTM is quite smooth.
The SOC estimation and the SOC error for datasets of discharging at −10 and 50 • C based on the low current voltage test with 500 epochs are shown in Figures 12 and 13, respectively. For these datasets, SOC estimation error does not have an observable change while changing the temperature. The results show that, with 500 epochs in the RoLSTM method, the loss function converges to zero in all ambient temperatures. In summary, these results show that the maximum error of SOC estimation for Li f ePO 4 battery by the RoLSTM method for all datasets with fixed ambient is less than 2% and for different ambient is less than 2.5%. The values of RMSE and MAX error derived from the RoLSTM were compared with previous models used for SOC estimation of A123 Li f ePO 4 Li-ion Battery. In [22], the authors introduced a method based on simple neural network and combined it with an unscented Kalman filter. Their neural network is static and does not have a memory, so UKF is used to filter out the outliers. Meanwhile, in the RoLSTM model, multiple LSTM layers can be learned by a bigger dataset, and it uses a self-learning algorithm to tune the parameters against uncertain outliers. In addition, the RoLSTM has a memory that is fitted for time series sequences. Generally, our proposed model has better performance in comparison with NN and UKF [22]. The MAX error at 0 • C is 1.9 by the RoLSTM while this values is 3.1 by NN and UKF [22]. The 25 and 50 • C the MAX error is equal in both methods. From the MAX error values in Table 4, it is apparent that the performance of RoLSTM is better than the simple NN [22]. Table 4 reveals that the RMSE has dropped using RoLSTM method on the same database. In addition, in another study, Yang et al. [37] introduced a multi-hidden LSTM network for SOC estimation. The minimum RMSE reported by them was 1.07, and an overall comparison shows RoLSTM gives a better performance.

Conclusions
The purpose of the current study was to reform an Adaptive Online LSTM method to find the SOC estimation of EVs' Li-ion batteries. It is based on deep learning and builds the connection between the input and output variables by nonlinear mapping. In other methods which depend on the battery model, a complex nonlinear equation is required and finding a model with high accuracy is one of their main challenges. For example, the Kalman filter method's performance is highly dependent on the measurement noise covariance, the battery model, and any imprecision in the battery model. Thus, any the noise of the system will reduce the performance of this method. The suggested RoLSTM network does not depend on the battery model and the initial values of SOC. The inputs are voltage, current, and temperature and the output is SOC estimation. Each input uses one LSTM. Then, three LSTM networks with fewer units are processed in parallel. As a result, the number of LSTM units can be reduced in the whole model. The method is a self-learning algorithm that can learn all the network parameters. The proposed algorithm is suitable for SOC estimation in different ambient temperatures. In addition, the number of LSTM units can be reduced in the whole model. In addition, the number of epochs for training the system is dropped. However, RoLSTM needs big data and extended training time to learn the system. The present study shows that the errors decrease when the system is trained by a proper number of epochs. Moreover, the RoAdam optimizer gives a smoother estimate in comparison with other optimizers of LSTM network. This network is applied in two different batteries. Changing the battery, the network architecture does not change, and one just needs to retrain the system. The results from the RoLSTM method are compared to previous methods in the literature (NN, NN and UKF, GRU, and LSTM with Adam optimization). This comparison indicates that the Maximum error of estimation and RMSE have decreased significantly for the two investigated battery types.

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

Abbreviations
The following abbreviations are used in this manuscript: