Skip to content

Commit b75cb08

Browse files
author
Brad Carman
committed
WIP
1 parent 0234f51 commit b75cb08

File tree

5 files changed

+191
-216
lines changed

5 files changed

+191
-216
lines changed

src/Hydraulic/IsothermalCompressible/components.jl

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Caps a hydraulic port to prevent mass flow in or out.
1010
# Connectors:
1111
- `port`: hydraulic port
1212
"""
13-
@component function Cap(; p_int, name)
13+
@component function Cap(; name)
1414

1515
vars = @variables p(t), [guess=0]
1616

@@ -553,7 +553,7 @@ dm ────► │ │ area
553553
@component function DynamicVolume(N, add_inertia = true, reversible = false;
554554
# p_int,
555555
area,
556-
# x_int = 0,
556+
x_int = 0,
557557
x_max,
558558
x_min = 0,
559559
x_damp = x_min,
@@ -578,7 +578,7 @@ dm ────► │ │ area
578578
# p_int = p_int
579579
area = area
580580

581-
# x_int = x_int
581+
x_int = x_int
582582
x_max = x_max
583583
x_min = x_min
584584
x_damp = x_damp
@@ -594,7 +594,7 @@ dm ────► │ │ area
594594
minimum_area = minimum_area
595595
end
596596

597-
vars = @variables x(t) vol(t)
597+
vars = @variables x(t)=x_int vol(t)=x_int * area
598598

599599
ports = @named begin
600600
port = HydraulicPort(;)
@@ -621,7 +621,7 @@ dm ────► │ │ area
621621
@named moving_volume = VolumeBase(;
622622
# x_int = 0,
623623
area,
624-
dead_volume = N == 0 ? area * x_min : 0,
624+
dead_volume = N == 0 ? area * x_int : 0,
625625
Χ1 = N == 0 ? 1 : 0,
626626
Χ2 = 1) # changed x_int to x_min
627627

@@ -641,7 +641,7 @@ dm ────► │ │ area
641641
volumes = []
642642
if N > 0
643643
Δx = ParentScope(x_max) / N
644-
x₀ = ParentScope(x) # x_int
644+
x₀ = ParentScope(x_int)
645645

646646
for i in 1:N
647647
length = ifelse(x₀ > Δx * i,
@@ -729,7 +729,7 @@ See [`Valve`](@ref) for more information.
729729
connect(valve.port_b, port_b)
730730
valve.area ~ x * 2π * d]
731731

732-
ODESystem(eqs, t, vars, pars; name, systems, defaults = [flange.v => 0])
732+
ODESystem(eqs, t, vars, pars; name, systems)
733733
end
734734

735735
"""
@@ -790,7 +790,7 @@ See [`SpoolValve`](@ref) for more information.
790790
connect(vBR.port_b, port_r)
791791
connect(vSA.flange, vBR.flange, mass.flange, flange)]
792792

793-
ODESystem(eqs, t, vars, pars; name, systems, defaults = [flange.v => 0])
793+
ODESystem(eqs, t, vars, pars; name, systems)
794794
end
795795

796796
"""
@@ -861,17 +861,19 @@ Actuator made of two DynamicVolumes connected in opposite direction with body ma
861861
- `flange`: mechanical translational port
862862
"""
863863
@component function Actuator(N, add_inertia = true, reversible = false;
864-
total_length,
865864
area_a,
866865
area_b,
867866
perimeter_a = 2 * sqrt(area_a * pi),
868867
perimeter_b = 2 * sqrt(area_b * pi),
868+
length_a_int,
869+
length_b_int,
869870
shape_factor_a = 64,
870871
shape_factor_b = 64,
871872
head_factor_a = 1,
872873
head_factor_b = 1,
873874
m,
874875
g,
876+
x_int = 0,
875877
minimum_volume_a = 0,
876878
minimum_volume_b = 0,
877879
damping_volume_a = minimum_volume_a,
@@ -888,6 +890,9 @@ Actuator made of two DynamicVolumes connected in opposite direction with body ma
888890
shape_factor_b = shape_factor_b
889891
head_factor_a = head_factor_a
890892
head_factor_b = head_factor_b
893+
x_int = x_int
894+
length_a_int = length_a_int
895+
length_b_int = length_b_int
891896
minimum_volume_a = minimum_volume_a
892897
minimum_volume_b = minimum_volume_b
893898
damping_volume_a = damping_volume_a
@@ -899,16 +904,17 @@ Actuator made of two DynamicVolumes connected in opposite direction with body ma
899904
end
900905

901906
vars = @variables begin
902-
x(t)
907+
x(t) = x_int
903908
dx(t)
904909
end
905910

906-
# total_length = length_a_int + length_b_int # Need parameters to define the total length.
911+
total_length = length_a_int + length_b_int
907912

908913
#TODO: include effective_length
909914
systems = @named begin
910915
vol_a = DynamicVolume(N, add_inertia, reversible; direction = +1,
911916
area = area_a,
917+
x_int = length_a_int,
912918
x_max = total_length,
913919
x_min = minimum_volume_a / area_a,
914920
x_damp = damping_volume_a / area_a,
@@ -920,6 +926,7 @@ Actuator made of two DynamicVolumes connected in opposite direction with body ma
920926

921927
vol_b = DynamicVolume(N, add_inertia, reversible; direction = -1,
922928
area = area_b,
929+
x_int = length_b_int,
923930
x_max = total_length,
924931
x_min = minimum_volume_b / area_b,
925932
x_damp = damping_volume_b / area_b,
@@ -929,16 +936,16 @@ Actuator made of two DynamicVolumes connected in opposite direction with body ma
929936
Cd,
930937
Cd_reverse)
931938
mass = Mass(; m, g)
932-
port_a = HydraulicPort(; )
933-
port_b = HydraulicPort(; )
939+
port_a = HydraulicPort()
940+
port_b = HydraulicPort()
934941
flange = MechanicalPort()
935942
end
936943

937944
eqs = [connect(vol_a.port, port_a)
938-
connect(vol_b.port, port_b)
939-
connect(vol_a.flange, vol_b.flange, mass.flange, flange)
940-
D(x) ~ dx
941-
dx ~ vol_a.flange.v]
945+
connect(vol_b.port, port_b)
946+
connect(vol_a.flange, vol_b.flange, mass.flange, flange)
947+
D(x) ~ dx
948+
dx ~ vol_a.flange.v]
942949

943-
ODESystem(eqs, t, vars, pars; name, systems, defaults = [flange.v => 0])
950+
ODESystem(eqs, t, vars, pars; name, systems)
944951
end

src/Hydraulic/IsothermalCompressible/sources.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Hydraulic mass flow input source
88
- `port`: hydraulic port
99
- `dm`: real input
1010
"""
11-
@component function MassFlow(; name, p_int)
12-
pars = @parameters p_int = p_int
11+
@component function MassFlow(; name)
12+
pars = []
1313

1414
systems = @named begin
15-
port = HydraulicPort(; p_int)
15+
port = HydraulicPort()
1616
dm = RealInput()
1717
end
1818

src/Mechanical/Translational/components.jl

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ Fixes a flange position (velocity = 0)
3838
end
3939

4040
"""
41-
Mass(; name, v_0 = 0.0, m, s = nothing, g = nothing)
41+
Mass(; name, m, g = 0)
4242
4343
Sliding mass with inertia
4444
4545
# Parameters:
4646
4747
- `m`: [kg] mass of sliding body
48-
- `v_0`: [m/s] Initial value of absolute linear velocity of sliding mass (default 0 m/s)
49-
- `s`: [m] initial value of absolute position of sliding mass (optional)
50-
- `g`: [m/s²] gravity field acting on the mass, positive value acts in the positive direction (optional)
48+
- `g = 0`: [m/s^2] [m/s²] gravity field acting on the mass, positive value acts in the positive direction
49+
5150
5251
# States:
5352
@@ -58,36 +57,26 @@ Sliding mass with inertia
5857
5958
- `flange`: 1-dim. translational flange
6059
"""
61-
@component function Mass(; name, v = 0.0, m, s = nothing, g = nothing)
60+
@component function Mass(; name, m, g = 0)
6261
pars = @parameters begin
6362
m = m
63+
g = g
6464
end
65-
@named flange = MechanicalPort(; v = v)
65+
@named flange = MechanicalPort()
6666

6767
vars = @variables begin
68-
v(t) = v
68+
s(t)
69+
v(t)
6970
f(t)
7071
end
7172

72-
eqs = [flange.v ~ v
73-
flange.f ~ f]
74-
75-
# gravity option
76-
if g !== nothing
77-
@parameters g = g
78-
push!(pars, g)
79-
push!(eqs, D(v) ~ f / m + g)
80-
else
81-
push!(eqs, D(v) ~ f / m)
82-
end
83-
84-
# position option
85-
if s !== nothing
86-
@variables s(t) = s
87-
push!(vars, s)
73+
eqs = [
74+
flange.v ~ v
75+
flange.f ~ f
8876

89-
push!(eqs, D(s) ~ v)
90-
end
77+
D(s) ~ v
78+
D(v) ~ f / m + g
79+
]
9180

9281
return compose(ODESystem(eqs, t, vars, pars; name = name),
9382
flange)
@@ -188,8 +177,8 @@ Linear 1D translational damper
188177
end
189178

190179
@components begin
191-
flange_a = MechanicalPort(; v = 0.0)
192-
flange_b = MechanicalPort(; v = 0.0)
180+
flange_a = MechanicalPort()
181+
flange_b = MechanicalPort()
193182
end
194183

195184
@equations begin

0 commit comments

Comments
 (0)