Discrete systems in MTK

Hello everyone!
I’m trying to do a discrete system example, using Difference and Differential functions, when I create the ODEProblem without structural_simplify() I get the results I want.

`using ModelingToolkit

using DifferentialEquations

using Plots

@parameters t

@variablesy(t)=0 x(t)=0

dt = 0.1

Δ = Difference(t; dt=dt,update=true)

D = Differential(t)

eqs = [

Δ(x) ~ t

D(y) ~ x

]

@named sys = ODESystem(eqs,t)

prob = ODEProblem(sys, , (0,1), )

sol = solve(prob, adaptive=false, dt=dt)

plot(sol)`
image

But when I use structural_simplify() It gives me this error:
sys_simp=structural_simplify(sys) ERROR: ExtraVariablesSystemException: The system is unbalanced. There are 3 highest order derivative variables and 2 equations. More variables than equations, here are the potential extra variable(s): y(t) x(t)
I think it deletes the difference equation, is there a solution to avoid this problem? it’s important for me to keep structural_simplify().

can you open this as an issue?

1 Like