Skip to content

Commit 4cfc041

Browse files
author
Sathvik Bhagavan
committed
refactor: change start values as guesses rather than default values for RealInput/Output/Array
1 parent 6bf4b5d commit 4cfc041

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/Blocks/utils.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
@connector function RealInput(; name, nin = 1, u_start = nin > 1 ? zeros(nin) : 0.0)
22
nin > 1 && @warn "For inputs greater than one, use `RealInputArray`."
33
if nin == 1
4-
@variables u(t)=u_start [
4+
@variables u(t) [
55
input = true,
66
description = "Inner variable in RealInput $name"
77
]
88
else
9-
@variables u(t)[1:nin]=u_start [
9+
@variables u(t)[1:nin] [
1010
input = true,
1111
description = "Inner variable in RealInput $name"
1212
]
1313
u = collect(u)
1414
end
15-
ODESystem(Equation[], t, [u...], []; name = name)
15+
ODESystem(Equation[], t, [u...], []; name = name, guesses = [u => u_start])
1616
end
1717
@doc """
1818
RealInput(;name, u_start)
1919
2020
Connector with one input signal of type Real.
2121
2222
# Parameters:
23-
- `u_start=0`: Initial value for `u`.
23+
- `u_start=0`: Guess value for `u`.
2424
2525
# States:
2626
- `u`: Value of the connector which is a scalar.
2727
""" RealInput
2828

2929
@connector function RealInputArray(; name, nin = 2, u_start = zeros(nin))
30-
@variables u(t)[1:nin]=u_start [
30+
@variables u(t)[1:nin] [
3131
input = true,
3232
description = "Inner variable in RealInputArray $name"
3333
]
3434
u = collect(u)
35-
ODESystem(Equation[], t, [u...], []; name = name)
35+
ODESystem(Equation[], t, [u...], []; name = name, guesses = [u => u_start])
3636
end
3737
@doc """
3838
RealInputArray(;name, nin, u_start)
@@ -41,7 +41,7 @@ Connector with an array of input signals of type Real.
4141
4242
# Parameters:
4343
- `nin=2`: Number of inputs.
44-
- `u_start=zeros(nin)`: Initial value for `u`.
44+
- `u_start=zeros(nin)`: Guess value for `u`.
4545
4646
# States:
4747
- `u`: Value of the connector which is an array.
@@ -50,38 +50,38 @@ Connector with an array of input signals of type Real.
5050
@connector function RealOutput(; name, nout = 1, u_start = nout > 1 ? zeros(nout) : 0.0)
5151
nout > 1 && @warn "For outputs greater than one, use `RealOutputArray`."
5252
if nout == 1
53-
@variables u(t)=u_start [
53+
@variables u(t) [
5454
output = true,
5555
description = "Inner variable in RealOutput $name"
5656
]
5757
else
58-
@variables u(t)[1:nout]=u_start [
58+
@variables u(t)[1:nout] [
5959
output = true,
6060
description = "Inner variable in RealOutput $name"
6161
]
6262
u = collect(u)
6363
end
64-
ODESystem(Equation[], t, [u...], []; name = name)
64+
ODESystem(Equation[], t, [u...], []; name = name, guesses = [u => u_start])
6565
end
6666
@doc """
6767
RealOutput(;name, u_start)
6868
6969
Connector with one output signal of type Real.
7070
7171
# Parameters:
72-
- `u_start=0`: Initial value for `u`.
72+
- `u_start=0`: Guess value for `u`.
7373
7474
# States:
7575
- `u`: Value of the connector which is a scalar.
7676
""" RealOutput
7777

7878
@connector function RealOutputArray(; name, nout = 2, u_start = zeros(nout))
79-
@variables u(t)[1:nout]=u_start [
79+
@variables u(t)[1:nout] [
8080
output = true,
81-
description = "Inner variable in RealOutput $name"
81+
description = "Inner variable in RealOutputArray $name"
8282
]
8383
u = collect(u)
84-
ODESystem(Equation[], t, [u...], []; name = name)
84+
ODESystem(Equation[], t, [u...], []; name = name, guesses = [u => u_start])
8585
end
8686
@doc """
8787
RealOutputArray(;name, nout, u_start)
@@ -90,7 +90,7 @@ Connector with an array of output signals of type Real.
9090
9191
# Parameters:
9292
- `nout=2`: Number of outputs.
93-
- `u_start=zeros(nout)`: Initial value for `u`.
93+
- `u_start=zeros(nout)`: Guess value for `u`.
9494
9595
# States:
9696
- `u`: Value of the connector which is an array.

0 commit comments

Comments
 (0)