PyBaMM
Python Battery Mathematical Modelling — an open-source library for fast, flexible physics-based battery simulation.
Why PyBaMM?
PyBaMM accelerates battery modelling research by providing open-source tools for multi-institutional, interdisciplinary collaboration. It delivers:- A framework for writing and solving systems of differential equations
- A library of battery models (SPM, SPMe, DFN, MPM, MSMR, ECM, and more)
- Specialized tools for simulating battery experiments and visualizing results
Get Started
Run your first battery simulation in minutes with the quickstart guide.
Installation
Install PyBaMM via pip or conda on Linux, macOS, or Windows.
Battery Models
Explore physics-based models for lithium-ion, lead-acid, sodium-ion, and more.
API Reference
Comprehensive reference for every class, method, and parameter.
Key capabilities
Physics-based models
DFN, SPM, SPMe, MPM, MSMR — from full-order to reduced-order models.
Multiple solvers
CasADi, IDAKLU, SciPy, and JAX backends for speed and flexibility.
Rich parameter sets
Published parameters for Chen2020, Marquis2019, OKane2022, and many more.
Experiment definition
Define CC, CV, rest, and hold steps with plain-text experiment strings.
Batch studies
Sweep parameters and compare models with BatchStudy.
Interactive plots
Built-in QuickPlot with interactive visualization of any model variable.
Quick example
Run a constant-current/constant-voltage charge cycle:Supported battery chemistries
Lithium-ion
SPM, SPMe, DFN, MPM, MSMR, Newman-Tobias, Yang2017 — full suite of Li-ion models.
Lead-acid
Isothermal porous-electrode and quasi-static models for lead-acid batteries.
Equivalent circuit
Thevenin and other ECM models for fast, empirical simulation.
Sodium-ion
Physics-based models adapted for sodium-ion chemistries.
Installation
PyBaMM is a NumFOCUS fiscally sponsored project. If PyBaMM is useful in your research, consider citing the paper and making a tax-deductible donation.