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

Step response (at a t0 instant) of a first order system with delay doesn't work correctly with lsim (but works fine with step but with t0=0) #920

Closed
s-celles opened this issue Mar 5, 2024 · 5 comments

Comments

@s-celles
Copy link

s-celles commented Mar 5, 2024

Hello,

using ControlSystems
using Plots
τ = 2.0  # s (time constant)
td = 0.5  # s (delay)
K = 1
T1 = K / (1 + τ * s) * delay(td)
plot(rep, label=["output" "input"], plotu=true, ploty=true)
ylims!(-0.15, 1.15)

plots

image

but

t = 0:0.01:10
t0 = 1.0
u = 2.0 * (t .>= t0)'
res = lsim(T1, u, t)
plot(res, label=["output" "input"], plotu=true, ploty=true)

raises

No methods were found for the model function passed to the equation solver.

The function `f` needs to have dispatches, for example, for an ODEProblem

`f` must define either `f(u,p,t)` or `f(du,u,p,t)`. For more information

on how the model function `f` should be defined, consult the docstring for

the appropriate `AbstractSciMLFunction`.

...

PS : but it works fine with pade

"""
pade(τ::Real, N::Int)
Compute the `N`th order Padé approximation of a time-delay of length `τ`.
See also [`thiran`](@ref) for discretization of delays.
"""

@mzaffalon
Copy link
Contributor

mzaffalon commented Mar 5, 2024

u must a function of the state x and time t: see https://juliacontrol.github.io/ControlSystems.jl/stable/lib/timefreqresponse/#ControlSystemsBase.lsim-Tuple{AbstractStateSpace,%20AbstractVecOrMat,%20AbstractVector}

@s-celles
Copy link
Author

s-celles commented Mar 5, 2024

u = (x, t) -> (t < t0 ? 0 : 1)

this is function of the state x and time t but it raises now

u must be a vector of size (1,)

Sorry for my questions!

@s-celles
Copy link
Author

s-celles commented Mar 5, 2024

u = (x, t) -> (t < t0 ? [0] : [1])

works fine but is quite tricky (especially when dealing with SISO systems

t = 0:0.01:10
t0 = 1.0
u = (x, t) -> (t < t0 ? [0] : [1])
res = lsim(T1, u, t)
plot(res, label=["output" "input"], plotu=true, sp=[2 1])

image

@s-celles s-celles closed this as completed Mar 5, 2024
@baggepinnen
Copy link
Member

baggepinnen commented Mar 5, 2024

Try

u = (x, t) -> [t < t0]

@s-celles
Copy link
Author

s-celles commented Mar 5, 2024

Thanks

u = (x, t) -> 2 * [t > t0]

works fine

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

3 participants