Add support for DAE models with PathSim solvers · Issue #18 · pathsim/pathsim-batt · GitHub
Skip to content

Add support for DAE models with PathSim solvers #18

Open

Description

@DavidMStraub

PyBaMM v26.7.0 was released today and it contains a breaking change: all models are now DAEs. (outdated)

PathSim v0.23.0 added support for DAEs.

This makes DAE support no longer a nice to have, but a prerequisite.

Activity

  1. self-assigned this
    on Jul 21, 2026
  2. DavidMStraub commented on Jul 22, 2026

    @DavidMStraub
    Author
  3. DavidMStraub commented on Sep 24, 2026

    @DavidMStraub
    CollaboratorAuthor

    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:

    1. 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.
    2. 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.

  4. milanofthe commented on Sep 24, 2026

    @milanofthe
    Member

    Go ahead with the PR in pathsim we can discuss details there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions