1. Introduction
With the development of the automobile industry and accelerated urbanization, environmental issues and energy problems are becoming more and more concerning [
1,
2]. Traditional fuel cars are not friendly to the solution of environmental problems, due to the high emission of carbon monoxide, hydrocarbons, and some other solid particles that have adverse effects on human body [
2]. On the other hand, as fuel is a non-renewable resource, with the current scale of fuel, fuel depletion will eventually come, and the automotive market must reduce fuel vehicles accordingly to reduce carbon emissions. Because of this, Norway will implement the policy of banning the sale of traditional fuel cars in 2025, and countries such as Germany, the UK, and France will also stop selling fuel cars between 2025 and 2040 one after another. Therefore, the development of electric vehicles has become a necessary direction and trend, and its rapid development will change all aspects of transportation and environmental issues [
3]. Lithium batteries have a high energy density and low self-discharge rate; they are also characterized by relatively light weight, large storage capacity, no memory effect, and a long-life cycle [
4], and they have been recognized as the main energy storage device for electric vehicles (EVs). However, because Li-ion battery packs operate in a highly dynamic driving environment, they will continue to deteriorate throughout the life cycle of the battery pack, thus affecting the performance of the BMS [
5,
6].
SOC indicates the remaining capacity of the battery, i.e., the percentage of the rated capacity remaining in the battery at a given discharge multiplier [
7].
In this case,
is the current charge of the battery, and
is the calibrated capacity of the battery. SOC plays a pivotal role in the performance evaluation of a BMS system, and simultaneous and accurate dynamic SOC estimation has become an important part of the BMS system [
6,
8]. However, SOC cannot be measured directly; due to the highly non-linear and dynamic nature of the internal chemistry of Li-ion batteries [
9], only indirect methods can be used to estimate the SOC of the battery. Therefore, dynamic yet accurate SOC estimation becomes a challenging task.
1.1. Literature Review
The current mainstream SOC algorithms are grouped into four categories, namely the open circuit voltage (OCV) [
10], ampere-hour integral, model-based estimation, and data-based estimation methods.
The OCV method finds the corresponding SOC value by open-circuit voltage measurement based on the OCV–SOC mapping relationship [
2,
4,
5,
11]. The disadvantage is that OCV–SOC curve will become very sensitive in the middle of the discharge process, and a smaller change in OCV will cause a larger SOC error, and the OCV measurement needs to be left for a period of time to be measured, so it is difficult to achieve real-time SOC estimation [
5,
12].
The ampere-hour integral method is currently the most widely used algorithm for the SOC estimation of Li-ion batteries. It calculates the total power flowing into or out of the battery by integrating the current of the battery, as well as the current [
11]. Although the ampere-hour integral method is relatively easy to calculate, the uncertainty of its initial power and instability of the discharge current lead to the low accuracy of SOC estimation, due to its open-loop estimation by nature.
Model-based estimation methods describe the external characteristics of the battery by combining different circuit elements to relate the SOC of the battery to variables, such as voltage and current [
13]. In addition, circuit models are often combined with nonlinear observers, in order to achieve dynamic SOC estimation. The circuit model mainly includes the electrochemical model (EM) and equivalent circuit model (ECM) [
14]. EM mainly responds to the internal chemical reaction mechanism of the battery, but it is difficult to determine all the parameters and has a large computational complexity. ECM is used with various battery components to depict the dynamic characteristics of the captured battery, and various ECM models have been proposed for lithium battery SOC estimation, including Rint [
15], Thevenin, and partnership for new generation of vehicles (PNGV) models [
15]. The model-based estimation methods that are widely used are mainly the Kalman filter (KF), particle filter (PF) [
16], H infinity filter (HIF), other state observers, etc. Because of the highly nonlinear nature of the battery, Fengchun Sun et al. proposed an adaptive unscented Kalman filter (UKF) to estimate the battery SOC and approximate this highly nonlinear system [
17]. Fei Zhang et al. proposed an H-infinity filter to estimate it in 2012 [
18]. However, among these methods, building an accurate circuit model is the key to model-based estimation methods. For the complex and dynamic nonlinear system of lithium batteries, it is difficult to find a circuit model that can depict it completely accurately, thus resulting in a low applicability to SOC estimation.
In recent years, data-based estimation methods have been emerging in SOC estimation algorithms. The data-based estimation algorithm is used to measure a series of data, such as voltage, current, and temperature of the battery, and estimate the prediction of the SOC of the battery by one or more sets of measured data. Common data-based estimation methods include support vector machine (SVM), extreme learning machine (ELM), and neural network deep learning algorithms [
19].
The SVM algorithm, first proposed by Cortes and Vapnik et al. In 1995 [
20], maps the nonlinear sample features into higher dimensional feature vectors via kernel functions, thus resulting in a mapping relationship between the input variables and output SOC. In order to obtain the most suitable kernel function and parameters for the working conditions, the algorithm of particle swarm (PSO) was used to optimize the SVM by Ran Li et al. [
21].
ELM was proposed by Guangbin Huang in 2004 [
22], featuring that the weight values of the input and hidden layer connections and thresholds of the hidden layer can be randomized without subsequent processing adjustments. Jiani Du et al. applied ELM to the SOC estimation of batteries in 2013 [
23].
Due to the rapid development of graphic processing units (GPU) in recent years, the training speed of neural networks has been reduced from months to days and hours or even minutes. Thanks to this, neural networks and SOC estimation methods for deep learning have also emerged. A neural network can be considered a black box, in which a large number of nonlinear functions are stored, which are nonlinear and can learn various deep, as well as abstract, features [
24]. In battery SOC estimation, the input data of the battery is sampled, processed for analysis, and passed into the neural network. According to the powerful learning ability of the neural network, a set of suitable neural network parameters can be trained to fit the final SOC output value that needs to be obtained, and the method does not require a tedious and complicated battery modeling process; as long as the data input to the network is large and accurate enough [
25], the SOC estimation is robust for all different battery situations.
The neural networks in SOC estimation are wavelet neural network (WNN), back propagation neural network (BP) trained by error backpropagation, etc. Bizhong Xia et al. proposed a multi-hidden layer WNN model optimized by the L-M algorithm to estimate SOC in 2018 [
26]; in the same year, Hannan, MA et al. proposed to improve BP network using BSA algorithm [
27].
Since the battery charging and discharging process is continuous, and the sampling of the battery data is also continuous, SOC estimation can be considered as a time-series regression prediction problem. In traditional neural networks, signals are not passed between neurons at the same level, which leads to a problem, i.e., that the output signal is only related to the input signal, but not to the backward and forward relationship or sequence of the input signal. If the overall network lacks a “memory” function, then a “memory” network with the ability to understand the before and after information or the temporal order of data is needed. Based on this, recurrent neural networks (RNN) were introduced, and Hicham Chaoui et al. proposed estimating the SOC using RNN in 2017 [
28].
RNN use the internal circulation of neural networks to preserve the connection of the contextual information of the time series; however, in practical applications, temporal information tends to decay because the transmission interval is too long. Therefore, ordinary RNN do not have a good way to deal with the long-term dependence problem of temporal information; in addition, RNN produce a series of gradient vanishing problems when back-propagating. To solve these, LSTM was proposed by Hochreiter, S and Schmidhuber, J in 1997 [
29], which can learn the long-term dependence problem of information, and LSTM has achieved great success in natural language processing (NLP), as well as temporal data processing [
30]. Fangfang Yang et al. successfully applied LSTM network applied to battery SOC estimation, which produced better results [
31].
Gated recurrent unit (GRU) is a variant of LSTM, which was proposed by K. Cho in 2014. GRU uses two gates to regulate the flow of long-term information, as well as forgetting with fewer parameters and faster training, compared to LSTM. Meng Jiao et al. proposed GRU-RNN in 2020 to estimate the SOC of the battery [
32].
Although LSTM has a good effect on battery SOC estimation, it cannot do a very accurate estimation of battery SOC under various battery temperatures and operating conditions, due to the dynamic nature of battery operation. Fangfang Yang et al. proposed a method combining LSTM and UKF [
33], and Yong Tian et al. proposed combining LSTM with an adaptive cubature Kalman filter (ACKF) [
4], which greatly improved the estimation accuracy. However, since the results of the filtering algorithm partly depend on the output of the network, the ups and downs of the network output results will lead to a large impact on the final filtering results. Therefore, a stable network output under different battery conditions becomes an indispensable part.
1.2. Contributions of the Work
In order to solve the above series of problems, this paper proposes a method combining machine learning and traditional filtering to estimate the SOC of lithium batteries, i.e., LSTM–attention combined with Kalman filtering. First, for the characteristics of the internal nonlinearity of the battery and SOC estimation as a time series problem, an LSTM network was designed through the collected battery voltage, current, and temperature data, combined with the attention mechanism to assign weights to each time step and according to the assigned weight scores, in order to decide which time step input data information; it will be more useful for training, so as to roughly estimate the SOC. In addition, Kalman filtering was used to improve the accuracy of the predicted SOC values, reduce the prediction error, and smooth the prediction output. Then, data from different dynamic driving cycles were used to evaluate the performance of the method. The contributions of this work are mainly as follows.
An LSTM–attention model for SOC estimation is proposed. The attention mechanism was used to optimize the LSTM network, so that the network can capture deeper input–output mapping relationships, as well as the importance of timing information, and it was experimentally demonstrated that the optimized network converges faster and smoother, in terms of loss values during training and testing, to ensure the accuracy of SOC estimation.
Kalman filtering was used to update the prediction results. The estimation accuracy of the SOC was further improved, so that the estimation results of the proposed network can be smoother and have less error.
The effects of different initial power, temperature, and operating conditions on the model accuracy were analyzed experimentally. In addition, the system model in this paper was compared with the existing LSTM and LSTM, combined with the Kalman filter, and the effectiveness of the LSTM–attention–Kalman method for SOC estimation was verified using a public data set.
1.3. Organization of This Article
The remainder of this paper is organized as follows.
Section 1 introduces the principles of long short-term memory networks.
Section 2 describes the network structure and the application of the attention mechanism on LSTM.
Section 3 details the Kalman filtering method and how it is applied on top of the output results of the network.
Section 4 summarizes the sources of the data and the normalized processing of the data.
Section 5 is used to conduct comparative experiments and record the results. Finally,
Section 6 is used to conclude the whole work.
3. Kalman Filter
In this section, Kalman algorithm is used to improve the output results of the attention network. It allows the optimal estimation of the state of the system by using the data from the input and output observations of the system. In addition, in this process, the noise, including the system, can also be filtered out and does not need to meet the condition that both the signal and noise are smooth; therefore, it is widely used in various fields.
Kalman filtering is a recursive estimation built on the hidden Markov model. Its dynamical system can be represented by a Markov chain built on a linear operator that satisfies a normal distribution of disturbances, and this linear operator increases with time to produce a new state.
In order to estimate the internal state of the observed process from a series of noisy observations using the Kalman filter, the process must be modeled in the framework of the Kalman filter. This means that for each moment of , the matrix , , , , and is defined separately.
The Kalman model assumes that the real state at time
evolves from the previous moment, that is, time
. The state vector
can be represented by the following equation.
The above equation is called the equation of state, where is the state transformation matrix acting on . is the state control matrix acting on the state control vector . is the noise satisfying a Gaussian distribution with mean 0. ~ . is the system noise covariance matrix.
For the measurement vector
of
at the moment
.
The above equation is called the measurement equation. In this, is the observation matrix. It is used to map the real state space into the observed space. is the noise of Gaussian distribution with mean 0. is its covariance matrix, which satisfies ~ .
The operation of Kalman’s algorithm consists of two steps: predict and update, respectively. The prediction phase filter can use the estimation result of the previous moment to estimate the state of the current moment. The update filter optimizes the predict value with the current state observation. This is used to make the estimates more accurate.
Figure 8 shows the flow chart of Kalman’s algorithm.
In the prediction phase, since the optimal state of the system at time
obeys a Gaussian distribution:
According to the prediction equation
of Equation (13), the predicted state at the moment of
can be obtained as:
The predicted state at the moment of
is obtained:
is the posterior estimation state at the moment . Similarly, is the posterior estimation state at the moment . is the state of the prior estimate at the moment . is the covariance of the posterior estimate at the moment .
Since the product of two Gaussian distributions is still a Gaussian distribution, it is expressed as follows.
Knowing
,
, then
, where:
The measurement Equation (14) is also transformed to obtain the measurement state
at moment
, which also satisfies the Gaussian distribution. The measurement itself also satisfies the Gaussian distribution
, and multiplying the above two measurement quantities together, i.e.,
, can be obtained as follows-.
where
. Replace
above. The updated part can be obtained as follows.
where
is the posterior estimated covariance at time
.
is the prior estimated covariance at time
.
is the Kalman gain.
In this paper, the traditional ampere-hour integral method is used as the state equation of Kalman’s algorithm. The state vector is set as the Ansatz integral obtained by
in the following equation.
This is where is the current measured at time , is the nominal capacity of the lithium battery, is the time interval between the two samples, and is the measured by the ampere-hour integral method at time . is the noise satisfying a Gaussian distribution with mean 0 satisfying ~ .
To make the network results better using Kalman’s algorithm, the output of the network is used here as Kalman’s measurement function, represented as follows.
In this case, is the output of the network, and and are both Gaussian distributed noise with mean 0.
Here, the measurement noise covariance is transformed from 1e3 to 1e1, respectively, to obtain the final filtering effect with the noise covariance transformation, as in
Figure 9.
It can be seen that the measurement covariance has little effect on the system within a certain range, which proves that the filtering has good robustness. In the experiment, , , is chosen to consider the uncertainty of the system.
The system framework designed in this paper is shown in
Figure 10 below: it is divided into online and offline phases. The collected battery data is first trained in the offline phase using the established LSTM + attention network. Then, the Kalman algorithm is used to perform a real-time online update of the collected results.
4. Dataset
The EV battery data used in this paper was obtained from the University of Maryland (CALCE) advanced life cycle. The test sample was an 18,650
graphite lithium-electric battery, and the specific specifications of this battery type are shown in
Table 1 below.
The battery was placed at 0, 25, and 45 °C for charge and discharge experiments, respectively. The discharge includes the US06, DST, FUDS working conditions, which is used to simulate different driving conditions of electric vehicles.
Figure 11 below shows the discharge curves for each operating condition in one cycle at 25 degrees Celsius.
From the above figure, it can be known that there is a significant difference in the variation of current with time for each working condition discharge. US06 is more complicated, while the discharge current of DST working condition is relatively simple.
Figure 12 below shows the curves of current, voltage, and SOC versus time for the entire experimental testing process of the battery under the three conditions of US06, DST, and FUDS. First, the battery is charged with a cross-current charge current of 1 A; when the voltage reaches 4.2 V, the constant voltage discharge starts, keeping the voltage constant. Once the current reaches below 20 mA, the battery is rested; after resting, the battery is discharged with a cross-current discharge current of 1 A, and it has been discharged cross-currently until the working condition is discharged. Two working condition discharge starting capacities are set in the experiment, 50% and 80%, respectively.
To fully test the robustness of the network, data collected from the US06, DST, and FUDS conditions were used here as the training set; then, the other two conditions were used as the test set, respectively; the input to the network represents the voltage, current, and temperature collected in the time step, with a sampling interval of 1 s, respectively.
The experiments in this article were conducted with an Intel I7 12700KF CPU, RTX3070TI graphics card, and Windows 10 operating system, Tensorflow-keras framework, Python version 3.7, US06, DST, and FUDS conditions, with 200 training epochs and training times of 15, 8, and 20 min, respectively. The training epochs for US06, DST, and FUDS cases were 200, and the training times were 15, 8, and 20 min, respectively. Subsequent Kalman filter processing was performed using MATLAB.
To evaluate the accuracy of the proposed network and curve fit between the predicted and true values, MAE and RMSE are used here as metrics for the evaluation. MAE denotes the mean value of the absolute error, and RMSE denotes the squared open root sign of the difference between the true value and the error, and they can be described by the following equation.
is the predicted value, is the actual value, and is the sample size.
6. Conclusions
In this paper, an algorithm combining LSTM–attention and Kalman filtering is proposed to estimate the battery SOC in dynamic systems. The method first uses the measured temperature, voltage, and current data for processing and passes them into an LSTM–attention network to obtain an approximate SOC value. It then uses Kalman’s algorithm to further improve the reliability of the algorithm. It is demonstrated that the proposed method can learn the internal dynamics of the battery well and has higher estimation accuracy than both the simple LSTM–attention and LSTM–Kalman under different temperatures, working conditions, and initial charge conditions, with DST for training at room temperature and two other working conditions for testing. The average RMSE of LSTM–attention-Kalman was 0.466 and 0.3995 percentage points higher than that of LSTM–attention and LSTM–Kalman, respectively. In addition, the method is data-driven and does not require circuit models, very precise tuning of network parameters, or the construction of OCV–SOC lookup tables.
With the high-speed development of the GPU and wide application of the BMS system, it provides a lot of technical, as well as data, support for the training of neural network. The use of collected big data for SOC estimation has very broad prospects. Therefore, in the future, the machine learning method will become a powerful tool for lithium battery SOC estimation.