Skip to content

Commit af7fea0

Browse files
committed
Evalfr for DelayLtiSystems
1 parent 4f288ee commit af7fea0

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/delay_systems.jl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function freqresp(sys::DelayLtiSystem, ω::AbstractVector{T}) where {T <: Real}
1212
P21_fr = P_fr[ω_idx, ny+1:end, 1:nu]
1313
P22_fr = P_fr[ω_idx, ny+1:end, nu+1:end]
1414

15-
delay_matrix_inv_fr = Diagonal(exp.(im*sys.Tau*ω[ω_idx])) # Frequency response of the diagonal matrix with delays
15+
delay_matrix_inv_fr = Diagonal(exp.(im*ω[ω_idx]*sys.Tau)) # Frequency response of the diagonal matrix with delays
1616
# Inverse of the delay matrix, so there should not be any minus signs in the exponents
1717

1818
G_fr[ω_idx,:,:] .= P11_fr + P12_fr/(delay_matrix_inv_fr - P22_fr)*P21_fr # The matrix is invertible (?!)
@@ -21,6 +21,20 @@ function freqresp(sys::DelayLtiSystem, ω::AbstractVector{T}) where {T <: Real}
2121
return G_fr
2222
end
2323

24+
function evalfr(sys::DelayLtiSystem, s)
25+
(ny, nu) = size(sys)
26+
27+
P_fr = evalfr(sys.P.P, s)
28+
29+
P11_fr = P_fr[1:ny, 1:nu]
30+
P12_fr = P_fr[1:ny, nu+1:end]
31+
P21_fr = P_fr[ny+1:end, 1:nu]
32+
P22_fr = P_fr[ny+1:end, nu+1:end]
33+
34+
delay_matrix_inv_fr = Diagonal(exp.(s*sys.Tau))
35+
36+
return P11_fr + P12_fr/(delay_matrix_inv_fr - P22_fr)*P21_fr
37+
end
2438

2539
"""
2640
`y, t, x = lsim(sys::DelayLtiSystem, u, t::AbstractArray{<:Real}; x0=fill(0.0, nstates(sys)), alg=MethodOfSteps(Tsit5()), kwargs...)`
@@ -223,7 +237,7 @@ function _linscale(p::Poly, a)
223237
end
224238

225239
# Coefficeints for Padé approximations
226-
# Q_COEFFS = [Poly([binomial(N,i)*prod(N+1:2*N-i) for i=0:N]) for N=1:10]
240+
# PADE_Q_COEFFS = [Poly([binomial(N,i)*prod(N+1:2*N-i) for i=0:N]) for N=1:10]
227241
const PADE_Q_COEFFS = [[2, 1],
228242
[12, 6, 1],
229243
[120, 60, 12, 1],

test/test_delayed_systems.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ P2_fr = (im*ω .+ 1) ./ (im*ω .+ 2)
4747
@test freqresp(delay(1) * P2, ω)[:] P2_fr .* exp.(-im*ω) rtol=1e-15
4848

4949

50-
51-
50+
# evalfr
51+
s_vec = [0, 1im, 1, 1 + 1im]
52+
@test [evalfr(delay(2), s)[1] for s in s_vec] [exp(-2*s) for s in s_vec] rtol=1e-16
5253

5354
## Feedback
5455
# The first tests don't include delays, but the linear system is of DelayLtiForm type

0 commit comments

Comments
 (0)