Skip to content

Latest commit

 

History

59 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Battery and Power Reference Lab: original vector system illustration

Hardened CI Python validation CodeQL

Dependency-free Python references and MATLAB equivalents cover lumped battery heating and DC-link sizing. The browser lab follows the thermal balance and directs electrical sizing questions to the native functions.

Native-source lesson guide · Offline interactive lab · Lesson configuration · Configuration schema

Reproducibility and scientific verification

The eight-domain audit package contains the requirement matrix, mathematical and MATLAB parity evidence, browser QA, CI security report, branch inventory, fix log and release gate.

Native Python 3.10 and 3.12 models are standard-library-only; running the regression and property suites requires the development dependency group. The MATLAB R2026a numerical gate tests independent physics fixtures at 1e-12 relative and near-zero absolute tolerance; its public single-purpose DC-link functions do not require dummy parameters.

python -m pip install --group dev
python -m unittest discover -s tests -v
python -m pytest -q
python src/battery_thermal.py --current 80 --duration 900 --output thermal_trace.csv
python src/dc_link.py
node tests/browser/offline-e2e.mjs

The last browser command requires local Chrome/Chromium and Node 24; it tests the four-module standalone lab with networking disconnected, keyboard interaction, reduced motion, 320–1280px viewports, and actual 241-row synthetic CSV export. Hardened GitHub Actions runs this automatically, including source lint/types, security scanners, MATLAB tests, numerical coverage and a clean PR diff.

Safety and applicability: All figures and outputs are deterministic educational reference calculations, not measured cell/pack performance, inverter certification, battery safety qualification, component rating or operational engineering advice. The lumped temperature model uses constant resistance and effective cooling; DC-link equations omit ESR/ESL and require a zero-mean symmetric triangular capacitor-current assumption. See the scientific limits before adaptation.

Previous animations

Open the live lab → Previous animations · Open the local gallery

Earlier animated artwork, waveform demos, and original interactive experiences are linked alongside the current animations.

Your first interactive result

  1. Download or clone this repository and open docs/index.html in a modern browser.
  2. Select Module 1, apply its preset, and compare the declared checkpoint with the plotted result.
  3. Change one slider, inspect the model assumptions, then export the configuration or telemetry for your notes.

The browser lab runs offline with no packages, accounts, or live data feeds. Its numbers are deterministic teaching simulations. Each checkpoint states its model time and tolerance; passing it demonstrates agreement with that model, not field calibration or production readiness.

System topology and model boundaries

Lumped pouch thermal

Source-defined first-order lumped thermal model; no cell-specific spatial field.

Motion is optional; the vector topology remains readable with reduced motion enabled.

Four-module learning path

Module Investigation Approximate time
1. Balance generated and rejected heat Use steady-state rise and the time constant to predict a first-order response. 12 min
2. Translate a current change into heat Recognize quadratic Joule heating while holding the thermal path fixed. 15 min
3. Choose a cooling sensitivity Separate the effects of cooling conductance on steady rise and response time. 12 min
4. Transfer the accounting habit to DC-link sizing Keep energy, power, waveform, and boundary assumptions explicit across two reference models. 18 min

Who this is for: Engineers and students making early thermal and power-electronics sensitivity checks.

Continue into the implementation

Explore or run the source

Python 3.10+; no third-party Python runtime dependencies. The test suite additionally needs the declared dev dependency group (install with python -m pip install --group dev). MATLAB is optional for the equivalent functions, including standalone three- and four-argument DC-link functions alongside the original seven-argument combined interface.

python src/battery_thermal.py --current 80 --duration 900 --output thermal_trace.csv
python src/dc_link.py
python -m unittest discover -s tests -v

These commands come from the audited source revision. Runtime requirements and the project's own validation limits are documented below; the standalone browser lab does not execute these commands.

The detailed project guide below remains the source for installation, supported features, licences, and scientific limits. The browser equations and laboratory settings do not change the original application or numerical engine.

Project documentation, installation, attribution, and existing validation

Battery and Power Electronics Reference Models

Last commit Open issues License

Small, inspectable reference models for early battery-thermal and DC-link design checks. The repository favors explicit equations, stated assumptions, and tests over opaque tooling.

Start Here

Models

Lumped Battery Thermal Response

src/battery_thermal.py solves a first-order cell thermal balance for a piecewise-constant current profile:

C_th dT/dt = I^2 R - hA(T - T_ambient)

The implementation uses the analytical state update over each time step, including the exact adiabatic limit at zero cooling conductance. It is useful for sensitivity checks involving current, internal resistance, thermal capacitance, ambient temperature, and effective cooling conductance.

Scope: Resistance, thermal capacitance, cooling conductance and ambient conditions are fixed within each interval. Heating is I²R only; temperature/SOC-dependent resistance, reversible entropic heat and spatial gradients are not modelled. A lumped-temperature assumption should be checked against geometry, thermal conductivity and a sufficiently small Biot number, Bi = h L_c / k << 0.1; this condition is not established by the reference model.

DC-Link Ripple and Capacitance

src/dc_link.py contains two transparent sizing relationships:

  • Ideal voltage ripple ΔVpp = ΔIpp / (8 f_sw C) for a zero-mean, symmetric triangular capacitor-current waveform (not a universal inductor-current or inverter ripple rule).
  • Exact minimum capacitance C = 2 P t / [ΔV(2 Vbus - ΔV)] for an ideal capacitor supplying a constant-power pulse, where 0 < ΔV < Vbus.

These are ideal capacitance relations: ESR, ESL, tolerance, DC-bias/temperature dependence, ripple-current heating, switching transients and hardware qualification are excluded. The ESR-associated voltage swing alone may be as large as ΔIpp × ESR, but capacitive and resistive voltage extrema need not coincide. Do not simply add them as an exact total. The small-drop approximation C ≈ Pt/(Vbus ΔV) is not used by the solver.

MATLAB equivalents are provided in matlab/ for model-based engineering workflows.

Quick start

Python 3.10 or later is sufficient; there are no third-party runtime dependencies.

python src/battery_thermal.py --current 80 --duration 900 --output thermal_trace.csv
python src/dc_link.py
python -m unittest discover -s tests -v

In MATLAB, the thermal function accepts an optional parameter struct and an optional initial temperature. Missing parameter fields use the reference defaults; the initial temperature defaults to the configured ambient value.

addpath('matlab');
temperature_c = battery_thermal_lumped([80 80], 1, struct('ambient_c', 30));
results = runtests('matlab/tests');
assertSuccess(results);

Repository Layout

src/       # dependency-free Python reference implementations
matlab/    # MATLAB equivalents for model-based workflows
tests/     # regression tests for the Python references

Engineering Boundary

These are reference models, not production-qualified battery, BMS, inverter, or safety models. They do not replace electrochemical characterization, CFD/FEA, component tolerances, control-loop analysis, standards compliance, or test evidence. Inputs and assumptions must be replaced with project-specific data before an engineering decision is made.

Contributing

See CONTRIBUTING.md for focused documentation, model, and validation changes. Please keep units, assumptions, and project-specific data visible in any example you add.

Citation

For research, teaching, or technical reports, use the machine-readable CITATION.cff metadata and identify the model inputs and assumptions used in the result.

Author

Mohammad Rezwan Khan - Electrical R&D Engineer and PhD in Energy Technology.

License

MIT

Source-backed reference documentation

The documentation index and rendered reference guide add developer, scientific, maintainer and owner reading paths for source snapshot 0304bfec25c43f42f103ebda239749b88609a187 (reviewed 2026-11-19).

The native model runtime uses Python's standard library. The current test suite requires the declared development group in pyproject.toml; see setup before running the earlier quick-start test command. Native thermal time is in seconds; the active browser lesson uses minutes, direct heat input and different defaults. Its exported lesson config retains a historical source snapshot. Current CLI interval handling and these differences are documented explicitly in the reference guide.

Releases

Packages

Used by

Contributors

Languages