Skip to content
Draft
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
6 changes: 3 additions & 3 deletions src/Blocks/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
12 changes: 9 additions & 3 deletions test/continuous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading