diff --git a/src/Blocks/continuous.jl b/src/Blocks/continuous.jl index f7c2116b..0d856cab 100644 --- a/src/Blocks/continuous.jl +++ b/src/Blocks/continuous.jl @@ -116,9 +116,9 @@ sT + 1 and if `lowpass=false`, by ``` -sT + 1 - k -────────── - sT + 1 + k*sT +─────── +sT + 1 ``` Initial value of the state `x` can be set with `x` diff --git a/test/continuous.jl b/test/continuous.jl index 40c1289d..e1ad8b7e 100644 --- a/test/continuous.jl +++ b/test/continuous.jl @@ -57,14 +57,20 @@ end @test sol.retcode == Success @test sol[pt1.output.u] ≈ pt1_func.(sol.t, k, T) atol = 1.0e-3 - # Test highpass feature + # Highpass: Y/U = k*sT/(sT+1); unit-step response y(t) = k*exp(-t/T) + highpass_step(t, k, T) = k * exp(-t / T) + abstol = 1.0e-6 + reltol = 1.0e-6 @named pt1 = FirstOrder(; k = k, T = T, lowpass = false) @named iosys = System(connect(c.output, pt1.input), t, systems = [pt1, c]) sys = mtkcompile(iosys) prob = ODEProblem(sys, Pair[], (0.0, 100.0)) - sol = solve(prob, Rodas4()) + sol = solve(prob, Rodas4(); abstol, reltol) @test sol.retcode == Success - @test sol[pt1.output.u] ≈ k .- pt1_func.(sol.t, k, T) atol = 1.0e-3 + # 100× margin over solver tolerances (scaled by gain magnitude) + tol = 100 * max(abstol, reltol * abs(k)) + @test sol[pt1.output.u] ≈ highpass_step.(sol.t, k, T) atol = tol + @test abs(sol[pt1.output.u][end]) ≤ tol # asymptotic DC gain is 0 end @testset "PT2" begin