diff --git a/src/Thermal/HeatTransfer/ideal_components.jl b/src/Thermal/HeatTransfer/ideal_components.jl index e1ba65194..fa415aed6 100644 --- a/src/Thermal/HeatTransfer/ideal_components.jl +++ b/src/Thermal/HeatTransfer/ideal_components.jl @@ -97,7 +97,7 @@ Lumped thermal element for heat convection. # States: - - `dT`: [`K`] Temperature difference across the component solid.T - fluid.T + - `dT`: [`K`] Temperature difference across the component `solid.T` - `fluid.T` - `Q_flow`: [`W`] Heat flow rate from `solid` -> `fluid` # Connectors: @@ -110,15 +110,13 @@ Lumped thermal element for heat convection. - `G`: [W/K] Convective thermal conductance """ @component function ConvectiveConductor(; name, G) - @named solid = HeatPort() - @named fluid = HeatPort() + @named convective_element1d = ConvectiveElement1D() + @unpack Q_flow, dT = convective_element1d @parameters G = G - sts = @variables Q_flow(t)=0.0 dT(t)=0.0 - eqs = [dT ~ solid.T - fluid.T - solid.Q_flow ~ Q_flow - fluid.Q_flow ~ -Q_flow - Q_flow ~ G * dT] - ODESystem(eqs, t, sts, [G]; systems = [solid, fluid], name = name) + eqs = [ + Q_flow ~ G * dT + ] + extend(ODESystem(eqs, t, [], [G]; name = name), convective_element1d) end """ @@ -128,7 +126,7 @@ Lumped thermal element for heat convection. # States: - - `dT`: [`K`] Temperature difference across the component solid.T - fluid.T + - `dT`: [`K`] Temperature difference across the component `solid.T` - `fluid.T` - `Q_flow`: [`W`] Heat flow rate from `solid` -> `fluid` # Connectors: @@ -141,15 +139,13 @@ Lumped thermal element for heat convection. - `R`: [`K/W`] Constant thermal resistance of material """ @component function ConvectiveResistor(; name, R) - @named solid = HeatPort() - @named fluid = HeatPort() + @named convective_element1d = ConvectiveElement1D() + @unpack Q_flow, dT = convective_element1d @parameters R = R - sts = @variables Q_flow(t)=0.0 dT(t)=0.0 - eqs = [dT ~ solid.T - fluid.T - solid.Q_flow ~ Q_flow - fluid.Q_flow ~ -Q_flow - dT ~ R * Q_flow] - ODESystem(eqs, t, sts, [R]; systems = [solid, fluid], name = name) + eqs = [ + dT ~ R * Q_flow + ] + extend(ODESystem(eqs, t, [], [R]; name = name), convective_element1d) end """ diff --git a/src/Thermal/utils.jl b/src/Thermal/utils.jl index 3305bf24b..a6adcade2 100644 --- a/src/Thermal/utils.jl +++ b/src/Thermal/utils.jl @@ -18,7 +18,7 @@ Port for a thermal system. """ HeatPort """ - Element1D(;name, dT0=0.0, Q_flow0=0.0) + Element1D(; name, dT_start = 0.0, Q_flow_start = 0.0) This partial model contains the basic connectors and variables to allow heat transfer models to be created that do not store energy. This model defines and includes equations for the temperature drop across the element, `dT`, and the heat @@ -52,3 +52,40 @@ flow rate through the element from `port_a` to `port_b`, `Q_flow`. return compose(ODESystem(eqs, t, sts, []; name = name), port_a, port_b) end + +""" + ConvectiveElement1D(; name, dT_start = 0.0, Q_flow_start = 0.0) + +This partial model contains the basic connectors and variables to allow heat +transfer models to be created that do not store energy. This model defines and +includes equations for the temperature drop across the element, `dT`, and the heat +flow rate through the element from `solid` to `fluid`, `Q_flow`. + +# States: + + - `dT`: [`K`] Temperature difference across the component `solid.T` - `fluid.T` + - `Q_flow`: [`W`] Heat flow rate from `solid` -> `fluid` + +# Connectors: + +`solid` +`fluid` + +# Parameters: + + - `dT_start`: [K] Initial temperature difference across the component `solid.T` - `fluid.T` + - `Q_flow_start`: [W] Initial heat flow rate from `solid` -> `fluid` +""" +@component function ConvectiveElement1D(; name, dT_start = 0.0, Q_flow_start = 0.0) + @named solid = HeatPort() + @named fluid = HeatPort() + sts = @variables begin + dT(t) = dT_start + Q_flow(t) = Q_flow_start + end + eqs = [dT ~ solid.T - fluid.T + solid.Q_flow ~ Q_flow + solid.Q_flow + fluid.Q_flow ~ 0] + + return compose(ODESystem(eqs, t, sts, []; name = name), solid, fluid) +end