@@ -5,8 +5,12 @@ using DelayDiffEq
5
5
6
6
# broken: typeof(promote(delay(0.2), ss(1))[1]) == DelayLtiSystem{Float64}
7
7
8
+
8
9
@test typeof (promote (delay (0.2 ), ss (1.0 + im))[1 ]) == DelayLtiSystem{Complex{Float64}, Float64}
9
10
11
+ @test sprint (show, ss (1 ,1 ,1 ,1 )* delay (1.0 )) == " StateSpace{Float64,Array{Float64,2}}\n A = \n 1.0\n B = \n 0.0 1.0\n C = \n 1.0\n 0.0\n D = \n 0.0 1.0\n 1.0 0.0\n\n Continuous-time state-space model\n\n Delays: [1.0]\n "
12
+
13
+
10
14
# Extremely baseic tests
11
15
@test freqresp (delay (1 ), ω) ≈ reshape (exp .(- im* ω), length (ω), 1 , 1 ) rtol= 1e-15
12
16
@test freqresp (delay (2.5 ), ω)[:] ≈ exp .(- 2.5im * ω) rtol= 1e-15
@@ -43,6 +47,9 @@ P2_fr = (im*ω .+ 1) ./ (im*ω .+ 2)
43
47
@test freqresp (delay (1 ) * P2, ω)[:] ≈ P2_fr .* exp .(- im* ω) rtol= 1e-15
44
48
45
49
50
+
51
+
52
+
46
53
# # Feedback
47
54
# The first tests don't include delays, but the linear system is of DelayLtiForm type
48
55
# (very simple system so easy to troubleshoot)
@@ -76,6 +83,16 @@ G_fr = 0.5 .+ 0.5*exp.(-2*im*ω)# + 0.5*exp.(-3*im*ω)
76
83
@test freqresp (feedback (P2, G), ω)[:] ≈ P2_fr ./ (1 .+ P2_fr .* G_fr) rtol= 1e-15
77
84
78
85
s = tf (" s" )
86
+
87
+ # Test alternative exp constructor for delays
88
+ d = exp (- 2 * s)
89
+ @test freqresp (d, [0 , 1 , 2 ]) ≈ [1 , exp (- 2im ), exp (- 4im )]
90
+
91
+ @test_throws ErrorException exp (- s^ 2 - 2 * s)
92
+ @test_throws ErrorException exp (- 2 * s+ 1 ) # in principle ok, but not allowed anyway
93
+ @test_throws ErrorException exp ([- 2 * s; - s])
94
+ @test_throws ErrorException exp (2 * s) # Non-causal
95
+
79
96
# Random conversions
80
97
sys1 = DelayLtiSystem (1.0 / s)
81
98
@test sys1. P. A == sys1. P. D == fill (0 ,1 ,1 )
@@ -183,6 +200,4 @@ y_impulse, t, _ = impulse(sys_known, 3, alg=MethodOfSteps(Tsit5()))
183
200
@test y_impulse ≈ dy_expected .(t, K) rtol= 1e-2 # Two orders of magnitude better with BS3 in this case, which is default for impulse
184
201
@test maximum (abs, y_impulse - dy_expected .(t, K)) < 1e-2
185
202
186
- [s11; s12]
187
-
188
203
end
0 commit comments