ModelingToolkit Standard Library: Hydraulic Components
Index
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Cap
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedPressure
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FlowDivider
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.MassFlow
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Open
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Pressure
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Actuator
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolume
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedVolume
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluid
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicPort
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2Way
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Tube
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBase
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Valve
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Volume
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor
IsothermalCompressible Components
IsothermalCompressible Utils
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicPort
— FunctionHydraulicPort(; name)
Connector port for hydraulic components.
States:
p
: [Pa] gauge total pressuredm
: [kg/s] mass flow
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.HydraulicFluid
— FunctionHydraulicFluid(; density = 997, bulk_modulus = 2.09e9, viscosity = 0.0010016, gas_density = 0.0073955, gas_pressure = -1000, n = 1, let_gas = 1, name)
Fluid parameter setter for isothermal compressible fluid domain. Defaults given for water at 20°C and 0Pa gage (1atm absolute) reference pressure. Density is modeled using the Tait equation of state. For pressures below the reference pressure, density is linearly interpolated to the gas state (when let_gas
is set to 1), this helps prevent pressures from going below the reference pressure.
Parameters:
ρ
: [kg/m^3] fluid density at 0Pa reference gage pressure (set bydensity
argument)Β
: [Pa] fluid bulk modulus describing the compressibility (set bybulk_modulus
argument)μ
: [Pa*s] or [kg/m-s] fluid dynamic viscosity (set byviscosity
argument)n
: density exponentlet_gas
: set to 1 to allow fluid to transition from liquid to gas (for density calculation only)ρ_gas
: [kg/m^3] density of fluid in gas state at reference gage pressurep_gas
(set bygas_density
argument)p_gas
: [Pa] reference pressure (set bygas_pressure
argument)
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.friction_factor
— Functionfriction_factor(dm, area, d_h, viscosity, shape_factor)
Calculates the friction factor $f$ for fully developed flow in a tube such that $Δp = f \cdot \rho \frac{u^2}{2} \frac{l}{d_h}$ where
- $Δp$: [Pa] is the pressure difference over the tube length $l$
- $\rho$: [kg/m^3] is the average fluid density
- $u$: [m/s] is the average fluid velocity
- $l$: [m] is the tube length
The friction factor is calculated for laminar and turbulent flow with a transition region between Reynolds number 2000 to 3000. Turbulent flow equation is for smooth tubes, valid for the Reynolds number range up to 5e6.
Arguments:
dm
: [kg/s] mass flowarea
: [m^2] tube cross sectional aread_h
: [m] tube hydraulic diameter. For circular tubes d_h is the tube diameter, otherwise it can be found from4*area/perimeter
density
: [kg/m^3] fluid densityviscosity
: [Pa*s] or [kg/m-s] fluid dynamic viscosityshape_factor
: the constant defining the laminar fully developed constant f*Re related to the shape of the tube cross section
Reference: Introduction to Fluid Mechanics, Fox & McDonald, 5th Edition, equations 8.19 and 8.21
IsothermalCompressible Components
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Cap
— ConstantCap(; name)
Caps a hydraulic port to prevent mass flow in or out.
Connectors:
port
: hydraulic port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Open
— ConstantOpen(; name)
Provides an "open" boundary condition for a hydraulic port such that mass flow dm
is non-zero. This is opposite from an un-connected hydraulic port or the Cap
boundary component which sets the mass flow dm
to zero.
Connectors:
port
: hydraulic port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.TubeBase
— FunctionTubeBase(add_inertia = true, variable_length = true; 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.
States:
x
: [m] length of the pipeddm
: [kg/s^2] Rate of change of mass flow rate in control volume.
Parameters:
area
: [m^2] tube cross sectional arealength_int
: [m] initial tube lengthperimeter
: [m] perimeter of the pipe cross section (needed only for non-circular pipes)shape_factor
: shape factor, seefriction_factor
functionhead_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:
port_a
: hydraulic portport_b
: hydraulic port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Tube
— FunctionTube(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.
Parameters:
p_int
: [Pa] initial pressurearea
: [m^2] tube cross sectional arealength
: [m] real length of the tubeperimeter
: [m] perimeter of the pipe cross section (needed only for non-circular pipes)shape_factor
: shape factor, seefriction_factor
functionhead_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:
port_a
: hydraulic portport_b
: hydraulic port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FlowDivider
— ConstantFlowDivider(; n, name)
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:
n
: divide flow fromport_a
toport_b
byn
Connectors:
port_a
: full flow hydraulic portport_b
: part flow hydraulic port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Valve
— FunctionValve(reversible = false; p_a_int, p_b_int, area_int, Cd, Cd_reverse = Cd, minimum_area = 0, name)
Valve with area
input and discharge coefficient Cd
defined by https://en.wikipedia.org/wiki/Dischargecoefficient. The `Cdreverse` parameter allows for directional flow restriction, making it possible to define a check valve.
Parameters:
p_a_int
: [Pa] initial pressure forport_a
p_b_int
: [Pa] initial pressure forport_b
area_int
: [m^2] initial valve openingCd
: discharge coefficient flowing froma → b
Cd_reverse
: discharge coefficient flowing fromb → a
minimum_area
: whenreversible = false
applies a forced minimum area
Connectors:
port_a
: hydraulic portport_b
: hydraulic portarea
: real input setting the valvearea
. Whenreversible = true
, negative input reverses flow direction, otherwise a floor ofminimum_area
is enforced.
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedVolume
— FunctionFixedVolume(; p_int, vol, name)
Fixed fluid volume.
Parameters:
p_int
: [Pa] initial pressurevol
: [m^3] fixed volume
Connectors:
port
: hydraulic port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Volume
— FunctionVolume(; x, dx=0, p, drho=0, dm=0, area, direction = 1, 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.
┌─────────────────┐ ───
│ │ ▲
│ │
dm ────► │ │ area
│ │
│ │ ▼
└─────────────────┤ ───
│
└─► x (= ∫ flange.v * direction)
Features:
- volume discretization with flow resistance and inertia: use
N
to control number of volume and resistance elements. SetN=0
to turn off volume discretization. SeeTubeBase
for more information about flow resistance. - minimum volume flow shutoff with damping and directional resistance. Use
reversible=false
when problem defines volume positionx
and solves fordm
to prevent numerical instability.
Parameters:
volume
p
: [Pa] initial pressurearea
: [m^2] moving wall areax
: [m] initial wall positiondx=0
: [m/s] initial wall velocitydrho=0
: [kg/m^3/s] initial density derivativedm=0
: [kg/s] initial flowdirection
: [+/-1] applies the direction conversion from theflange
tox
Connectors:
port
: hydraulic portflange
: mechanical translational port
See also FixedVolume
, DynamicVolume
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.DynamicVolume
— FunctionDynamicVolume(reversible = false; 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.
┌─────────────────┐ ───
│ │ ▲
│ │
dm ────► │ │ area
│ │
│ │ ▼
└─────────────────┤ ───
│
└─► x (= ∫ flange.v * direction)
Features:
- minimum volume flow shutoff with damping and directional resistance. Use
reversible=false
when problem defines volume positionx
and solves fordm
to prevent numerical instability.
Parameters:
volume
p_int
: [Pa] initial pressurearea
: [m^2] moving wall areax_max
: [m] max wall position, needed for volume discretization to apply the correct volume sizing as a function ofx
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 theflange
tox
flow resistance
perimeter
: [m] perimeter of the cross section (needed only for non-circular volumes)shape_factor
: shape factor, seefriction_factor
functionhead_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
Cd
: discharge coefficient for flow out of the volume. Note: area is 1m² when valve is fully open. Ensure this does not induce unwanted flow resistance.Cd_reverse
: discharge coefficient for flow into the volume. Use a lower value to allow easy wall release, in some cases the wall can "stick".
Connectors:
port
: hydraulic portflange
: mechanical translational port
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve
— FunctionSpoolValve(reversible = false; x_int, Cd, d, name)
Spool valve with x
valve opening input as mechanical flange port and d
diameter of orifice. See Valve
for more information.
Parameters:
x_int
: [m] initial valve openingd
: [m] orifice diameterCd
: discharge coefficient flowing froma → b
Connectors:
port_a
: hydraulic portport_b
: hydraulic portflange
: mechanical translational port
See Valve
for more information.
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.SpoolValve2Way
— FunctionSpoolValve2Way(reversible = false; m, g, x_int, Cd, d, name)
2-ways spool valve with 4 ports and spool mass. Fluid flow direction S → A and B → R when x
is positive and S → B and A → R when x
is negative.
Parameters:
m
: [kg] mass of the spoolg
: [m/s²] gravity field acting on the spool, positive value acts in the positive directionx_int
: [m] initial valve openingd
: [m] orifice diameterCd
: discharge coefficient flowing froms → a
andb → r
Connectors:
port_s
: hydraulic portport_a
: hydraulic portport_b
: hydraulic portport_r
: hydraulic portflange
: mechanical translational port
See SpoolValve
for more information.
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Actuator
— FunctionActuator(N, add_inertia = true, reversible = false;
p_a_int,
p_b_int,
area_a,
area_b,
perimeter_a = 2 * sqrt(area_a * pi),
perimeter_b = 2 * sqrt(area_b * pi),
length_a_int,
length_b_int,
shape_factor_a = 64,
shape_factor_b = 64,
head_factor_a = 1,
head_factor_b = 1,
m,
g,
x_int = 0,
minimum_volume_a = 0,
minimum_volume_b = 0,
damping_volume_a = minimum_volume_a,
damping_volume_b = minimum_volume_b,
Cd = 1e4,
Cd_reverse = Cd,
p_a_int,
p_b_int,
name)
Actuator made of two DynamicVolumes connected in opposite direction with body mass attached.
Features:
- volume discretization with flow resistance and inertia: use
N
to control number of volume and resistance elements. SetN=0
to turn off volume discretization. SeeTubeBase
for more information about flow resistance. - minimum volume flow shutoff with damping and directional resistance. Use
reversible=false
when problem defines volume positionx
and solves fordm
to prevent numerical instability.
Parameters:
volume
p_a_int
: [Pa] initial pressure forport_a
p_b_int
: [Pa] initial pressure forport_b
area_a
: [m^2] moving wall area of volumeA
area_b
: [m^2] moving wall area of volumeB
length_a_int
: [m] initial wall position forA
length_b_int
: [m] initial wall position forb
mass
m
: [kg] mass of the bodyg
: [m/s²] gravity field acting on the mass, positive value acts in the positive directionx_int
: [m] initial flange position
flow resistance
perimeter_a
: [m] perimeter of the cross sectionA
(needed only for non-circular volumes)perimeter_b
: [m] perimeter of the cross sectionB
(needed only for non-circular volumes)shape_factor_a
: shape factor ofA
, seefriction_factor
functionshape_factor_b
: shape factor ofB
, seefriction_factor
functionhead_factor_a
: effective length multiplier forA
, used to account for addition friction from flow development and additional friction such as pipe bends, entrance/exit lossses, etc.head_factor_b
: effective length multiplier forB
, 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
minimum_volume_a
: [m^3] minimum volumeA
that shuts off flow and prevents negative volume.minimum_volume_b
: [m^3] minimum volumeB
that shuts off flow and prevents negative volume.damping_volume_a
: [m^3] volume ofA
that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.damping_volume_b
: [m^3] volume ofB
that initiates a linear damping region before reaching full flow shut off. Helps provide a smooth end stop.Cd
: discharge coefficient for flow out of the volume. Note: area is 1m² when valve is fully open. Ensure this does not induce unwanted flow resistance.Cd_reverse
: discharge coefficient for flow into the volume. Use a lower value to allow easy wall release, in some cases the wall can "stick".
Connectors:
port_a
: hydraulic portport_b
: hydraulic portflange
: mechanical translational port
IsothermalCompressible Sources
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.MassFlow
— ConstantMassFlow(; name)
Hydraulic mass flow input source
Connectors:
port
: hydraulic portdm
: real input
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.Pressure
— ConstantPressure(; name)
input pressure source
Connectors:
port
: hydraulic portp
: real input
ModelingToolkitStandardLibrary.Hydraulic.IsothermalCompressible.FixedPressure
— ConstantFixedPressure(; p, name)
Fixed pressure source
Parameters:
p
: [Pa] set pressure (set byp
argument)
Connectors:
port
: hydraulic port