Skip to content

Commit 1a7f2f0

Browse files
committed
improve study
1 parent ad52b1d commit 1a7f2f0

File tree

1 file changed

+114
-86
lines changed

1 file changed

+114
-86
lines changed

examples/study1/study1.jl

Lines changed: 114 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ do_study = haskey(ENV, "GITHUB_ACTIONS") ? true : false
2121
# | |
2222
# (P1)-(L5)-(P2)
2323
model_square = CartesianDiscreteModel(
24-
(0, 1, 0, 1), haskey(ENV, "GITHUB_ACTIONS") ? (40, 40) : (200, 200)
24+
(0, 1, 0, 1), haskey(ENV, "GITHUB_ACTIONS") ? (40, 40) :
25+
round.(Int, floor.((61, 61).*sqrt(2)^(i-1)))
2526
)
2627
model_squares = [CartesianDiscreteModel(
2728
(0, 1, 0, 1), haskey(ENV, "GITHUB_ACTIONS") ? (40, 40) :
@@ -101,7 +102,7 @@ for (i, case) in enumerate(cases)
101102
name=name*"/Pi",
102103
contourargs=(;levels=[2.0^i for i in -1:1:3]|>x->vcat(-x,x)),
103104
surfaceargs=(;
104-
colormap=:coolwarm
105+
colormap=:turbo
105106
)
106107
) |> display
107108
GeMotion.contourplot_unitsquare(;
@@ -135,10 +136,6 @@ end
135136
if do_study
136137
begin
137138
scale = 1.5
138-
f = Figure(
139-
size=scale .* (600, 250),
140-
figure_padding= (0,10,0,0)
141-
)
142139
nplot_Nu = 100
143140
xs_Nu = LinRange(0.0, 1.0, 2*nplot_Nu)[1:end]
144141

@@ -147,46 +144,67 @@ if do_study
147144
4:6
148145
])) do (i_indices, indices)
149146

150-
ax = Axis(
151-
f[1, i_indices],
152-
title=i_indices==1 ? "inner wall, uniform heating" : "inner wall, non-uniform heating",
153-
xlabel="position x",
154-
ylabel="Nusselt number Nu",
155-
xminorticksvisible=true,
156-
yminorticksvisible=true,
157-
xticks=LinearTicks(5),
158-
yticks=LinearTicks(5),
159-
limits=((0.0, 1.0), (0,20))
160-
)
147+
map(["left", "bottom"]) do wall
161148

162-
map(outs1[indices]) do o
163-
nb = get_normal_vector(o.btrian)
164-
NUU = Interpolable(
165-
# get (-dT/dr) with a transformation to polar coordinates
166-
(- (o.Th) (x->VectorValue([0.0,1.0])));
167-
searchmethod=KDTreeSearch(num_nearest_vertices=500)
149+
150+
f = Figure(
151+
size=scale .* (250, 250),
152+
figure_padding= (0,10,0,0)
168153
)
169-
cache = return_cache(NUU, Gridap.Point(0.0, 0.0))
170-
Nu_inner = [
171-
evaluate!(cache, NUU, Gridap.Point([x, 0.0]))
172-
for x in xs_Nu
173-
]
174-
@info sum(Nu_inner[1:end-1])/length(Nu_inner[1:end-1])
175-
lines!(
176-
xs_Nu,
177-
Nu_inner,
178-
label="n = $(o.n)",
154+
ax = Axis(
155+
f[1, 1],
156+
title=(
157+
wall * " wall, " * (i_indices==1 ? "uniform heating" : "non-uniform heating")
158+
),
159+
xlabel="position " * (wall=="left" ? "y" : "x"),
160+
ylabel="Nusselt number Nu",
161+
xminorticksvisible=true,
162+
yminorticksvisible=true,
163+
xticks=LinearTicks(5),
164+
yticks=LinearTicks(5),
165+
limits=((0.0, 1.0), (0,20))
166+
)
167+
168+
map(outs1[indices]) do o
169+
nb = get_normal_vector(o.btrian)
170+
NUU = Interpolable(
171+
# get (-dT/dr) with a transformation to polar coordinates
172+
(- (o.Th) (
173+
wall=="left" ?
174+
x->VectorValue([-1.0,0.0]) :
175+
x->VectorValue([0.0,1.0])
176+
)); searchmethod=KDTreeSearch(num_nearest_vertices=500)
177+
)
178+
cache = return_cache(NUU, Gridap.Point(0.0, 0.0))
179+
Nu = [
180+
evaluate!(cache, NUU,
181+
wall=="left" ?
182+
Gridap.Point([0.0, x]) :
183+
Gridap.Point([x, 0.0])
184+
)
185+
for x in xs_Nu
186+
]
187+
@info sum(Nu[1:end-1])/length(Nu[1:end-1])
188+
lines!(
189+
xs_Nu,
190+
Nu,
191+
label="n = $(o.n)",
192+
)
193+
CSV.write("nusselt_number_square_$(wall)_$(i_indices)_$(o.n).csv",
194+
DataFrame(pos = xs_Nu, Nu = Nu)
195+
)
196+
end
197+
axislegend(
198+
labelsize=10,
199+
position=:lt,
200+
orientation=:horizontal,
201+
nbanks=1,
179202
)
203+
f |> display
204+
save("nusselt_number_square_$(wall)_$(i_indices).pdf", f)
205+
# export as CSV
180206
end
181-
axislegend(
182-
labelsize=10,
183-
position=:lt,
184-
orientation=:horizontal,
185-
nbanks=1,
186-
)
187207
end
188-
f |> display
189-
save("nusselt_number_square.pdf", f)
190208
end
191209
end
192210

@@ -381,7 +399,7 @@ for (i, case) in enumerate(cases)
381399
fun=out.Pih,
382400
name=name*"/Pi",
383401
contourargs=(;levels=[2.0^i for i in -1:1:3]|>x->vcat(-x,x)),
384-
surfaceargs=(;colormap=:coolwarm)
402+
surfaceargs=(;colormap=:turbo)
385403
) |> display
386404
GeMotion.contourplot_coannulus(
387405
;opts...,
@@ -412,60 +430,70 @@ end
412430
if do_study
413431
begin
414432
scale = 1.5
415-
f = Figure(
416-
size=scale .* (600, 250),
417-
figure_padding= (0,10,0,0)
418-
)
419433
nplot_Nu = 100
420434
phis_Nu = LinRange(0, 2*pi, 2*nplot_Nu)[1:end]
421435

422436
map(enumerate([1:3,4:6])) do (i_indices, indices)
437+
map(["inner", "outer"]) do wall
423438

424-
ax = Axis(
425-
f[1, i_indices],
426-
title = (
427-
"inner wall, $(i_indices == 1 ? "uniform" : "non-uniform") heating"
428-
),
429-
xlabel="angle ϕ",
430-
ylabel="Nusselt number Nu",
431-
xminorticksvisible=true,
432-
yminorticksvisible=true,
433-
xticks = (0:1/2*pi:2*pi, ["0", "π/2", "π", "3π/2", ""]),
434-
yticks=LinearTicks(5),
435-
limits=((0.0, 2*pi), (-0.5,10.5))
436-
)
437-
438-
map(outs2[indices]) do o
439-
nb = get_normal_vector(o.btrian)
440-
Nu = Interpolable(
441-
# get (-dT/dr) with a transformation to polar coordinates
442-
(- (o.Th) (x->VectorValue([x[1],x[2]] / sqrt(x[1]^2 + x[2]^2))));
443-
searchmethod=KDTreeSearch(num_nearest_vertices=50)
439+
f = Figure(
440+
size=scale .* (250, 250),
441+
figure_padding= (0,11,0,0)
444442
)
445-
cache = return_cache(Nu, Gridap.Point(0.0, 0.0))
446-
dist = 0.0
447-
ri = 2/3
448-
Nu_inner = [
449-
evaluate!(
450-
cache, Nu, Gridap.Point([(ri+dist)*cos(p), (ri+dist)*sin(p)])
443+
ax = Axis(
444+
f[1, 1],
445+
title = (
446+
wall * " wall, " * (i_indices==1 ? "uniform" : "non-uniform") *
447+
" heating"
448+
),
449+
xlabel="angle ϕ",
450+
ylabel="Nusselt number Nu",
451+
xminorticksvisible=true,
452+
yminorticksvisible=true,
453+
xticks = (0:1/2*pi:2*pi, ["0", "π/2", "π", "3π/2", ""]),
454+
yticks=LinearTicks(5),
455+
limits=((0.0, 2*pi), (-0.5,13.5))
456+
)
457+
458+
map(outs2[indices]) do o
459+
nb = get_normal_vector(o.btrian)
460+
Nu = Interpolable(
461+
# get (-dT/dr) with a transformation to polar coordinates
462+
(- (o.Th) (x->VectorValue([x[1],x[2]] / sqrt(x[1]^2 + x[2]^2))));
463+
searchmethod=KDTreeSearch(num_nearest_vertices=50)
451464
)
452-
for p in phis_Nu
453-
]
454-
lines!(
455-
phis_Nu,
456-
Nu_inner,
457-
label="n = $(o.n)",
465+
cache = return_cache(Nu, Gridap.Point(0.0, 0.0))
466+
dist = 0
467+
ri = 2/3
468+
ro = 5/3-0.001
469+
Nu = [
470+
evaluate!(
471+
cache, Nu,
472+
wall=="inner" ?
473+
Gridap.Point([(ri+dist)*cos(p), (ri+dist)*sin(p)]) :
474+
Gridap.Point([(ro-dist)*cos(p), (ro-dist)*sin(p)])
475+
)
476+
for p in phis_Nu
477+
]
478+
lines!(
479+
phis_Nu,
480+
Nu,
481+
label="n = $(o.n)",
482+
)
483+
CSV.write("nusselt_number_annulus_$(wall)_$(i_indices)_$(o.n).csv",
484+
DataFrame(pos = xs_Nu, Nu = Nu)
485+
)
486+
end
487+
axislegend(
488+
labelsize=10,
489+
position=:lt,
490+
orientation=:horizontal,
491+
nbanks=1,
458492
)
493+
f |> display
494+
save("nusselt_number_annulus_$(wall)_$(i_indices).pdf", f)
459495
end
460-
axislegend(
461-
labelsize=10,
462-
position=:lt,
463-
orientation=:horizontal,
464-
nbanks=1,
465-
)
466496
end
467-
f |> display
468-
save("nusselt_number_annulus.pdf", f)
469497
end
470498
end
471499

0 commit comments

Comments
 (0)