
In the realm of modern energy systems, the accurate estimation of the state of charge (SOC) for an energy storage battery remains a critical yet challenging task. The SOC of an energy storage battery directly reflects the remaining capacity and is fundamental to efficient energy management, performance optimization, and lifespan prediction. However, due to the inherent nonlinearity, time-varying dynamics, and operational complexity of the energy storage battery, direct measurement of SOC is infeasible. Instead, it must be inferred from external measurable quantities such as voltage, current, and temperature. Conventional methods like ampere-hour integration and open-circuit voltage approaches suffer from cumulative errors, sensitivity to initial conditions, and poor adaptability under dynamic operating conditions. As a result, data-driven techniques, particularly deep learning models, have gained significant traction in recent years.
Among these, the long short-term memory (LSTM) network has demonstrated exceptional capability in capturing temporal dependencies in sequential data, making it a natural choice for SOC estimation of the energy storage battery. Nevertheless, standard LSTM models often fall short in extracting the most salient features across different time steps, especially when the discharge profile exhibits abrupt changes or varying rates. To address this limitation, I propose an integrated framework that combines LSTM with an attention mechanism and further optimizes hyperparameters using grid search (GS). This model, termed GS-LSTM-Attention, is specifically designed to enhance the accuracy and robustness of SOC estimation for the energy storage battery under multiple operating conditions.
The remainder of this article is structured as follows. First, I elaborate on the theoretical foundations of LSTM, attention mechanism, and grid search optimization. Next, I describe the experimental setup, dataset characteristics, and evaluation metrics. Then, I present comprehensive results comparing the proposed model with baseline LSTM and LSTM-Attention models across three different current rates (2 A, 5 A, and 6 A). Finally, I discuss the implications of the findings and provide concluding remarks.
1. Model Construction
1.1 Long Short-Term Memory Network
The LSTM network is a specialized variant of recurrent neural networks (RNNs) designed to overcome the vanishing and exploding gradient problems encountered in long-sequence learning. Each LSTM unit comprises three gating mechanisms: the forget gate, input gate, and output gate. These gates regulate the flow of information, enabling the network to retain relevant historical patterns while discarding irrelevant ones. The mathematical formulation of an LSTM cell is given by the following equations:
$$ f_t = \sigma(W_f x_t + U_f h_{t-1} + V_f c_{t-1} + b_f) $$
$$ i_t = \sigma(W_i x_t + U_i h_{t-1} + V_i c_{t-1} + b_i) $$
$$ \tilde{c}_t = \tanh(W_c x_t + U_c h_{t-1} + b_c) $$
$$ c_t = f_t \odot c_{t-1} + i_t \odot \tilde{c}_t $$
$$ o_t = \sigma(W_o x_t + U_o h_{t-1} + V_o c_t + b_o) $$
$$ h_t = o_t \odot \tanh(c_t) $$
In these equations, \(x_t\) is the input vector at time step \(t\), \(h_{t-1}\) and \(c_{t-1}\) are the previous hidden state and cell state, respectively. The variables \(f_t\), \(i_t\), and \(o_t\) denote the outputs of the forget, input, and output gates. The sigmoid function \(\sigma\) and hyperbolic tangent function \(\tanh\) serve as activation functions. The weight matrices \(W\), \(U\), and \(V\) along with bias terms \(b\) are learnable parameters. The symbol \(\odot\) represents element-wise multiplication. Through this gating mechanism, the LSTM effectively captures long-range dependencies in time series data, which is particularly beneficial for modeling the dynamic behavior of an energy storage battery during charging and discharging cycles.
1.2 Grid Search Optimization
Grid search (GS) is a systematic hyperparameter optimization technique that exhaustively searches through a predefined parameter space to identify the combination that yields the best model performance. In the context of SOC estimation for the energy storage battery, key hyperparameters include the number of hidden layer neurons, learning rate, and number of training epochs. The goal is to minimize the mean squared error (MSE) on the validation set. Let \(\Theta = \{\theta_1, \theta_2, \dots, \theta_n\}\) denote the hyperparameter space, where each \(\theta_i\) has a discrete set of candidate values. The optimal configuration \(\theta^*\) is found by maximizing a performance metric, as formalized below:
$$ \theta^* = \arg\max_{\theta \in \Theta} \text{Performance}(M(\theta), D_{\text{val}}) $$
In this work, I define the performance metric as the negative MSE, so that maximizing it is equivalent to minimizing the prediction error. The grid search algorithm evaluates all possible combinations within the search grid, making it computationally intensive but highly reliable for small to moderate parameter spaces. The specific hyperparameter ranges considered in this study are summarized in Table 1.
| Hyperparameter | Candidate Values |
|---|---|
| Number of hidden neurons | 32, 64, 128, 256 |
| Learning rate | 0.001, 0.005, 0.01, 0.05 |
| Number of training epochs | 50, 100, 150, 200 |
1.3 Attention Mechanism
The attention mechanism empowers the model to dynamically assign different weights to different time steps of the input sequence, thereby focusing on the most informative portions for the current prediction task. In the proposed GS-LSTM-Attention architecture, the attention layer is placed on top of the LSTM layer. After the LSTM produces a sequence of hidden states \(\{h_1, h_2, \dots, h_T\}\), the attention mechanism computes a context vector \(c\) as a weighted sum of these hidden states. The weights \(\alpha_t\) are derived from a compatibility score, typically computed via a feedforward network. The process can be described as:
$$ e_t = v^\top \tanh(W_e h_t + b_e) $$
$$ \alpha_t = \frac{\exp(e_t)}{\sum_{k=1}^T \exp(e_k)} $$
$$ c = \sum_{t=1}^T \alpha_t h_t $$
Here, \(v\), \(W_e\), and \(b_e\) are learnable parameters. The context vector \(c\) is then concatenated or combined with the final LSTM hidden state and passed through a fully connected layer to produce the SOC estimate. By emphasizing critical time steps—such as those where the voltage or current changes significantly—the attention mechanism enhances the model’s ability to track the nonlinear discharge behavior of the energy storage battery.
1.4 Overall SOC Estimation Procedure
The complete workflow for SOC estimation using the GS-LSTM-Attention model is illustrated in the following step-by-step process:
- Data normalization: All input features (voltage and current) and the target (SOC) are normalized to the range [0,1] using min-max normalization:
$$ x’ = \frac{x – x_{\min}}{x_{\max} – x_{\min}} $$
- Model construction: The LSTM-Attention framework is built with an input layer, an LSTM layer, an attention layer, a fully connected layer, and an output layer.
- Hyperparameter search space definition: Based on the data size and model complexity, the candidate values for hidden neurons, learning rate, and epochs are specified as in Table 1.
- Grid search execution: The GS algorithm iterates through all combinations, training a model for each and recording the MSE on a validation set. The combination with the lowest MSE is selected as the optimal configuration.
- Final model training and SOC prediction: With the optimal hyperparameters, the LSTM-Attention model is trained on the entire training set and then used to estimate SOC for test data.
This procedure ensures that the model is not only structurally capable of capturing temporal dependencies but also finely tuned for the specific characteristics of the energy storage battery dataset.
2. Experimental Setup
2.1 Energy Storage Battery Dataset
The dataset employed in this study originates from laboratory charge-discharge experiments conducted on 18650 cylindrical commercial sodium-based energy storage batteries. The nominal capacity of each cell is 1.0 Ah. Data were recorded at 1-second intervals during constant current charging and discharging cycles at a controlled temperature of 25 °C. Three distinct operating conditions were considered: 2 A, 5 A, and 6 A discharge currents. For each condition, the recorded measurements include voltage (V), current (A), and capacity (Ah). The SOC is derived from the capacity data using the coulomb counting method as a reference. To evaluate the generalization capability of the model, I created separate datasets for each current rate, with 80% used for training and 20% for testing. The input features are voltage and current, while the target variable is SOC.
A statistical overview of the dataset is provided in Table 2.
| Discharge Current (A) | Number of Samples | Voltage Range (V) | Current Range (A) | SOC Range (%) |
|---|---|---|---|---|
| 2 | 15,480 | 1.5 – 3.6 | 2.0 (constant) | 0.0 – 100.0 |
| 5 | 11,160 | 1.3 – 3.5 | 5.0 (constant) | 0.0 – 100.0 |
| 6 | 9,720 | 1.2 – 3.4 | 6.0 (constant) | 0.0 – 100.0 |
2.2 Evaluation Metrics
To quantitatively assess the performance of the proposed model, I employ three standard metrics: mean squared error (MSE), mean absolute error (MAE), and the coefficient of determination (\(R^2\)). These metrics are defined as follows:
$$ \text{MSE} = \frac{1}{n} \sum_{i=1}^{n} (y_i – \hat{y}_i)^2 $$
$$ \text{MAE} = \frac{1}{n} \sum_{i=1}^{n} |y_i – \hat{y}_i| $$
$$ R^2 = 1 – \frac{\sum_{i=1}^{n} (y_i – \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i – \bar{y})^2} $$
In these formulas, \(n\) is the number of samples, \(y_i\) and \(\hat{y}_i\) represent the actual and estimated SOC values, and \(\bar{y}\) is the mean of the actual SOC values. Lower MSE and MAE indicate better accuracy, while an \(R^2\) value closer to 1 signifies a better fit of the model to the true SOC trajectory. All metrics are computed on the test set without renormalization of the predictions to the original scale.
3. Results and Discussion
3.1 Comparison of SOC Estimation Performance
I compare the proposed GS-LSTM-Attention model against two baseline models: a standard LSTM and an LSTM with attention (LSTM-Attention) but without grid search optimization. Each model is trained independently for each of the three operating conditions (2 A, 5 A, and 6 A). The results, in terms of MSE, MAE, and \(R^2\), are summarized in Table 3.
| Model | Condition (A) | MSE (%) | MAE (%) | \(R^2\) |
|---|---|---|---|---|
| LSTM | 2 | 0.10 | 2.35 | 0.8568 |
| 5 | 0.06 | 1.88 | 0.8590 | |
| 6 | 0.18 | 3.57 | 0.8318 | |
| LSTM-Attention | 2 | 0.07 | 2.03 | 0.9008 |
| 5 | 0.04 | 1.48 | 0.9032 | |
| 6 | 0.07 | 1.99 | 0.9388 | |
| GS-LSTM-Attention (Proposed) | 2 | 0.02 | 0.87 | 0.9771 |
| 5 | 0.03 | 1.34 | 0.9140 | |
| 6 | 0.05 | 1.88 | 0.9527 |
From Table 3, it is evident that the proposed GS-LSTM-Attention model consistently outperforms both baseline models across all operating conditions. Under the 2 A condition, the proposed model achieves an \(R^2\) of 0.9771, which is 0.1203 higher than that of the LSTM model and 0.0763 higher than that of the LSTM-Attention model. The MSE and MAE are reduced to 0.02% and 0.87%, respectively, representing substantial improvements. For the 5 A condition, the \(R^2\) of the proposed model reaches 0.9140, while the LSTM and LSTM-Attention models yield 0.8590 and 0.9032, respectively. The 6 A condition presents a more challenging scenario due to higher current stress, yet the proposed model still achieves an \(R^2\) of 0.9527, significantly outperforming the others. In absolute error terms, the GS-LSTM-Attention model reduces MAE by 1.48%, 0.54%, and 1.69% compared to the LSTM model for 2 A, 5 A, and 6 A, respectively. Relative to the LSTM-Attention model, the improvements in MAE are 1.16%, 0.14%, and 0.11% for the three conditions.
These results clearly demonstrate the synergistic effect of the attention mechanism and grid search optimization. The attention mechanism allows the model to focus on critical temporal patterns, while grid search fine-tunes hyperparameters that are otherwise manually selected, leading to enhanced generalization and reduced overfitting. The consistently high \(R^2\) values (all above 0.91) across different current rates indicate that the GS-LSTM-Attention model maintains excellent predictive capability even when the energy storage battery operates under varying discharge intensities.
3.2 Detailed Analysis of Specific Conditions
To further appreciate the performance gains, I examine the SOC estimation curves for each operating condition. The true SOC values follow a monotonically decreasing pattern due to constant current discharge. The LSTM model tends to exhibit noticeable deviations, particularly in the mid-to-late discharge stages, where the SOC drops more rapidly. The LSTM-Attention model reduces these errors but still struggles with capturing sudden nonlinearities. In contrast, the GS-LSTM-Attention model’s estimated SOC curve aligns almost perfectly with the true trajectory across the entire discharge cycle. The improvement is especially pronounced near the end of discharge, where the battery’s internal resistance increases and the voltage profile becomes highly nonlinear. By leveraging the attention mechanism, the model assigns higher weights to the terminal discharge phases, thereby improving local accuracy. Grid search fine-tuning ensures that the learning rate is optimal for convergence, the number of hidden neurons is sufficient to capture the complexity, and the training epochs avoid underfitting or overfitting.
It is worth noting that the 6 A condition exhibits the largest errors among all models, which is expected because higher discharge rates induce greater polarization effects and more rapid SOC decline. Nevertheless, the proposed model still maintains an \(R^2\) above 0.95, underscoring its robustness. The relative improvement over the LSTM model is most dramatic under 6 A, with MSE dropping from 0.18% to 0.05% and MAE from 3.57% to 1.88%. This suggests that the combination of LSTM, attention, and grid search is particularly effective in handling the dynamic stress experienced by the energy storage battery under high current demands.
3.3 Impact of Grid Search Optimization
To isolate the contribution of grid search, I compare the performance of the LSTM-Attention model (with default hyperparameters) against the GS-LSTM-Attention model (with optimized hyperparameters). The optimal hyperparameters found by grid search for each condition are listed in Table 4.
| Condition (A) | Hidden Neurons | Learning Rate | Epochs |
|---|---|---|---|
| 2 | 128 | 0.005 | 150 |
| 5 | 64 | 0.01 | 100 |
| 6 | 256 | 0.001 | 200 |
It is interesting to observe that the optimal configurations differ across conditions. For the 2 A condition, a moderate number of hidden neurons (128) and a relatively low learning rate (0.005) with 150 epochs yield the best results. For the 5 A condition, fewer neurons (64) and a higher learning rate (0.01) with fewer epochs (100) are preferred, suggesting that the data at this rate is less complex and can be learned efficiently. The 6 A condition, being the most demanding, requires the largest model (256 neurons) and the lowest learning rate (0.001) with the most epochs (200) to achieve convergence without oscillation. These findings highlight the necessity of hyperparameter tuning tailored to each specific dataset, as a one-size-fits-all approach would inevitably degrade performance.
3.4 Generalization and Practical Implications
From a practical standpoint, the ability to accurately estimate SOC across different discharge rates is crucial for real-world applications of the energy storage battery. In grid-scale energy storage systems, for instance, the battery may experience fluctuating power demands. The proposed GS-LSTM-Attention model, once trained on a variety of conditions, can be deployed to provide reliable SOC estimates without requiring retraining for each new operating scenario, provided that the conditions fall within the training distribution. Moreover, the attention mechanism offers interpretability by indicating which time steps the model deems most important, potentially aiding engineers in understanding battery behavior under stress.
One limitation of the current study is that the data were collected under constant current conditions. In practice, energy storage batteries often undergo variable current profiles (e.g., pulsed discharge or charge). Future work should extend the evaluation to dynamic current profiles, such as the US06 or WLTC drive cycles, to test the model’s adaptability. Additionally, the effect of temperature variations should be incorporated since temperature significantly influences the electrochemical processes of the energy storage battery. I anticipate that augmenting the input features with temperature and employing transfer learning techniques could further enhance the model’s robustness.
4. Conclusion
In this work, I have proposed a comprehensive framework for SOC estimation of the energy storage battery, integrating long short-term memory networks with an attention mechanism and grid search hyperparameter optimization. The GS-LSTM-Attention model was evaluated on three distinct constant current discharge conditions (2 A, 5 A, and 6 A) using real experimental data from commercial sodium-based energy storage batteries. The experimental results consistently demonstrate that the proposed model outperforms both the standard LSTM and LSTM-Attention baselines across all evaluation metrics. Specifically, under the 2 A condition, the \(R^2\) reaches 0.9771, representing an improvement of 0.1203 over LSTM and 0.0763 over LSTM-Attention. Comparable gains are observed under 5 A and 6 A conditions, with \(R^2\) values of 0.9140 and 0.9527, respectively.
The attention mechanism enables the model to dynamically prioritize critical temporal information, while grid search fine-tunes essential hyperparameters that amplify the model’s predictive accuracy. The optimal hyperparameter configurations differ with operating conditions, emphasizing the importance of data-specific tuning. These findings affirm that the GS-LSTM-Attention model is a powerful and practical tool for accurate SOC estimation in energy storage battery systems. Future research directions include testing on dynamic load profiles, incorporating temperature and aging effects, and exploring lightweight versions of the model for embedded deployment in battery management systems.
In summary, the integration of LSTM, attention, and grid search provides a synergistic enhancement that significantly elevates the state-of-the-art in SOC estimation for the energy storage battery. I believe this approach will facilitate more intelligent energy management, prolong battery life, and support the broader adoption of sodium-based energy storage technology in renewable energy systems.
