Baroclinic adjustment
In this example, we simulate the evolution and equilibration of a baroclinically unstable front.
Install dependencies
First let's make sure we have all required packages installed.
using Pkg
pkg"add Oceananigans, CairoMakie"
using Oceananigans
using Oceananigans.Units
Grid
We use a three-dimensional channel that is periodic in the x
direction:
Lx = 1000kilometers # east-west extent [m]
Ly = 1000kilometers # north-south extent [m]
Lz = 1kilometers # depth [m]
grid = RectilinearGrid(size = (48, 48, 8),
x = (0, Lx),
y = (-Ly/2, Ly/2),
z = (-Lz, 0),
topology = (Periodic, Bounded, Bounded))
48×48×8 RectilinearGrid{Float64, Periodic, Bounded, Bounded} on CPU with 3×3×3 halo
├── Periodic x ∈ [0.0, 1.0e6) regularly spaced with Δx=20833.3
├── Bounded y ∈ [-500000.0, 500000.0] regularly spaced with Δy=20833.3
└── Bounded z ∈ [-1000.0, 0.0] regularly spaced with Δz=125.0
Model
We built a HydrostaticFreeSurfaceModel
with an ImplicitFreeSurface
solver. Regarding Coriolis, we use a beta-plane centered at 45° South.
model = HydrostaticFreeSurfaceModel(; grid,
coriolis = BetaPlane(latitude = -45),
buoyancy = BuoyancyTracer(),
tracers = :b,
momentum_advection = WENO(),
tracer_advection = WENO())
HydrostaticFreeSurfaceModel{CPU, RectilinearGrid}(time = 0 seconds, iteration = 0)
├── grid: 48×48×8 RectilinearGrid{Float64, Periodic, Bounded, Bounded} on CPU with 3×3×3 halo
├── timestepper: QuasiAdamsBashforth2TimeStepper
├── tracers: b
├── closure: Nothing
├── buoyancy: BuoyancyTracer with ĝ = NegativeZDirection()
├── free surface: ImplicitFreeSurface with gravitational acceleration 9.80665 m s⁻²
│ └── solver: FFTImplicitFreeSurfaceSolver
├── advection scheme:
│ ├── momentum: WENO{3, Float64, Float32}(order=5)
│ └── b: WENO{3, Float64, Float32}(order=5)
└── coriolis: BetaPlane{Float64}
We start our simulation from rest with a baroclinically unstable buoyancy distribution. We use ramp(y, Δy)
, defined below, to specify a front with width Δy
and horizontal buoyancy gradient M²
. We impose the front on top of a vertical buoyancy gradient N²
and a bit of noise.
"""
ramp(y, Δy)
Linear ramp from 0 to 1 between -Δy/2 and +Δy/2.
For example:
```
y < -Δy/2 => ramp = 0
-Δy/2 < y < -Δy/2 => ramp = y / Δy
y > Δy/2 => ramp = 1
```
"""
ramp(y, Δy) = min(max(0, y/Δy + 1/2), 1)
N² = 1e-5 # [s⁻²] buoyancy frequency / stratification
M² = 1e-7 # [s⁻²] horizontal buoyancy gradient
Δy = 100kilometers # width of the region of the front
Δb = Δy * M² # buoyancy jump associated with the front
ϵb = 1e-2 * Δb # noise amplitude
bᵢ(x, y, z) = N² * z + Δb * ramp(y, Δy) + ϵb * randn()
set!(model, b=bᵢ)
Let's visualize the initial buoyancy distribution.
using CairoMakie
set_theme!(Theme(fontsize = 20))
# Build coordinates with units of kilometers
x, y, z = 1e-3 .* nodes(grid, (Center(), Center(), Center()))
b = model.tracers.b
fig, ax, hm = heatmap(view(b, 1, :, :),
colormap = :deep,
axis = (xlabel = "y [km]",
ylabel = "z [km]",
title = "b(x=0, y, z, t=0)",
titlesize = 24))
Colorbar(fig[1, 2], hm, label = "[m s⁻²]")
fig
Simulation
Now let's build a Simulation
.
simulation = Simulation(model, Δt=20minutes, stop_time=20days)
Simulation of HydrostaticFreeSurfaceModel{CPU, RectilinearGrid}(time = 0 seconds, iteration = 0)
├── Next time step: 20 minutes
├── Elapsed wall time: 0 seconds
├── Wall time per iteration: NaN days
├── Stop time: 20 days
├── Stop iteration: Inf
├── Wall time limit: Inf
├── Minimum relative step: 0.0
├── Callbacks: OrderedDict with 4 entries:
│ ├── stop_time_exceeded => 4
│ ├── stop_iteration_exceeded => -
│ ├── wall_time_limit_exceeded => e
│ └── nan_checker => }
├── Output writers: OrderedDict with no entries
└── Diagnostics: OrderedDict with no entries
We add a TimeStepWizard
callback to adapt the simulation's time-step,
conjure_time_step_wizard!(simulation, IterationInterval(20), cfl=0.2, max_Δt=20minutes)
Also, we add a callback to print a message about how the simulation is going,
using Printf
wall_clock = Ref(time_ns())
function print_progress(sim)
u, v, w = model.velocities
progress = 100 * (time(sim) / sim.stop_time)
elapsed = (time_ns() - wall_clock[]) / 1e9
@printf("[%05.2f%%] i: %d, t: %s, wall time: %s, max(u): (%6.3e, %6.3e, %6.3e) m/s, next Δt: %s\n",
progress, iteration(sim), prettytime(sim), prettytime(elapsed),
maximum(abs, u), maximum(abs, v), maximum(abs, w), prettytime(sim.Δt))
wall_clock[] = time_ns()
return nothing
end
add_callback!(simulation, print_progress, IterationInterval(100))
Diagnostics/Output
Here, we save the buoyancy, $b$, at the edges of our domain as well as the zonal ($x$) average of buoyancy.
u, v, w = model.velocities
ζ = ∂x(v) - ∂y(u)
B = Average(b, dims=1)
U = Average(u, dims=1)
V = Average(v, dims=1)
filename = "baroclinic_adjustment"
save_fields_interval = 0.5day
slicers = (east = (grid.Nx, :, :),
north = (:, grid.Ny, :),
bottom = (:, :, 1),
top = (:, :, grid.Nz))
for side in keys(slicers)
indices = slicers[side]
simulation.output_writers[side] = JLD2Writer(model, (; b, ζ);
filename = filename * "_$(side)_slice",
schedule = TimeInterval(save_fields_interval),
overwrite_existing = true,
indices)
end
simulation.output_writers[:zonal] = JLD2Writer(model, (; b=B, u=U, v=V);
filename = filename * "_zonal_average",
schedule = TimeInterval(save_fields_interval),
overwrite_existing = true)
JLD2Writer scheduled on TimeInterval(12 hours):
├── filepath: baroclinic_adjustment_zonal_average.jld2
├── 3 outputs: (b, u, v)
├── array type: Array{Float32}
├── including: [:grid, :coriolis, :buoyancy, :closure]
├── file_splitting: NoFileSplitting
└── file size: 32.5 KiB
Now we're ready to run.
@info "Running the simulation..."
run!(simulation)
@info "Simulation completed in " * prettytime(simulation.run_wall_time)
[ Info: Running the simulation...
[ Info: Initializing simulation...
[00.00%] i: 0, t: 0 seconds, wall time: 29.826 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (27.997 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (20.048 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 41.433 seconds, max(u): (1.307e-01, 1.277e-01, 1.559e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 763.286 ms, max(u): (2.212e-01, 1.769e-01, 1.756e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 732.205 ms, max(u): (3.047e-01, 2.379e-01, 1.823e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 803.951 ms, max(u): (3.900e-01, 3.428e-01, 1.799e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 688.812 ms, max(u): (4.793e-01, 5.150e-01, 2.033e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 731.065 ms, max(u): (6.297e-01, 8.711e-01, 2.669e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 735.662 ms, max(u): (9.119e-01, 1.269e+00, 3.662e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 748.966 ms, max(u): (1.253e+00, 1.338e+00, 5.599e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 673.352 ms, max(u): (1.365e+00, 1.182e+00, 4.625e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 791.836 ms, max(u): (1.355e+00, 1.176e+00, 5.321e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 728.377 ms, max(u): (1.354e+00, 1.098e+00, 2.759e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 786.722 ms, max(u): (1.419e+00, 1.098e+00, 3.256e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 656.235 ms, max(u): (1.435e+00, 1.444e+00, 3.941e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 584.012 ms, max(u): (1.382e+00, 1.237e+00, 3.488e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.032 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.033 minutes
Visualization
All that's left is to make a pretty movie. Actually, we make two visualizations here. First, we illustrate how to make a 3D visualization with Makie
's Axis3
and Makie.surface
. Then we make a movie in 2D. We use CairoMakie
in this example, but note that using GLMakie
is more convenient on a system with OpenGL, as figures will be displayed on the screen.
using CairoMakie
Three-dimensional visualization
We load the saved buoyancy output on the top, north, and east surface as FieldTimeSeries
es.
filename = "baroclinic_adjustment"
sides = keys(slicers)
slice_filenames = NamedTuple(side => filename * "_$(side)_slice.jld2" for side in sides)
b_timeserieses = (east = FieldTimeSeries(slice_filenames.east, "b"),
north = FieldTimeSeries(slice_filenames.north, "b"),
top = FieldTimeSeries(slice_filenames.top, "b"))
B_timeseries = FieldTimeSeries(filename * "_zonal_average.jld2", "b")
times = B_timeseries.times
grid = B_timeseries.grid
48×48×8 RectilinearGrid{Float64, Periodic, Bounded, Bounded} on CPU with 3×3×3 halo
├── Periodic x ∈ [0.0, 1.0e6) regularly spaced with Δx=20833.3
├── Bounded y ∈ [-500000.0, 500000.0] regularly spaced with Δy=20833.3
└── Bounded z ∈ [-1000.0, 0.0] regularly spaced with Δz=125.0
We build the coordinates. We rescale horizontal coordinates to kilometers.
xb, yb, zb = nodes(b_timeserieses.east)
xb = xb ./ 1e3 # convert m -> km
yb = yb ./ 1e3 # convert m -> km
Nx, Ny, Nz = size(grid)
x_xz = repeat(x, 1, Nz)
y_xz_north = y[end] * ones(Nx, Nz)
z_xz = repeat(reshape(z, 1, Nz), Nx, 1)
x_yz_east = x[end] * ones(Ny, Nz)
y_yz = repeat(y, 1, Nz)
z_yz = repeat(reshape(z, 1, Nz), grid.Ny, 1)
x_xy = x
y_xy = y
z_xy_top = z[end] * ones(grid.Nx, grid.Ny)
Then we create a 3D axis. We use zonal_slice_displacement
to control where the plot of the instantaneous zonal average flow is located.
fig = Figure(size = (1600, 800))
zonal_slice_displacement = 1.2
ax = Axis3(fig[2, 1],
aspect=(1, 1, 1/5),
xlabel = "x (km)",
ylabel = "y (km)",
zlabel = "z (m)",
xlabeloffset = 100,
ylabeloffset = 100,
zlabeloffset = 100,
limits = ((x[1], zonal_slice_displacement * x[end]), (y[1], y[end]), (z[1], z[end])),
elevation = 0.45,
azimuth = 6.8,
xspinesvisible = false,
zgridvisible = false,
protrusions = 40,
perspectiveness = 0.7)
Axis3()
We use data from the final savepoint for the 3D plot. Note that this plot can easily be animated by using Makie's Observable
. To dive into Observable
s, check out Makie.jl's Documentation.
n = length(times)
41
Now let's make a 3D plot of the buoyancy and in front of it we'll use the zonally-averaged output to plot the instantaneous zonal-average of the buoyancy.
b_slices = (east = interior(b_timeserieses.east[n], 1, :, :),
north = interior(b_timeserieses.north[n], :, 1, :),
top = interior(b_timeserieses.top[n], :, :, 1))
# Zonally-averaged buoyancy
B = interior(B_timeseries[n], 1, :, :)
clims = 1.1 .* extrema(b_timeserieses.top[n][:])
kwargs = (colorrange=clims, colormap=:deep, shading=NoShading)
surface!(ax, x_yz_east, y_yz, z_yz; color = b_slices.east, kwargs...)
surface!(ax, x_xz, y_xz_north, z_xz; color = b_slices.north, kwargs...)
surface!(ax, x_xy, y_xy, z_xy_top; color = b_slices.top, kwargs...)
sf = surface!(ax, zonal_slice_displacement .* x_yz_east, y_yz, z_yz; color = B, kwargs...)
contour!(ax, y, z, B; transformation = (:yz, zonal_slice_displacement * x[end]),
levels = 15, linewidth = 2, color = :black)
Colorbar(fig[2, 2], sf, label = "m s⁻²", height = Relative(0.4), tellheight=false)
title = "Buoyancy at t = " * string(round(times[n] / day, digits=1)) * " days"
fig[1, 1:2] = Label(fig, title; fontsize = 24, tellwidth = false, padding = (0, 0, -120, 0))
rowgap!(fig.layout, 1, Relative(-0.2))
colgap!(fig.layout, 1, Relative(-0.1))
save("baroclinic_adjustment_3d.png", fig)
Two-dimensional movie
We make a 2D movie that shows buoyancy $b$ and vertical vorticity $ζ$ at the surface, as well as the zonally-averaged zonal and meridional velocities $U$ and $V$ in the $(y, z)$ plane. First we load the FieldTimeSeries
and extract the additional coordinates we'll need for plotting
ζ_timeseries = FieldTimeSeries(slice_filenames.top, "ζ")
U_timeseries = FieldTimeSeries(filename * "_zonal_average.jld2", "u")
B_timeseries = FieldTimeSeries(filename * "_zonal_average.jld2", "b")
V_timeseries = FieldTimeSeries(filename * "_zonal_average.jld2", "v")
xζ, yζ, zζ = nodes(ζ_timeseries)
yv = ynodes(V_timeseries)
xζ = xζ ./ 1e3 # convert m -> km
yζ = yζ ./ 1e3 # convert m -> km
yv = yv ./ 1e3 # convert m -> km
-500.0:20.833333333333332:500.0
Next, we set up a plot with 4 panels. The top panels are large and square, while the bottom panels get a reduced aspect ratio through rowsize!
.
fig = Figure(size=(1800, 1000))
axb = Axis(fig[1, 2], xlabel="x (km)", ylabel="y (km)", aspect=1)
axζ = Axis(fig[1, 3], xlabel="x (km)", ylabel="y (km)", aspect=1, yaxisposition=:right)
axu = Axis(fig[2, 2], xlabel="y (km)", ylabel="z (m)")
axv = Axis(fig[2, 3], xlabel="y (km)", ylabel="z (m)", yaxisposition=:right)
rowsize!(fig.layout, 2, Relative(0.3))
To prepare a plot for animation, we index the timeseries with an Observable
,
n = Observable(1)
b_top = @lift interior(b_timeserieses.top[$n], :, :, 1)
ζ_top = @lift interior(ζ_timeseries[$n], :, :, 1)
U = @lift interior(U_timeseries[$n], 1, :, :)
V = @lift interior(V_timeseries[$n], 1, :, :)
B = @lift interior(B_timeseries[$n], 1, :, :)
Observable([-0.009360515512526035 -0.008129563182592392 -0.006867580581456423 -0.00560120539739728 -0.004368279129266739 -0.0031271232292056084 -0.0018791274633258581 -0.000646161672193557; -0.009359482675790787 -0.008119036443531513 -0.006889553740620613 -0.005601288750767708 -0.0043712821789085865 -0.0031418122816830873 -0.0018659370252862573 -0.0006405958556570113; -0.009407208301126957 -0.008152410387992859 -0.006898969877511263 -0.005625209771096706 -0.004379430785775185 -0.0031369528733193874 -0.0018839329713955522 -0.0006151690613478422; -0.009358924813568592 -0.008130463771522045 -0.0068658096715807915 -0.005584131460636854 -0.004373969975858927 -0.0031197532080113888 -0.0018927135970443487 -0.0006461403681896627; -0.009391043335199356 -0.008127236738801003 -0.00687264883890748 -0.005647587589919567 -0.0043705240823328495 -0.0031270673498511314 -0.0018594525754451752 -0.000628666311968118; -0.009408203884959221 -0.00810256041586399 -0.006860662717372179 -0.005605517420917749 -0.004365287255495787 -0.0031029987148940563 -0.0018677589250728488 -0.0006354170036502182; -0.009377719834446907 -0.008138133212924004 -0.006885320879518986 -0.005642102565616369 -0.004362339153885841 -0.0031175599433481693 -0.0018474821699783206 -0.0006281954701989889; -0.009385996498167515 -0.008121658116579056 -0.006893175654113293 -0.005622848402708769 -0.004399265628308058 -0.0031120136845856905 -0.0018912400119006634 -0.0006049188086763024; -0.009378721937537193 -0.008123155683279037 -0.0068778847344219685 -0.005617325659841299 -0.004344915971159935 -0.0031009248923510313 -0.0018710093572735786 -0.000606883317232132; -0.009346005506813526 -0.0081147076562047 -0.006880675908178091 -0.00563913444057107 -0.00438564782962203 -0.0031299449037760496 -0.00186024303548038 -0.0006302339606918395; -0.009374297223985195 -0.008131258189678192 -0.006855495739728212 -0.005617362447082996 -0.004396195989102125 -0.0031069598626345396 -0.0018835625378414989 -0.0006014964892528951; -0.009373148903250694 -0.008107812143862247 -0.006862387992441654 -0.005609903950244188 -0.00437281746417284 -0.003129241056740284 -0.0018869292689487338 -0.0006130780093371868; -0.009375168941915035 -0.008103706873953342 -0.006863866932690144 -0.00561967259272933 -0.004361514467746019 -0.0031574671156704426 -0.0018769772723317146 -0.000636701995972544; -0.009389424696564674 -0.008143250830471516 -0.006864758674055338 -0.005611103028059006 -0.004371988121420145 -0.0031110181007534266 -0.0018839032854884863 -0.0006327488808892667; -0.009354840032756329 -0.008139902725815773 -0.006871230434626341 -0.005661063827574253 -0.004364199470728636 -0.0031352071091532707 -0.0018834617221727967 -0.0006367871537804604; -0.009369691833853722 -0.00810633972287178 -0.006854357197880745 -0.0056440518237650394 -0.004353983327746391 -0.003150098491460085 -0.0018605440855026245 -0.0006355597288347781; -0.009360630996525288 -0.008111963979899883 -0.006882261484861374 -0.00562825845554471 -0.0043543423525989056 -0.003122486639767885 -0.001883827499113977 -0.0006185456877574325; -0.009386631660163403 -0.008131692185997963 -0.00683882599696517 -0.005640772636979818 -0.004363383166491985 -0.003128688782453537 -0.0018718470819294453 -0.0006156315212137997; -0.009370509535074234 -0.008119616657495499 -0.006875384598970413 -0.005616154987365007 -0.004357276018708944 -0.003123660571873188 -0.0018724333494901657 -0.0006465418264269829; -0.009362961165606976 -0.008135051466524601 -0.006879107095301151 -0.005622439086437225 -0.004378561861813068 -0.003129858523607254 -0.0018812604248523712 -0.0006222504889592528; -0.009381767362356186 -0.00813267845660448 -0.0068515026941895485 -0.00560773303732276 -0.00437557976692915 -0.0030859364196658134 -0.0018814732320606709 -0.0006027938215993345; -0.009385069832205772 -0.008112437091767788 -0.006905045360326767 -0.005639870185405016 -0.004377840552479029 -0.0031386474147439003 -0.0018807923188433051 -0.0006331364274956286; -0.007514771074056625 -0.006256353110074997 -0.005025730933994055 -0.0037461123429238796 -0.0024770793970674276 -0.0012350110337138176 1.0108115930052008e-5 0.001266305218450725; -0.005403843708336353 -0.004160564858466387 -0.0029021063819527626 -0.0016487498069182038 -0.0004349337541498244 0.0008275931468233466 0.0020852149464190006 0.0033310470171272755; -0.0033382000401616096 -0.0020633265376091003 -0.0008501172997057438 0.00042232003761455417 0.0016392696416005492 0.0029151674825698137 0.0041843135841190815 0.005390751175582409; -0.0012337439693510532 -1.736527224238671e-6 0.0012390671763569117 0.00247674947604537 0.003745571942999959 0.005012167152017355 0.006246388889849186 0.007488791365176439; 0.0006233130116015673 0.001869324827566743 0.003129419405013323 0.004374456591904163 0.0056337229907512665 0.0068729049526154995 0.008147064596414566 0.009366360493004322; 0.000619277881924063 0.0018562646582722664 0.00312506384216249 0.004368928261101246 0.005607088096439838 0.006881591863930225 0.008130699396133423 0.009371892549097538; 0.0006214219611138105 0.0018629885744303465 0.003122395370155573 0.0043703531846404076 0.005604235455393791 0.006883193738758564 0.00814133696258068 0.009362979792058468; 0.0006505611236207187 0.0018645154777914286 0.0031330815982073545 0.004346691071987152 0.005637355614453554 0.006900089792907238 0.008129267022013664 0.00940836500376463; 0.0006555690197274089 0.0019045043736696243 0.0031148213893175125 0.004362332168966532 0.005593510344624519 0.006879008840769529 0.008129658177495003 0.00937501061707735; 0.0006355550140142441 0.0018929223297163844 0.0031191823072731495 0.0043888995423913 0.005656086839735508 0.006886573508381844 0.008141172118484974 0.009388774633407593; 0.0006522328476421535 0.0018748685251921415 0.0031543970108032227 0.004371542949229479 0.005605395417660475 0.006870782934129238 0.008126886561512947 0.009372575208544731; 0.000631804286967963 0.0018724488327279687 0.0031588792335242033 0.00437395041808486 0.005609434098005295 0.006869369652122259 0.008096822537481785 0.009384050965309143; 0.000611542840488255 0.0018729220610111952 0.0031476779840886593 0.004374731332063675 0.005619600415229797 0.0068597677163779736 0.008142311125993729 0.009382037445902824; 0.0006285925628617406 0.001858279574662447 0.003134495811536908 0.004367227666079998 0.005629054736346006 0.006852899212390184 0.008121520280838013 0.009379657916724682; 0.0006227765115909278 0.0018605514196678996 0.0031258235685527325 0.004409682005643845 0.005629997234791517 0.006857209373265505 0.008134148083627224 0.009378408081829548; 0.0006175533635541797 0.0018899294082075357 0.003115047700703144 0.004376289434731007 0.0055869813077151775 0.006879813503473997 0.00813599955290556 0.00939583033323288; 0.0006281847599893808 0.0018734826007857919 0.0030972175300121307 0.004395658615976572 0.005620540585368872 0.006847096141427755 0.008130470290780067 0.009374301880598068; 0.0006243945681490004 0.0018720785155892372 0.003135000355541706 0.004373598378151655 0.00561621505767107 0.0068783811293542385 0.008112728595733643 0.009384023025631905; 0.0006246613920666277 0.0018794778734445572 0.003099957015365362 0.004346595145761967 0.005636030342429876 0.006892118137329817 0.008129279129207134 0.009387198835611343; 0.0006343667628243566 0.0018808618187904358 0.0031193713657557964 0.004382679704576731 0.005637302994728088 0.006873987149447203 0.008136198855936527 0.00934895034879446; 0.0006327587179839611 0.0018676294712349772 0.0031406644266098738 0.004371929913759232 0.0056319586001336575 0.0068813227117061615 0.008116677403450012 0.009370975196361542; 0.0006164705846458673 0.001866390579380095 0.0031171899754554033 0.0043922774493694305 0.005608461331576109 0.006868906784802675 0.008126907981932163 0.009364496916532516; 0.0006214242312125862 0.0018765997374430299 0.0031305684242397547 0.004386057145893574 0.005608685314655304 0.0068771434016525745 0.008142336271703243 0.009351462125778198; 0.0006146403611637652 0.001877612085081637 0.0031341430731117725 0.004390543792396784 0.005639141425490379 0.006862963549792767 0.008150880225002766 0.009385116398334503; 0.0006226536934264004 0.0019071729620918632 0.0031355922110378742 0.004384825937449932 0.005640164017677307 0.00688475277274847 0.008127855136990547 0.009359066374599934; 0.0006079754675738513 0.0018712375313043594 0.003102471586316824 0.0043835872784256935 0.005644488614052534 0.006907478906214237 0.008123653940856457 0.009399723261594772])
and then build our plot:
hm = heatmap!(axb, xb, yb, b_top, colorrange=(0, Δb), colormap=:thermal)
Colorbar(fig[1, 1], hm, flipaxis=false, label="Surface b(x, y) (m s⁻²)")
hm = heatmap!(axζ, xζ, yζ, ζ_top, colorrange=(-5e-5, 5e-5), colormap=:balance)
Colorbar(fig[1, 4], hm, label="Surface ζ(x, y) (s⁻¹)")
hm = heatmap!(axu, yb, zb, U; colorrange=(-5e-1, 5e-1), colormap=:balance)
Colorbar(fig[2, 1], hm, flipaxis=false, label="Zonally-averaged U(y, z) (m s⁻¹)")
contour!(axu, yb, zb, B; levels=15, color=:black)
hm = heatmap!(axv, yv, zb, V; colorrange=(-1e-1, 1e-1), colormap=:balance)
Colorbar(fig[2, 4], hm, label="Zonally-averaged V(y, z) (m s⁻¹)")
contour!(axv, yb, zb, B; levels=15, color=:black)
Finally, we're ready to record the movie.
frames = 1:length(times)
record(fig, filename * ".mp4", frames, framerate=8) do i
n[] = i
end
This page was generated using Literate.jl.