Skip to content

Commit 9ccbd3d

Browse files
committed
more updates for julia v 1.x.x
1 parent 4f8c9bf commit 9ccbd3d

File tree

17 files changed

+1642
-35
lines changed

17 files changed

+1642
-35
lines changed

example_sims/free-surface/pipe/pipe_with_obs.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@ version: 1.0.0
33
preamble: >
44
@init_plot_env();
55
const datadir = joinpath("data", "pipe_with_obs");
6-
const nu = 0.2;
7-
const constit_rel_f = init_constit_srt_const(nu);
6+
const nuv = 0.2;
7+
const constit_rel_f = init_constit_srt_const(nuv);
88
const F = [2.0e-6; -0.0e-6];
9-
const forcing_kf = init_sukop_gravity_Fk(F);
10-
const ni = 16;
9+
const forcing_kf = init_sukop_Fk(F);
10+
const ni = 64;
1111
const nj = 64;
1212
const nsteps = 200000;
13+
const obs1 = [8; 16; 1; 8];
1314
1415
# data directory
1516
datadir: { value: datadir, expr: true }
1617

1718
# material properties
1819
rho_0: { value: 1.0, expr: false }
19-
nu: { value: nu, expr: true }
20+
nu: { value: nuv, expr: true }
2021

2122
# lattice parameters
2223
dx: { value: 1.0, expr: false }
@@ -32,7 +33,7 @@ nsteps: { value: nsteps, expr: true }
3233
# obstacles
3334
obstacles:
3435
- type: bounce_back
35-
coords: "[8; 16; 0; 8]"
36+
coords: obs1
3637

3738
# boundary conditions
3839
bcs:
@@ -48,7 +49,7 @@ fill_y: { value: 1.0, expr: false }
4849
# callback functions
4950
callbacks:
5051
- print_step_callback(50, "free-surf")
51-
- plot_mass_contours_callback(200, joinpath(datadir, "mass"), [(1, 8, 8/ni, 16/ni)]; levs=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5])
52+
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(1, 8, 8/ni, 16/ni)], levels=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5])
5253
- write_jld_file_callback(datadir, 500)
5354

5455
# clean-up, backup, write out
@@ -73,5 +74,5 @@ finally:
7374
end
7475
print_with_color(:green, "TEST PASSED\n");
7576
end
76-
- plot_mass_contours_callback(1, joinpath(datadir, "mass"))
77+
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(1, 8, 8/ni, 16/ni)], levels=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5])
7778
- write_jld_file_callback(datadir)
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
version: 1.0.0
2+
3+
preamble: >
4+
@init_plot_env();
5+
const datadir = joinpath("data", "tow");
6+
const nuv = 0.2;
7+
const constit_rel_f = init_constit_srt_const(nuv);
8+
const F = [2.0e-6; -0.0e-6];
9+
const forcing_kf = init_sukop_Fk(F);
10+
const ni = 128;
11+
const nj = 128;
12+
const nsteps = 200000;
13+
const obssize = 10;
14+
const gapsize = 5;
15+
const obs1 = Int[ni/2 - obssize/2; ni/2 + obssize/2; nj/2 - obssize/2; nj/2 + obssize/2];
16+
const oset = obssize+gapsize;
17+
const obs2 = obs1 + Int[oset; oset; 0; 0];
18+
const obs3 = obs1 + Int[oset; oset; -oset; -oset];
19+
const obs4 = obs1 + Int[0; 0; -oset; -oset];
20+
const obs5 = obs1 + Int[-oset; -oset; -oset; -oset];
21+
const obs6 = obs1 + Int[-oset; -oset; 0; 0];
22+
const obs7 = obs1 + Int[-oset; -oset; oset; oset];
23+
const obs8 = obs1 + Int[0; 0; oset; oset];
24+
const obs9 = obs1 + Int[oset; oset; oset; oset];
25+
const rects = map(x -> [x[3]; x[4]; x[1]/ni; x[2]/ni], Vector[obs1, obs2, obs3, obs4, obs5, obs6, obs7, obs8, obs9]);
26+
const levels = [-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5];
27+
28+
# data directory
29+
datadir: { value: datadir, expr: true }
30+
31+
# material properties
32+
rho_0: { value: 1.0, expr: false }
33+
nu: { value: nuv, expr: true }
34+
35+
# lattice parameters
36+
dx: { value: 1.0, expr: false }
37+
dt: { value: 1.0, expr: false }
38+
ni: { value: ni, expr: true }
39+
nj: { value: nj, expr: true }
40+
41+
# simulation parameters
42+
simtype: free_surface
43+
col_f: BGK_F(constit_rel_f, forcing_kf);
44+
nsteps: { value: nsteps, expr: true }
45+
46+
# obstacles
47+
obstacles:
48+
- type: bounce_back
49+
coords: obs1
50+
- type: bounce_back
51+
coords: obs2
52+
- type: bounce_back
53+
coords: obs3
54+
- type: bounce_back
55+
coords: obs4
56+
- type: bounce_back
57+
coords: obs5
58+
- type: bounce_back
59+
coords: obs6
60+
- type: bounce_back
61+
coords: obs7
62+
- type: bounce_back
63+
coords: obs8
64+
- type: bounce_back
65+
coords: obs9
66+
67+
# boundary conditions
68+
bcs:
69+
- north_bounce_back!
70+
- east_bounce_back!
71+
- south_bounce_back!
72+
- (sim) -> east_pressure!(sim, 1.0);
73+
- (sim) -> mass_inlet!(sim, 1, 1:nj, 1.0)
74+
75+
# free surface conditions
76+
rho_g: 1.0
77+
78+
fill_x: { value: 0.1, expr: false }
79+
fill_y: { value: 1.0, expr: false }
80+
81+
# callback functions
82+
callbacks:
83+
- print_step_callback(100, "tow")
84+
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true)
85+
- write_jld_file_callback(datadir, 500)
86+
87+
# clean-up, backup, write out
88+
finally:
89+
- >
90+
(sim::FreeSurfSim, k::Int) -> begin
91+
@assert(k == nsteps, "There was an error that ended the simulation early");
92+
for m in sim.tracker.M
93+
@assert(-100 < m < 100, "Mass was numerically unstable");
94+
end
95+
for u in sim.msm.u
96+
@assert(-100 < u < 100, "Velocity was numerically unstable");
97+
end
98+
for ρ in sim.msm.rho
99+
@assert(-100 < ρ < 100, "ρ was numerically unstable");
100+
end
101+
for f in sim.lat.f
102+
@assert(-100 < f < 100, "f was numerically unstable");
103+
end
104+
for ϵ in sim.tracker.eps
105+
@assert(-10 < ϵ < 10, "ϵ was numerically unstable");
106+
end
107+
print_with_color(:green, "TEST PASSED\n");
108+
end
109+
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true)
110+
- write_jld_file_callback(datadir)

inc/col/mrt.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,14 @@ function (col_f::MRT_F)(sim::FreeSurfSim, active_cells::AbstractMatrix{Bool})
332332

333333
mu = col_f.constit_relation_f(sim, fneq, col_f.S, col_f.M,
334334
col_f.iM, i, j);
335-
omega = omega(mu, lat.cssq, lat.dt);
335+
omegav= omega(mu, lat.cssq, lat.dt);
336336
Sij = col_f.S(mu, rhoij, lat.cssq, lat.dt);
337-
F = map(k -> col_f.forcing_f[2](sim, omega, k, i, j), 1:lat.n);
337+
F = map(k -> col_f.forcing_f[2](sim, omegav, k, i, j), 1:lat.n);
338338

339339
@inbounds lat.f[:,i,j] -= col_f.iM * Sij * col_f.M * fneq - F;
340340

341341
# update collision frequency matrix
342-
@inbounds msm.omega[i,j] = omega;
342+
@inbounds msm.omega[i,j] = omegav;
343343

344344
end
345345
end

inc/io/animate.jl

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -193,30 +193,18 @@ function pycontour_callback(stepout::Real, accessor::LBXFunction;
193193
mat = accessor(sim);
194194

195195
PyPlot.clf();
196-
if filled
197-
if colorbar
198-
if levels != false
199-
cs = PyPlot.contourf(mat, levels=levels);
200-
PyPlot.colorbar(cs);
201-
else
202-
cs = PyPlot.contourf(mat);
203-
PyPlot.colorbar(cs);
204-
end
205-
else
206-
cs = PyPlot.contourf(mat)
207-
end
208-
else
209-
if colorbar
210-
if levels != false
211-
cs = PyPlot.contour(mat, levels=levels);
212-
PyPlot.colorbar(cs);
213-
else
214-
cs = PyPlot.contour(mat);
215-
PyPlot.colorbar(cs);
216-
end
217-
else
218-
cs = PyPlot.contour(mat)
219-
end
196+
cs = if filled && levels != false;
197+
PyPlot.contourf(mat, levels=levels);
198+
elseif !filled && levels != false
199+
PyPlot.contour(mat, levels=levels);
200+
elseif filled
201+
PyPlot.contourf(mat);
202+
else
203+
PyPlot.contour(mat)
204+
end
205+
206+
if colorbar
207+
PyPlot.colorbar(cs);
220208
end
221209

222210
if title != ""
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
version: 1.0.0
2+
3+
preamble: >
4+
@init_plot_env();
5+
const datadir = joinpath("data", "tow");
6+
const nuv = 0.2;
7+
const constit_rel_f = init_constit_srt_const(nuv);
8+
const F = [2.0e-6; -0.0e-6];
9+
const forcing_kf = init_sukop_Fk(F);
10+
const ni = 128;
11+
const nj = 128;
12+
const nsteps = 40000;
13+
const obssize = 10;
14+
const gapsize = 5;
15+
const obs1 = Int[ni/2 - obssize/2; ni/2 + obssize/2; nj/2 - obssize/2; nj/2 + obssize/2];
16+
const oset = obssize+gapsize;
17+
const obs2 = obs1 + Int[oset; oset; 0; 0];
18+
const obs3 = obs1 + Int[oset; oset; -oset; -oset];
19+
const obs4 = obs1 + Int[0; 0; -oset; -oset];
20+
const obs5 = obs1 + Int[-oset; -oset; -oset; -oset];
21+
const obs6 = obs1 + Int[-oset; -oset; 0; 0];
22+
const obs7 = obs1 + Int[-oset; -oset; oset; oset];
23+
const obs8 = obs1 + Int[0; 0; oset; oset];
24+
const obs9 = obs1 + Int[oset; oset; oset; oset];
25+
const rects = map(x -> [x[3]; x[4]; x[1]/ni; x[2]/ni], Vector[obs1, obs2, obs3, obs4, obs5, obs6, obs7, obs8, obs9]);
26+
const levels = [-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5];
27+
const inletsize = 3*obssize + 2*gapsize;
28+
const outletsize = 3*obssize + 2*gapsize;
29+
const inletrange = (Int(nj/2 - inletsize/2), Int(nj/2 + inletsize/2));
30+
const outletrange = (Int(nj/2 - inletsize/2), Int(nj/2 + inletsize/2));
31+
32+
# data directory
33+
datadir: { value: datadir, expr: true }
34+
35+
# material properties
36+
rho_0: { value: 1.0, expr: false }
37+
nu: { value: nuv, expr: true }
38+
39+
# lattice parameters
40+
dx: { value: 1.0, expr: false }
41+
dt: { value: 1.0, expr: false }
42+
ni: { value: ni, expr: true }
43+
nj: { value: nj, expr: true }
44+
45+
# simulation parameters
46+
simtype: free_surface
47+
col_f: BGK_F(constit_rel_f, forcing_kf);
48+
nsteps: { value: nsteps, expr: true }
49+
50+
# obstacles
51+
obstacles:
52+
- type: bounce_back
53+
coords: obs1
54+
- type: bounce_back
55+
coords: obs2
56+
- type: bounce_back
57+
coords: obs3
58+
- type: bounce_back
59+
coords: obs4
60+
- type: bounce_back
61+
coords: obs5
62+
- type: bounce_back
63+
coords: obs6
64+
- type: bounce_back
65+
coords: obs7
66+
- type: bounce_back
67+
coords: obs8
68+
- type: bounce_back
69+
coords: obs9
70+
71+
# boundary conditions
72+
bcs:
73+
- north_bounce_back!
74+
- (sim) -> east_bounce_back!(sim.lat, ni, 1, outletrange[1]-1);
75+
- (sim) -> east_pressure!(sim.lat, 0.0, ni, outletrange[1], outletrange[2]);
76+
- (sim) -> mass_inlet!(sim, ni, outletrange[1]:outletrange[2], 0.0)
77+
- (sim) -> east_bounce_back!(sim.lat, ni, outletrange[2]+1, nj);
78+
- south_bounce_back!
79+
- (sim) -> west_pressure!(sim, 1.0);
80+
- (sim) -> west_mass_inlet!(sim, 1.0)
81+
# - (sim) -> west_bounce_back!(sim.lat, 1, 1, inletrange[1]-1);
82+
# - (sim) -> west_pressure!(sim.lat, 0.0, 1, inletrange[1], inletrange[2]);
83+
# - (sim) -> mass_inlet!(sim, 1, inletrange[1]:inletrange[2], 0.0)
84+
# - (sim) -> west_bounce_back!(sim.lat, 1, inletrange[2]+1, nj);
85+
86+
# free surface conditions
87+
rho_g: 1.0
88+
89+
fill_x: { value: 0.1, expr: false }
90+
fill_y: { value: 1.0, expr: false }
91+
92+
# callback functions
93+
callbacks:
94+
- print_step_callback(100, "tow")
95+
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true, title="\$n = 1.0\$")
96+
- write_jld_file_callback(datadir, 500)
97+
98+
# clean-up, backup, write out
99+
finally:
100+
- >
101+
(sim::FreeSurfSim, k::Int) -> begin
102+
@assert(k == nsteps, "There was an error that ended the simulation early");
103+
for m in sim.tracker.M
104+
@assert(-100 < m < 100, "Mass was numerically unstable");
105+
end
106+
for u in sim.msm.u
107+
@assert(-100 < u < 100, "Velocity was numerically unstable");
108+
end
109+
for ρ in sim.msm.rho
110+
@assert(-100 < ρ < 100, "ρ was numerically unstable");
111+
end
112+
for f in sim.lat.f
113+
@assert(-100 < f < 100, "f was numerically unstable");
114+
end
115+
for ϵ in sim.tracker.eps
116+
@assert(-10 < ϵ < 10, "ϵ was numerically unstable");
117+
end
118+
print_with_color(:green, "TEST PASSED\n");
119+
end
120+
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true)
121+
- write_jld_file_callback(datadir)

0 commit comments

Comments
 (0)