@@ -8,7 +8,7 @@ using DelayDiffEq
8
8
9
9
@test typeof (promote (delay (0.2 ), ss (1.0 + im))[1 ]) == DelayLtiSystem{Complex{Float64}, Float64}
10
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 "
11
+ @test sprint (show, ss (1 ,1 ,1 ,1 )* delay (1.0 )) == " DelayLtiSystem{Float64,Float64} \n\n P: 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
12
13
13
14
14
# Extremely baseic tests
@@ -201,4 +201,38 @@ y_impulse, t, _ = impulse(sys_known, 3, alg=MethodOfSteps(Tsit5()))
201
201
@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
202
202
@test maximum (abs, y_impulse - dy_expected .(t, K)) < 1e-2
203
203
204
+
205
+
206
+ # # Test of basic pade functionality
207
+
208
+ Ω = [0 , 0.5 , 1 , 2 , 5 ]
209
+ @test freqresp (pade (1 , 1 ), Ω) == freqresp (tf ([- 1 / 2 , 1 ], [1 / 2 , 1 ]), Ω)
210
+ @test freqresp (pade (1 , 2 ), Ω) ≈ freqresp (tf ([1 / 12 , - 1 / 2 , 1 ], [1 / 12 , 1 / 2 , 1 ]), Ω)
211
+
212
+ for (n, tol)= enumerate ([0.05 ; 1e-3 ; 1e-5 ; 1e-7 ; 1e-11 ; 1e-14 * ones (5 )])
213
+ G = pade (0.8 , n)
214
+
215
+ @test isstable (G)
216
+ @test evalfr (G, 0 )[1 ] ≈ 1
217
+ @test abs (evalfr (G, 2im )[1 ]) ≈ 1
218
+ @test evalfr (G, 1im )[1 ] ≈ exp (- 0.8im ) atol= tol
219
+ end
220
+
221
+
222
+ # # Test pade applied to DelayLtiSystem
223
+
224
+ @test freqresp (pade (delay (0.5 ), 2 ), Ω) ≈ freqresp (pade (0.5 , 2 ), Ω)
225
+
226
+ P = delay (1.0 ) * DemoSystems. lag (T= 1 )
227
+ @test freqresp (pade (feedback (1 ,P), 2 ), Ω) == freqresp (feedback (1 , pade (P,2 )), Ω)
228
+
229
+
230
+ Ω = [0 , 0.1 , 0.2 ]
231
+ P_wb = DemoSystems. woodberry ()
232
+
233
+ @test freqresp (pade (P_wb, 2 ), Ω) ≈ freqresp (P_wb, Ω) atol= 0.02
234
+ @test freqresp (pade (P_wb, 3 ), Ω) ≈ freqresp (P_wb, Ω) atol= 5e-4
235
+
236
+ @test freqresp (pade (feedback (eye_ (2 ), P_wb), 3 ), Ω) ≈ freqresp (feedback (eye_ (2 ), P_wb), Ω) atol= 1e-4
237
+
204
238
end
0 commit comments