Skip to content

pyomo.dae extract integrator timesteps from CasADi #3718

@adowling2

Description

@adowling2

Summary

When using the DAE simulator (e.g., CasADi), extract the adaptive time steps from cvodes or idas integrator.

Rationale

For stiff systems, it is increadibly helpful to get the adaptive timesteps. These timesteps can then be used to place collocation points.

Description

ChatGPT 5o suggested this is easy to do with CasADi 3.5 or later using the monitor option:

opts = {"t0": 0, "tf": 10, "monitor": ["t", "x"]}
F = ca.integrator("F", "idas", dae, opts)
res = F(x0=x0, z0=z0, p=p)
print(F.stats()["monitor"]["t"])

I have not tried this code sample yet, but I think it may just require a few modifications here:

F = casadi.integrator('F', integrator, dae, integrator_options)

Additional information

@djlaky what do you think?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions