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

lsim not working for systems that are not strictly proper #195

Closed
hurak opened this issue Mar 10, 2019 · 3 comments
Closed

lsim not working for systems that are not strictly proper #195

hurak opened this issue Mar 10, 2019 · 3 comments

Comments

@hurak
Copy link
Contributor

hurak commented Mar 10, 2019

Apparently, lsim does not work for SISO systems that are not strictly proper, that is, it fails for systems whose D term in the state space description is nonzero. I have not checked the case in which D is a matrix.

using ControlSystems

a = b = c = d = 1
G = ss(a,b,c,d)
u(x,t) = [0.0]
t = 0:0.1:1
x0 = [1]
y, t, x, uout = lsim(G,u,t,x0=x0)

ERROR: LoadError: AssertionError: Can not simulate systems with direct term D != 0
Stacktrace:
[1] Simulator(::StateSpace{Int64,Array{Int64,2}}, ::typeof(u)) at /home/hurak/.julia/packages/ControlSystems/6Nac2/src/simulators.jl:41
[2] #lsim#112(::Array{Int64,1}, ::Symbol, ::Function, ::StateSpace{Int64,Array{Int64,2}}, ::typeof(u), ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at /home/hurak/.julia/packages/ControlSystems/6Nac2/src/timeresp.jl:165
[3] (::getfield(ControlSystems, Symbol("#kw##lsim")))(::NamedTuple{(:x0,),Tuple{Array{Int64,1}}}, ::typeof(lsim), ::StateSpace{Int64,Array{Int64,2}}, ::Function, ::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}) at ./none:0
[4] top-level scope at none:0
in expression starting at /home/hurak/ownCloud/julia/lsim_breaking_for_siso.jl:8

Any plans to make it working for systems for nonzero D term in the state space description? Were there any issues?

@mfalt
Copy link
Member

mfalt commented Mar 11, 2019

This is unfortunately a result of us switching to a differential equations solver for simulating continuous systems. If zero-order-hold is used to simulate a system, this is not a problem, so a workaround is simply using
y, t, x, uout = lsim(G,u,t,x0=x0, method=:zoh)
However, I see no reason why we should not be able to add the direct term. It may be as easy as to uncomment the direct term in https://github.com/JuliaControl/ControlSystems.jl/blob/master/src/simulators.jl#L39
Feel free to investigate if this solves the problem and if the tests still pass.

@baggepinnen
Copy link
Member

The commen was introduced in e0bb7c5 due to stack overflow

@baggepinnen
Copy link
Member

This issue has been resolved since long :)

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