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

Parameters (and probably variables) occurring in events only are not inferred into ODESystems #2659

Open
TorkelE opened this issue Apr 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@TorkelE
Copy link
Member

TorkelE commented Apr 19, 2024

If you have parameters which only occur in an event, these are not inferred as parameters of the system (in the same way as e.g. parameters of equations).

E.g. in this MWE, the parameter thres is not found in either system (to which it belong).

using ModelingToolkit

@variables t X(t)
@parameters p d
@parameters thres
D = Differential(t)
eq = D(X) ~ p - d*X

discrete_events = [(X > thres) => [X ~ X/2.0]]
@mtkbuild osys1 = ODESystem([eq], t; discrete_events)
parameters(osys1) # [p, d]

continuous_events = [(X ~ thres) => [X ~ X/2.0]]
@mtkbuild osys2 = ODESystem([eq], t; discrete_events)
parameters(osys2) # [p, d]
@TorkelE TorkelE added the bug Something isn't working label Apr 19, 2024
@SebastianM-C
Copy link
Contributor

I think that's on purpose as parameters that appear in an event can be potentially modified during the callback. Are they present in the full_parameters(osys1)?

@TorkelE
Copy link
Member Author

TorkelE commented Apr 20, 2024

Yes, having these things be parameters (and not values) is useful because it means that they can be changed. However, since they are not added to the system, this is not possible (as you cannot interface with them through e.g. the integrator.

full_parameters(osys1)

also returns [p, d]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants