Skip to content

Commit

Permalink
handle 1/(1 + L) for delay systems
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Dec 4, 2023
1 parent 9d401b8 commit 28c3712
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ControlSystemsBase/src/types/DelayLtiSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ end


function /(anything, sys::DelayLtiSystem)
all(iszero, sys.Tau) || error("A delayed system can not be inverted. Consider use of the function `feedback`.")
if !all(iszero, sys.Tau)
ny,nu = size(sys)
ny == nu || error("The denominator system must be square")
return anything * feedback(I(nu), sys - I(nu))

Check warning on line 101 in lib/ControlSystemsBase/src/types/DelayLtiSystem.jl

View check run for this annotation

Codecov / codecov/patch

lib/ControlSystemsBase/src/types/DelayLtiSystem.jl#L98-L101

Added lines #L98 - L101 were not covered by tests
end
/(anything, sys.P.P) # If all delays are zero, invert the inner system
end

Expand Down
5 changes: 5 additions & 0 deletions lib/ControlSystemsBase/test/test_delayed_systems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ P2_fr = (im*ω .+ 1) ./ (im*ω .+ 2)
@test freqresp(P2 * delay(1), ω)[:] P2_fr .* exp.(-im*ω) rtol=1e-15
@test freqresp(delay(1) * P2, ω)[:] P2_fr .* exp.(-im*ω) rtol=1e-15


# Division / feedback
@test freqresp(1/(1+P1), ω) freqresp(feedback(I(size(P1, 1)), P1), ω) rtol=1e-15


## append
P12 = append(P1, P2)
G12 = [P1 tf(0); tf(0) P2]
Expand Down

0 comments on commit 28c3712

Please sign in to comment.