diff --git a/docs/src/API/hydraulic.md b/docs/src/API/hydraulic.md index 03f22d864..1ad93e9ae 100644 --- a/docs/src/API/hydraulic.md +++ b/docs/src/API/hydraulic.md @@ -1,4 +1,4 @@ -# ModelingToolkit Standard Library: Hydrualic Components +# ModelingToolkit Standard Library: Hydraulic Components ```@contents Pages = ["hydraulic.md"] diff --git a/src/Hydraulic/Hydraulic.jl b/src/Hydraulic/Hydraulic.jl index 941e7016a..cb3cb1deb 100644 --- a/src/Hydraulic/Hydraulic.jl +++ b/src/Hydraulic/Hydraulic.jl @@ -1,5 +1,5 @@ """ -Library of hydrualic models. +Library of hydraulic models. """ module Hydraulic diff --git a/src/Hydraulic/IsothermalCompressible/components.jl b/src/Hydraulic/IsothermalCompressible/components.jl index 04705682e..c256f310a 100644 --- a/src/Hydraulic/IsothermalCompressible/components.jl +++ b/src/Hydraulic/IsothermalCompressible/components.jl @@ -2,7 +2,7 @@ """ Cap(; p_int, name) -Caps a hydrualic port to prevent mass flow in or out. +Caps a hydraulic port to prevent mass flow in or out. # Parameters: - `p_int`: [Pa] initial pressure (set by `p_int` argument) @@ -42,7 +42,7 @@ end """ TubeBase(add_inertia = true; p_int, area, length_int, head_factor = 1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name) -Variable length internal flow model of the fully developed incompressible flow friction. Includes optional inertia term when `add_inertia = true` to model wave propagation. Hydraulic ports have equal flow but variable pressure. Density is averaged over the pressures, used to calculated average flow velocity and flow friction. +Variable length internal flow model of the fully developed incompressible flow friction. Includes optional inertia term when `add_inertia = true` to model wave propagation. Hydraulic ports have equal flow but variable pressure. Density is averaged over the pressures, used to calculated average flow velocity and flow friction. # States: - `x`: [m] length of the pipe @@ -53,7 +53,7 @@ Variable length internal flow model of the fully developed incompressible flow f - `area`: [m^2] tube cross sectional area - `length_int`: [m] initial tube length - `perimeter`: [m] perimeter of the pipe cross section (needed only for non-circular pipes) -- `shape_factor`: shape factor, see `friction_factor` function +- `shape_factor`: shape factor, see `friction_factor` function - `head_factor`: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc. # Connectors: @@ -120,14 +120,14 @@ end """ Tube(N, add_inertia=true; p_int, area, length, head_factor=1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, name) -Constant length internal flow model discretized by `N` (`FixedVolume`: `N`, `TubeBase`:`N-1`) which models the fully developed flow friction, compressibility (when `N>1`), and inertia effects when `add_inertia = true`. See `TubeBase` and `FixedVolume` for more information. +Constant length internal flow model discretized by `N` (`FixedVolume`: `N`, `TubeBase`:`N-1`) which models the fully developed flow friction, compressibility (when `N>1`), and inertia effects when `add_inertia = true`. See `TubeBase` and `FixedVolume` for more information. # Parameters: - `p_int`: [Pa] initial pressure - `area`: [m^2] tube cross sectional area - `length`: [m] real length of the tube - `perimeter`: [m] perimeter of the pipe cross section (needed only for non-circular pipes) -- `shape_factor`: shape factor, see `friction_factor` function +- `shape_factor`: shape factor, see `friction_factor` function - `head_factor`: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc. # Connectors: @@ -209,7 +209,7 @@ end Reduces the flow from `port_a` to `port_b` by `n`. Useful for modeling parallel tubes efficiently by placing a `FlowDivider` on each end of a tube. # Parameters: -- `p_int`: [Pa] initial pressure +- `p_int`: [Pa] initial pressure - `n`: divide flow from `port_a` to `port_b` by `n` # Connectors: @@ -407,14 +407,14 @@ end """ DynamicVolume(N, add_inertia=true; p_int, area, x_int = 0, x_max, x_min = 0, x_damp = x_min, direction = +1, perimeter = 2 * sqrt(area * pi), shape_factor = 64, head_factor = 1, Cd = 1e2, Cd_reverse = Cd, name) -Volume with moving wall with `flange` connector for converting hydraulic energy to 1D mechanical. The `direction` argument aligns the mechanical port with the hydraulic port, useful when connecting two dynamic volumes together in oppsing directions to create an actuator. +Volume with moving wall with `flange` connector for converting hydraulic energy to 1D mechanical. The `direction` argument aligns the mechanical port with the hydraulic port, useful when connecting two dynamic volumes together in oppsing directions to create an actuator. ``` ┌─────────────────┐ ─── │ │ ▲ │ │ dm ────► │ │ area - │ │ + │ │ │ │ ▼ └─────────────────┤ ─── │ @@ -431,14 +431,14 @@ dm ────► │ │ area - `area`: [m^2] moving wall area - `x_int`: [m] initial wall position - `x_max`: [m] max wall position, needed for volume discretization to apply the correct volume sizing as a function of `x` -- `x_min`: [m] wall position that shuts off flow and prevents negative volume. +- `x_min`: [m] wall position that shuts off flow and prevents negative volume. - `x_damp`: [m] wall position that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop. - `direction`: [+/-1] applies the direction conversion from the `flange` to `x` ## flow resistance - `perimeter`: [m] perimeter of the cross section (needed only for non-circular volumes) -- `shape_factor`: shape factor, see `friction_factor` function +- `shape_factor`: shape factor, see `friction_factor` function - `head_factor`: effective length multiplier, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc. ## flow shut off and damping diff --git a/src/Thermal/HeatTransfer/ideal_components.jl b/src/Thermal/HeatTransfer/ideal_components.jl index 368869a2c..4e4bf1bde 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 - dT ~ G * Q_flow] - 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