Skip to content
Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”‹ Data-Driven Battery Diagnostics β€” NASA PCOE Dataset

End-to-end ML pipeline for SoC, SoH, and RUL prediction of lithium-ion batteries.

Python PyTorch XGBoost License: MIT


🎯 What This Project Does

Battery Management Systems (BMS) need answers to three critical questions:

# Question Technical Term Our Model
1 "How much charge is left right now?" State of Charge (SoC) LSTM Neural Network
2 "How degraded is this battery?" State of Health (SoH) XGBoost (Gradient Boosting)
3 "How many cycles before it dies?" Remaining Useful Life (RUL) LSTM Neural Network

This pipeline takes raw NASA battery cycling data β†’ parses .mat files β†’ engineers physics-informed features β†’ trains 3 models β†’ outputs evaluation metrics + publication-ready plots.


πŸ“ˆ Results

Performance Metrics

Model RMSE MAE RΒ² Score Interpretation
SoC (LSTM) 7.24% 2.82% 0.9499 Excellent β€” explains 95% of variance
SoH (XGBoost) 3.09% 2.76% 0.8260 Good β€” captures degradation trend
RUL (LSTM) 12.49 cycles 9.21 cycles 0.8699 Good β€” average error ~9 cycles

Capacity Fade Analysis

All 4 batteries show clear degradation over cycling. B0018 (4A discharge) degrades faster than B0005–B0007 (2A), consistent with Arrhenius kinetics.

Capacity Fade

Model A β€” SoC Estimation (LSTM)

The LSTM captures the full discharge curve trajectory. Predictions closely track the actual SoC with RΒ² = 0.95.

SoC Prediction

Model B β€” SoH Estimation (XGBoost)

XGBoost tracks the overall degradation trend from 93% β†’ 65% SoH. Feature importance reveals temperature variance (57%) and discharge time (29%) are the dominant aging indicators.

SoH Prediction

Model C β€” RUL Prediction (LSTM)

The LSTM learns the countdown pattern (120 β†’ 0 cycles remaining). Error distribution is centered near zero, with most predictions within Β±10 cycles.

RUL Prediction

Training Convergence

Both LSTM models converge smoothly with early stopping preventing overfitting.

SoC Training RUL Training


πŸ“Š Dataset

NASA Prognostics Center of Excellence (PCoE) Battery Dataset β€” 4 Γ— 18650 Li-ion cells cycled to failure.

Battery Discharge Rate ~Cycles EOL Reached?
B0005 2A 168 βœ…
B0006 2A 168 βœ…
B0007 2A 168 βœ…
B0018 4A 132 βœ…
  • Charge: CC-CV at 1.5A β†’ 4.2V cutoff
  • Discharge: Constant current until 2.7V
  • EOL threshold: 70% of rated capacity (1.4 Ah out of 2.0 Ah)
  • Source: NASA PCoE Repository

🧠 Technical Approach

Pipeline Flow

NASA .mat files
    ↓  scipy.io.loadmat
Parse MATLAB structs β†’ Extract discharge cycles only
    ↓  Current integration: Q(t) = ∫|I(Ο„)|dΟ„
Clean DataFrame (remove NaN/Inf)
    ↓
    β”œβ”€β”€ SoC Path: MinMax normalize β†’ sliding window (50 steps) β†’ LSTM
    β”‚
    └── Cycle Path: Aggregate 8 features per cycle
            β”œβ”€β”€ SoH: XGBoost on tabular features
            └── RUL: Lookback window (10 cycles) β†’ LSTM

Feature Engineering (8 Physics-Informed Features)

Feature Formula Physical Basis
max_capacity NASA reported (Ah) Direct health indicator
discharge_time t_end βˆ’ t_start Shorter = degraded
avg_voltage mean(V) Drops with SEI growth
voltage_drop V_max βˆ’ V_min Internal resistance proxy
avg_current mean(|I|) Operating condition
avg_temperature mean(T) Arrhenius aging factor
temp_variance var(T) Thermal instability
internal_resistance Ξ”V / I_avg Primary aging indicator

Model Architectures

SoC (LSTM)SoH (XGBoost)RUL (LSTM)
Input: 3 features Γ— 50 steps
LSTM(64) β†’ Drop(0.2)
LSTM(32) β†’ Drop(0.2)
Dense(1)
Input: 8 cycle features
200 trees, depth=5
lr=0.05, L1+L2 reg
5-fold CV
Input: 8 features Γ— 10 cycles
LSTM(128) β†’ Drop(0.3)
LSTM(64)  β†’ Drop(0.3)
Dense(32, ReLU) β†’ Dense(1)
Why LSTM? SoC depends on temporal voltage/current history β€” same voltage can mean different SoC depending on trajectory. Why XGBoost? Only ~630 cycles of tabular data β€” trees outperform neural nets on small structured datasets. Why LSTM? RUL requires detecting acceleration in degradation β€” the model needs to see trends over past cycles.

Key Design Decisions

  • Chronological split (80/20) β€” prevents future data leakage (critical for time-series)
  • MinMax scaling β€” bounded [0,1] range works better with LSTM's sigmoid/tanh activations
  • Early stopping β€” prevents overfitting by monitoring validation loss
  • max_capacity excluded from SoH features β€” avoids circular prediction (SoH is derived from capacity)

πŸ“ Project Structure

battery-diagnostics-NASA/
β”œβ”€β”€ data/
β”‚   └── download_data.py         # Auto-downloads from NASA S3
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ data_loader.py           # .mat parsing + current integration
β”‚   β”œβ”€β”€ preprocessing.py         # Clean, normalize, sliding windows
β”‚   β”œβ”€β”€ feature_engineering.py   # 8 cycle features + SoH/RUL labels
β”‚   β”œβ”€β”€ evaluation.py            # RMSE, MAE, RΒ² metrics
β”‚   β”œβ”€β”€ visualization.py         # 6 publication-ready plots
β”‚   └── models/
β”‚       β”œβ”€β”€ soc_model.py         # LSTM for SoC
β”‚       β”œβ”€β”€ soh_model.py         # XGBoost for SoH
β”‚       └── rul_model.py         # LSTM for RUL
β”œβ”€β”€ plots/                       # Generated diagnostic plots
β”œβ”€β”€ results/                     # Saved predictions & metrics (CSV/JSON)
β”œβ”€β”€ main.py                      # ← Run this! End-to-end pipeline
└── requirements.txt

πŸš€ Quick Start

# Clone
git clone https://github.com/ARYANRAJ1121/battery-diagnostics-NASA.git
cd battery-diagnostics-NASA

# Setup
python -m venv venv && venv\Scripts\activate   # Windows
pip install -r requirements.txt

# Run entire pipeline (~5 min)
python main.py

Output: Metrics printed to console + 6 plots in plots/ + 7 result files in results/


πŸ”¬ Research Context

This project bridges data-driven ML and electrochemical domain knowledge:

Degradation Mechanism Feature That Captures It
SEI layer growth internal_resistance ↑, avg_voltage ↓
Lithium inventory loss max_capacity ↓, discharge_time ↓
Thermal aging (Arrhenius) avg_temperature ↑, temp_variance ↑
Electrode cracking voltage_drop ↑

Relevant to: Battery Management Systems (BMS), Prognostics & Health Management (PHM), Electric Vehicle reliability, Grid-scale energy storage

Future Work

  • Transformer-based models (PatchTST) for longer-range dependencies
  • Physics-Informed Neural Networks (PINNs) combining data + electrochemical equations
  • Transfer learning across battery chemistries
  • Uncertainty quantification (confidence intervals on predictions)

πŸ“š References

  1. B. Saha, K. Goebel (2007). "Battery Data Set", NASA Ames Prognostics Data Repository
  2. K. Severson et al. (2019). "Data-driven prediction of battery cycle life before capacity degradation", Nature Energy
  3. M. Berecibar et al. (2016). "Critical review of state of health estimation methods", Renewable & Sustainable Energy Reviews
  4. Y. Zhang et al. (2018). "LSTM RNN for remaining useful life prediction", Engineering Applications of AI
  5. T. Chen, C. Guestrin (2016). "XGBoost: A Scalable Tree Boosting System", KDD

πŸ“„ License

MIT License β€” see LICENSE


Built for research internship application β€” IIT Jammu
Demonstrating proficiency in battery diagnostics, deep learning, and reproducible ML research

About

Data-driven battery diagnostics system built on the NASA PCOE Battery Dataset. Implements three predictive models ,LSTM for State of Charge (SoC) estimation, XGBoost for State of Health (SoH) degradation tracking, and LSTM for Remaining Useful Life (RUL) prediction. Includes full data preprocessing, cycle-level feature engineering.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages