Battery simulation blocks for PathSim
Documentation • PathSim Homepage • GitHub
PathSim-Batt extends the PathSim simulation framework with battery cell blocks backed by PyBaMM. All blocks follow the standard PathSim interface and can be wired into any simulation diagram.
Install
pip install pathsim-batt
Quick start
import pybamm
from pathsim import Connection, Simulation
from pathsim.blocks import Constant
from pathsim.solvers import ESDIRK43
from pathsim_batt import CellElectrothermal
cell = CellElectrothermal(initial_soc=1.0) # defaults: SPMe + Chen2020
I_src = Constant(5.0) # 5 A discharge
T_src = Constant(298.15) # 25 °C ambient
sim = Simulation(
blocks=[I_src, T_src, cell],
connections=[Connection(I_src, cell["I"]), Connection(T_src, cell["T_amb"])],
dt=1.0,
Solver=ESDIRK43,
)
sim.run(3600)
print(f"V = {cell.outputs[0]:.3f} V T = {cell.outputs[1]:.1f} K SOC = {cell.outputs[3]:.3f}")
Choosing a block
Two decisions determine the right block: thermal ownership and integration strategy.
| Block | Thermal | Strategy | Use when |
|---|---|---|---|
CellElectrothermal |
PyBaMM (internal) | Monolithic | Single cell, coupled electro-thermal |
CellElectrical + LumpedThermal |
PathSim (external) | Monolithic | Pack-level, custom cooling |
CellCoSimElectrothermal |
PyBaMM (internal) | Co-simulation | Large models (e.g. DFN), mixed solvers |
CellCoSimElectrical + LumpedThermal |
PathSim (external) | Co-simulation | Large models with external thermal network |
LumpedThermal is a single-node thermal block (mass, Cp, UA, T0) that receives Q_dot from a CellElectrical block and feeds back cell temperature.
PyBaMM models
All blocks work with the standard PyBaMM battery models, e.g. lithium_ion.SPM, SPMe, DFN, lead_acid.LOQS, lead_acid.Full or equivalent_circuit.Thevenin. The model must provide the variables the block outputs (terminal voltage, heat generation and, for the electrothermal blocks, cell temperature); some minimal models such as sodium_ion.BasicDFN do not. Thermal sub-model and heat-source options are injected automatically — pass the bare model class with no options=.
The monolithic blocks integrate the model with PathSim's solvers, which is fast for reduced models (SPM, SPMe, ECM) but slow for spatially resolved models such as DFN: a 10-minute discharge takes over a minute, compared with about a second in CellCoSimElectrical with a 10 s macro-step. For such models prefer the co-simulation blocks. In the monolithic blocks, tolerance=1e-9 makes DFN about three times faster; lead_acid.Full needs the default 1e-6.
Known limitations of the co-simulation blocks:
lead_acid.LOQSon PyBaMM < 26.7: passpybamm_solver=pybamm.CasadiSolver(mode="safe"); the defaultIDAKLUSolvererrors onLOQS.equivalent_circuit.Thevenin:initial_soc=1.0fails because PyBaMM requires event values to be strictly positive att=0; use e.g.initial_soc=0.99.
import pybamm
from pathsim_batt import CellElectrical, CellElectrothermal
# Custom chemistry / parameter set
cell = CellElectrothermal(
model=pybamm.lithium_ion.SPMe(),
parameter_values=pybamm.ParameterValues("Mohtat2020"),
)
# High-fidelity model (slow in the monolithic blocks, see above)
cell = CellElectrical(
model=pybamm.lithium_ion.DFN(),
parameter_values=pybamm.ParameterValues("Chen2020"),
)
# Equivalent circuit model
cell = CellElectrical(
model=pybamm.equivalent_circuit.Thevenin(),
parameter_values=pybamm.ParameterValues("ECM_Example"),
initial_soc=0.9,
)
License
MIT
Metadata
Release files for pathsim-batt 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pathsim_batt-0.5.0.tar.gz | 52.4 kB | With provenance | Details for pathsim_batt-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pathsim_batt-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for pathsim_batt-0.5.0-py3-none-any.whl |
Total release size: 69.1 kB
Release files / pathsim_batt-0.5.0.tar.gz
| Download URL | pathsim_batt-0.5.0.tar.gz |
|---|---|
| Size | 52.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d09dad328c62f486946a17e1321bf109cdcf7ed5c486abf2019105e081b13f8
|
|
BLAKE2b-256 checksum How to use checksums |
f22fa8bbd5f491e10bdac70db97e094551c5c076e369799906ed0ccae6ea7b21
|
| 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 20, 2026.
Transparency logRelease files / pathsim_batt-0.5.0-py3-none-any.whl
| Download URL | pathsim_batt-0.5.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d75a1e82d1f6f774c083f97de1e44545f6357d775b13a1024d558c0b02f30986
|
|
BLAKE2b-256 checksum How to use checksums |
0bf88bb69919570e5282c8862c347d6ad3c926acc4a3e76f768561a1e7274fcc
|
| 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 20, 2026.
Transparency logSecurity for pathsim-batt 0.5.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.
Attestation for pathsim_batt-0.5.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 20, 2026.
Transparency logA 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.