-
-
Notifications
You must be signed in to change notification settings - Fork 233
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
MWE with discrete parameter heading(t)
...
using ModelingToolkit
using ModelingToolkit: t_nounits as t, D_nounits as D
using OrdinaryDiffEq
using Plots
inch = 25.4e-3
sec = 1
rate = 2*inch/sec
L = 4*inch
pars = @parameters begin
heading(t) = 1
end
vars = @variables begin
x(t) = 0
dx(t) = rate
end
eqs = [
dx ~ heading*rate
D(x) ~ dx
]
events = [
[x~0] => [heading ~ +1]
[x~L] => [heading ~ -1]
]
@mtkbuild sys = ODESystem(eqs, t, vars, pars; continuous_events=events)
prob = ODEProblem(sys, [], (0, 8))
sol = solve(prob)
plot(sol; idxs=x)
plot(sol; idxs=dx)
plot(sol; idxs=heading)
This gives the correct result for x
and heading
However, the observed variable dx
plots a constant value...
As can be seen, the observed function for dx
is
julia> observed(sys)
1-element Vector{Equation}:
dx(t) ~ 0.0508heading(t)
Which means the calculation of dx
is not handling the change in heading
correctly.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working