Skip to content

Wonky interface for Dicrete/Continious callbacks when using ModelingToolkit #2303

@TorkelE

Description

@TorkelE

When using a ContiniousCallback or a DiscreteCallback you provide a condition function

function condition(u,t,integrator)

end

Here, if you wish to interface the state or the time, it is recommended to use the u vector or the t variable. However, u is a normal vector and cannot be interfaced with MTK variables. Hence, this doesn't work. Instead one have to use the integrator, which poses two problems:

  • According to the doc, interfacing using integrator is worse for performance.
  • It is also kind of awkward to have a function include an argument (u) that is not used.

From an interface point of view, if possible, it seems that the best solution is to make these callbacks work well with only the integrator as an argument to condition.

More generally, it seems that we have all this internal DiffEq code that depend on indexing, which doesn't mesh with the MTK approach or not using indexes. I guess it would be a homogeneous project, but is there any plan to make MTK interfacing universal through the system, instead of relying on converting MTK converting its symbolic to value maps to value arrays of the right order everywhere?

Metadata

Metadata

Assignees

No one assigned

    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