Skip to main content

Python Battery Mathematical Modelling.

Project description


Build readthedocs codecov Open In Colab black_code_style

All Contributors

PyBaMM (Python Battery Mathematical Modelling) solves physics-based electrochemical DAE models by using state-of-the-art automatic differentiation and numerical solvers. The Doyle-Fuller-Newman model can be solved in under 0.1 seconds, while the reduced-order Single Particle Model and Single Particle Model with electrolyte can be solved in just a few milliseconds. Additional physics can easily be included such as thermal effects, fast particle diffusion, 3D effects, and more. All models are implemented in a flexible manner, and a wide range of models and parameter sets (NCA, NMC, LiCoO2, ...) are available. There is also functionality to simulate any set of experimental instructions, such as CCCV or GITT, or specify drive cycles.

How do I use 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

or simulate an experiment such as CCCV:

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, solver=pybamm.CasadiSolver())

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.

For further examples, see the list of repositories that use PyBaMM here

How can I install 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.

conda install -c conda-forge pybamm

Optional solvers

On GNU/Linux and MacOS, an optional scikits.odes-based solver is available, 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. (2020). Python Battery Mathematical Modelling (PyBaMM). ECSarXiv. February, 7.

You can use the bibtex

  title={Python Battery Mathematical Modelling (PyBaMM)},
  author={Sulzer, Valentin and Marquis, Scott G and Timms, Robert and Robinson, Martin and Chapman, S Jon},
  journal={ECSarXiv. February},

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


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 for information on how to add your own citations when you contribute.

How can I contribute 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.


PyBaMM is fully open source. For more information about its license, see LICENSE.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Valentin Sulzer

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ โœ… ๐Ÿ“

Robert Timms

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ โœ…

Scott Marquis

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿšง ๐Ÿ‘€ โš ๏ธ โœ…

Martin Robinson

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿ‘€ โš ๏ธ

Ferran Brosa Planella

๐Ÿ‘€ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿšง โš ๏ธ โœ… ๐Ÿ“

Tom Tranter

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿ‘€ โš ๏ธ

Thibault Lestang

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿ‘€ โš ๏ธ ๐Ÿš‡


๐Ÿ› ๐Ÿ‘€ ๐Ÿ’ป ๐Ÿš‡


๐Ÿ’ป โš ๏ธ


๐Ÿ’ป โš ๏ธ


๐Ÿ’ป โš ๏ธ


๐Ÿ› ๐Ÿ’ป โš ๏ธ

Yannick Kuhn

๐Ÿ’ป โš ๏ธ

Jacqueline Edge

๐Ÿค” ๐Ÿ“‹ ๐Ÿ”

Fergus Cooper

๐Ÿ’ป โš ๏ธ


๐Ÿค” ๐Ÿ”

Colin Please

๐Ÿค” ๐Ÿ”

Faraday Institution


Alexander Bessman

๐Ÿ› ๐Ÿ’ก



Anand Mohan Yadav



๐Ÿ’ป ๐Ÿ’ก โš ๏ธ

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pybamm, version 0.3.0.post1
Filename, size File type Python version Upload date Hashes
Filename, size pybamm-0.3.0.post1-cp36-cp36m-macosx_10_15_x86_64.whl (1.1 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pybamm-0.3.0.post1-cp36-cp36m-manylinux2014_x86_64.whl (1.4 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pybamm-0.3.0.post1-cp37-cp37m-macosx_10_15_x86_64.whl (1.1 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pybamm-0.3.0.post1-cp37-cp37m-manylinux2014_x86_64.whl (1.4 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pybamm-0.3.0.post1-cp38-cp38-macosx_10_15_x86_64.whl (1.1 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pybamm-0.3.0.post1-cp38-cp38-manylinux2014_x86_64.whl (1.4 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pybamm-0.3.0.post1-py3-none-any.whl (906.2 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page