Skip to content

chaffybird56/BatteryPack

Repository files navigation

BatteryPack

License: MIT Python

BatteryPack is a Python framework that simulates how a lithium-ion battery pack behaves electrically and thermally under charge, discharge, and load—so you can estimate efficiency, temperature rise, power limits, and safety margins before hardware sign-off.

It couples a first-order equivalent-circuit cell model with pack-level series/parallel topology, lumped (and optional multi-node) thermal dynamics, configurable cell chemistries, drive-cycle profiles, and Python-based failure-mode / thermal-runaway screening.


Key capabilities

  • Electro-thermal modeling
  • DC power & efficiency
  • Configurable chemistries
  • Load & charge profiles
  • Automotive-style cycles
  • BMS & safety
  • Analysis extras
  • CI

Full module-by-module inventory: FEATURES.md


Screenshots

Time series — pack current, voltage, power, SoC during discharge:

Time series

Thermal — temperature through charge/discharge:

Temperature

Round-trip efficiency:

RTE

Charge / load profile:

Load profile

Chemistry comparison — RTE across cell presets (same pack topology):

Chemistry RTE

Safety — thermal-runaway hazard vs pack temperature:

Safety

Power limits — max charge/discharge vs SoC:

Power limits


Project layout

battery_pack/
  cell.py, pack.py, thermal.py   # ECM + pack + thermal
  simulation.py                  # charge/discharge, RTE
  drive_cycles.py                # synthetic / dataframe cycles
  drive_cycles_real.py           # EPA/WLTP/NEDC-style generators
  charging.py, bms.py, safety.py
  config.py                      # chemistry presets
scripts/
  generate_readme_plots.py       # figures in assets/
  run_demo.py, run_sweeps.py, run_ups_demo.py
tests/

More examples: EXAMPLES.md


Quickstart

git clone https://github.com/chaffybird56/BatteryPack.git && cd BatteryPack
python3 -m venv .venv && source .venv/bin/activate
pip install -e .

pytest tests/ -q
python scripts/generate_readme_plots.py   # refresh assets/*.png
from battery_pack.config import cell_params_for_chemistry
from battery_pack.pack import BatteryPack

cell = cell_params_for_chemistry("LFP")  # or NMC811, NCA, LCO
pack = BatteryPack(cell_params=cell, ...)

License

MIT — see LICENSE.