Skip to content

Support DAE models (DFN, lead_acid.Full) in CellElectrical and CellElectrothermal - #22

Draft
DavidMStraub wants to merge 1 commit into
pathsim:masterfrom
DavidMStraub:dae-cells
Draft

DavidMStraub wants to merge 1 commit into
pathsim:masterfrom
DavidMStraub:dae-cells

Conversation

@DavidMStraub

Copy link
Copy Markdown
Collaborator

Closes #18. With the reduced Jacobian and constraint tolerance now in PathSim 0.26, the monolithic cell blocks are based on SemiExplicitDAE, so models with algebraic variables after discretisation (DFN, lead_acid.Full, LOQS on PyBaMM 26.7) no longer raise NotImplementedError and are integrated by PathSim's own solvers. ODE models such as SPMe take the same path with an empty algebraic part; results are unchanged.

Changes

  • _CellBase derives from SemiExplicitDAE and passes the analytic CasADi Jacobians; new tolerance parameter (default 1e-6) for the algebraic solve.
  • Requires pathsim>=0.26.
  • Tests: DAE-raises tests replaced by DFN and lead_acid.Full tests, including voltage comparisons against PyBaMM's own solver.
  • README: model compatibility table replaced by a short list, since all blocks now support all models.

Notes

  • 600 s discharge at 5 A, final voltage vs PyBaMM: SPMe 3.8198/3.8198 V (0.6 s), DFN 3.8237/3.8237 V (73 s), lead_acid.Full 2.1301/2.1304 V (1.9 s).
  • The tolerance default is a compromise: lead_acid.Full stalls at 1e-7 and below due to ill-conditioned algebraic equations, while DFN runs about twice as fast at 1e-9.
  • Notebook 03 still describes DFN as co-simulation only; to be updated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Empty algebraic states currently break pure ODE models, and the DFN notebook contradicts the updated compatibility documentation.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
What changed in this PR

Adds monolithic DAE support for PyBaMM cell models using PathSim’s SemiExplicitDAE.

Changes:

  • Integrates algebraic states with analytic CasADi Jacobians and configurable tolerance.
  • Adds DFN and lead-acid DAE coverage.
  • Updates compatibility documentation and requires PathSim 0.26.
File Description
src/​pathsim_batt/​cells/​pybamm_cell.py Implements monolithic DAE integration.
tests/​cells/​test_pybamm_cell.py Adds DFN integration tests.
tests/​cells/​test_lead_acid.py Enables monolithic lead-acid DAE tests.
README.md Updates model compatibility guidance.
pyproject.toml Raises the PathSim minimum version.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +392 to +397
# SemiExplicitDAE sizes its outputs to the stacked state [x, z]; this
# block exposes the cell outputs instead.
self.outputs = Register(
size=len(self.output_port_labels),
mapping=self.output_port_labels.copy(),
)
Comment thread README.md
## PyBaMM models

Thermal sub-model and heat-source options are injected automatically — pass the bare model class with no `options=`.
All blocks accept any PyBaMM battery model, e.g. `lithium_ion.SPM`, `SPMe`, `DFN`, `lead_acid.LOQS`, `lead_acid.Full` or `equivalent_circuit.Thevenin`. Thermal sub-model and heat-source options are injected automatically — pass the bare model class with no `options=`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for DAE models with PathSim solvers

2 participants