Skip to content

Commit f724bd5

Browse files
author
Brad Carman
committed
added Volume component (needed for lecture 2)
1 parent 22f6b97 commit f724bd5

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

src/Hydraulic/IsothermalCompressible/components.jl

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,89 @@ Fixed fluid volume.
430430
ODESystem(eqs, t, vars, pars; name, systems)
431431
end
432432

433+
"""
434+
Volume(; x, dx=0, p, drho=0, dm=0, area, direction = +1, name)
435+
436+
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.
437+
438+
```
439+
┌─────────────────┐ ───
440+
│ │ ▲
441+
│ │
442+
dm ────► │ │ area
443+
│ │
444+
│ │ ▼
445+
└─────────────────┤ ───
446+
447+
└─► x (= ∫ flange.v * direction)
448+
```
449+
450+
# Parameters:
451+
## volume
452+
- `p`: [Pa] initial pressure
453+
- `area`: [m^2] moving wall area
454+
- `x`: [m] initial wall position
455+
- `dx=0`: [m/s] initial wall velocity
456+
- `drho=0`: [kg/m^3/s] initial density derivative
457+
- `dm=0`: [kg/s] initial flow
458+
459+
- `direction`: [+/-1] applies the direction conversion from the `flange` to `x`
460+
461+
# Connectors:
462+
- `port`: hydraulic port
463+
- `flange`: mechanical translational port
464+
465+
See also [`FixedVolume`](@ref), [`DynamicVolume`](@ref)
466+
"""
467+
@component function Volume(;
468+
#initial conditions
469+
x,
470+
dx = 0,
471+
p,
472+
drho = 0,
473+
dm = 0,
474+
475+
#parameters
476+
area,
477+
direction = +1, name)
478+
pars = @parameters begin
479+
area = area
480+
end
481+
482+
vars = @variables begin
483+
x(t) = x
484+
dx(t) = dx
485+
p(t) = p
486+
f(t) = p * area
487+
rho(t)
488+
drho(t) = drho
489+
dm(t) = dm
490+
end
491+
492+
systems = @named begin
493+
port = HydraulicPort(; p_int = p)
494+
flange = MechanicalPort(; f, v = dx)
495+
end
496+
497+
eqs = [
498+
# connectors
499+
port.p ~ p
500+
port.dm ~ dm
501+
flange.v * direction ~ dx
502+
flange.f * direction ~ -f
503+
504+
# differentials
505+
D(x) ~ dx
506+
D(rho) ~ drho
507+
508+
# physics
509+
rho ~ liquid_density(port, p)
510+
f ~ p * area
511+
dm ~ drho * x * area + rho * dx * area]
512+
513+
ODESystem(eqs, t, vars, pars; name, systems, defaults = [rho => liquid_density(port)])
514+
end
515+
433516
"""
434517
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)
435518

0 commit comments

Comments
 (0)