Skip to content

Commit c351837

Browse files
Merge pull request #347 from avinashresearch1/avi/heatport_function_constructor
fix: change HeatPort to allow changing the guess
2 parents e41dcfc + cd12a18 commit c351837

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Thermal/utils.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
@connector HeatPort begin
2-
T(t), [guess = 273.15 + 20.0]
3-
Q_flow(t), [guess = 0.0, connect = Flow]
1+
@connector function HeatPort(; T = nothing, T_guess = 273.15 + 20, Q_flow = nothing, Q_flow_guess = 0.0, name)
2+
pars = @parameters begin
3+
T_guess = T_guess
4+
Q_flow_guess = Q_flow_guess
5+
end
6+
vars = @variables begin
7+
T(t) = T, [guess = T_guess]
8+
Q_flow(t) = Q_flow, [guess = Q_flow_guess, connect = Flow]
9+
end
10+
return ODESystem(Equation[], t, vars, pars; name)
411
end
512
Base.@doc """
6-
HeatPort(; name, T = 273.15 + 20.0, Q_flow = 0.0)
13+
HeatPort(; T = nothing, T_guess = 273.15 + 20, Q_flow = nothing, Q_flow_guess = 0.0, name)
714
815
Port for a thermal system.
16+
# Parameters:
17+
- `T_guess`: [K] Initial guess for the temperature of the port (set to 273.15 + 20).
18+
- `Q_flow_guess`: [W] Initial guess for the heat flow rate at the port (set to 0.0).
919
1020
# States:
11-
- `T`: [K] Temperature of the port. It accepts an initial value, which defaults to 273.15 + 20.
12-
- `Q_flow`: [W] Heat flow rate at the port. It accepts an initial value, which defaults to 0.0.
21+
- `T`: [K] Temperature of the port. Guess set to `T_guess`. Passing a value for `T` will set its default.
22+
- `Q_flow`: [W] Heat flow rate at the port. Guess set to `Q_flow_guess`. Passing a value for `Q_flow` will set its default.
1323
""" HeatPort
1424

1525
"""

0 commit comments

Comments
 (0)