Skip to main content

Logo


Documentation Build Status DOI

PyBattMo

PyBattMo is a Python wrapper around the Julia-based BattMo.jl. The Battery Modelling Toolbox (BattMo) is a resource for continuum modelling of electrochemical devices. The initial development features a pseudo X-dimensional (PXD) framework for the Doyle-Fuller-Newman model of lithium-ion battery cells. This is currently a early release that implements a subset of features from the MATLAB version of BattMo.

BattMo Family

BattMo can be used through several interfaces:

Installation

To install PyBattMo, use the following pip command:

pip install battmo

Quick start

Run examples using our internal library, for example the cell parameters from Chen et al.

Important tip: run the examples within a notebook or using cells in VSCode to make use of the high performance of Julia. Julia compiles the functions and objects that you use when you first run a code. Because of this, the second time you run the same code it is super fast! But to make use of this, you need to have a kernel that keeps running in between code executions. Therefore, it does work with jupytor notebooks.

P2D example

Here are a few examples to get you started:

from battmo import *
import plotly.express as px
import pandas as pd
import numpy as np

# Initialize the model
model = LithiumIonBattery()

# Load cell parameters and cycling protocol
cell_parameters = load_cell_parameters(from_default_set = "chen_2020")
cycling_protocol = load_cycling_protocol(from_default_set = "cc_discharge")

# Have a quick look into what kind of cell we're dealing with
quick_cell_check(cell_parameters)

# Set up the simulation
sim = Simulation(model, cell_parameters, cycling_protocol)

# Run the simulation
output = solve(sim)

# Have a look into which output quantities are available
print_info(output)

# Plotting using Plotly
df = to_pandas(output.time_series)
fig = px.line(df, x="Time", y="Voltage", title="Voltage curve")
fig.show()

# Use BattMo internal plotting functions
plot_dashboard(output, plot_type="contour")

Run a 3D simulation

from battmo import *

# Load parameter sets and settings
cell_parameters = load_cell_parameters(from_default_set="chen_2020")
cycling_protocol = load_cycling_protocol(from_default_set="cc_discharge")
model_settings = load_model_settings(from_default_set="p4d_cylindrical")
simulation_settings = load_model_settings(from_default_set="p4d_cylindrical")

# We adjust the parameters so that the simulation in this example is not too long

cell_parameters["Cell"]["OuterRadius"]                                   = 0.004
cell_parameters["NegativeElectrode"]["CurrentCollector"]["TabFractions"] = [0.5]
cell_parameters["PositiveElectrode"]["CurrentCollector"]["TabFractions"] = [0.5]
cell_parameters["NegativeElectrode"]["CurrentCollector"]["TabWidth"]     = 0.002
cell_parameters["PositiveElectrode"]["CurrentCollector"]["TabWidth"]     = 0.002
simulation_settings["AngularGridPoints"]                                 = 8

# Setup model and simulation
model = LithiumIonBattery(model_settings=model_settings)
sim = Simulation(model, cell_parameters, cycling_protocol, simulation_settings = simulation_settings)
output = solve(sim)

# Plot interative 3D results
plot_interactive_3d(output)

Documentation

Some additional examples are be found in the BattMo.jl documentation as well as a comprehensive documentation on the API and architecture of BattMo.jl.

Acknowledgements

BattMo has received funding from the European Union’s Horizon 2020 innovation program under grant agreement numbers:

  • 875527 HYDRA
  • 957189 BIG-MAP
  • 101104013 BATMAX
  • 101103997 DigiBatt

Metadata

Release files for battmo 0.2.3

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

Source distribution (sdist)

Source distribution for battmo 0.2.3
File Size Uploaded Provenance Actions
battmo-0.2.3.tar.gz 12.0 kB Without provenance Details for battmo-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for battmo 0.2.3
File Interpreter ABI Platform Actions
battmo-0.2.3-py3-none-any.whl Python 3 none any Details for battmo-0.2.3-py3-none-any.whl

Total release size: 20.6 kB

Release files / battmo-0.2.3.tar.gz

Download URL battmo-0.2.3.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7508a58fc3e12fb908c50e0e44f201d374a3e075cf76be55ae3f45a2eeefe925
BLAKE2b-256 checksum
How to use checksums
7086a5ceaa0100ec4a58366a323b274351dc91fd94b1c827d52ffb3c16fa7ee3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / battmo-0.2.3-py3-none-any.whl

Download URL battmo-0.2.3-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b353e88df3d7330b43e8608addee5211ab0416b0e49f8e7ac0102c8dcf3a13c6
BLAKE2b-256 checksum
How to use checksums
9f471e905913f45657af4480cb03fc5c191bdd7476b043861b5281d94a2a6bff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for battmo 0.2.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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