From f724bd5ac924289106afa23e812fbf081aad91e4 Mon Sep 17 00:00:00 2001 From: Brad Carman Date: Tue, 9 Jan 2024 07:18:42 -0500 Subject: [PATCH] added Volume component (needed for lecture 2) --- .../IsothermalCompressible/components.jl | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/src/Hydraulic/IsothermalCompressible/components.jl b/src/Hydraulic/IsothermalCompressible/components.jl index b7422f35c..79686d671 100644 --- a/src/Hydraulic/IsothermalCompressible/components.jl +++ b/src/Hydraulic/IsothermalCompressible/components.jl @@ -430,6 +430,89 @@ Fixed fluid volume. ODESystem(eqs, t, vars, pars; name, systems) end +""" + Volume(; 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) +``` + +# Parameters: +## volume +- `p`: [Pa] initial pressure +- `area`: [m^2] moving wall area +- `x`: [m] initial wall position +- `dx=0`: [m/s] initial wall velocity +- `drho=0`: [kg/m^3/s] initial density derivative +- `dm=0`: [kg/s] initial flow + +- `direction`: [+/-1] applies the direction conversion from the `flange` to `x` + +# Connectors: +- `port`: hydraulic port +- `flange`: mechanical translational port + +See also [`FixedVolume`](@ref), [`DynamicVolume`](@ref) +""" +@component function Volume(; + #initial conditions + x, + dx = 0, + p, + drho = 0, + dm = 0, + + #parameters + area, + direction = +1, name) + pars = @parameters begin + area = area + end + + vars = @variables begin + x(t) = x + dx(t) = dx + p(t) = p + f(t) = p * area + rho(t) + drho(t) = drho + dm(t) = dm + end + + systems = @named begin + port = HydraulicPort(; p_int = p) + flange = MechanicalPort(; f, v = dx) + end + + eqs = [ + # connectors + port.p ~ p + port.dm ~ dm + flange.v * direction ~ dx + flange.f * direction ~ -f + + # differentials + D(x) ~ dx + D(rho) ~ drho + + # physics + rho ~ liquid_density(port, p) + f ~ p * area + dm ~ drho * x * area + rho * dx * area] + + ODESystem(eqs, t, vars, pars; name, systems, defaults = [rho => liquid_density(port)]) +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)