diff --git a/src/types/DelayLtiSystem.jl b/src/types/DelayLtiSystem.jl index b403c5200..9c12835a8 100644 --- a/src/types/DelayLtiSystem.jl +++ b/src/types/DelayLtiSystem.jl @@ -97,7 +97,7 @@ function +(sys::DelayLtiSystem{T}, n::T) where {T<:Number} new_D = copy(ssold.D) new_D[1:ny, 1:nu] .+= n - pnew = PartionedStateSpace(StateSpace(ssold.A, ssold.B, ssold.C, new_D, 0.0), ny, nu) + pnew = PartionedStateSpace(StateSpace(ssold.A, ssold.B, ssold.C, new_D, Continuous()), ny, nu) DelayLtiSystem(pnew, sys.Tau) end diff --git a/test/test_delayed_systems.jl b/test/test_delayed_systems.jl index 779a64a37..d252e6111 100644 --- a/test/test_delayed_systems.jl +++ b/test/test_delayed_systems.jl @@ -16,12 +16,17 @@ else @test sprint(show, ss(1,1,1,1)*delay(1.0)) == "DelayLtiSystem{Float64,Float64}\n\nP: StateSpace{Continuous,Float64}\nA = \n 1.0\nB = \n 0.0 1.0\nC = \n 1.0\n 0.0\nD = \n 0.0 1.0\n 1.0 0.0\n\nContinuous-time state-space model\n\nDelays: [1.0]\n" end -# Extremely baseic tests +# Extremely basic tests @test freqresp(delay(1), ω) ≈ reshape(exp.(-im*ω), length(ω), 1, 1) rtol=1e-15 @test freqresp(delay(2.5), ω)[:] ≈ exp.(-2.5im*ω) rtol=1e-15 @test freqresp(3.5*delay(2.5), ω)[:] ≈ 3.5*exp.(-2.5im*ω) rtol=1e-15 @test freqresp(delay(2.5)*1.5, ω)[:] ≈ exp.(-2.5im*ω)*1.5 rtol=1e-15 +# Addition of constant +@test evalfr(1 + delay(1.0), 0)[] ≈ 2 +@test evalfr(1 - delay(1.0), 0)[] ≈ 0 +@test evalfr([2 -delay(1.0)], 0) ≈ [2 -1] + # Stritcly proper system P1 = DelayLtiSystem(ss(-1.0, 1, 1, 0)) P1_fr = 1 ./ (im*ω .+ 1)