Lithium-ion Battery State of Charge Estimation Based on a Gated Recurrent Unit Encoder-Decoder Framework

The accurate estimation of the State of Charge (SOC) is a cornerstone for the safe, efficient, and reliable operation of lithium-ion batteries, which are the dominant energy storage solution in modern applications ranging from electric vehicles to grid-scale storage systems. As the application domains for lithium-ion battery technology continue to expand, the demand for precise, robust, and real-time SOC estimation within the Battery Management System (BMS) has become increasingly critical. This necessity drives the continuous evolution of estimation methodologies beyond traditional approaches.

Traditional SOC estimation methods, such as Coulomb counting and model-based filters like the Kalman filter, face significant challenges. Coulomb counting is highly susceptible to initial value errors and current sensor drift, while model-based methods rely on precise electrochemical or equivalent circuit models that are difficult to parameterize accurately across the entire lifecycle and under varying operational conditions of a lithium-ion battery. These limitations have catalyzed the shift towards data-driven techniques, particularly deep learning, which can learn complex, non-linear mappings directly from measurable operational data—current, voltage, and temperature—to the target SOC.

Among deep learning architectures, Recurrent Neural Networks (RNNs) are naturally suited for sequential data. However, vanilla RNNs suffer from the vanishing gradient problem, making it difficult to learn long-term dependencies in time-series data from a lithium-ion battery. Advanced gated RNN variants, namely the Long Short-Term Memory (LSTM) and the Gated Recurrent Unit (GRU), were introduced to mitigate this issue. The GRU, with its simpler structure featuring update and reset gates, often demonstrates comparable performance to LSTM with faster training convergence, making it an attractive choice for modeling the temporal dynamics of a lithium-ion battery.

While standard (unidirectional) GRU networks process sequence data in chronological order, they can only utilize past context. Bidirectional GRU (BiGRU) networks enhance this by processing data in both forward and backward directions, capturing context from the entire input sequence for each time step. Nonetheless, for sequence-to-sequence prediction tasks like SOC estimation, where the goal is to generate an output sequence (SOC) from an input sequence (measurements), the Encoder-Decoder (ED) framework offers a more powerful paradigm. This paper proposes a novel SOC estimation method by constructing an Encoder-Decoder model based entirely on GRU cells (GRU-ED). In this architecture, a bidirectional GRU network acts as the encoder to comprehensively compress the entire input sequence into a context vector. A unidirectional GRU network then serves as the decoder, using this context to autoregressively generate the accurate SOC estimation sequence. This end-to-end model is designed to more completely learn and exploit the temporal dependencies in lithium-ion battery operational data.

Methodology: The GRU-ED Model

1. Gated Recurrent Unit (GRU) Fundamentals

The GRU is a type of recurrent neural network designed to capture long-range dependencies in sequential data. It addresses the vanishing gradient problem through gating mechanisms that regulate the flow of information. A single GRU cell operates using the following equations at each time step \(t\):

Update Gate: The update gate \(z_t\) determines how much of the past hidden state should be retained.
$$z_t = \sigma(W_z \cdot [h_{t-1}, x_t] + b_z)$$

Reset Gate: The reset gate \(r_t\) controls how much of the past hidden state is used to compute the candidate state.
$$r_t = \sigma(W_r \cdot [h_{t-1}, x_t] + b_r)$$

Candidate Hidden State: This is a proposed new memory content, computed using the reset gate.
$$\tilde{h}_t = \tanh(W_h \cdot [r_t \odot h_{t-1}, x_t] + b_h)$$

Final Hidden State: The final hidden state for time step \(t\) is a linear interpolation between the previous hidden state and the candidate state, governed by the update gate.
$$h_t = (1 – z_t) \odot h_{t-1} + z_t \odot \tilde{h}_t$$

Here, \(x_t\) is the input vector at time \(t\), \(h_{t-1}\) is the hidden state from the previous time step, \(\sigma\) denotes the sigmoid activation function, \(\tanh\) is the hyperbolic tangent function, \(\odot\) represents the Hadamard (element-wise) product, and \(W_z, W_r, W_h, b_z, b_r, b_h\) are trainable weight matrices and bias vectors. The ability of the GRU to selectively remember and forget information makes it highly effective for modeling the complex, time-dependent behavior of a lithium-ion battery.

2. Encoder-Decoder Architecture with GRU

The proposed GRU-ED model is an end-to-end sequence-to-sequence learning framework. Its primary components and workflow are detailed below.

Encoder (Bidirectional GRU): The encoder’s role is to read and compress the entire input sequence \(X = (x_1, x_2, …, x_L)\) of length \(L\) into a fixed-dimensional context vector \(c\). Each \(x_t\) is a vector containing the measurable parameters from the lithium-ion battery: current, voltage, and temperature. To prevent the loss of early-sequence information—a common issue with long sequences in unidirectional RNNs—we employ a Bidirectional GRU (BiGRU). A BiGRU consists of two independent GRU layers: one processing the sequence forward (\(\overrightarrow{GRU}\)) and the other processing it backward (\(\overleftarrow{GRU}\)). The final hidden state is a concatenation of the final states from both directions:
$$\overrightarrow{h}_L = \overrightarrow{GRU}(x_1, x_2, …, x_L)$$
$$\overleftarrow{h}_1 = \overleftarrow{GRU}(x_L, x_{L-1}, …, x_1)$$
$$c = [\overrightarrow{h}_L; \overleftarrow{h}_1]$$
This context vector \(c\) encapsulates a rich, bidirectional summary of the entire input sequence’s dynamics, crucial for accurate SOC estimation of the lithium-ion battery.

Decoder (Unidirectional GRU): The decoder’s task is to generate the output SOC sequence \(\hat{Y} = (\hat{y}_1, \hat{y}_2, …, \hat{y}_L)\) one step at a time, conditioned on the context vector \(c\). The decoder is a unidirectional GRU network. Its initial hidden state \(s_0\) is typically initialized with the context vector \(c\) or a transformation of it. The decoding process is autoregressive:
$$s_t = GRU_{dec}([\hat{y}_{t-1}], s_{t-1}) \quad \text{for } t \geq 1$$
$$\hat{y}_t = \psi(s_t)$$
where \(s_t\) is the decoder’s hidden state at time \(t\), \(\hat{y}_{t-1}\) is the previously estimated SOC value (or a start token for \(t=1\)), and \(\psi\) is a fully connected output layer, often with a linear activation for regression tasks. The decoder thus unfolds the compressed information in \(c\) back into a temporal sequence, generating the SOC estimate for each corresponding time step of the lithium-ion battery input.

The overall model is trained end-to-end by minimizing the Mean Squared Error (MSE) between the predicted SOC sequence \(\hat{Y}\) and the ground-truth sequence \(Y\) (typically obtained via high-precision Coulomb counting for training data).

3. Data Preprocessing and Model Configuration

To effectively train the GRU-ED model for lithium-ion battery SOC estimation, careful data preparation is essential. The continuous stream of measurement data (current \(I\), voltage \(U\), temperature \(T\)) is segmented into fixed-length, overlapping or non-overlapping sequences of length \(L\). This creates a dataset of input-output pairs \(\{(X_i, Y_i)\}\), where \(X_i \in \mathbb{R}^{L \times 3}\) and \(Y_i \in \mathbb{R}^{L \times 1}\). To ensure stable and fast convergence during training, the input features are standardized by removing the mean and scaling to unit variance. The model’s key hyperparameters are summarized in the table below.

Hyperparameter Value / Description
Input Features Current (I), Voltage (U), Temperature (T)
Output Target State of Charge (SOC)
Sequence Length (L) 80 time steps
Encoder Hidden Units 300 (per direction in BiGRU)
Decoder Hidden Units 300
Training Optimizer Adam
Initial Learning Rate 0.001
Loss Function Mean Squared Error (MSE)
Batch Size 64
Output Layer Fully Connected (Linear Activation)

4. Evaluation Metrics

The performance of the lithium-ion battery SOC estimation model is quantitatively assessed using two primary error metrics calculated over all \(M\) test samples:

Mean Absolute Error (MAE): This metric provides the average magnitude of estimation errors.
$$MAE = \frac{1}{M} \sum_{i=1}^{M} |y_i – \hat{y}_i|$$

Maximum Absolute Error (MAX): This metric identifies the worst-case estimation error, which is critical for BMS safety.
$$MAX = \max_{i=1,…,M} (|y_i – \hat{y}_i|)$$

Here, \(y_i\) is the true SOC value and \(\hat{y}_i\) is the estimated SOC value from the model for the lithium-ion battery.

Experimental Validation and Analysis

1. Dataset Description

The experiments utilize a publicly available dataset featuring Panasonic NCR18650PF lithium-ion battery cells. The dataset was generated under simulated electric vehicle driving profiles at multiple ambient temperatures (-20°C, -10°C, 0°C, 10°C, 25°C). For the scope of this study, data from 0°C, 10°C, and 25°C are primarily used. Each driving cycle consists of sequences of measured current, voltage, surface temperature, and the corresponding reference SOC calculated via Coulomb counting. Key battery specifications are listed below.

Parameter Specification
Chemistry LiNiCoAlO2 (NCA)
Rated Capacity 2.9 Ah
Voltage Range 2.5 V – 4.2 V

2. SOC Estimation under Fixed Ambient Temperatures

The GRU-ED model was first evaluated and compared against other prominent bidirectional recurrent networks—BiSRNN, BiLSTM, and BiGRU—under fixed temperature conditions (0°C, 10°C, 25°C). For each temperature, models were trained on data from several driving cycles and tested on unseen cycles (HWFET and US06). The following table summarizes the comparative MAE results at 10°C, demonstrating the superior accuracy of the proposed architecture for lithium-ion battery SOC estimation.

Model MAE on HWFET (%) MAE on US06 (%)
BiSRNN 1.98 1.67
BiLSTM 1.58 1.42
BiGRU 1.54 1.48
GRU-ED (Proposed) 1.09 1.03

The GRU-ED model consistently achieved the lowest MAE and MAX errors across all three temperatures. The encoder-decoder framework’s ability to build a comprehensive contextual understanding of the entire input sequence before decoding allows it to produce smoother and more accurate SOC trajectories for the lithium-ion battery compared to standard recurrent networks that make step-by-step predictions with limited future context.

3. SOC Estimation with Unknown Initial States

In real-world operation, a lithium-ion battery is rarely always charged to 100% SOC before a drive cycle begins. To test the model’s robustness, the trained GRU-ED model (trained on data starting from 100% SOC) was applied to test cycles with different initial SOC levels (80%, 60%, 40%). The results, shown in the table below for the HWFET cycle, indicate that while error increases as the initial condition deviates further from the training norm, the model maintains commendable accuracy, with MAE generally below 2%. This demonstrates the model’s strong generalization capability for the lithium-ion battery SOC estimation task.

Initial SOC MAE at 10°C (%) MAX at 10°C (%)
80% 1.23 3.23
60% 1.65 4.50
40% 2.01 3.63

4. SOC Estimation under Varying Ambient Temperatures

A crucial test for any BMS algorithm is performance under changing environmental conditions, as a lithium-ion battery in an electric vehicle experiences fluctuating temperatures. To address this, a single GRU-ED model was trained on a combined dataset encompassing driving cycles from 0°C, 10°C, and 25°C. This “mixed-temperature” model was then evaluated in two scenarios:

a) Fixed but Unseen Temperatures: The model was tested on held-out cycles at each individual temperature. The results confirmed that a single model could achieve high accuracy across a temperature range, with MAE values all below 1.2%.

b) Dynamic Temperature Change: The model was tested on a specific driving cycle where the ambient temperature gradually increased from 10°C to 25°C during operation. This is a challenging scenario that stresses the model’s ability to adapt its estimation based on the evolving temperature input. The GRU-ED model successfully estimated the SOC with an MAE of 0.92% and a MAX error of 4.96%, significantly outperforming previously reported results from simpler LSTM models on similar tasks for the lithium-ion battery.

The success in this scenario can be attributed to the encoder’s bidirectional processing: when estimating SOC at a point during the temperature transition, the encoder has access to measurement context from both the past (cooler period) and the future (warmer period), allowing it to synthesize a more informed context vector for the decoder.

Conclusion

This paper presented a novel data-driven approach for accurate State of Charge estimation in lithium-ion battery systems using a Gated Recurrent Unit based Encoder-Decoder (GRU-ED) model. The proposed framework leverages a bidirectional GRU encoder to create a rich, context-aware representation of the input measurement sequence (current, voltage, temperature), which a unidirectional GRU decoder then translates into an accurate SOC estimation sequence. Comparative experiments under fixed ambient temperatures demonstrated that the GRU-ED model outperforms other bidirectional recurrent neural networks like BiGRU, BiLSTM, and BiSRNN, achieving lower mean and maximum absolute errors. Furthermore, the model exhibits strong robustness in practical scenarios: it maintains good estimation accuracy when the initial SOC is unknown and, most importantly, delivers highly reliable SOC estimates even under varying ambient temperature conditions—a critical capability for real-world lithium-ion battery management in electric vehicles and other dynamic applications. The results affirm that the encoder-decoder architecture is a powerful and effective deep-learning paradigm for capturing the complex temporal dependencies inherent in lithium-ion battery behavior for state estimation.

Scroll to Top