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

better error message for improper delay conversion #831

Merged
merged 2 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/ControlSystemsBase/src/types/DelayLtiSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ function Base.convert(::Type{DelayLtiSystem{T1,S}}, d::T2) where {T1,T2 <: Abstr
end

function Base.convert(::Type{DelayLtiSystem{T,S}}, sys::TransferFunction{TE}) where {T,S,TE}
if issiso(sys) && length(numvec(sys.matrix[1,1])) > length(denvec(sys.matrix[1,1]))
error("The transfer function is not proper and can not be converted to a DelayLtiSystem type. If you tried to form the system `exp(sL) * B / A` where `B / A` is proper, add parenthesis to make it `exp(sL) * (B / A)`.")
end

DelayLtiSystem{T,S}(convert(StateSpace{TE, T}, sys))
end
# Catch convertsion between T
Expand Down
4 changes: 4 additions & 0 deletions lib/ControlSystemsBase/test/test_conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ H3 = zpk([(-1+im*sqrt(79))/8, (-1-im*sqrt(79))/8], [-3/2], 2)
@test zpk(G3) ≈ H3 rtol=1e-15
@test zpk(H3) == H3

s = tf("s")
@test_throws ErrorException delay(5)*((s+1))/((s+2)*(s+0.5))
@test_throws ErrorException delay(5)*zpk((s+1))/zpk((s+2)*(s+0.5))

# Test complex 1
A = [1.0 + im 1; 0 -2-3im]
B = [0;2]
Expand Down
Loading