Skip to content

Commit

Permalink
added Volume component (needed for lecture 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brad Carman committed Jan 9, 2024
1 parent 22f6b97 commit f724bd5
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/Hydraulic/IsothermalCompressible/components.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(;

Check warning on line 467 in src/Hydraulic/IsothermalCompressible/components.jl

View check run for this annotation

Codecov / codecov/patch

src/Hydraulic/IsothermalCompressible/components.jl#L467

Added line #L467 was not covered by tests
#initial conditions
x,
dx = 0,
p,
drho = 0,
dm = 0,

#parameters
area,
direction = +1, name)
pars = @parameters begin
area = area

Check warning on line 479 in src/Hydraulic/IsothermalCompressible/components.jl

View check run for this annotation

Codecov / codecov/patch

src/Hydraulic/IsothermalCompressible/components.jl#L478-L479

Added lines #L478 - L479 were not covered by tests
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

Check warning on line 489 in src/Hydraulic/IsothermalCompressible/components.jl

View check run for this annotation

Codecov / codecov/patch

src/Hydraulic/IsothermalCompressible/components.jl#L482-L489

Added lines #L482 - L489 were not covered by tests
end

systems = @named begin
port = HydraulicPort(; p_int = p)
flange = MechanicalPort(; f, v = dx)

Check warning on line 494 in src/Hydraulic/IsothermalCompressible/components.jl

View check run for this annotation

Codecov / codecov/patch

src/Hydraulic/IsothermalCompressible/components.jl#L492-L494

Added lines #L492 - L494 were not covered by tests
end

eqs = [

Check warning on line 497 in src/Hydraulic/IsothermalCompressible/components.jl

View check run for this annotation

Codecov / codecov/patch

src/Hydraulic/IsothermalCompressible/components.jl#L497

Added line #L497 was not covered by tests
# 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)])

Check warning on line 513 in src/Hydraulic/IsothermalCompressible/components.jl

View check run for this annotation

Codecov / codecov/patch

src/Hydraulic/IsothermalCompressible/components.jl#L513

Added line #L513 was not covered by tests
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)
Expand Down

0 comments on commit f724bd5

Please sign in to comment.