@@ -7,13 +7,12 @@ import ModelingToolkitStandardLibrary.Mechanical.Translational as T
7
7
D = Differential (t)
8
8
9
9
function system (N; bulk_modulus, name)
10
- pars = @parameters begin
11
- bulk_modulus = bulk_modulus
12
- end
10
+ pars = @parameters begin bulk_modulus = bulk_modulus end
13
11
14
12
systems = @named begin
15
- fluid = IC. HydraulicFluid (;bulk_modulus)
16
- stp = B. Step (; height = 10e5 , offset = 0 , start_time = 0.005 , duration = Inf , smooth = true )
13
+ fluid = IC. HydraulicFluid (; bulk_modulus)
14
+ stp = B. Step (; height = 10e5 , offset = 0 , start_time = 0.005 , duration = Inf ,
15
+ smooth = true )
17
16
src = IC. InputSource (; p_int = 0 )
18
17
vol = IC. FixedVolume (; p_int = 0 , vol = 10.0 )
19
18
end
@@ -25,23 +24,24 @@ function system(N; bulk_modulus, name)
25
24
end
26
25
push! (systems, res)
27
26
28
- eqs = [ connect (stp. output, src. input)
29
- connect (fluid, src. port)
30
- connect (src. port, res. port_a)
31
- connect (res. port_b, vol. port)]
27
+ eqs = [connect (stp. output, src. input)
28
+ connect (fluid, src. port)
29
+ connect (src. port, res. port_a)
30
+ connect (res. port_b, vol. port)]
32
31
33
32
ODESystem (eqs, t, [], pars; name, systems)
34
33
end
35
34
36
- @named sys1_2 = system (1 ; bulk_modulus= 2e9 )
37
- @named sys1_1 = system (1 ; bulk_modulus= 1e9 )
38
- @named sys5_1 = system (5 ; bulk_modulus= 1e9 )
35
+ @named sys1_2 = system (1 ; bulk_modulus = 2e9 )
36
+ @named sys1_1 = system (1 ; bulk_modulus = 1e9 )
37
+ @named sys5_1 = system (5 ; bulk_modulus = 1e9 )
39
38
40
39
NEWTON = NLNewton (check_div = false , always_new = true , max_iter = 100 , relax = 4 // 10 )
41
40
42
41
syss = structural_simplify .([sys1_2, sys1_1, sys5_1])
43
42
probs = [ODEProblem (sys, [], (0 , 0.2 )) for sys in syss];
44
- sols = [solve (prob, ImplicitEuler (nlsolve= NEWTON); initializealg= NoInit ()) for prob in probs];
43
+ sols = [solve (prob, ImplicitEuler (nlsolve = NEWTON); initializealg = NoInit ())
44
+ for prob in probs];
45
45
46
46
s1_2 = complete (sys1_2)
47
47
s1_1 = complete (sys1_1)
@@ -64,50 +64,46 @@ s5_1 = complete(sys5_1)
64
64
# Legend(fig[1,2], ax)
65
65
# fig
66
66
67
-
68
-
69
-
70
67
function system (; bulk_modulus, name)
71
- pars = @parameters begin
72
- bulk_modulus = bulk_modulus
73
- end
68
+ pars = @parameters begin bulk_modulus = bulk_modulus end
74
69
75
70
systems = @named begin
76
- fluid = IC. HydraulicFluid (;bulk_modulus)
77
- stp = B. Step (; height = 10e5 , offset = 0 , start_time = 0.05 , duration = Inf , smooth = 0.001 )
71
+ fluid = IC. HydraulicFluid (; bulk_modulus)
72
+ stp = B. Step (; height = 10e5 , offset = 0 , start_time = 0.05 , duration = Inf ,
73
+ smooth = 0.001 )
78
74
src = IC. InputSource (; p_int = 0 )
79
- vol1 = IC. DynamicVolume (; p_int = 0 , area= 0.01 , direction= + 1 )
80
- vol2 = IC. DynamicVolume (; p_int = 0 , area= 0.01 , direction= - 1 , x_int= 1.0 )
81
- mass = T. Mass (; m= 1000 , s_0= 0 )
75
+ vol1 = IC. DynamicVolume (; p_int = 0 , area = 0.01 , direction = + 1 )
76
+ vol2 = IC. DynamicVolume (; p_int = 0 , area = 0.01 , direction = - 1 , x_int = 1.0 )
77
+ mass = T. Mass (; m = 1000 , s_0 = 0 )
82
78
res = IC. PipeBase (; p_int = 0 , area = 0.001 , length = 50.0 )
83
- cap = IC. Cap (;p_int= 0 )
79
+ cap = IC. Cap (; p_int = 0 )
84
80
end
85
81
86
- eqs = [ connect (stp. output, src. input)
87
- connect (fluid, src. port, cap. port)
88
- connect (src. port, res. port_a)
89
- connect (res. port_b, vol1. port)
90
- connect (vol1. flange, mass. flange, vol2. flange)
91
- connect (vol2. port, cap. port)]
82
+ eqs = [connect (stp. output, src. input)
83
+ connect (fluid, src. port, cap. port)
84
+ connect (src. port, res. port_a)
85
+ connect (res. port_b, vol1. port)
86
+ connect (vol1. flange, mass. flange, vol2. flange)
87
+ connect (vol2. port, cap. port)]
92
88
93
89
ODESystem (eqs, t, [], pars; name, systems)
94
90
end
95
91
96
- @named sys1 = system (; bulk_modulus= 1e9 )
97
- @named sys2 = system (; bulk_modulus= 2e9 )
92
+ @named sys1 = system (; bulk_modulus = 1e9 )
93
+ @named sys2 = system (; bulk_modulus = 2e9 )
98
94
99
95
syss = structural_simplify .([sys1, sys2])
100
96
probs = [ODEProblem (sys, [], (0 , 0.2 )) for sys in syss];
101
97
dt = 1e-4
102
- sols = [solve (prob, ImplicitEuler (nlsolve= NEWTON); adaptive= false , dt, initializealg= NoInit ()) for prob in probs];
98
+ sols = [solve (prob, ImplicitEuler (nlsolve = NEWTON); adaptive = false , dt,
99
+ initializealg = NoInit ()) for prob in probs];
103
100
104
101
s1 = complete (sys1)
105
102
s2 = complete (sys2)
106
103
107
104
# less stiff will compress more
108
105
@test maximum (sols[1 ][s1. mass. s]) > maximum (sols[2 ][s2. mass. s])
109
106
110
-
111
107
# fig = Figure()
112
108
# ax = Axis(fig[1,1])
113
109
# lines!(ax, sols[1].t, sols[1][s1.src.port.p]; label="sorce", color=:black)
@@ -117,15 +113,13 @@ s2 = complete(sys2)
117
113
# Legend(fig[1,2], ax)
118
114
# fig
119
115
120
-
121
116
# fig = Figure()
122
117
# ax = Axis(fig[1,1])
123
118
# scatterlines!(ax, sols[1].t, sols[1][s1.mass.s]; label="bulk=1e9")
124
119
# scatterlines!(ax, sols[2].t, sols[2][s2.mass.s]; label="bulk=2e9")
125
120
# Legend(fig[1,2], ax)
126
121
# fig
127
122
128
-
129
123
# fig = Figure()
130
124
# ax = Axis(fig[1,1])
131
125
# lines!(ax, sols[1].t, sols[1][s1.vol1.dx]; label="bulk=2e9")
0 commit comments