You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's an example that builds a hybrid cont./disc. system and successfully produces a solution. The sol.u contains only finite values, but sol(0) is NaN
dt =0.5# Sample interval@variablesr(t)
clock =Clock(t, dt)
k =ShiftIndex(clock)
functionplant(; name)
@variablesx(t)=1u(t) y(t)
D =Differential(t)
eqs = [D(x) ~-x + u
y ~ x]
ODESystem(eqs, t; name = name)
endfunctionfilt(; name) # Reference filter@variablesx(t) u(t) y(t)
a =1/exp(dt)
# eqs = [x(k) ~ a * x(k - 1) + (1 - a) * u(k-1)# y ~ x(k-1)]
eqs = [x(k) ~ a *x(k -1) + (1- a) *u(k -1)
y ~x(k)]
ODESystem(eqs, t, name = name)
endfunctioncontroller(kp; name)
@variablesy(t) r(t) ud(t) yd(t)
@parameters kp = kp
eqs = [yd ~Sample(clock)(y)
ud ~ kp * (r - yd)]
ODESystem(eqs, t; name = name)
end
Tf =15
kp =1@named f =filt()
@named c =controller(kp)
@named p =plant()
connections = [r ~ (t >=1) + (t >=6) # reference signal
f.u ~ r # reference to filter input
f.y ~ c.r # filtered reference to controller referenceHold(c.ud) ~ p.u # controller output to plant input (zero-order-hold)
p.y ~ c.y] # plant output to controller feedback@named cl =ODESystem(connections, t, systems = [f, c, p])
model =complete(cl)
ssys =structural_simplify(model)
prob =ODEProblem(ssys, [], (0, Tf),
[model.f.x(k -1) =>1, model.f.u(k -1) =>1]);
sol_mtk =solve(
prob, Rodas5P(), abstol =1e-8, reltol =1e-8, kwargshandle = KeywordArgSilent);
Here's an example that builds a hybrid cont./disc. system and successfully produces a solution. The
sol.u
contains only finite values, butsol(0)
is NaNThe text was updated successfully, but these errors were encountered: