Skip to main content

PyBaMM-GEM

An open-source extension package for PyBaMM providing advanced battery models, degradation models, and simulation tools.

What's in GEM

>>> import pybamm_gem as gem
>>> gem.models()

Models (also listed in the PyBaMM model zoo)
  dfn_2d                  Doyle-Fuller-Newman model resolved in x and z
  dfn_3d                  Doyle-Fuller-Newman model resolved in x, y and z
  dfn_cracking_isolation  DFN with particle cracking and isolation of active material
  dfn_phase_kinetics      DFN with a different intercalation kinetics in each particle phase
  spm_2d                  Single Particle Model resolved in the vertical direction z
  spm_3d                  Single Particle Model resolved over the electrode area (y and z)

Options (switched on inside a model)
  dfn_cracking_isolation  "cracking and isolation"
                          "cracking and isolation interfacial current coupling"
                          "cracking and isolation induced transport effects"
                          "particle volume expansion induced effects"
                          "SEI crack interaction"
                          "porosity blocking efficiencies"
                          "lithium plating overpotential"
  dfn_phase_kinetics      "intercalation kinetics": "Tafel", "one-sided Butler-Volmer"

Tools (run between solves)
  solvent_consumption     Electrolyte dry-out from SEI solvent consumption (Li2022, Fang2021)
                          -> PyBaMM's DFN, dfn_2d, dfn_3d

Parameter sets (pybamm.ParameterValues(name))
  Rawat2025               Graphite vs LFP-LFO composite positive electrode  -> dfn_phase_kinetics
  Rawat2026               LG M50, graphite/silicon negative electrode       -> dfn_cracking_isolation
  OKane2022_solvent       OKane2022 + the solvent consumption parameters    -> solvent_consumption

gem.info("dfn_2d") gives the details of one model, and every model folder has its own README.

Installation

pip install pybamm-gem

PyBaMM 26.10.1 or newer is needed. To get the newest code from GitHub instead: pip install git+https://github.com/ImperialCollegeLondon/PyBaMM-GEM

Usage

import pybamm
import pybamm_gem as gem

model = gem.load("spm_2d")()
simulation = pybamm.Simulation(model)
solution = simulation.solve([0, 3000])
print(solution["Voltage [V]"](1500))

The classes are also available directly, for example gem.lithium_ion.BasicSPM2D or gem.lithium_ion.DFN2D.

A tool is used between solves. For example, the electrolyte dry-out after every block of cycles (Li et al. 2022, with the dry pores as in Fang et al. 2021):

from pybamm_gem.tools import solvent_consumption

model = gem.load("dfn_2d")({"SEI": "solvent-diffusion limited", "SEI porosity change": "true"})
parameters = pybamm.ParameterValues("OKane2022_solvent")
experiment = pybamm.Experiment(
    [("Discharge at 1C until 2.5 V", "Charge at 0.3C until 4.2 V", "Hold at 4.2 V until C/100")] * 26
)
state = solvent_consumption.start(parameters)
for block in range(10):
    simulation = pybamm.Simulation(model, parameter_values=parameters, experiment=experiment)
    solution = simulation.solve()
    state, parameters, _ = solvent_consumption.update(solution, parameters, state)
    model = solvent_consumption.restart_model(model, solution, state)
    print(solvent_consumption.summary(state))

The commands are the same as in the PyBaMM model zoo (pybamm_model_zoo): list_models(), info(), load(), require() and register_citation(). info(), load(), require() and register_citation() take either the slug ("spm_2d") or the class name ("BasicSPM2D"); list_models() returns the slugs of the models only; models() also shows the options, tools and parameter sets. With pybamm-model-zoo installed, the GEM models are also listed by pybamm_model_zoo.list_models().

The notebook examples/higher_dimensional_models.ipynb runs the 2D and 3D models, compares them with the stock PyBaMM models and shows a temperature that changes with height. examples/solvent_consumption.ipynb shows the dry-out tool: no reservoir against 6 % and 9 % reservoirs, and the same in dfn_2d.

About PyBaMM-GEM

PyBaMM-GEM is an open, collaborative home for battery models that extend PyBaMM. Many new models are experimental, specialised or still under active research, which makes them unsuitable for the core PyBaMM project in their early stages. GEM is where they can be developed, validated, compared and shared, while staying close to PyBaMM. Some GEM models may later move into PyBaMM; others stay in GEM because they answer specialised questions. Both outcomes count as success.

Stay close to PyBaMM. Explore beyond it. GEM models follow PyBaMM's design, options and user experience, so PyBaMM users feel at home. Where a GEM model differs scientifically from a PyBaMM model, it is a separate, explicitly named model. Every release states the PyBaMM versions it supports.

GEM stands for General Enough Model and Good Enough Model: the fewest physical processes needed to explain the behaviour of interest. The name also honours Professor John B. Goodenough.

The models are laid out like the PyBaMM model zoo: one folder per model, each with a model.toml manifest, a CITATION.bib, a README, tests and an example. A new mechanism is added as an option of an existing model where it fits, and listed in src/pybamm_gem/catalogue.toml.

Automatic checks

  • Every push and pull request, and every Monday: ruff, GEM's tests and the PyBaMM model zoo's contract checks, against the newest PyBaMM and pybamm-model-zoo. A failed Monday run shows in the Actions tab, and the monthly report lists the last four weekly results. The tests also check that the block under "What's in GEM" is the same as the output of gem.models().
  • 1st of every month: a health report of the released package (installed from PyPI) with the newest PyBaMM and model zoo, posted on the pinned issue "Monthly health report". It can also be run by hand with python scripts/health_report.py.

Releasing a new version

  1. In a pull request, raise version in pyproject.toml (for example 0.2.2) and add a CHANGELOG.md entry. Merge it.
  2. On GitHub, go to Releases, then "Draft a new release". Create the tag v0.2.2 (a "v" and the version), add a title and notes, and publish.
  3. The Release workflow builds and tests the package, uploads it to TestPyPI and tests it again. It then waits for a maintainer to approve the upload to PyPI (GitHub sends an email).

Licence

BSD 3-Clause, see LICENSE.txt. Copyright (c) 2026, Imperial College London. Some of the model code is adapted from PyBaMM; see LICENSES-bundled.txt.

Metadata

Release files for PyBaMM-GEM 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyBaMM-GEM 0.3.0
File Size Uploaded Provenance Actions
pybamm_gem-0.3.0.tar.gz 1.2 MB With provenance Details for pybamm_gem-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PyBaMM-GEM 0.3.0
File Interpreter ABI Platform Actions
pybamm_gem-0.3.0-py3-none-any.whl Python 3 none any Details for pybamm_gem-0.3.0-py3-none-any.whl

Total release size: 2.1 MB

Release files / pybamm_gem-0.3.0.tar.gz

Download URL pybamm_gem-0.3.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
04f8ca904ade82fa92c67cd2b0f147ba8106024fb92c9a2dde5d0ff171101f8f
BLAKE2b-256 checksum
How to use checksums
2d0d216543f609920e53d443537d90abfac43b9f2be0fd67392939ee56253b40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / pybamm_gem-0.3.0-py3-none-any.whl

Download URL pybamm_gem-0.3.0-py3-none-any.whl
Size 917.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6826d4734fcdddab3e706ddaf1c20004f19b50f4a9764518f4e4bcc0ea6249ff
BLAKE2b-256 checksum
How to use checksums
2f8919099af766e3722f392a3a82db8d8458c73aaa8f90daac34c907431a7598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for PyBaMM-GEM 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pybamm_gem-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page