Accurately estimating the State of Charge (SOC) in battery systems is a critical challenge for the efficient and safe operation of modern cell energy storage systems. SOC represents the remaining usable capacity of a battery, analogous to a fuel gauge, and its precise knowledge is indispensable for energy management, performance optimization, and longevity prediction. In the context of sodium-ion batteries, which are gaining prominence due to their cost advantages and material abundance for large-scale cell energy storage system applications, robust SOC estimation becomes even more vital. However, SOC is an internal state that cannot be measured directly; it must be inferred from external, measurable parameters such as terminal voltage, current, and temperature. The inherent nonlinearity, time-varying dynamics, and complex electrochemical behaviors of batteries, especially under diverse operating conditions, make this estimation problem highly challenging.
Traditional methods for SOC estimation, such as the Ampere-hour (Ah) integration and Open-Circuit Voltage (OCV) methods, are often inadequate for dynamic real-world applications. The Ah integration method suffers from error accumulation due to current sensor inaccuracies and unknown initial SOC, while the OCV method requires long rest periods to reach equilibrium, making it impractical for online estimation. Model-based approaches, including equivalent circuit models (ECMs) and electrochemical models, have been employed to address these issues. While ECMs offer a balance between complexity and accuracy, their performance heavily depends on the accurate identification of model parameters, which can vary with aging, temperature, and operational history. For the cell energy storage system operating in fluctuating environments, these variations can lead to significant estimation errors.

In recent years, data-driven methods, particularly those leveraging deep learning, have emerged as powerful alternatives for SOC estimation. These methods learn the complex mapping between battery measurements and SOC directly from historical data, bypassing the need for explicit physical or electrochemical models. Among various deep learning architectures, Recurrent Neural Networks (RNNs) and their variants, such as Long Short-Term Memory (LSTM) networks and Gated Recurrent Units (GRUs), have shown exceptional promise due to their inherent ability to capture temporal dependencies in time-series data. However, standard LSTM models may not always focus on the most relevant time steps for the current prediction, and their performance is highly sensitive to the choice of hyperparameters, often requiring extensive manual tuning.
To overcome these limitations and enhance the accuracy and robustness of SOC estimation for sodium-based cell energy storage systems, this work proposes a novel integrated framework: the Grid Search-optimized LSTM with Attention mechanism (GS-LSTM-Attention) model. The core innovation lies in synergistically combining three key elements. First, the LSTM network serves as the foundational temporal feature extractor, capable of learning long-range dependencies in the sequential battery data. Second, an attention mechanism is incorporated to dynamically weigh the importance of different time steps in the LSTM’s hidden state sequence, allowing the model to focus on the most informative periods for SOC estimation. Third, a systematic Grid Search (GS) algorithm is employed to optimize critical model hyperparameters, moving beyond heuristic tuning to find a configuration that maximizes estimation performance. This comprehensive approach aims to deliver high-precision, reliable SOC estimates across various operational conditions, which is essential for the advanced battery management systems (BMS) of any large-scale cell energy storage system.
The remainder of this article is structured as follows. First, a detailed theoretical foundation of the core components—LSTM, Attention Mechanism, and Grid Search—is provided, complete with mathematical formulations. Subsequently, the complete architecture and operational workflow of the proposed GS-LSTM-Attention model for SOC estimation are described. The experimental setup, including the sodium-ion battery dataset, data preprocessing, and evaluation metrics, is then presented. A comprehensive analysis of the results follows, comparing the performance of the proposed model against baseline LSTM and LSTM-Attention models under different constant-current discharge conditions. Finally, conclusions are drawn, and potential directions for future research are discussed.
Theoretical Foundation and Model Architecture
Long Short-Term Memory (LSTM) Networks
For modeling sequential data like that from a cell energy storage system, standard feedforward neural networks are insufficient as they lack memory of past inputs. Recurrent Neural Networks (RNNs) address this by having loops, allowing information to persist. However, vanilla RNNs suffer from the vanishing and exploding gradient problems, making it difficult to learn long-term dependencies. The Long Short-Term Memory (LSTM) network, a special kind of RNN, was designed to mitigate this issue through a more sophisticated memory cell and gating mechanisms.
An LSTM unit maintains a cell state $$c_t$$ that runs through the entire sequence chain, with linear interactions allowing information to flow unchanged. It regulates the information flow via three gates: the forget gate $$f_t$$, the input gate $$i_t$$, and the output gate $$o_t$$. The mathematical operations within an LSTM cell at time step $$t$$ are defined as follows:
Forget Gate: This gate decides what information from the previous cell state $$c_{t-1}$$ should be discarded.
$$ f_t = \sigma(W_f \cdot [h_{t-1}, x_t] + b_f) $$
where $$x_t$$ is the current input, $$h_{t-1}$$ is the previous hidden state, $$W_f$$ is the weight matrix, $$b_f$$ is the bias vector, and $$\sigma$$ denotes the sigmoid activation function, outputting values between 0 and 1.
Input Gate: This gate determines what new information will be stored in the cell state. It has two parts: a sigmoid layer that decides which values to update, and a tanh layer that creates a vector of new candidate values, $$\tilde{c}_t$$.
$$ i_t = \sigma(W_i \cdot [h_{t-1}, x_t] + b_i) $$
$$ \tilde{c}_t = \tanh(W_c \cdot [h_{t-1}, x_t] + b_c) $$
Cell State Update: The old cell state $$c_{t-1}$$ is updated to the new cell state $$c_t$$.
$$ c_t = f_t \odot c_{t-1} + i_t \odot \tilde{c}_t $$
Here, $$\odot$$ represents the Hadamard (element-wise) product.
Output Gate: This gate decides what part of the cell state will be output as the hidden state $$h_t$$.
$$ o_t = \sigma(W_o \cdot [h_{t-1}, x_t] + b_o) $$
$$ h_t = o_t \odot \tanh(c_t) $$
The hidden state $$h_t$$ serves as the output of the LSTM unit and is passed to the next time step and potentially to subsequent network layers.
This gated structure allows the LSTM to learn which information in the sequence is important to keep or discard over long periods, making it highly suitable for learning the temporal patterns in cell energy storage system data such as voltage and current profiles related to SOC.
Attention Mechanism
While LSTMs are effective at capturing temporal dependencies, all time steps in the sequence are treated equally when making a prediction at a given time. In reality, for tasks like SOC estimation, certain periods in the input sequence (e.g., moments of high current change or specific voltage plateaus) may be more informative than others. The attention mechanism provides a solution by enabling the model to dynamically focus on relevant parts of the input sequence.
In the context of sequence modeling, attention computes a weighted sum of the hidden states $$(h_1, h_2, …, h_T)$$ from the LSTM layer, where the weights indicate the relative importance of each time step for the current prediction task. The mechanism involves three key steps:
1. Score Calculation: A scoring function evaluates the relevance of each hidden state $$h_i$$. A common additive scoring function is used:
$$ e_{t,i} = v_a^T \tanh(W_a \cdot h_i + U_a \cdot h_t + b_a) $$
Here, $$h_t$$ is often the hidden state at the current decoder step, but in many sequence-to-point models for regression (like SOC estimation), a simplified context vector is computed for the entire sequence. A simpler but effective approach for a many-to-one regression model is to use a feedforward network on each hidden state:
$$ e_i = \text{MLP}(h_i) $$
2. Weight Calculation: The scores are normalized using the softmax function to produce attention weights $$\alpha_i$$ that sum to 1.
$$ \alpha_i = \frac{\exp(e_i)}{\sum_{j=1}^{T} \exp(e_j)} $$
3. Context Vector Calculation: The context vector $$C$$, which is a weighted summary of the entire input sequence, is computed as:
$$ C = \sum_{i=1}^{T} \alpha_i h_i $$
This context vector, rich with the most salient information from the sequence, is then fed into subsequent layers (e.g., fully connected layers) to make the final SOC prediction. Integrating attention with LSTM allows the model to accentuate critical temporal features, potentially leading to more accurate and robust estimates for the cell energy storage system’s SOC, especially under complex operating conditions.
Grid Search Optimization
The performance of deep learning models, including LSTM-Attention networks, is profoundly influenced by the choice of hyperparameters. These are parameters set before the training process begins, such as the number of LSTM units, learning rate, batch size, and number of training epochs. Manual tuning based on experience or trial-and-error is inefficient and often suboptimal. Grid Search (GS) is a systematic and exhaustive hyperparameter optimization technique that automates this process.
Grid Search operates by defining a finite set of possible values for each hyperparameter to be tuned. It then evaluates the model performance for every possible combination of these values in the defined hyperparameter space. The combination that yields the best performance on a held-out validation set is selected as the optimal configuration.
Formally, let the set of hyperparameters to be optimized be denoted by $$\Theta = \{\theta_1, \theta_2, …, \theta_n\}$$. For each hyperparameter $$\theta_i$$, a discrete set of candidate values is defined: $$\theta_i \in \{v_{i1}, v_{i2}, …, v_{im}\}$$. The Cartesian product of these sets forms the grid $$\mathcal{G}$$. For each hyperparameter combination $$\boldsymbol{\theta} \in \mathcal{G}$$, a model $$M(\boldsymbol{\theta})$$ is trained on the training data $$D_{train}$$ and evaluated on the validation data $$D_{val}$$ using a predefined performance metric $$P$$ (e.g., Mean Squared Error). The optimal hyperparameter set $$\boldsymbol{\theta}^*$$ is found by:
$$ \boldsymbol{\theta}^* = \arg \min_{\boldsymbol{\theta} \in \mathcal{G}} P(M(\boldsymbol{\theta}), D_{val}) $$
For the SOC estimation task, minimizing the Mean Squared Error (MSE) on the validation set is a typical objective. Applying Grid Search to optimize the LSTM-Attention model ensures that the model’s capacity and learning dynamics are tailored to the specific characteristics of the cell energy storage system data, leading to improved generalization and estimation accuracy.
Proposed GS-LSTM-Attention Model Architecture
The proposed GS-LSTM-Attention model integrates the LSTM network, the attention mechanism, and Grid Search optimization into a cohesive framework for SOC estimation. The complete architecture and workflow are illustrated in the diagram below and described in detail thereafter.
The model takes sequential data from the cell energy storage system as input. For each time step, the input features typically include measured current (I), voltage (V), and sometimes temperature (T). The target output is the corresponding SOC value. The operational pipeline consists of the following stages:
1. Data Preprocessing: The raw time-series data is first normalized to a common scale, typically [0, 1], to accelerate and stabilize the training process. The Min-Max normalization is applied to each feature channel independently:
$$ x’ = \frac{x – x_{\text{min}}}{x_{\text{max}} – x_{\text{min}}} $$
where $$x$$ is the original value, and $$x_{\text{min}}$$ and $$x_{\text{max}}$$ are the minimum and maximum values of that feature in the training set, respectively. The dataset is then segmented into fixed-length sequences (with a defined look-back window) to form the input samples for the model.
2. Model Construction: The neural network model is constructed with the following layers:
- Input Layer: Receives the normalized sequential data of shape (sequence_length, number_of_features).
- LSTM Layer(s): One or more LSTM layers process the input sequence, outputting a sequence of hidden states $$(h_1, h_2, …, h_T)$$ for each sample. The number of LSTM units (or hidden size) is a key hyperparameter.
- Attention Layer: The attention mechanism takes the sequence of LSTM hidden states as input. It computes attention weights and produces a context vector $$C$$ as described earlier.
- Fully Connected (Dense) Layers: The context vector is fed into one or more fully connected layers, which perform non-linear transformations to map the high-level features to the final output.
- Output Layer: A single neuron with a linear activation function outputs the estimated SOC value (after appropriate rescaling if necessary).
3. Hyperparameter Optimization via Grid Search: Before the final model training, a Grid Search is conducted to find the optimal values for critical hyperparameters. For this SOC estimation model, the primary hyperparameters considered are:
- Number of units in the LSTM layer(s).
- Learning rate for the optimizer (e.g., Adam).
- Number of training epochs.
- Batch size.
A predefined grid of values for each parameter is established. The model is trained and validated for every combination, and the combination yielding the lowest validation MSE is selected.
4. Model Training and SOC Estimation: Using the optimal hyperparameters found by Grid Search, the final LSTM-Attention model is trained on the combined training and validation data (or via cross-validation). After training, the model can estimate the SOC for new, unseen sequences of current and voltage data from the cell energy storage system.
The synergy of these components is key: the LSTM captures complex temporal dynamics, the attention mechanism focuses on critical intervals, and Grid Search ensures the model structure and training process are optimally configured. This comprehensive approach is designed to significantly enhance the precision and reliability of SOC estimation, which is a cornerstone for the efficient management of any cell energy storage system.
Experimental Setup and Methodology
Dataset Description
To validate the proposed GS-LSTM-Attention model, experimental data from commercial 18650 cylindrical sodium-ion batteries was utilized. The nominal capacity of the batteries was 1.0 Ah. Data was collected under controlled laboratory conditions at a constant ambient temperature of 25°C. The charge-discharge cycles were performed at constant current (CC) rates to simulate different load conditions relevant to a cell energy storage system. Three distinct discharge current profiles were selected to test model robustness under varying operational stresses: 2 A, 5 A, and 6 A. For each cycle, time-synchronized measurements of voltage (V), current (I), and the calculated discharge capacity (used to derive the reference SOC) were recorded at a 1-second sampling interval.
The reference SOC was calculated using the accurate Coulomb counting method based on the measured current and the known initial capacity, providing the ground truth for model training and evaluation. For each discharge current (2A, 5A, 6A), a separate dataset was created. Each dataset was then split into training, validation, and testing sets using an 80-10-10 chronological split to prevent look-ahead bias. This approach allows for the assessment of the model’s performance under specific, consistent loads, which is common in the operational profiling of a cell energy storage system.
Data Preprocessing and Feature Engineering
As previously mentioned, the input features for the model were the measured current and voltage. Temperature was not included as the experiments were conducted under isothermal conditions, but the framework can easily accommodate it. The following preprocessing steps were applied:
- Normalization: Both current and voltage values were normalized to the range [0, 1] using the Min-Max scaler fitted on the training set. This is crucial for the stable convergence of gradient-based optimization.
- Sequence Creation: The continuous time-series data was transformed into supervised learning samples. A sliding window approach with a fixed look-back window length (e.g., 50 seconds) was used. Each sample consisted of a sequence of the past 50 time steps of (I, V) data, and the corresponding target was the SOC value at the last time step of the window (or a future step for prediction, but here we focus on current-time estimation).
- Target Normalization: The SOC values (range 0% to 100%) were also normalized to [0, 1] for training. The final model output was then rescaled back to the original range for evaluation.
Evaluation Metrics
To quantitatively assess and compare the performance of different SOC estimation models, three standard regression metrics were employed: Mean Squared Error (MSE), Mean Absolute Error (MAE), and the Coefficient of Determination (R²). Their formulas are given below, where $$y_i$$ is the true SOC value, $$\hat{y}_i$$ is the estimated SOC value, $$\bar{y}$$ is the mean of the true values, and $$n$$ is the total number of samples in the test set.
Mean Squared Error (MSE): Penalizes larger errors more heavily.
$$ \text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i – \hat{y}_i)^2 $$
Mean Absolute Error (MAE): Provides a linear penalty for errors.
$$ \text{MAE} = \frac{1}{n} \sum_{i=1}^{n} |y_i – \hat{y}_i| $$
Coefficient of Determination (R²): Indicates the proportion of variance in the dependent variable that is predictable from the independent variables. A value closer to 1 indicates a better fit.
$$ R^2 = 1 – \frac{\sum_{i=1}^{n} (y_i – \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i – \bar{y})^2} $$
Lower values of MSE and MAE are desirable, while a higher R² value is better. These metrics provide a comprehensive view of the model’s accuracy and explanatory power for the cell energy storage system’s SOC.
Baseline Models and Implementation Details
The proposed GS-LSTM-Attention model was benchmarked against two baseline models to isolate the contribution of its components:
- Standard LSTM Model: A vanilla LSTM network followed by fully connected layers, without any attention mechanism or systematic hyperparameter optimization (using default or commonly chosen hyperparameters).
- LSTM-Attention Model: An LSTM network integrated with an attention layer, but its hyperparameters (e.g., number of LSTM units, learning rate) were set based on common practice or a limited manual search, not an exhaustive Grid Search.
All models were implemented using the TensorFlow and Keras deep learning frameworks. The Grid Search was implemented using the scikit-learn library’s GridSearchCV functionality, with 3-fold cross-validation on the training/validation set to ensure robustness. The hyperparameter grid defined for the GS-LSTM-Attention model is summarized in the table below.
| Hyperparameter | Candidate Values |
|---|---|
| Number of LSTM Units | [32, 64, 128] |
| Learning Rate | [0.001, 0.0005, 0.0001] |
| Number of Training Epochs | [50, 100, 150] |
| Batch Size | [32, 64] |
The Adam optimizer was used for all models due to its adaptive learning rate properties. The loss function was Mean Squared Error (MSE). Early stopping with a patience of 10 epochs was employed during Grid Search and final training to prevent overfitting. For a fair comparison, the baseline models were trained for a comparable number of effective epochs.
Results and Discussion
The performance of the three models—LSTM, LSTM-Attention, and GS-LSTM-Attention—was evaluated on the independent test sets for each discharge current (2A, 5A, 6A). The primary results are consolidated in the table below. All reported MSE and MAE values are in percentage SOC units (%), calculated after rescaling the model outputs back to the 0-100% range. The R² score is a dimensionless quantity.
| Discharge Current | Model | MSE (%) | MAE (%) | R² Score |
|---|---|---|---|---|
| 2 A | LSTM | 0.1024 | 2.351 | 0.8568 |
| LSTM-Attention | 0.0701 | 2.028 | 0.9008 | |
| GS-LSTM-Attention | 0.0232 | 0.872 | 0.9771 | |
| 5 A | LSTM | 0.0615 | 1.879 | 0.8590 |
| LSTM-Attention | 0.0398 | 1.482 | 0.9032 | |
| GS-LSTM-Attention | 0.0314 | 1.336 | 0.9140 | |
| 6 A | LSTM | 0.1759 | 3.568 | 0.8318 |
| LSTM-Attention | 0.0723 | 1.987 | 0.9388 | |
| GS-LSTM-Attention | 0.0486 | 1.876 | 0.9527 |
The results clearly demonstrate the superior performance of the proposed GS-LSTM-Attention model across all discharge conditions and all evaluation metrics. Several key observations can be made:
1. Overall Superiority of GS-LSTM-Attention: For every test case (2A, 5A, 6A), the GS-LSTM-Attention model achieved the lowest MSE and MAE, and the highest R² score. This consistent outperformance validates the effectiveness of combining the attention mechanism with systematic hyperparameter optimization via Grid Search. The R² scores for the proposed model are all above 0.91, indicating an excellent fit to the data. Notably, at the 2A discharge rate, the R² reaches an impressive 0.9771, which is 0.1203 and 0.0763 higher than the vanilla LSTM and LSTM-Attention models, respectively.
2. Impact of the Attention Mechanism: Comparing the LSTM and LSTM-Attention models shows that adding the attention layer consistently improves performance. For instance, at 6A, the LSTM-Attention model reduces the MSE from 0.1759% to 0.0723% and increases R² from 0.8318 to 0.9388. This confirms the hypothesis that allowing the model to focus on more informative time steps in the sequence enhances its ability to estimate SOC accurately, a crucial capability for managing a dynamic cell energy storage system.
3. Impact of Grid Search Optimization: The further improvement from LSTM-Attention to GS-LSTM-Attention highlights the critical role of hyperparameter tuning. The Grid Search process successfully identified a set of hyperparameters (e.g., optimal number of LSTM units, learning rate) that allowed the LSTM-Attention architecture to perform at its peak. The performance gain is substantial. Taking the 2A case as an example, GS optimization led to reductions in MSE and MAE of 0.0469% and 1.156% respectively, compared to the non-optimized LSTM-Attention model.
4. Performance Under Different Loads: The models’ performance varies with discharge current. Generally, estimation appears more accurate at moderate currents (2A, 5A) than at the higher 6A rate for the baseline models. The higher current likely introduces more pronounced nonlinear polarization effects, making the mapping from voltage/current to SOC more complex. However, the GS-LSTM-Attention model maintains high accuracy even at 6A (R² = 0.9527), demonstrating its robustness and strong generalization ability across different operational regimes of a cell energy storage system.
The quantitative improvements can be further analyzed by calculating the relative error reduction offered by the proposed model. Let us define the relative reduction in MSE when moving from Model A to Model B as:
$$ \text{Reduction}_{\text{MSE}} = \frac{\text{MSE}_A – \text{MSE}_B}{\text{MSE}_A} \times 100\% $$
Applying this to the transition from the standard LSTM to the GS-LSTM-Attention model yields substantial reductions: approximately 77% at 2A, 49% at 5A, and 72% at 6A. This underscores the significant leap in estimation precision achievable with the integrated approach.
To illustrate the estimation quality visually, the following conceptual description is provided (note: actual plot generation is not performed here, but the trends are described). The plot of true SOC versus estimated SOC for the test data under the 6A condition would show that the GS-LSTM-Attention model’s estimates (plotted as points) would cluster tightly along the ideal y=x line (perfect estimation). In contrast, the estimates from the baseline LSTM model would show more significant scatter and deviation from this line, especially during transition phases like the beginning and end of discharge where dynamics are more complex. The LSTM-Attention model’s points would show less scatter than the vanilla LSTM but still more than the proposed model. This tight clustering for GS-LSTM-Attention across all SOC ranges confirms its ability to accurately track the SOC throughout the entire discharge process, a vital feature for reliable state monitoring in a cell energy storage system.
Conclusion and Future Work
Accurate and reliable State of Charge estimation is a non-negotiable requirement for the safe, efficient, and long-lasting operation of modern cell energy storage systems, particularly with promising technologies like sodium-ion batteries. This work has presented a novel, data-driven estimation framework based on a Grid Search-optimized Long Short-Term Memory network with an Attention mechanism (GS-LSTM-Attention). The model leverages the temporal modeling strength of LSTM, the focus-enhancing capability of the attention mechanism, and the rigorous optimization power of Grid Search to achieve high-precision SOC estimation.
Experimental validation on sodium-ion battery data under constant current discharge conditions (2A, 5A, 6A) demonstrated the clear superiority of the proposed model over baseline LSTM and LSTM-Attention models. The GS-LSTM-Attention model achieved the highest Coefficient of Determination (R² > 0.91 in all cases, up to 0.9771) and the lowest Mean Squared Error and Mean Absolute Error across the board. The results confirm that both the inclusion of an attention layer and the systematic optimization of hyperparameters are crucial for maximizing estimation performance. The model’s robustness across different discharge rates indicates its strong potential for practical application in real-world cell energy storage system management, where load conditions can vary.
While this study focused on constant current profiles and a single temperature, the proposed framework is inherently flexible and can be extended in several promising directions for future research:
- Dynamic and Real-World Driving Cycles: Testing and adapting the model under highly dynamic load profiles, such as electric vehicle driving cycles or renewable energy smoothing profiles, which are more representative of actual cell energy storage system operation.
- Incorporation of Temperature and Aging Effects: Expanding the input features to include battery temperature and integrating data from batteries at different states of health (SOH) to create a unified model that is robust to thermal variations and aging, which are critical for lifecycle management.
- Advanced Optimization Techniques: Exploring more sophisticated hyperparameter optimization algorithms, such as Bayesian Optimization or Genetic Algorithms, which may be more efficient than Grid Search for higher-dimensional hyperparameter spaces.
- Model Lightweighting for Edge Deployment: Investigating techniques like model pruning, quantization, or knowledge distillation to reduce the computational complexity of the GS-LSTM-Attention model, enabling its deployment on embedded systems within the Battery Management System (BMS) hardware.
- Transfer Learning Across Battery Chemistries: Studying the potential of pre-training the model on data from one type of cell energy storage system (e.g., lithium-ion) and fine-tuning it for sodium-ion systems to reduce data requirements and accelerate deployment.
In conclusion, the GS-LSTM-Attention model presents a powerful and accurate solution for the SOC estimation challenge in sodium-based cell energy storage systems. By intelligently combining established deep learning techniques with systematic optimization, it paves the way for more intelligent, adaptive, and reliable battery management, ultimately contributing to the advancement and widespread adoption of sustainable energy storage technologies.
