Skip to content

Commit 56fc69b

Browse files
glwagnernavidcy
andauthored
Make shallow water Bickley jet less expensive (#3180)
* Make shallow water Bickley jet less expensive * A bit more cleanup * slight modification at interval to fit exponential --------- Co-authored-by: Navid C. Constantinou <[email protected]>
1 parent df2304b commit 56fc69b

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

examples/shallow_water_Bickley_jet.jl

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ using Oceananigans.Models: ShallowWaterModel
2828

2929
# ## Two-dimensional domain
3030
#
31-
# The shallow water model is a two-dimensional model and thus the number of vertical
32-
# points `Nz` must be set to one. Note that ``L_z`` is the mean depth of the fluid.
31+
# The shallow water model is two-dimensional and uses grids that are `Flat`
32+
# in the vertical direction. We use length scales non-dimensionalized by the width
33+
# of the Bickley jet.
3334

34-
Lx, Ly, Lz = 2π, 20, 10
35-
Nx, Ny = 128, 128
36-
37-
grid = RectilinearGrid(size = (Nx, Ny),
38-
x = (0, Lx), y = (-Ly/2, Ly/2),
35+
grid = RectilinearGrid(size = (48, 128),
36+
x = (0, 2π),
37+
y = (-10, 10),
3938
topology = (Periodic, Bounded, Flat))
4039

4140
# ## Building a `ShallowWaterModel`
@@ -59,12 +58,13 @@ model = ShallowWaterModel(; grid, coriolis, gravitational_acceleration,
5958
# geostrophically balanced Bickely jet with maximum speed of ``U`` and maximum
6059
# free-surface deformation of ``Δη``,
6160

62-
U = 1 # Maximum jet velocity
61+
U = 1 # Maximum jet velocity
62+
H = 10 # Reference depth
6363
f = coriolis.f
6464
g = gravitational_acceleration
6565
Δη = f * U / g # Maximum free-surface deformation as dictated by geostrophy
6666

67-
(x, y, z) = Lz - Δη * tanh(y)
67+
(x, y, z) = H - Δη * tanh(y)
6868
(x, y, z) = U * sech(y)^2
6969

7070
# The total height of the fluid is ``h = L_z + \eta``. Linear stability theory predicts that
@@ -116,10 +116,10 @@ set!(model, uh = uhⁱ)
116116
# ## Running a `Simulation`
117117
#
118118
# We pick the time-step so that we make sure we resolve the surface gravity waves, which
119-
# propagate with speed of the order ``\sqrt{g L_z}``. That is, with `Δt = 1e-2` we ensure
120-
# that `` \sqrt{g L_z} Δt / Δx, \sqrt{g L_z} Δt / Δy < 0.7``.
119+
# propagate with speed of the order ``\sqrt{g H}``. That is, with `Δt = 1e-2` we ensure
120+
# that `` \sqrt{g H} Δt / Δx, \sqrt{g H} Δt / Δy < 0.7``.
121121

122-
simulation = Simulation(model, Δt = 1e-2, stop_time = 150)
122+
simulation = Simulation(model, Δt = 1e-2, stop_time = 100)
123123

124124
# ## Prepare output files
125125
#
@@ -136,7 +136,7 @@ perturbation_norm(args...) = norm(v)
136136
fields_filename = joinpath(@__DIR__, "shallow_water_Bickley_jet_fields.nc")
137137
simulation.output_writers[:fields] = NetCDFOutputWriter(model, (; ω, ω′),
138138
filename = fields_filename,
139-
schedule = TimeInterval(1),
139+
schedule = TimeInterval(2),
140140
overwrite_existing = true)
141141

142142
# Build the `output_writer` for the growth rate, which is a scalar field.
@@ -170,11 +170,7 @@ nothing # hide
170170

171171
fig = Figure(resolution = (1200, 660))
172172

173-
axis_kwargs = (xlabel = "x",
174-
ylabel = "y",
175-
aspect = AxisAspect(1),
176-
limits = ((0, Lx), (-Ly/2, Ly/2)))
177-
173+
axis_kwargs = (xlabel = "x", ylabel = "y")
178174
ax_ω = Axis(fig[2, 1]; title = "Total vorticity, ω", axis_kwargs...)
179175
ax_ω′ = Axis(fig[2, 3]; title = "Perturbation vorticity, ω - ω̄", axis_kwargs...)
180176

@@ -203,8 +199,6 @@ fig
203199
frames = 1:length(times)
204200

205201
record(fig, "shallow_water_Bickley_jet.mp4", frames, framerate=12) do i
206-
msg = string("Plotting frame ", i, " of ", frames[end])
207-
print(msg * " \r")
208202
n[] = i
209203
end
210204
nothing #hide
@@ -230,7 +224,7 @@ nothing # hide
230224

231225
using Polynomials: fit
232226

233-
I = 6000:7000
227+
I = 5000:6000
234228

235229
degree = 1
236230
linear_fit_polynomial = fit(t[I], log.(norm_v[I]), degree, var = :t)

0 commit comments

Comments
 (0)