11"""
22 Integrator(;name, k = 1, x = 0.0)
33
4- Outputs `y = ∫k*u dt`, corresponding to the transfer function `1/s`.
5- Initial value of integrator state `x ` can be set with `x`
4+ Outputs `y = ∫k*u dt`, corresponding to the transfer function `` 1/s` `.
5+ Initial value of integrator state ``x` ` can be set with `x`
66
77# Connectors:
88
@@ -19,7 +19,7 @@ Initial value of integrator state `x` can be set with `x`
1919 x (t) = 0.0 , [description = " State of Integrator" ]
2020 end
2121 @parameters begin
22- k = 1 , [description = " Gain of Integrator " ]
22+ k = 1 , [description = " Gain" ]
2323 end
2424 @equations begin
2525 D (x) ~ k * u
3030 Derivative(; name, k = 1, T, x = 0.0)
3131
3232Outputs an approximate derivative of the input. The transfer function of this block is
33- Initial value of the state `x ` can be set with `x`
33+ Initial value of the state ``x` ` can be set with `x`
3434
3535```
3636k k
@@ -57,11 +57,11 @@ A smaller `T` leads to a more ideal approximation of the derivative.
5757@mtkmodel Derivative begin
5858 @extend u, y = siso = SISO ()
5959 @variables begin
60- x (t) = 0.0 , [description = " State of Derivative" ]
60+ x (t) = 0.0 , [description = " Derivative-filter state " ]
6161 end
6262 @parameters begin
63- T = T, [description = " Time constant of Derivative " ]
64- k = 1 , [description = " Gain of Derivative " ]
63+ T = T, [description = " Time constant" ]
64+ k = 1 , [description = " Gain" ]
6565 end
6666 begin
6767 @symcheck T > 0 ||
7777 FirstOrder(; name, k = 1.0, T, x = 0.0, lowpass = true)
7878
7979A first-order filter with a single real pole in `s = -T` and gain `k`. If `lowpass=true` (default), the transfer function
80- is given by `Y(s)/U(s) = `
81- Initial value of the state `x` can be set with `x`
80+ is given by `` Y(s)/U(s) = ` `
81+
8282
8383```
8484 k
@@ -94,10 +94,12 @@ sT + 1 - k
9494 sT + 1
9595```
9696
97+ Initial value of the state `x` can be set with `x`
98+
9799# Parameters:
98100
99101 - `k`: Gain
100- - `T`: [s] Time constants (T>0 required)
102+ - `T`: [s] Time constant (T>0 required)
101103
102104# Connectors:
103105
@@ -108,26 +110,28 @@ See also [`SecondOrder`](@ref)
108110"""
109111@mtkmodel FirstOrder begin
110112 @extend u, y = siso = SISO ()
113+ @structural_parameters begin
114+ lowpass = true
115+ end
111116 @variables begin
112117 x (t) = 0.0 , [description = " State of FirstOrder filter" ]
113118 end
114119 @parameters begin
115- lowpass = true
116- T = T, [description = " Time constant of FirstOrder filter" ]
117- k = 1.0 , [description = " Gain of FirstOrder" ]
120+ T = T, [description = " Time constant" ]
121+ k = 1.0 , [description = " Gain" ]
118122 end
119123 begin
120124 @symcheck T > 0 ||
121125 throw (ArgumentError (" Time constant `T` has to be strictly positive" ))
122126 end
123127 @equations begin
124128 D (x) ~ (k * u - x) / T
125- getdefault ( lowpass) ? y ~ x : y ~ k * u - x
129+ lowpass ? y ~ x : y ~ k * u - x
126130 end
127131end
128132
129133"""
130- SecondOrder(; name, k = 1.0, w, d, x = 0.0, xd = 0.0)
134+ SecondOrder(; name, k = 1.0, w = 1.0 , d = 1.0 , x = 0.0, xd = 0.0)
131135
132136A second-order filter with gain `k`, a bandwidth of `w` rad/s and relative damping `d`. The transfer function
133137is given by `Y(s)/U(s) = `
@@ -160,9 +164,9 @@ Initial value of the state `x` can be set with `x`, and of derivative state `xd`
160164 xd (t) = 0.0 , [description = " Derivative state of SecondOrder filter" ]
161165 end
162166 @parameters begin
163- k = 1.0 , [description = " Gain of SecondOrder " ]
164- w, [description = " Bandwidth of SecondOrder " ]
165- d, [description = " Relative damping of SecondOrder " ]
167+ k = 1.0 , [description = " Gain" ]
168+ w = 1.0 , [description = " Bandwidth (angular frequency) " ]
169+ d = 1.0 , [description = " Relative damping" ]
166170 end
167171 @equations begin
168172 D (x) ~ xd
0 commit comments