Battery Simulation Blocks for PathSim
Project description
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 ODE | Single cell, coupled electro-thermal, ODE model |
CellElectrical + LumpedThermal |
PathSim (external) | Monolithic ODE | Pack-level, custom cooling, ODE model |
CellCoSimElectrothermal |
PyBaMM (internal) | Co-simulation | DAE models (DFN, lead_acid.Full), mixed solvers |
CellCoSimElectrical + LumpedThermal |
PathSim (external) | Co-simulation | DAE 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 model compatibility
Thermal sub-model and heat-source options are injected automatically — pass the bare model class with no options=.
| PyBaMM model | Default parameter set | CellElectrical |
CellElectrothermal |
CellCoSimElectrical |
CellCoSimElectrothermal |
|---|---|---|---|---|---|
lithium_ion.SPM |
Chen2020 |
✅ | ✅ | ✅ | ✅ |
lithium_ion.SPMe |
Chen2020 |
✅ | ✅ | ✅ | ✅ |
lithium_ion.DFN |
Chen2020 |
❌ DAE | ❌ DAE | ✅ | ✅ |
lead_acid.LOQS |
Sulzer2019 |
✅ | ✅ | ✅ ¹ | ✅ ¹ |
lead_acid.Full |
Sulzer2019 |
❌ DAE | ❌ DAE | ✅ | ✅ |
equivalent_circuit.Thevenin |
ECM_Example |
✅ | ✅ | ✅ ² | ✅ ² |
¹ Pass pybamm_solver=pybamm.CasadiSolver(mode="safe") — the default IDAKLUSolver requires a Jacobian that ODE models do not provide.
² initial_soc=1.0 fails because PyBaMM requires event values to be strictly positive at t=0; the "Maximum SoC" event is zero exactly at full charge. Any value below 1.0 (e.g. initial_soc=0.99) works.
import pybamm
from pathsim_batt import CellElectrothermal, CellCoSimElectrical
# Custom chemistry / parameter set
cell = CellElectrothermal(
model=pybamm.lithium_ion.SPMe(),
parameter_values=pybamm.ParameterValues("Mohtat2020"),
)
# Lead-acid via co-simulation (DAE model)
cell = CellCoSimElectrical(
model=pybamm.lead_acid.Full(),
parameter_values=pybamm.ParameterValues("Sulzer2019"),
dt=1.0,
)
# Equivalent circuit model
cell = CellElectrical(
model=pybamm.equivalent_circuit.Thevenin(),
parameter_values=pybamm.ParameterValues("ECM_Example"),
initial_soc=0.9,
)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pathsim_batt-0.2.1.tar.gz.
File metadata
- Download URL: pathsim_batt-0.2.1.tar.gz
- Upload date:
- Size: 48.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32fdd3b577e1162f272ca2d28ff3215f6455ec69fed8e96facd4888d4a3f89c9
|
|
| MD5 |
09783892f7b3e17dad0052356c06d34e
|
|
| BLAKE2b-256 |
732d42b573a11184b097dd985085050e231971815b55d81fd4ce3cd2c25b753a
|
Provenance
The following attestation bundles were made for pathsim_batt-0.2.1.tar.gz:
Publisher:
pypi_deployment.yml on pathsim/pathsim-batt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathsim_batt-0.2.1.tar.gz -
Subject digest:
32fdd3b577e1162f272ca2d28ff3215f6455ec69fed8e96facd4888d4a3f89c9 - Sigstore transparency entry: 1641821900
- Sigstore integration time:
-
Permalink:
pathsim/pathsim-batt@3b9b92891e4a10ed78ba8fb350353eec9f434a12 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/pathsim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_deployment.yml@3b9b92891e4a10ed78ba8fb350353eec9f434a12 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pathsim_batt-0.2.1-py3-none-any.whl.
File metadata
- Download URL: pathsim_batt-0.2.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a9212f3b8aa00f2783f7008918fd8987f08a232e34777aaed4fd5acfed12b4e
|
|
| MD5 |
a5c7005a76ccbcc3c3b8a7ed6966428a
|
|
| BLAKE2b-256 |
24dd60e20dcfe08166c74e34a77a686744b27ed83bbd5a6a71bf4596cb813ebb
|
Provenance
The following attestation bundles were made for pathsim_batt-0.2.1-py3-none-any.whl:
Publisher:
pypi_deployment.yml on pathsim/pathsim-batt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pathsim_batt-0.2.1-py3-none-any.whl -
Subject digest:
7a9212f3b8aa00f2783f7008918fd8987f08a232e34777aaed4fd5acfed12b4e - Sigstore transparency entry: 1641822038
- Sigstore integration time:
-
Permalink:
pathsim/pathsim-batt@3b9b92891e4a10ed78ba8fb350353eec9f434a12 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/pathsim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_deployment.yml@3b9b92891e4a10ed78ba8fb350353eec9f434a12 -
Trigger Event:
release
-
Statement type: