Skip to content

Commit 15bf96b

Browse files
committed
Debugging Fluid Domain and Tube Test
The multi volume tube does not solve successfully.
1 parent 882d3f2 commit 15bf96b

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/Hydraulic/IsothermalCompressible/components.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ Fixed fluid volume.
414414
end
415415

416416
vars = @variables begin
417-
rho(t)#, [guess = liquid_density(port)]
417+
rho(t), [guess = liquid_density(port)]
418418
drho(t), [guess = 0]
419419
end
420420

test/Hydraulic/isothermal_compressible.jl

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ NEWTON = NLNewton(check_div = false, always_new = true, max_iter = 100, relax =
1717
systems = @named begin
1818
fluid = IC.HydraulicFluid(; bulk_modulus)
1919
stp = B.Step(; height = 2*101325, offset = 101325, start_time = 0.05, duration = Inf,
20-
smooth = true)
20+
smooth = false)
2121
src = IC.Pressure(;)
2222
vol = IC.FixedVolume(; vol = 10.0)
2323
res = IC.Tube(N; area = 0.01, length = 50.0)
@@ -33,7 +33,7 @@ NEWTON = NLNewton(check_div = false, always_new = true, max_iter = 100, relax =
3333

3434
@named sys1_2 = System(1; bulk_modulus = 2e9)
3535
@named sys1_1 = System(1; bulk_modulus = 1e7)
36-
@named sys5_1 = System(5; bulk_modulus = 1e9)
36+
@named sys5_1 = System(2; bulk_modulus = 1e9)
3737

3838
# syss = structural_simplify.([sys1_2, sys1_1, sys5_1])
3939

@@ -46,51 +46,52 @@ NEWTON = NLNewton(check_div = false, always_new = true, max_iter = 100, relax =
4646
initsys1_1 = structural_simplify(initsys1_1)
4747
initprob1_1 = NonlinearProblem(initsys1_1, [t=>0])
4848
initsol1_1 = solve(initprob1_1)
49-
initsol1_1[sys.src.port.p]
50-
initsol1_1[sys.src.port.dm]
51-
initsol1_1[sys.vol.port.p]
49+
initsol1_1[sys1_1.src.port.p]
50+
initsol1_1[sys1_1.src.port.dm]
51+
initsol1_1[sys1_1.vol.port.p]
5252
# probs = [ODEProblem(sys, ModelingToolkit.missing_variable_defaults(sys), (0, 0.05))
5353
# for sys in syss] #
54-
prob1_1 = ODEProblem(sys1_1, ModelingToolkit.missing_variable_defaults(sys), (0, 1.05))
54+
# prob1_1 = ODEProblem(sys1_1, ModelingToolkit.missing_variable_defaults(sys), (0, 1.05))
55+
prob1_1 = ODEProblem(sys1_1, [], (0, 50); initialization_eqs)
5556
#
5657

5758
# sols = [solve(prob, ImplicitEuler(nlsolve = NEWTON); dt = 1e-4, adaptive = false)
5859
# for prob in probs]
5960

60-
sol1_1 = solve(prob1_1, ImplicitEuler(nlsolve = NEWTON); dt = 1e-4, adaptive = false)
61+
sol1_1 = solve(prob1_1)
6162

6263
# s1_2 = complete(sys1_2)
6364
s1_1 = complete(sys1_1)
6465
# s5_1 = complete(sys5_1)
6566

6667
# system 1_2
6768
sys1_2 = structural_simplify(sys1_2)
68-
initialization_eqs = [sys1_2.vol.port.p ~ 101800, sys1_2.res.port_a.dm ~ 0]
69+
initialization_eqs = [sys1_2.vol.port.p ~ 101325, sys1_2.res.port_a.dm ~ 0]
6970
initsys1_2 = ModelingToolkit.generate_initializesystem(sys1_2;initialization_eqs)
7071

7172
initsys1_2 = structural_simplify(initsys1_2)
7273
initprob1_2 = NonlinearProblem(initsys1_2, [t=>0])
7374
initsol1_2 = solve(initprob1_2)
7475

75-
prob1_2 = ODEProblem(sys1_2, ModelingToolkit.missing_variable_defaults(sys), (0, 1.05))
76-
sol1_2 = solve(prob1_2, ImplicitEuler(nlsolve = NEWTON); dt = 1e-4, adaptive = false)
76+
prob1_2 = ODEProblem(sys1_2, [], (0, 50); initialization_eqs)
77+
sol1_2 = solve(prob1_2)
7778
s1_2 = complete(sys1_2)
7879
# system 5-1
7980

8081
sys5_1 = structural_simplify(sys5_1)
81-
initialization_eqs = [sys5_1.vol.port.p ~ 101325,sys5_1.res.p1.port_a.dm ~ 0,
82-
sys5_1.res.p2.port_a.dm ~ 0,sys5_1.res.p3.port_a.dm ~ 0, sys5_1.res.p4.port_a.dm ~ 0,
83-
sys5_1.res.p1.port_a.p ~ 101325,
84-
sys5_1.res.p2.port_a.p ~ 101325,
85-
sys5_1.src.port.dm~0]
82+
# initialization_eqs = [sys5_1.vol.port.p ~ 101325,sys5_1.res.p1.port_a.dm ~ 0,
83+
# sys5_1.res.v2.port.p ~ 101325,sys5_1.res.v2.port.dm ~ 0,
84+
# sys5_1.res.v3.port.p ~ 101325,sys5_1.res.v3.port.dm ~ 0,
85+
# sys5_1.res.v4.port.p ~ 101325,sys5_1.res.v4.port.dm ~ 0]
86+
initialization_eqs = [sys5_1.vol.port.p ~ 101325,sys5_1.res.p1.port_a.dm ~ 0]
8687
initsys5_1 = ModelingToolkit.generate_initializesystem(sys5_1;initialization_eqs)
8788

8889
initsys5_1 = structural_simplify(initsys5_1)
8990
initprob5_1 = NonlinearProblem(initsys5_1, [t=>0])
9091
initsol5_1 = solve(initprob5_1)
9192

92-
prob5_1 = ODEProblem(sys5_1, ModelingToolkit.missing_variable_defaults(sys), (0, 0.05))
93-
sol5_1 = solve(prob5_1, ImplicitEuler(nlsolve = NEWTON); dt = 1e-4, adaptive = false)
93+
prob5_1 = ODEProblem(sys5_1, [], (0, 50); initialization_eqs)
94+
sol5_1 = solve(prob5_1) # This model is unstable whether N=1 or N = 5
9495
s5_1 = complete(sys5_1)
9596

9697
# higher stiffness should compress more quickly and give a higher pressure
@@ -99,14 +100,17 @@ NEWTON = NLNewton(check_div = false, always_new = true, max_iter = 100, relax =
99100
# N=5 pipe is compressible, will pressurize more slowly
100101
@test sols[2][s1_1.vol.port.p][end] > sols[3][s5_1.vol.port.p][end]
101102

103+
using CairoMakie
102104
fig = Figure()
103105
ax = Axis(fig[1,1])
104106
# hlines!(ax, 10e5)
105107
# lines!(ax, sols[1][s1_2.vol.port.p])
106108
# lines!(ax, sols[2][s1_1.vol.port.p])
107109
# lines!(ax, sols[3][s5_1.vol.port.p])
108-
lines!(ax, sol1_1[s1_1.vol.rho])
109-
lines!(ax, sol1_2[s1_2.vol.rho])
110+
#lines!(ax, sol1_1.t, sol1_1[s1_1.vol.port.p])
111+
#lines!(ax, sol1_2.t,sol1_2[s1_2.vol.port.p])
112+
lines!(ax, sol5_1.t,sol5_1[s5_1.vol.port.p])
113+
#lines!(ax, sol1_2[s1_2.vol.rho])
110114
fig
111115

112116
#end

0 commit comments

Comments
 (0)