Back to Portfolio
Sustainable Technology

Battery SoH Predictor — Physics-Informed iTransformer

A web app that reads a lithium-ion discharge cycle and estimates how much battery life is left — pairing a deep-learning prediction with a physics-based cross-check.

ET
Eric Tran · Project lead
Battery SoH Predictor — Physics-Informed iTransformer

Key Features

  • Three input modes: manual 20×4 entry, preprocessed CSV, and raw sensor CSV straight from test equipment
  • Automatic pipeline for raw data — voltage cutoff at 2.7 V, Coulomb-counting to derive SoC, downsampling to 20 bins
  • Dual prediction: a transformer SoH estimate alongside an independent physics estimate from cumulative current
  • SoH gauge with health banding, plus a remaining-useful-life estimate in charge cycles
  • Multi-cycle batch prediction from one file, with predicted-vs-actual comparison when ground truth is present
  • Interactive chart of all four features (voltage, current, temperature, SoC) across the discharge window
  • Runs on a 88 KB TensorFlow Lite model — CPU-only inference, no GPU required

Overview

A lithium-ion battery loses capacity as it ages, and State of Health (SoH) — today's usable capacity as a percentage of the original — is the number that decides whether a pack keeps working or gets replaced. The catch is that SoH cannot be measured directly during normal use. It has to be inferred from the signals a battery management system already records: voltage, current and temperature.

Battery SoH Predictor does that inference in the browser. Feed it one discharge cycle and it returns an SoH estimate, a health verdict, and a remaining-useful-life figure in charge cycles — the inputs an operator actually needs to schedule a replacement rather than wait for a failure.

The Battery SoH Predictor interface showing the input method selector, column reference guide and the 20-bin input table

Why It Matters

Battery health sits underneath a lot of the energy transition. Electric vehicles need it to report honest range and to price the second-hand market; grid and solar storage needs it to plan capacity; industrial fleets need it for predictive maintenance instead of reactive replacement. In every case the alternative to a good estimate is the same: replace packs too early and waste them, or too late and risk the failure.

How It Works

The model is a Physics-Informed iTransformer. A conventional transformer attends across time; the "inverted" design attends across features instead, treating each of the four measurements as a token so the network can learn how voltage, current, temperature and SoC relate to one another before it reasons about their progression through the discharge.

The "physics-informed" half is what makes the output auditable. A second branch integrates cumulative current — Coulomb counting, the textbook way to measure capacity — and produces its own estimate from first principles. Training both heads together regularises the network, and at inference the two numbers act as a cross-check: when the learned prediction and the physics estimate agree, there is real reason to trust the result.

Processing pipeline

Raw sensor logs never arrive in model-ready shape, so the backend does the conditioning itself. A raw upload is truncated at the 2.7 V cutoff that marks the end of a usable discharge, SoC is reconstructed from current over time by Coulomb counting, the series is downsampled into 20 equal bins, and the result is standardised with a scaler fitted at training time. Cycles whose computed capacity falls below 1.4 Ah are rejected as incomplete rather than quietly predicted on.

The Application

Three input modes cover the range of users. Manual entry fills a 20×4 grid — with a one-click sample loader of real NASA data for a quick trial. Preprocessed CSV takes data that already has the four features computed, and supports many cycles in one file; when the file carries a ground-truth SoH column, the app shows predicted against actual. Raw sensor CSV accepts logs straight off a battery cycler and runs the full pipeline server-side.

Results are reported the way an engineer would want them: a gauge for the SoH figure, a health band (healthy above 80%, needs attention between 60% and 80%, replace below 60%), a remaining-useful-life estimate in cycles, and the physics estimate and model error shown alongside so the headline number arrives with its uncertainty attached — not as a bare figure. A line chart of all four features across the 20 bins lets you sanity-check the input itself.

Model

  • Architecture: Physics-Informed iTransformer, 40,974 parameters
  • Input: 20 time-bins × 4 features (voltage, current, temperature, SoC)
  • Output: SoH (%) plus an independent physics estimate (%)
  • MAE: 1.74 % SoH · RMSE: 2.41 · R²: 0.844
  • Training data: NASA Prognostics Center of Excellence battery dataset (cells B0005–B0048)
  • Deployed size: 88 KB after TensorFlow Lite conversion, down from 620 KB

A mean absolute error of about 1.74 percentage points is the practical headline: on a pack reported at 87.6% health, the true value sits within roughly a point and a half either side — tight enough to act on when the end-of-life threshold is 80%.

Engineering Notes

The frontend is a Next.js 16 / React 19 client using Ant Design and Recharts; the backend is a FastAPI service exposing prediction endpoints for both JSON and file upload. Converting the trained model to TensorFlow Lite cut it to 88 KB and removed the need for a GPU or a heavyweight runtime, which is what lets the whole thing run on a small CPU instance and stay cheap to host.

Outcome

The result is a deployed, working tool rather than a notebook: a battery engineer can drop in a CSV from their own equipment and get back a health figure, a replacement horizon, and an independent physics cross-check on the model's answer — in a browser, in seconds.