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

Permit preset time vents with parametric times #2681

Open
TorkelE opened this issue Apr 30, 2024 · 0 comments
Open

Permit preset time vents with parametric times #2681

TorkelE opened this issue Apr 30, 2024 · 0 comments

Comments

@TorkelE
Copy link
Member

TorkelE commented Apr 30, 2024

Wanting to have the time(s) be parametric is probably a rather common thing, wouldn't something like this be good to permit:

using ModelingToolkit, OrdinaryDiffEq, Plots

@variables t X(t)
@parameters p d pT
D = Differential(t)
eqs = [
    D(X) ~ p - d*X
]
discrete_events = [
    [pT] => [p ~ 2*p]
]
@mtkbuild osys = ODESystem(eqs, t; discrete_events)

u0 = [X => 0.0]
tspan = (0.0, 10.)
ps = [p => 5.0, d => 1.0, pT => 2.0]
oprob = ODEProblem(osys, u0, tspan, ps)
sol = solve(oprob, Tsit5()) # Yields a `ERROR: TypeError: non-boolean (Num) used in boolean context`

?

I realise there might be a problem if the parameters of the even are changed due to e.g. other events. But this feels niche and is a situation we already have for a few things (like jump simulations).

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

1 participant