Skip to content

Commit 6bb01f5

Browse files
committed
ThermalCollector refactored to @mtkbuild syntax
1 parent a3bdab3 commit 6bb01f5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Thermal/HeatTransfer/ideal_components.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ This is a model to collect the heat flows from `m` heatports to one single heatp
201201
202202
- `m`: Number of heat ports (e.g. m=2: `port_a1`, `port_a2`)
203203
"""
204+
205+
"""
204206
@component function ThermalCollector(; name, m::Integer = 1)
205207
port_a = [HeatPort(name = Symbol(:port_a, i)) for i in 1:m]
206208
@named port_b = HeatPort()
@@ -211,3 +213,22 @@ This is a model to collect the heat flows from `m` heatports to one single heatp
211213
end
212214
ODESystem(eqs, t, [], []; systems = [port_a..., port_b], name = name)
213215
end
216+
"""
217+
218+
@mtkmodel ThermalCollector begin
219+
@structural_parameters begin
220+
m::Integer = 1
221+
end
222+
223+
@components begin
224+
port_a = [HeatPort(name = Symbol(:port_a, i)) for i in 1:m]
225+
port_b = HeatPort()
226+
end
227+
228+
@equations begin
229+
port_b.Q_flow + sum(k -> k.Q_flow, port_a) ~ 0
230+
port_b.T ~ port_a[1].T
231+
[port_a[i].T ~ port_a[i + 1].T for i in 1:(m - 1)]
232+
end
233+
234+
end

0 commit comments

Comments
 (0)