Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions test/test_connections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ arr4[1] = ss(0); arr4[2] = ss(1); arr4[3] = ss(2)
@test [C_111 1.0] == ss([1.0], [2.0 0.0], [3.0], [4.0 1.0])
@test [1.0 C_111] == ss([1.0], [0.0 2.0], [3.0], [1.0 4.0])
@test [C_111 1.0] isa StateSpace{Continuous,Float64}
@test [C_111 1.0].Ts == 0.0
@test_logs (:warn,
@test (@test_logs (:warn,
"Getting time 0.0 for non-discrete systems is deprecated. Check `isdiscrete` before trying to access time."
) [C_111 1.0].Ts
) [C_111 1.0].Ts) == 0.0
# Concatenation of discrete system with matrix
@test [D_222 fill(1.5, 2, 2)] == [D_222 ss(fill(1.5, 2, 2),0.005)]
@test [C_222 fill(1.5, 2, 2)] == [C_222 ss(fill(1.5, 2, 2))]
Expand Down
4 changes: 2 additions & 2 deletions test/test_freqresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ G = ss([-5 0 0 0; 0 -1 -2.5 0; 0 4 0 0; 0 0 0 -6], [2 0; 0 1; 0 0; 0 2],
@test evalfr(H, -1) == [0.0 -0.3; 0.0 0.4]
@test evalfr(H, 0) ≈ [0.0 0.0; 0.2 1/3]

@test evalfr(G, -6) == [Inf Inf; Inf Inf]
@test evalfr(G, -5) == [Inf Inf; Inf Inf]
@test (@test_logs (:warn, "Got exception SingularException(4), returning Inf") evalfr(G, -6)) == [Inf Inf; Inf Inf]
@test (@test_logs (:warn, "Got exception SingularException(1), returning Inf") evalfr(G, -5)) == [Inf Inf; Inf Inf]
@test evalfr(G, -1) ≈ [0.0 -0.3; 0.0 0.4]
@test evalfr(G, 0) ≈ [0.0 0.0; 0.2 1/3]

Expand Down
10 changes: 5 additions & 5 deletions test/test_timeresp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Q = I # eye(2)
R = I # eye(1)
L = lqr(sys,Q,R)

u(x,i) = -L*x # Form control law
u1(x,i) = -L*x # Form control law
t=0:0.1:50
x0 = [1.,0]
y, t, x, uout = lsim(sys,u,t,x0=x0) # Continuous time
y, t, x, uout = lsim(sys,u1,t,x0=x0) # Continuous time

th = 1e-6
@test sum(abs.(x[:,end])) < th

y, t, x, uout = lsim(c2d(sys,0.1),u,t,x0=x0) # Discrete time
y, t, x, uout = lsim(c2d(sys,0.1),u1,t,x0=x0) # Discrete time
@test sum(abs.(x[:,end])) < th

#Do a manual simulation with uout
Expand Down Expand Up @@ -83,8 +83,8 @@ G2 = ss(1.0im, 1, 1, 0, 1)

# Test that the discrete lsim accepts u function that returns scalar
L = lqr(sysd,Q,R)
u(x,i) = -L*x
yd, td, xd = lsim(sysd, u, t, x0=x0)
u2(x,i) = -L*x
yd, td, xd = lsim(sysd, u2, t, x0=x0)
@test norm(y - yd)/norm(y) < 0.05 # Since the cost matrices are not discretized, these will differ a bit
@test norm(x - xd)/norm(x) < 0.05

Expand Down