Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
TorkelE opened this issue Oct 6, 2023 · 3 comments
Closed

Comments

@TorkelE
Copy link
Member

TorkelE commented Oct 6, 2023

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?

@ChrisRackauckas
Copy link
Member

It might be nice to put a small DSL over this.

@TorkelE
Copy link
Member Author

TorkelE commented Oct 6, 2023

Yeah, that would be a solution

@ChrisRackauckas
Copy link
Member

This got a DSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants