- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Labels
Description
julia> sol[sys.conversion.y]
ERROR: ArgumentError: Symbol conversion₊y(t) is not present in the system.
MWE:
using ModelingToolkit
using OrdinaryDiffEq
t = ModelingToolkit.t_nounits
k = ShiftIndex(t)
function Float2Bool2(; name)
@variables begin
u(t)::Float64
y(t)::Bool
end
equations = [
y ~ u != 0
]
DiscreteSystem(equations, t; name)
end
function Model2(; name)
@variables begin
x(t) = 1
end
systems = @named begin
conversion = Float2Bool2()
end
equations = [
x(k) ~ 0.99x(k-1)
conversion.u ~ x
]
DiscreteSystem(equations, t; name, systems)
end
@mtkbuild sys = Model2()
prob = DiscreteProblem(sys, [], (0,10))
sol = solve(prob, FunctionMap())
sol[sys.conversion.y]
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
AayushSabharwal commentedon Mar 26, 2025
This is known behavior. Due to how structural simplification of discrete systems is handled, observed variables are sihfted forward by one step. Fixing this requires proper compilation of synchronous systems.
AayushSabharwal commentedon Mar 26, 2025
We have had this behavior since MTKv9
baggepinnen commentedon Mar 26, 2025
Do we have an existing issue for it? It may be known, but certainly not desirable so we should track it and eventually fix it
AayushSabharwal commentedon Mar 26, 2025
I don't think we do. This can serve as the tracking issue, I guess.