Repository navigation
Support DAE models (DFN, lead_acid.Full) in CellElectrical and CellElectrothermal - #22
Draft
DavidMStraub wants to merge 1 commit into
Draft
DavidMStraub wants to merge 1 commit into
DavidMStraub wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
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
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(), | ||
| ) |
| ## 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=`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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 raiseNotImplementedErrorand 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
_CellBasederives fromSemiExplicitDAEand passes the analytic CasADi Jacobians; newtoleranceparameter (default 1e-6) for the algebraic solve.pathsim>=0.26.Notes