Skip to main content

Battery simulation with BattMo in Python.

Project description

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.

Note the BattMo plotting functions in PyBattMo are experimental and not very stable yet.

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

Project details


Download files

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

Source Distribution

battmo-0.2.2.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

battmo-0.2.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file battmo-0.2.2.tar.gz.

File metadata

  • Download URL: battmo-0.2.2.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for battmo-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ffd53485d25d2b154022d11116add62b96ee4a6f431a5512ad4907f6db6875c5
MD5 caffd1ac0706165608f8c8062bef81b8
BLAKE2b-256 6b712809b72affbe323052a17509eae5c2e4b1a166a66a192b8e7dee5b1c9031

See more details on using hashes here.

File details

Details for the file battmo-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: battmo-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for battmo-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad4378a548778b754556a6937db7882ecadaf61dd56d4cfba4da19f3fbab0bd6
MD5 f0ace61ecf313234e26c93f09a484b55
BLAKE2b-256 ac40b3bf630045688f128a71ae45f204445cb6232d54d6518a505817ac6cb1d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page