Skip to content

Commit

Permalink
more updates for julia v 1.x.x
Browse files Browse the repository at this point in the history
  • Loading branch information
grasingerm committed May 16, 2022
1 parent 4f8c9bf commit 9ccbd3d
Show file tree
Hide file tree
Showing 17 changed files with 1,642 additions and 35 deletions.
17 changes: 9 additions & 8 deletions example_sims/free-surface/pipe/pipe_with_obs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ version: 1.0.0
preamble: >
@init_plot_env();
const datadir = joinpath("data", "pipe_with_obs");
const nu = 0.2;
const constit_rel_f = init_constit_srt_const(nu);
const nuv = 0.2;
const constit_rel_f = init_constit_srt_const(nuv);
const F = [2.0e-6; -0.0e-6];
const forcing_kf = init_sukop_gravity_Fk(F);
const ni = 16;
const forcing_kf = init_sukop_Fk(F);
const ni = 64;
const nj = 64;
const nsteps = 200000;
const obs1 = [8; 16; 1; 8];
# data directory
datadir: { value: datadir, expr: true }

# material properties
rho_0: { value: 1.0, expr: false }
nu: { value: nu, expr: true }
nu: { value: nuv, expr: true }

# lattice parameters
dx: { value: 1.0, expr: false }
Expand All @@ -32,7 +33,7 @@ nsteps: { value: nsteps, expr: true }
# obstacles
obstacles:
- type: bounce_back
coords: "[8; 16; 0; 8]"
coords: obs1

# boundary conditions
bcs:
Expand All @@ -48,7 +49,7 @@ fill_y: { value: 1.0, expr: false }
# callback functions
callbacks:
- print_step_callback(50, "free-surf")
- 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])
- 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])
- write_jld_file_callback(datadir, 500)

# clean-up, backup, write out
Expand All @@ -73,5 +74,5 @@ finally:
end
print_with_color(:green, "TEST PASSED\n");
end
- plot_mass_contours_callback(1, joinpath(datadir, "mass"))
- 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])
- write_jld_file_callback(datadir)
110 changes: 110 additions & 0 deletions example_sims/free-surface/pipe/tow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
version: 1.0.0

preamble: >
@init_plot_env();
const datadir = joinpath("data", "tow");
const nuv = 0.2;
const constit_rel_f = init_constit_srt_const(nuv);
const F = [2.0e-6; -0.0e-6];
const forcing_kf = init_sukop_Fk(F);
const ni = 128;
const nj = 128;
const nsteps = 200000;
const obssize = 10;
const gapsize = 5;
const obs1 = Int[ni/2 - obssize/2; ni/2 + obssize/2; nj/2 - obssize/2; nj/2 + obssize/2];
const oset = obssize+gapsize;
const obs2 = obs1 + Int[oset; oset; 0; 0];
const obs3 = obs1 + Int[oset; oset; -oset; -oset];
const obs4 = obs1 + Int[0; 0; -oset; -oset];
const obs5 = obs1 + Int[-oset; -oset; -oset; -oset];
const obs6 = obs1 + Int[-oset; -oset; 0; 0];
const obs7 = obs1 + Int[-oset; -oset; oset; oset];
const obs8 = obs1 + Int[0; 0; oset; oset];
const obs9 = obs1 + Int[oset; oset; oset; oset];
const rects = map(x -> [x[3]; x[4]; x[1]/ni; x[2]/ni], Vector[obs1, obs2, obs3, obs4, obs5, obs6, obs7, obs8, obs9]);
const levels = [-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5];
# data directory
datadir: { value: datadir, expr: true }

# material properties
rho_0: { value: 1.0, expr: false }
nu: { value: nuv, expr: true }

# lattice parameters
dx: { value: 1.0, expr: false }
dt: { value: 1.0, expr: false }
ni: { value: ni, expr: true }
nj: { value: nj, expr: true }

# simulation parameters
simtype: free_surface
col_f: BGK_F(constit_rel_f, forcing_kf);
nsteps: { value: nsteps, expr: true }

# obstacles
obstacles:
- type: bounce_back
coords: obs1
- type: bounce_back
coords: obs2
- type: bounce_back
coords: obs3
- type: bounce_back
coords: obs4
- type: bounce_back
coords: obs5
- type: bounce_back
coords: obs6
- type: bounce_back
coords: obs7
- type: bounce_back
coords: obs8
- type: bounce_back
coords: obs9

# boundary conditions
bcs:
- north_bounce_back!
- east_bounce_back!
- south_bounce_back!
- (sim) -> east_pressure!(sim, 1.0);
- (sim) -> mass_inlet!(sim, 1, 1:nj, 1.0)

# free surface conditions
rho_g: 1.0

fill_x: { value: 0.1, expr: false }
fill_y: { value: 1.0, expr: false }

# callback functions
callbacks:
- print_step_callback(100, "tow")
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true)
- write_jld_file_callback(datadir, 500)

# clean-up, backup, write out
finally:
- >
(sim::FreeSurfSim, k::Int) -> begin
@assert(k == nsteps, "There was an error that ended the simulation early");
for m in sim.tracker.M
@assert(-100 < m < 100, "Mass was numerically unstable");
end
for u in sim.msm.u
@assert(-100 < u < 100, "Velocity was numerically unstable");
end
for ρ in sim.msm.rho
@assert(-100 < ρ < 100, "ρ was numerically unstable");
end
for f in sim.lat.f
@assert(-100 < f < 100, "f was numerically unstable");
end
for ϵ in sim.tracker.eps
@assert(-10 < ϵ < 10, "ϵ was numerically unstable");
end
print_with_color(:green, "TEST PASSED\n");
end
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true)
- write_jld_file_callback(datadir)
6 changes: 3 additions & 3 deletions inc/col/mrt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ function (col_f::MRT_F)(sim::FreeSurfSim, active_cells::AbstractMatrix{Bool})

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

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

# update collision frequency matrix
@inbounds msm.omega[i,j] = omega;
@inbounds msm.omega[i,j] = omegav;

end
end
Expand Down
36 changes: 12 additions & 24 deletions inc/io/animate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,18 @@ function pycontour_callback(stepout::Real, accessor::LBXFunction;
mat = accessor(sim);

PyPlot.clf();
if filled
if colorbar
if levels != false
cs = PyPlot.contourf(mat, levels=levels);
PyPlot.colorbar(cs);
else
cs = PyPlot.contourf(mat);
PyPlot.colorbar(cs);
end
else
cs = PyPlot.contourf(mat)
end
else
if colorbar
if levels != false
cs = PyPlot.contour(mat, levels=levels);
PyPlot.colorbar(cs);
else
cs = PyPlot.contour(mat);
PyPlot.colorbar(cs);
end
else
cs = PyPlot.contour(mat)
end
cs = if filled && levels != false;
PyPlot.contourf(mat, levels=levels);
elseif !filled && levels != false
PyPlot.contour(mat, levels=levels);
elseif filled
PyPlot.contourf(mat);
else
PyPlot.contour(mat)
end

if colorbar
PyPlot.colorbar(cs);
end

if title != ""
Expand Down
121 changes: 121 additions & 0 deletions publication_sims/tows/archive/tow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
version: 1.0.0

preamble: >
@init_plot_env();
const datadir = joinpath("data", "tow");
const nuv = 0.2;
const constit_rel_f = init_constit_srt_const(nuv);
const F = [2.0e-6; -0.0e-6];
const forcing_kf = init_sukop_Fk(F);
const ni = 128;
const nj = 128;
const nsteps = 40000;
const obssize = 10;
const gapsize = 5;
const obs1 = Int[ni/2 - obssize/2; ni/2 + obssize/2; nj/2 - obssize/2; nj/2 + obssize/2];
const oset = obssize+gapsize;
const obs2 = obs1 + Int[oset; oset; 0; 0];
const obs3 = obs1 + Int[oset; oset; -oset; -oset];
const obs4 = obs1 + Int[0; 0; -oset; -oset];
const obs5 = obs1 + Int[-oset; -oset; -oset; -oset];
const obs6 = obs1 + Int[-oset; -oset; 0; 0];
const obs7 = obs1 + Int[-oset; -oset; oset; oset];
const obs8 = obs1 + Int[0; 0; oset; oset];
const obs9 = obs1 + Int[oset; oset; oset; oset];
const rects = map(x -> [x[3]; x[4]; x[1]/ni; x[2]/ni], Vector[obs1, obs2, obs3, obs4, obs5, obs6, obs7, obs8, obs9]);
const levels = [-0.5; 0.0; 0.5; 1.0; 1.5; 2.0; 2.5];
const inletsize = 3*obssize + 2*gapsize;
const outletsize = 3*obssize + 2*gapsize;
const inletrange = (Int(nj/2 - inletsize/2), Int(nj/2 + inletsize/2));
const outletrange = (Int(nj/2 - inletsize/2), Int(nj/2 + inletsize/2));
# data directory
datadir: { value: datadir, expr: true }

# material properties
rho_0: { value: 1.0, expr: false }
nu: { value: nuv, expr: true }

# lattice parameters
dx: { value: 1.0, expr: false }
dt: { value: 1.0, expr: false }
ni: { value: ni, expr: true }
nj: { value: nj, expr: true }

# simulation parameters
simtype: free_surface
col_f: BGK_F(constit_rel_f, forcing_kf);
nsteps: { value: nsteps, expr: true }

# obstacles
obstacles:
- type: bounce_back
coords: obs1
- type: bounce_back
coords: obs2
- type: bounce_back
coords: obs3
- type: bounce_back
coords: obs4
- type: bounce_back
coords: obs5
- type: bounce_back
coords: obs6
- type: bounce_back
coords: obs7
- type: bounce_back
coords: obs8
- type: bounce_back
coords: obs9

# boundary conditions
bcs:
- north_bounce_back!
- (sim) -> east_bounce_back!(sim.lat, ni, 1, outletrange[1]-1);
- (sim) -> east_pressure!(sim.lat, 0.0, ni, outletrange[1], outletrange[2]);
- (sim) -> mass_inlet!(sim, ni, outletrange[1]:outletrange[2], 0.0)
- (sim) -> east_bounce_back!(sim.lat, ni, outletrange[2]+1, nj);
- south_bounce_back!
- (sim) -> west_pressure!(sim, 1.0);
- (sim) -> west_mass_inlet!(sim, 1.0)
# - (sim) -> west_bounce_back!(sim.lat, 1, 1, inletrange[1]-1);
# - (sim) -> west_pressure!(sim.lat, 0.0, 1, inletrange[1], inletrange[2]);
# - (sim) -> mass_inlet!(sim, 1, inletrange[1]:inletrange[2], 0.0)
# - (sim) -> west_bounce_back!(sim.lat, 1, inletrange[2]+1, nj);

# free surface conditions
rho_g: 1.0

fill_x: { value: 0.1, expr: false }
fill_y: { value: 1.0, expr: false }

# callback functions
callbacks:
- print_step_callback(100, "tow")
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true, title="\$n = 1.0\$")
- write_jld_file_callback(datadir, 500)

# clean-up, backup, write out
finally:
- >
(sim::FreeSurfSim, k::Int) -> begin
@assert(k == nsteps, "There was an error that ended the simulation early");
for m in sim.tracker.M
@assert(-100 < m < 100, "Mass was numerically unstable");
end
for u in sim.msm.u
@assert(-100 < u < 100, "Velocity was numerically unstable");
end
for ρ in sim.msm.rho
@assert(-100 < ρ < 100, "ρ was numerically unstable");
end
for f in sim.lat.f
@assert(-100 < f < 100, "f was numerically unstable");
end
for ϵ in sim.tracker.eps
@assert(-10 < ϵ < 10, "ϵ was numerically unstable");
end
print_with_color(:green, "TEST PASSED\n");
end
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=rects, levels=levels, colorbar=true)
- write_jld_file_callback(datadir)
Loading

0 comments on commit 9ccbd3d

Please sign in to comment.