Skip to content

Commit 38ae265

Browse files
glwagnernavidcy
andauthored
Clean up minor irregularities in tilted_bottom_boundary_layer (#4878)
* Update tilted_bottom_boundary_layer.jl * use advective/diffusive timescales --------- Co-authored-by: Navid C. Constantinou <[email protected]>
1 parent 7798178 commit 38ae265

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

examples/tilted_bottom_boundary_layer.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ b_bcs = FieldBoundaryConditions(bottom = negative_background_diffusive_flux)
114114

115115
V∞ = 0.1 # m s⁻¹
116116
z₀ = 0.1 # m (roughness length)
117-
κ = 0.4 # von Karman constant
117+
ϰ = 0.4 # von Karman constant
118118

119119
z₁ = first(znodes(grid, Center())) # Closest grid center to the bottom
120-
cᴰ = (κ / log(z₁ / z₀))^2 # Drag coefficient
120+
cᴰ = (ϰ / log(z₁ / z₀))^2 # Drag coefficient
121121

122122
@inline drag_u(x, t, u, v, p) = - p.cᴰ * (u^2 + (v + p.V∞)^2) * u
123123
@inline drag_v(x, t, u, v, p) = - p.cᴰ * (u^2 + (v + p.V∞)^2) * (v + p.V∞)
@@ -141,9 +141,7 @@ V∞_field = BackgroundField(V∞)
141141
# fifth-order `UpwindBiased` advection scheme and a constant viscosity and diffusivity.
142142
# Here we use a smallish value of ``10^{-4} \, \rm{m}^2\, \rm{s}^{-1}``.
143143

144-
ν = 1e-4
145-
κ = 1e-4
146-
closure = ScalarDiffusivity(; ν, κ)
144+
closure = ScalarDiffusivity=1e-4, κ=1e-4)
147145

148146
model = NonhydrostaticModel(; grid, buoyancy, coriolis, closure,
149147
advection = UpwindBiased(order=5),
@@ -163,7 +161,8 @@ set!(model, u=noise, w=noise)
163161
# conservatively, based on the smallest grid size of our domain and either an advective
164162
# or diffusive time scaling, depending on which is shorter.
165163

166-
Δt₀ = 0.5 * minimum([minimum_zspacing(grid) / V∞, minimum_zspacing(grid)^2/κ])
164+
Δt₀ = 0.5 * minimum([Oceananigans.Advection.cell_advection_timescale(model),
165+
Oceananigans.Diagnostics.cell_diffusion_timescale(model)])
167166
simulation = Simulation(model, Δt = Δt₀, stop_time = 1day)
168167

169168
# We use a `TimeStepWizard` to adapt our time-step,
@@ -215,7 +214,7 @@ run!(simulation)
215214
# First we load the required package to load NetCDF output files and define the coordinates for
216215
# plotting using existing objects:
217216

218-
using NCDatasets, CairoMakie
217+
using CairoMakie
219218

220219
xb, yb, zb = nodes(B)
221220
xω, yω, zω = nodes(ωy)
@@ -230,8 +229,7 @@ fig = Figure(size = (800, 600))
230229

231230
axis_kwargs = (xlabel = "Across-slope distance (m)",
232231
ylabel = "Slope-normal\ndistance (m)",
233-
limits = ((0, Lx), (0, Lz)),
234-
)
232+
limits = ((0, Lx), (0, Lz)))
235233

236234
ax_ω = Axis(fig[2, 1]; title = "Along-slope vorticity", axis_kwargs...)
237235
ax_v = Axis(fig[3, 1]; title = "Along-slope velocity (v)", axis_kwargs...)
@@ -240,16 +238,17 @@ n = Observable(1)
240238

241239
ωy = @lift ds["ωy"][:, :, $n]
242240
B = @lift ds["B"][:, :, $n]
243-
hm_ω = heatmap!(ax_ω, xω, zω, ωy, colorrange = (-0.015, +0.015), colormap = :balance)
241+
ωlim = 0.015
242+
hm_ω = heatmap!(ax_ω, xω, zω, ωy, colorrange = (-ωlim, +ωlim), colormap = :balance)
244243
Colorbar(fig[2, 2], hm_ω; label = "s⁻¹")
245-
ct_b = contour!(ax_ω, xb, zb, B, levels=-1e-3:0.5e-4:1e-3, color=:black)
244+
ct_b = contour!(ax_ω, xb, zb, B, levels=-1e-3:5e-5:1e-3, color=:black)
246245

247246
V = @lift ds["V"][:, :, $n]
248247
V_max = @lift maximum(abs, ds["V"][:, :, $n])
249248

250249
hm_v = heatmap!(ax_v, xv, zv, V, colorrange = (-V∞, +V∞), colormap = :balance)
251250
Colorbar(fig[3, 2], hm_v; label = "m s⁻¹")
252-
ct_b = contour!(ax_v, xb, zb, B, levels=-1e-3:0.5e-4:1e-3, color=:black)
251+
ct_b = contour!(ax_v, xb, zb, B, levels=-1e-3:5e-5:1e-3, color=:black)
253252

254253
times = collect(ds["time"])
255254
title = @lift "t = " * string(prettytime(times[$n]))

0 commit comments

Comments
 (0)