Skip to content

Commit

Permalink
feat: add ConvectiveElement1D, a partial model that definestemperat…
Browse files Browse the repository at this point in the history
…ure drop and heat flow rate from `solid` to `fluid`

+ `ConvectiveConductor` and `ConvectiveResistor` extend the `Convective Element1D`
  • Loading branch information
ven-k committed May 29, 2023
1 parent 023e80c commit 0a9803b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
32 changes: 14 additions & 18 deletions src/Thermal/HeatTransfer/ideal_components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

"""
Expand All @@ -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:
Expand All @@ -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

"""
Expand Down
39 changes: 38 additions & 1 deletion src/Thermal/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 0a9803b

Please sign in to comment.