Python Battery Mathematical Modelling
Project description
PyBaMM
PyBaMM (Python Battery Mathematical Modelling) is an open-source battery simulation package written in Python. Our mission is to accelerate battery modelling research by providing open-source tools for multi-institutional, interdisciplinary collaboration. Broadly, PyBaMM consists of (i) a framework for writing and solving systems of differential equations, (ii) a library of battery models and parameters, and (iii) specialized tools for simulating battery-specific experiments and visualizing the results. Together, these enable flexible model definitions and fast battery simulations, allowing users to explore the effect of different battery designs and modeling assumptions under a variety of operating scenarios.
PyBaMM uses an open governance model and is fiscally sponsored by NumFOCUS. Consider making a tax-deductible donation to help the project pay for developer time, professional services, travel, workshops, and a variety of other needs.
💻 Using PyBaMM
The easiest way to use PyBaMM is to run a 1C constant-current discharge with a model of your choice with all the default settings:
import pybamm
model = pybamm.lithium_ion.DFN() # Doyle-Fuller-Newman model
sim = pybamm.Simulation(model)
sim.solve([0, 3600]) # solve for 1 hour
sim.plot()
or simulate an experiment such as a constant-current discharge followed by a constant-current-constant-voltage charge:
import pybamm
experiment = pybamm.Experiment(
[
(
"Discharge at C/10 for 10 hours or until 3.3 V",
"Rest for 1 hour",
"Charge at 1 A until 4.1 V",
"Hold at 4.1 V until 50 mA",
"Rest for 1 hour",
)
]
* 3,
)
model = pybamm.lithium_ion.DFN()
sim = pybamm.Simulation(model, experiment=experiment)
sim.solve()
sim.plot()
However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN script or notebook).
For new users we recommend the Getting Started guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM, and can either be downloaded and used locally, or used online through Google Colab.
Further details can be found in a number of detailed examples, hosted here on github. In addition, there is a full API documentation, hosted on Read The Docs. Additional supporting material can be found here.
Note that the examples on the main branch are tested on the latest commit. If you are using an older version of PyBaMM from pip, you can switch to the corresponding release tag on GitHub to see the version of the examples that is compatible with that release.
Versioning
PyBaMM uses CalVer. Version numbers take the form YY.MM.N.P, where YY.MM is the year and month of the release, N is the feature release within that month (0 for the first), and P is the patch level (0 for the feature release itself). For example, 27.1.0.1 is the first patch of the first feature release in January 2027.
Releases ship when there's something worth releasing, not on a fixed schedule. Any release may contain breaking changes; when it does, they appear under a ## Breaking changes section at the top of CHANGELOG.md. Public APIs that are removed or renamed ship a DeprecationWarning for at least two prior feature releases first, where technically possible.
See RELEASE.md for the full release policy, including how we define "public API" and what counts as a breaking change.
🚀 Installing PyBaMM
PyBaMM is available on GNU/Linux, MacOS and Windows. We strongly recommend to install PyBaMM within a python virtual environment, in order not to alter any distribution python files. For instructions on how to create a virtual environment for PyBaMM, see the documentation.
Using pip
pip install pybamm
Using conda
PyBaMM is available as a conda package through the conda-forge channel.
[!NOTE] PyBaMM versions between 24.11.2 and 25.6 (not including these boundary versions) are not available on conda-forge.
# for no extra dependencies
conda install -c conda-forge pybamm-base
# for all extra dependencies except jax
conda install -c conda-forge pybamm
# optionally install jax >=0.7.0, <0.9.0 on python >=3.11
conda install -c conda-forge "jax>=0.7.0,<0.9.0"
Optional solvers
The following solvers are optionally available:
- jax-based solver, see the documentation.
📖 Citing PyBaMM
If you use PyBaMM in your work, please cite our paper
Sulzer, V., Marquis, S. G., Timms, R., Robinson, M., & Chapman, S. J. (2021). Python Battery Mathematical Modelling (PyBaMM). Journal of Open Research Software, 9(1).
You can use the BibTeX
@article{Sulzer2021,
title = {{Python Battery Mathematical Modelling (PyBaMM)}},
author = {Sulzer, Valentin and Marquis, Scott G. and Timms, Robert and Robinson, Martin and Chapman, S. Jon},
doi = {10.5334/jors.309},
journal = {Journal of Open Research Software},
publisher = {Software Sustainability Institute},
volume = {9},
number = {1},
pages = {14},
year = {2021}
}
We would be grateful if you could also cite the relevant papers. These will change depending on what models and solvers you use. To find out which papers you should cite, add the line
pybamm.print_citations()
to the end of your script. This will print BibTeX information to the terminal; passing a filename to print_citations will print the BibTeX information to the specified file instead. A list of all citations can also be found in the citations file. In particular, PyBaMM relies heavily on CasADi.
See CONTRIBUTING.md for information on how to add your own citations when you contribute.
🛠️ Contributing to PyBaMM
If you'd like to help us develop PyBaMM by adding new methods, writing documentation, or fixing embarrassing bugs, please have a look at these guidelines first.
📫 Get in touch
For any questions, comments, suggestions or bug reports, please visit:
- Our Contact Page
- Our Discussion Forum
📃 License
PyBaMM is fully open source. For more information about its license, see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybamm-26.6.0.0.tar.gz.
File metadata
- Download URL: pybamm-26.6.0.0.tar.gz
- Upload date:
- Size: 712.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0523315f859c99673f9ffbbb78b00bdb333ce82ba2737c60b6a52dab00b0a4f
|
|
| MD5 |
432dcbb40ba27b25b31fd10d86dcabf4
|
|
| BLAKE2b-256 |
0b8b1e36534860841954a8f22764cdf1f45758f419362eba867f022a6976cddb
|
Provenance
The following attestation bundles were made for pybamm-26.6.0.0.tar.gz:
Publisher:
publish_pypi.yml on pybamm-team/PyBaMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybamm-26.6.0.0.tar.gz -
Subject digest:
d0523315f859c99673f9ffbbb78b00bdb333ce82ba2737c60b6a52dab00b0a4f - Sigstore transparency entry: 1721282405
- Sigstore integration time:
-
Permalink:
pybamm-team/PyBaMM@8daf72afa0b9b734d54a48537ebcce736b78fe68 -
Branch / Tag:
refs/tags/v26.6.0.0 - Owner: https://github.com/pybamm-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@8daf72afa0b9b734d54a48537ebcce736b78fe68 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pybamm-26.6.0.0-py3-none-any.whl.
File metadata
- Download URL: pybamm-26.6.0.0-py3-none-any.whl
- Upload date:
- Size: 946.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1475a207bca3f8d8fe5f76160b3478c903ca041adfb844d54d6578d6bc0c5e6
|
|
| MD5 |
5fe3bdf44f0b1c9849c2414617a7e17d
|
|
| BLAKE2b-256 |
31176217f17325bd5dc10e4743b934f3c2ae401ee9795dc3255ec20617296c68
|
Provenance
The following attestation bundles were made for pybamm-26.6.0.0-py3-none-any.whl:
Publisher:
publish_pypi.yml on pybamm-team/PyBaMM
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pybamm-26.6.0.0-py3-none-any.whl -
Subject digest:
e1475a207bca3f8d8fe5f76160b3478c903ca041adfb844d54d6578d6bc0c5e6 - Sigstore transparency entry: 1721283069
- Sigstore integration time:
-
Permalink:
pybamm-team/PyBaMM@8daf72afa0b9b734d54a48537ebcce736b78fe68 -
Branch / Tag:
refs/tags/v26.6.0.0 - Owner: https://github.com/pybamm-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@8daf72afa0b9b734d54a48537ebcce736b78fe68 -
Trigger Event:
release
-
Statement type: