Skip to content

Commit

Permalink
Merge pull request #892 from JuliaControl/delfix
Browse files Browse the repository at this point in the history
Fix `append` for delay system
  • Loading branch information
baggepinnen committed Oct 21, 2023
2 parents 6a4525d + 3d4cc67 commit 154f41b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/ControlSystemsBase/src/types/LFTSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ end

function append(systems::LFTT...) where LFTT <: LFTSystem
timeevol = common_timeevol(systems...)
A = blockdiag(s.A for s in systems)
B1 = blockdiag(s.B1 for s in systems)
B2 = blockdiag(s.B2 for s in systems)
C1 = blockdiag(s.C1 for s in systems)
C2 = blockdiag(s.C2 for s in systems)
D11 = blockdiag(s.D11 for s in systems)
D12 = blockdiag(s.D12 for s in systems)
D21 = blockdiag(s.D21 for s in systems)
D22 = blockdiag(s.D22 for s in systems)
A = blockdiag(s.P.A for s in systems)
B1 = blockdiag(s.P.B1 for s in systems)
B2 = blockdiag(s.P.B2 for s in systems)
C1 = blockdiag(s.P.C1 for s in systems)
C2 = blockdiag(s.P.C2 for s in systems)
D11 = blockdiag(s.P.D11 for s in systems)
D12 = blockdiag(s.P.D12 for s in systems)
D21 = blockdiag(s.P.D21 for s in systems)
D22 = blockdiag(s.P.D22 for s in systems)
LFTT(
PartitionedStateSpace(A,B1,B2,C1,C2,D11,D12,D21,D22,timeevol),
reduce(vcat, [feedback_channel(s) for s in systems])
Expand Down
16 changes: 16 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,22 @@ 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

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

F = freqresp(P12, ω)

@test freqrespv(P1, ω) F[1,1,:]
@test freqrespv(P2, ω) F[2,2,:]
@test all(iszero, F[1,2,:])
@test all(iszero, F[2,1,:])

F = freqresp(G12, ω)
@test freqrespv(P1, ω) F[1,1,:]
@test freqrespv(P2, ω) F[2,2,:]
@test all(iszero, F[1,2,:])
@test all(iszero, F[2,1,:])

# Equality
@test P1 == deepcopy(P1)
Expand Down
1 change: 1 addition & 0 deletions lib/ControlSystemsBase/test/test_hammerstein_wiener.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ControlSystemsBase
using ControlSystemsBase: HammersteinWienerSystem
using SparseArrays
using Test


# @testset "test_nonlinearity_system" begin
Expand Down

0 comments on commit 154f41b

Please sign in to comment.