Accurate State-of-Charge Estimation for Lifepo4 Batteries: A Novel Hybrid Approach Combining Electrochemical Impedance Spectroscopy with an Optimized Time-Frequency Recurrent Neural Network

The precise and reliable estimation of the State of Charge (SOC) is a cornerstone for ensuring the safety, longevity, and efficient management of lithium-ion battery systems. Among various cathode chemistries, the lithium iron phosphate (LiFePO₄ or LFP) battery has gained dominant traction in energy storage applications due to its inherent safety, long cycle life, and cost-effectiveness. However, accurately estimating the SOC of a lifepo4 battery presents significant challenges. Traditional model-based methods, such as those relying on equivalent circuit models combined with Kalman filters, often struggle with the flat open-circuit voltage (OCV) profile characteristic of LFP chemistry, leading to diminished accuracy and robustness. Data-driven approaches, while powerful, typically depend on long sequences of operational data (current, voltage, temperature) and can be sensitive to the initial SOC and battery aging.

Electrochemical Impedance Spectroscopy (EIS) emerges as a potent, non-invasive diagnostic tool that probes the internal electrochemical state of a battery. By applying a small-amplitude alternating current signal across a wide frequency range and measuring the voltage response, EIS captures the dynamic processes within the lifepo4 battery, such as charge transfer, double-layer effects, and lithium-ion diffusion. These processes exhibit a strong correlation with the SOC. Consequently, EIS data contains rich, state-sensitive information that is largely independent of the preceding operational load profile, offering a promising foundation for SOC estimation.

This study presents a novel, hybrid methodology for high-precision SOC estimation in commercial 18650-type lifepo4 battery cells. The core innovation lies in the synergistic fusion of feature extraction from EIS data and a sophisticated deep learning model optimized via a bio-inspired algorithm. The process is methodically executed in three stages. First, a comprehensive EIS dataset is acquired at discrete SOC levels under controlled temperature conditions. Second, a dual-path feature engineering strategy is employed: one path fits the EIS spectra to a simplified equivalent circuit model to extract physically meaningful parameters, while the other performs direct frequency-domain analysis to select highly correlated impedance features. The most informative features from both paths are combined to form a robust input vector. Finally, a dedicated neural network architecture, the Time-Frequency Recurrent Neural Network (TFRNN), enhanced with a Transformer module, is constructed to learn the complex nonlinear mapping from the EIS feature space to the battery SOC. To circumvent the tedious and suboptimal manual tuning of hyperparameters, the Hippopotamus Optimization (HO) algorithm is leveraged to automatically identify the optimal network configuration. Extensive experimental validation confirms that the proposed HO-TFRNN-Transformer model achieves superior estimation accuracy and remarkable generalization across different temperature datasets, marking a significant advancement in data-driven battery management.

1. Experimental Methodology and Feature-Rich Dataset Construction

The foundation of any robust data-driven model is a high-quality, representative dataset. This section details the systematic process of acquiring EIS data from lifepo4 battery cells and engineering a compact yet highly informative set of input features for SOC estimation.

1.1 Battery Test System and EIS Measurement Protocol

A controlled laboratory setup was established to ensure consistent and reliable data acquisition. The core components included a thermal chamber for precise temperature regulation, a high-precision battery cycler for executing charge-discharge protocols, a potentiostat/galvanostat for EIS measurements, and a central computer for system control and data logging. Commercial 18650 cylindrical lifepo4 battery cells with a nominal capacity of 1500 mAh were used. The voltage limits were set at 2.75 V (discharge cutoff) and 4.2 V (charge cutoff).

The data collection protocol was meticulously designed to isolate the SOC as the primary variable. Each cell was initially fully charged to 100% SOC using a standard constant-current constant-voltage (CC-CV) procedure at a 1C rate (1.5 A). To collect data at lower SOC points, the cell was discharged with a 1C current for a duration corresponding to a 10% SOC decrease (6 minutes), followed by a prolonged rest period of 10 minutes to allow for voltage relaxation and the dissipation of transient polarization effects. This rest period is crucial for obtaining stable, quasi-equilibrium EIS measurements. After the rest, a full EIS scan was performed. The frequency range for EIS was typically from 10 kHz down to 0.1 Hz (or lower), with a logarithmic sweep and a small excitation signal amplitude (e.g., 10 mV RMS) to ensure linear system response. This sequence was repeated to gather EIS spectra at nominal SOC levels of 100%, 90%, 70%, 50%, 30%, 10%, and 0%. All experiments were conducted under isothermal conditions, with 25°C as the primary baseline.

1.2 Dual-Path Feature Engineering from EIS Data

Raw EIS data consists of complex impedance values $Z(f) = Z’ + jZ”$ across numerous frequencies. Using all data points is computationally inefficient and can lead to overfitting. Therefore, a dual-path strategy was adopted to extract the most SOC-sensitive features.

Path 1: Equivalent Circuit Model (ECM) Parameterization. A physically intuitive way to interpret EIS is through an equivalent circuit model. The Nyquist plot for a typical lifepo4 battery shows several characteristic regions: a high-frequency intercept related to ohmic resistance ($R_\Omega$), one or more depressed semicircles in the mid-frequency range representing charge-transfer kinetics ($R_{ct}$) coupled with double-layer capacitance (often modeled as a constant phase element, $CPE$), and a low-frequency Warburg tail indicative of solid-state diffusion. A simplified but effective ECM, such as the $R_\Omega$-(Rct//CPE)-Warburg model, was fitted to each measured spectrum using complex nonlinear least squares (CNLS) algorithms. The extracted parameters, particularly the Warburg coefficient or diffusion-related impedance $Z_W$, carry significant information about lithium-ion concentration and mobility, which are directly tied to SOC. The correlation between ECM parameters and SOC was quantitatively assessed. For instance, the Pearson correlation coefficient $\rho$ between a parameter $P$ and SOC is calculated as:

$$ \rho_{P,SOC} = \frac{\sum_{i=1}^{n} (P_i – \bar{P})(SOC_i – \overline{SOC})}{\sqrt{\sum_{i=1}^{n} (P_i – \bar{P})^2 \sum_{i=1}^{n} (SOC_i – \overline{SOC})^2}} $$
where $n$ is the number of data samples, and $\bar{P}$ and $\overline{SOC}$ are the sample means. Parameters with $|\rho|$ close to 1 were selected.

Path 2: Frequency-Domain Feature Selection. Direct analysis of the impedance spectrum’s shape at specific frequencies provides complementary information. By examining the Bode magnitude ($|Z|(f)$) and phase ($\angle Z(f)$) plots across different SOC levels, key frequencies where the curves exhibit maximal divergence can be identified. For the lifepo4 battery, the low-frequency region (e.g., 0.1 Hz) is highly sensitive to diffusion processes, making $|Z|_{0.1Hz}$ and $\angle Z_{0.1Hz}$ strong candidates. The characteristic frequency where the mid-frequency semicircle transitions to the Warburg tail (often around 1-10 Hz) is also SOC-dependent; the real and imaginary components of impedance at this point are informative. Therefore, features like $Z’_{10Hz}$ and $Z”_{10Hz}$ were extracted.

The final input feature vector $\mathbf{x}$ for the SOC estimation model is a fusion of the most correlated features from both paths:
$$ \mathbf{x} = [Z_W, |Z|_{0.1Hz}, \angle Z_{0.1Hz}, Z’_{10Hz}, Z”_{10Hz}, …]^T $$
This hybrid feature set provides a compact and powerful representation of the battery’s electrochemical state at a given SOC.

2. The Proposed HO-TFRNN-Transformer Estimation Framework

The relationship between the engineered EIS features and the battery SOC is complex and nonlinear. To model this effectively, a specialized neural network architecture is proposed, coupled with an advanced optimization strategy for tuning its hyperparameters.

2.1 Foundation: The Time-Frequency Recurrent Neural Network (TFRNN)

Standard Recurrent Neural Networks (RNNs) and their variants like Long Short-Term Memory (LSTM) networks are adept at processing sequential data. However, EIS features, while not a time series in the conventional sense, represent a frequency-sampled signature of an electrochemical state. The TFRNN architecture is specifically designed to handle such time-frequency characterized data. Its core building block processes input features through parallel temporal and spectral streams. The temporal stream, often using RNN/LSTM cells, captures ordered dependencies, while the spectral stream, which may involve convolutional layers or discrete transformations, extracts patterns across the frequency components of the input. The outputs of these streams are fused, allowing the network to learn representations that are informed by both the sequence and the spectral structure of the EIS feature vector. Preliminary comparisons against standard Multi-Layer Perceptrons (MLPs), Convolutional Neural Networks (CNNs), and basic RNNs demonstrated the TFRNN’s superior performance for this task, yielding lower estimation errors.

2.2 Architectural Enhancement: Integrating a Transformer Module

While effective, the initial TFRNN can be further enhanced. The Transformer architecture, renowned for its self-attention mechanism, excels at modeling global dependencies within a sequence regardless of distance. By integrating a lightweight Transformer encoder module into the feature fusion stage of the TFRNN block, the model’s ability to weigh the importance of different EIS features adaptively is significantly improved. The self-attention mechanism allows the model to learn contextual relationships between, for instance, the high-frequency ohmic resistance feature and the low-frequency Warburg feature, which are physically interrelated. The scaled dot-product attention is computed as:
$$ \text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V $$
where $Q$, $K$, and $V$ are the query, key, and value matrices derived from the fused feature representation, and $d_k$ is the dimensionality of the keys. This enhancement helps the model focus on the most salient feature interactions for SOC estimation, leading to more robust and accurate predictions.

2.3 Hyperparameter Optimization via Hippopotamus Algorithm (HO)

The performance of deep learning models is highly sensitive to the choice of hyperparameters (e.g., number of hidden units, learning rate, batch size, dropout rate). Manual tuning is time-consuming and often suboptimal. The Hippopotamus Optimization (HO) algorithm, a recent metaheuristic inspired by the social behaviors of hippopotamuses in nature, is employed for this task. HO mimics behaviors such as territorial marking (local search), herd migration (global search), and defensive mechanisms (diversification) to effectively explore the hyperparameter search space. The algorithm is used to find the set of hyperparameters $\theta^*$ that minimizes the validation error of the TFRNN-Transformer model:
$$ \theta^* = \arg \min_{\theta \in \Theta} \mathcal{L}(f_{\theta}(\mathbf{X}_{val}), \mathbf{Y}_{val}) $$
where $\Theta$ is the hyperparameter space, $f_{\theta}$ is the model, $\mathbf{X}_{val}$ and $\mathbf{Y}_{val}$ are the validation features and SOC labels, and $\mathcal{L}$ is a loss function like Mean Squared Error (MSE). The synergy of the bio-inspired HO algorithm with the sophisticated TFRNN-Transformer architecture forms the complete proposed framework, termed HO-TFRNN-Transformer.

3. Experimental Results, Analysis, and Discussion

The proposed methodology was rigorously validated using the collected EIS dataset from the lifepo4 battery. The dataset was partitioned into training, validation, and testing sets. The model’s performance was evaluated using standard regression metrics: Root Mean Square Error (RMSE), Mean Absolute Error (MAE), and Maximum Absolute Error (MaxAE).

$$ \text{RMSE} = \sqrt{\frac{1}{N} \sum_{i=1}^{N} (SOC_{est,i} – SOC_{true,i})^2} $$
$$ \text{MAE} = \frac{1}{N} \sum_{i=1}^{N} |SOC_{est,i} – SOC_{true,i}| $$
$$ \text{MaxAE} = \max(|SOC_{est,i} – SOC_{true,i}|) $$

3.1 Ablation Study: Component-wise Contribution

An ablation study was conducted to isolate the contribution of each key component in the proposed framework. The results, summarized in the table below, clearly demonstrate the progressive improvement.

Model Configuration RMSE (%) MAE (%) MaxAE (%)
Base TFRNN 2.01510 1.00940 6.66534
TFRNN + HO Optimization 1.36350 1.45960 5.71444
HO-TFRNN-Transformer (Proposed) 1.02460 0.86290 2.64960

The introduction of HO optimization reduced RMSE by approximately 32%, primarily by finding a superior network structure (e.g., optimal number of hidden units). The subsequent integration of the Transformer module further reduced RMSE by about 25% and drastically cut the MaxAE by over 50%, underscoring its role in improving model robustness and precision by capturing critical feature interdependencies.

3.2 Benchmark Comparison with Standard Networks

The performance of the proposed HO-TFRNN-Transformer model was benchmarked against several conventional deep learning architectures trained and tested on the same EIS feature dataset. The results affirm the superiority of the proposed architecture for this specific task.

Neural Network Model RMSE (%) MAE (%) MaxAE (%)
Convolutional Neural Network (CNN) 2.02064 1.72070 7.54539
Deep Neural Network (DNN) 2.24880 1.71140 7.80014
Recurrent Neural Network (RNN) 1.77170 1.33870 7.41727
Proposed HO-TFRNN-Transformer 1.02460 0.86290 2.64960

3.3 Generalization Validation Across Temperatures

To evaluate the robustness and generalizability of the trained model, EIS data was also collected at different ambient temperatures (15°C and 20°C) following the same protocol. The model, trained primarily on 25°C data, was then used to estimate SOC from these unseen datasets. The results, presented below, are highly promising.

Test Dataset (Temperature) RMSE (%) MAE (%) MaxAE (%)
15°C (Model trained on 25°C data) 1.03001 0.87560 1.90433
20°C (Model trained on 25°C data) 1.39880 1.18690 2.84019
25°C (Independent test set) 0.65050 0.66734 2.92306

The estimation errors remain within a very acceptable range (RMSE < 1.4%) even when the model is applied to data from lower temperatures. This demonstrates that the EIS features extracted and the relationships learned by the HO-TFRNN-Transformer model are fundamentally tied to the SOC state of the lifepo4 battery and exhibit a degree of invariance to moderate temperature changes. This is a critical advantage for practical BMS applications where operating temperature can vary.

4. Conclusion

This research has successfully developed and validated a novel, high-precision framework for estimating the State of Charge in lifepo4 battery cells. The framework innovatively combines the rich diagnostic information from Electrochemical Impedance Spectroscopy with a purpose-built, optimized deep learning model. The key contributions are threefold. First, a hybrid feature engineering strategy was implemented, merging physically interpretable parameters from equivalent circuit modeling with directly extracted, highly correlated frequency-domain impedance points. This resulted in a compact and powerful feature vector that accurately encapsulates the electrochemical state. Second, a specialized TFRNN-Transformer neural network architecture was designed and utilized to learn the complex, nonlinear mapping from these EIS features to the battery SOC. Third, the Hippopotamus Optimization algorithm was effectively deployed to automate the tuning of the network’s hyperparameters, ensuring optimal performance and eliminating guesswork.

Experimental results on data from commercial 18650 cells demonstrate the exceptional accuracy and robustness of the proposed HO-TFRNN-Transformer model. It significantly outperforms standard deep learning benchmarks such as CNNs, DNNs, and RNNs, achieving an RMSE consistently below 1.4% and a maximum error under 3% across various test conditions. Crucially, the model shows strong generalization capability, maintaining high accuracy when applied to EIS data collected at temperatures different from the training data. This work establishes that EIS, when processed through advanced feature engineering and modern deep learning techniques, can serve as a highly reliable basis for SOC estimation in lifepo4 battery systems, offering a promising alternative or complement to traditional ampere-hour integration or voltage-based methods, especially in applications where periodic diagnostic checks are feasible.

Scroll to Top