Skip to content

Commit 13e2b1c

Browse files
fix: change certain defaults to guesses in Blocks
1 parent 9412fef commit 13e2b1c

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/Blocks/continuous.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Initial value of integrator state ``x`` can be set with `x`
2020
@mtkmodel Integrator begin
2121
@extend u, y = siso = SISO()
2222
@variables begin
23-
x(t) = 0.0, [description = "State of Integrator"]
23+
x(t), [guess = 0.0, description = "State of Integrator"]
2424
end
2525
@parameters begin
2626
k = 1, [description = "Gain"]
@@ -65,7 +65,7 @@ Initial value of the state ``x`` can be set with `x`.
6565
@mtkmodel Derivative begin
6666
@extend u, y = siso = SISO()
6767
@variables begin
68-
x(t) = 0.0, [description = "Derivative-filter state"]
68+
x(t), [guess = 0.0, description = "Derivative-filter state"]
6969
end
7070
@parameters begin
7171
T = T, [description = "Time constant"]
@@ -122,7 +122,7 @@ See also [`SecondOrder`](@ref)
122122
lowpass = true
123123
end
124124
@variables begin
125-
x(t) = 0.0, [description = "State of FirstOrder filter"]
125+
x(t), [guess = 0.0, description = "State of FirstOrder filter"]
126126
end
127127
@parameters begin
128128
T = T, [description = "Time constant"]
@@ -545,7 +545,7 @@ linearized around the operating point `x₀, u₀`, we have `y0, u0 = h(x₀, u
545545
end
546546
@named input = RealInput(nin = nu)
547547
@named output = RealOutput(nout = ny)
548-
@variables x(t)[1:nx]=x [
548+
@variables x(t)[1:nx]=x [ # FIXME: should it be guess = x, not default?
549549
description = "State variables of StateSpace system $name"
550550
]
551551
# pars = @parameters A=A B=B C=C D=D # This is buggy
@@ -618,7 +618,7 @@ See also [`StateSpace`](@ref) which handles MIMO systems, as well as [ControlSys
618618
@parameters a_end = ifelse(a[end] > 100 * symbolic_eps(sqrt(a' * a)), a[end], 1.0)
619619

620620
pars = [collect(b); a; collect(bb); d; a_end]
621-
@variables begin
621+
@variables begin # FIXME: should it be guesses, not default?
622622
x(t)[1:nx] = zeros(nx),
623623
[description = "State of transfer function on controller canonical form"]
624624
x_scaled(t)[1:nx] = collect(x) * a_end, [description = "Scaled vector x"]

src/Blocks/utils.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ Single input single output (SISO) continuous system block.
130130
y_start = 0.0
131131
end
132132
@variables begin
133-
u(t) = u_start, [description = "Input of SISO system"]
134-
y(t) = y_start, [description = "Output of SISO system"]
133+
u(t), [guess = u_start, description = "Input of SISO system"]
134+
y(t), [guess = y_start, description = "Output of SISO system"]
135135
end
136136
@components begin
137137
input = RealInput(guess = u_start)
@@ -157,10 +157,12 @@ Base class for a multiple input multiple output (MIMO) continuous system block.
157157
"""
158158
@component function MIMO(; name, nin = 1, nout = 1, u_start = zeros(nin),
159159
y_start = zeros(nout))
160-
@named input = RealInput(nin = nin, guess = u_start)
161-
@named output = RealOutput(nout = nout, guess = y_start)
162-
@variables(u(t)[1:nin]=u_start, [description = "Input of MIMO system $name"],
163-
y(t)[1:nout]=y_start, [description = "Output of MIMO system $name"],)
160+
@named input = RealInput(nin = nin, u_start = u_start)
161+
@named output = RealOutput(nout = nout, u_start = y_start)
162+
@variables begin
163+
u(t)[1:nin], [guess = u_start, description = "Input of MIMO system $name"]
164+
y(t)[1:nout], [guess = y_start, description = "Output of MIMO system $name"]
165+
end
164166
eqs = [
165167
[u[i] ~ input.u[i] for i in 1:nin]...,
166168
[y[i] ~ output.u[i] for i in 1:nout]...

0 commit comments

Comments
 (0)