Skip to content

Commit 3921bca

Browse files
committed
add test
1 parent 936be19 commit 3921bca

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/Blocks/continuous.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ symbolic_eps(t) = eps(t)
556556
"""
557557
TransferFunction(; b, a, name)
558558
559-
A linear time-invariant system provided as a transfer-function.
559+
A single input, single output, linear time-invariant system provided as a transfer-function.
560560
```
561561
Y(s) = b(s) / a(s) U(s)
562562
```
@@ -568,13 +568,13 @@ To set the initial state, it's recommended to set the initial condition for `x`,
568568
569569
# Parameters:
570570
- `b`: Numerator polynomial coefficients, e.g., `2s + 3` is specified as `[2, 3]`
571-
- `a`: Denomenator polynomial coefficients, e.g., `s + 2ws + w^2` is specified as `[1, 2w, w^2]`
571+
- `a`: Denomenator polynomial coefficients, e.g., `s² + 2ωs + ω^2` is specified as `[1, 2ω, ω^2]`
572572
573573
# Connectors:
574574
- `input`
575575
- `output`
576576
577-
See also [`StateSpace`](@ref) as well as [ControlSystemsMTK.jl](https://juliacontrol.github.io/ControlSystemsMTK.jl/stable/) for an interface between [ControlSystems.jl](https://juliacontrol.github.io/ControlSystems.jl/stable/) and ModelingToolkit.jl for advanced manipulation of transfer functions and linear statespace systems. For linearization, see [`linearize`](@ref) and [Linear Analysis](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/linear_analysis/).
577+
See also [`StateSpace`](@ref) which handles MIMO systems, as well as [ControlSystemsMTK.jl](https://juliacontrol.github.io/ControlSystemsMTK.jl/stable/) for an interface between [ControlSystems.jl](https://juliacontrol.github.io/ControlSystems.jl/stable/) and ModelingToolkit.jl for advanced manipulation of transfer functions and linear statespace systems. For linearization, see [`linearize`](@ref) and [Linear Analysis](https://docs.sciml.ai/ModelingToolkitStandardLibrary/stable/API/linear_analysis/).
578578
"""
579579
@component function TransferFunction(; b = [1], a = [1, 1], name)
580580
nb = length(b)
@@ -596,10 +596,10 @@ See also [`StateSpace`](@ref) as well as [ControlSystemsMTK.jl](https://juliacon
596596
]
597597
a[1:na] = a,
598598
[
599-
description = "Denominator coefficients of transfer function (e.g., s + 2ws + w^2 is specified as [1, 2w, w^2])",
599+
description = "Denominator coefficients of transfer function (e.g., `s² + 2ωs + ω^2` is specified as [1, 2ω, ω^2])",
600600
]
601601
bb[1:(nbb + nb)] = [zeros(nbb); b]
602-
d = bb[1] / a[1]
602+
d = bb[1] / a[1], [description = "Direct feedthrough gain"]
603603
end
604604

605605
a = collect(a)

test/Blocks/continuous.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using ModelingToolkit, ModelingToolkitStandardLibrary, OrdinaryDiffEq
22
using ModelingToolkitStandardLibrary.Blocks
33
using OrdinaryDiffEq: ReturnCode.Success
4+
using Test
45

56
@parameters t
67

@@ -465,5 +466,14 @@ end
465466
@test sol.retcode == Success
466467
@test sol[pt1.output.u]1 .- pt1_func.(sol.t, 1, 1) atol=1e-3
467468
@test sol[pt1.x[1]]pt1_func.(sol.t, 1, 1) atol=1e-3 # Test that scaling of state works properly
469+
470+
# Test with no state
471+
@named pt1 = TransferFunction(b = [2.7], a = [pi])
472+
@named iosys = ODESystem(connect(c.output, pt1.input), t, systems = [pt1, c])
473+
sys = structural_simplify(iosys)
474+
prob = ODEProblem(sys, Pair[pt1.a_end => 1], (0.0, 100.0))
475+
sol = solve(prob, Rodas4())
476+
@test sol.retcode == Success
477+
@test all(==(2.7 / pi), sol[pt1.output.u])
468478
end
469479
end

0 commit comments

Comments
 (0)