You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for DAE models with PathSim solvers #18
The issue description is outdated, but the feature request still useful: using PathSim's internal DAE solver, we can run even the DFN model without cosimulation.
@milanofthe I launched an investigation into implementing this - it's straightforward, but needs a change in PathSim core. I could open a PR for it.
Claude:
Upstream requirements for running PyBaMM DAE models (DFN, lead_acid.Full) with PathSim solvers
A prototype based on SemiExplicitDAE runs DFN, DFN with lumped thermal, MPM, NewmanTobias and lead_acid.Full with ESDIRK43 and matches PyBaMM/IDAKLU to within 0.05 mV. It only works by overriding non-public parts of SemiExplicitDAE, so two additions to its public API are needed:
Analytic reduced Jacobian (required for all DAE models). Accept optional partial Jacobians (∂f_dyn/∂x, ∂f_dyn/∂z, ∂f_alg/∂x) and form the reduced Jacobian from them instead of using finite differences through the constraint solve. With finite differences, a DFN run covered only 2.6 s of simulated time in 150 s of wall time. With the analytic Jacobian it covers 600 s in 9–29 s.
Configurable tolerance for the algebraic solve (required for lead_acid.Full). The fixed absolute tolerance of 1e-9 cannot be reached by badly conditioned models: in lead_acid.Full the residual stalls at about 2e-7, so every solve runs to the iteration limit. Scaling the residual inside func_alg works around this, but the scale factor is model-dependent.
Optional: reusing the Jacobian across Newton iterations within a stage would make DFN about 3× faster, but it isn't required.
Activity
DavidMStraub commentedon Jul 22, 2026
DavidMStraub commentedon Sep 24, 2026
The issue description is outdated, but the feature request still useful: using PathSim's internal DAE solver, we can run even the DFN model without cosimulation.
@milanofthe I launched an investigation into implementing this - it's straightforward, but needs a change in PathSim core. I could open a PR for it.
Claude:
Upstream requirements for running PyBaMM DAE models (DFN, lead_acid.Full) with PathSim solvers
A prototype based on
SemiExplicitDAEruns DFN, DFN with lumped thermal, MPM, NewmanTobias andlead_acid.Fullwith ESDIRK43 and matches PyBaMM/IDAKLU to within 0.05 mV. It only works by overriding non-public parts ofSemiExplicitDAE, so two additions to its public API are needed:lead_acid.Full). The fixed absolute tolerance of 1e-9 cannot be reached by badly conditioned models: inlead_acid.Fullthe residual stalls at about 2e-7, so every solve runs to the iteration limit. Scaling the residual insidefunc_algworks around this, but the scale factor is model-dependent.Optional: reusing the Jacobian across Newton iterations within a stage would make DFN about 3× faster, but it isn't required.
milanofthe commentedon Sep 24, 2026
Go ahead with the PR in pathsim we can discuss details there.