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 . We impose the front on top of a vertical buoyancy gradient 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: 35.311 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (29.819 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (21.447 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 44.152 seconds, max(u): (1.344e-01, 1.192e-01, 1.626e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 702.213 ms, max(u): (2.173e-01, 1.713e-01, 1.710e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 767.476 ms, max(u): (2.973e-01, 2.272e-01, 1.640e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 729.704 ms, max(u): (3.751e-01, 3.045e-01, 1.676e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 646.486 ms, max(u): (4.684e-01, 4.506e-01, 1.825e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 763.319 ms, max(u): (5.855e-01, 7.126e-01, 2.592e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 737.157 ms, max(u): (8.371e-01, 1.111e+00, 3.105e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 775.602 ms, max(u): (1.238e+00, 1.159e+00, 4.173e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 741.683 ms, max(u): (1.399e+00, 1.116e+00, 4.752e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 702.132 ms, max(u): (1.323e+00, 1.043e+00, 3.895e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 738.338 ms, max(u): (1.261e+00, 1.123e+00, 3.653e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 750.104 ms, max(u): (1.155e+00, 1.086e+00, 2.822e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 724.418 ms, max(u): (1.238e+00, 1.187e+00, 2.353e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 701.784 ms, max(u): (1.212e+00, 1.212e+00, 2.383e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.091 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.092 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 FieldTimeSerieses.

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 Observables, 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.00936451368033886 -0.008110773749649525 -0.006858787965029478 -0.005625395569950342 -0.004392222501337528 -0.0031286494340747595 -0.0018854812951758504 -0.0006444216123782098; -0.009387381374835968 -0.008106754161417484 -0.006901883985847235 -0.005636054556816816 -0.004325302317738533 -0.003125240793451667 -0.0018746870337054133 -0.0006221103249117732; -0.009364446625113487 -0.008124273270368576 -0.006885300390422344 -0.005632196553051472 -0.004378402605652809 -0.0031387696508318186 -0.0018716210033744574 -0.000624154054094106; -0.00937117263674736 -0.008107414469122887 -0.006888303905725479 -0.0056103006936609745 -0.004376055672764778 -0.003139335894957185 -0.0018563992343842983 -0.0006077178986743093; -0.009380288422107697 -0.008125032298266888 -0.006905306130647659 -0.005614381283521652 -0.00436984421685338 -0.0031235956121236086 -0.001884390483610332 -0.0006144099752418697; -0.009374710731208324 -0.008131546899676323 -0.00686836801469326 -0.00561887351796031 -0.004376996774226427 -0.003135958919301629 -0.0018572849221527576 -0.0006247304263524711; -0.009355482645332813 -0.008111588656902313 -0.006876708939671516 -0.005635412875562906 -0.004385942127555609 -0.0031200319062918425 -0.0018853293731808662 -0.0006312428740784526; -0.00936741754412651 -0.008115497417747974 -0.006861492991447449 -0.005603162571787834 -0.0043572173453867435 -0.0031248030718415976 -0.0018541918834671378 -0.0006240518414415419; -0.009357638657093048 -0.008098471909761429 -0.006852450780570507 -0.005623529199510813 -0.0043993121944367886 -0.0031120197381824255 -0.001878584735095501 -0.0006171305431053042; -0.00935826450586319 -0.008135214447975159 -0.006870408076792955 -0.005650984589010477 -0.004388615023344755 -0.003151174169033766 -0.0018639408517628908 -0.0006268916768021882; -0.009387994185090065 -0.00812924187630415 -0.006868297234177589 -0.005607533734291792 -0.004411372356116772 -0.0031418874859809875 -0.0018838731339201331 -0.0006481502205133438; -0.009396299719810486 -0.008109744638204575 -0.0068707093596458435 -0.005635586101561785 -0.004374353680759668 -0.0031040452886372805 -0.00186931062489748 -0.0006167394458316267; -0.009366162121295929 -0.008147151209414005 -0.00689940107986331 -0.00564231164753437 -0.004394507501274347 -0.003148151794448495 -0.0018607104429975152 -0.0006396144744940102; -0.009351518005132675 -0.008086475543677807 -0.006870936136692762 -0.0056082867085933685 -0.004359014797955751 -0.00312329875305295 -0.0018799178069457412 -0.0006059977458789945; -0.009382860735058784 -0.008134622126817703 -0.006871864665299654 -0.005607772618532181 -0.004381214268505573 -0.0031436218414455652 -0.0018777073128148913 -0.0006531694671139121; -0.009367246180772781 -0.00812411867082119 -0.0068792360834777355 -0.005592874716967344 -0.004339768551290035 -0.003141465364024043 -0.0018578239250928164 -0.000592722266446799; -0.009367669932544231 -0.008113664574921131 -0.00687046442180872 -0.005629919935017824 -0.004389790818095207 -0.003107265802100301 -0.001864213147200644 -0.0006209094426594675; -0.009375042282044888 -0.008141683414578438 -0.006865593604743481 -0.005621620919555426 -0.004370340146124363 -0.0031385591719299555 -0.0018718839855864644 -0.0006246849079616368; -0.009373623877763748 -0.008113818243145943 -0.006862687412649393 -0.005619947798550129 -0.0043671936728060246 -0.0031359391286969185 -0.0018683758098632097 -0.000632200506515801; -0.00938329752534628 -0.008099190890789032 -0.0068673426285386086 -0.005632233340293169 -0.004375629127025604 -0.003128106938675046 -0.0018718960927799344 -0.0006232028244994581; -0.009372717700898647 -0.008109772577881813 -0.006894890684634447 -0.005630590487271547 -0.0043813809752464294 -0.003141196444630623 -0.0018578297458589077 -0.0006242393283173442; -0.009350813925266266 -0.008122017607092857 -0.006901425309479237 -0.005636898335069418 -0.004395840223878622 -0.003136650426313281 -0.001885629608295858 -0.0006402586586773396; -0.00750283757224679 -0.00623682327568531 -0.005007865838706493 -0.003752240678295493 -0.0025142179802060127 -0.0012636661995202303 -1.1166986041644122e-5 0.001246660016477108; -0.0054078600369393826 -0.0041475556790828705 -0.002916603581979871 -0.0016693357611075044 -0.00041629819315858185 0.0008275071741081774 0.0020737196318805218 0.003333824686706066; -0.0033542027231305838 -0.0020884231198579073 -0.0008293353021144867 0.000423247431172058 0.001674766419455409 0.002913621487095952 0.004182891920208931 0.005411974154412746; -0.001235560281202197 -1.2409356713760644e-5 0.0012462808517739177 0.002497102366760373 0.003715141210705042 0.004994654096662998 0.006267163902521133 0.0074838511645793915; 0.0006399932317435741 0.001868692459538579 0.003113111015409231 0.004374668467789888 0.005628510378301144 0.00688863405957818 0.008140071295201778 0.009380853734910488; 0.0006377918180078268 0.0018850108608603477 0.0031169215217232704 0.004398179706186056 0.005623538047075272 0.006877807434648275 0.008134100586175919 0.009381634183228016; 0.0006137259770184755 0.0018954576225951314 0.0031189878936856985 0.0043957470916211605 0.0056239464320242405 0.006872472353279591 0.008132477290928364 0.009377513080835342; 0.0006130526307970285 0.0018759079976007342 0.0031347188632935286 0.004360587801784277 0.005623053293675184 0.006870321463793516 0.008106915280222893 0.009373540058732033; 0.0006263692048378289 0.0018927509663626552 0.0031061272602528334 0.004369228146970272 0.005634167231619358 0.006879309192299843 0.008097670041024685 0.009367216378450394; 0.0006278997752815485 0.0018803568091243505 0.0031229592859745026 0.004360493738204241 0.005596023518592119 0.006885490845888853 0.00814239401370287 0.009393473155796528; 0.0006136908777989447 0.0019002255285158753 0.0031077112071216106 0.004343072418123484 0.005633664317429066 0.006895704660564661 0.008100551553070545 0.009390722960233688; 0.0006297057261690497 0.0018778141820803285 0.003120527369901538 0.004377746023237705 0.005613835994154215 0.00686341617256403 0.008143550716340542 0.00937693938612938; 0.000642837374471128 0.0018665482057258487 0.003137231105938554 0.004372062161564827 0.005633864551782608 0.006864986848086119 0.008129180409014225 0.009371621534228325; 0.0005959848058409989 0.0018776365322992206 0.003137473715469241 0.004380469210445881 0.00565175199881196 0.006874918472021818 0.008088881149888039 0.009388058446347713; 0.0006094658747315407 0.0018769670277833939 0.003109158482402563 0.0043866620399057865 0.005626796744763851 0.0068937442265450954 0.008134027943015099 0.009404139593243599; 0.0006032271776348352 0.0018997135339304805 0.0031216128263622522 0.0043937996961176395 0.005638279486447573 0.006885845679789782 0.008101904764771461 0.009378951974213123; 0.0006018979474902153 0.0018566619837656617 0.003141260240226984 0.004356610123068094 0.005608559586107731 0.006863387301564217 0.008119557984173298 0.009370229206979275; 0.0006014259997755289 0.0018912872765213251 0.0031216698698699474 0.004398354794830084 0.005621785297989845 0.006845199503004551 0.00811748392879963 0.00939960777759552; 0.0006409890484064817 0.0018738934304565191 0.003095196792855859 0.004367333836853504 0.005633272230625153 0.006876127328723669 0.008118903264403343 0.009348534047603607; 0.0006139405886642635 0.0018646597163751721 0.0030805058777332306 0.004371370654553175 0.005613662768155336 0.006873734295368195 0.008131837472319603 0.009391650557518005; 0.0006276341155171394 0.0018632019637152553 0.0031056194566190243 0.004361175931990147 0.00563186127692461 0.006883413530886173 0.008155101910233498 0.009390409104526043; 0.00062866898952052 0.0018761479295790195 0.003088339464738965 0.0043663824908435345 0.0056185354478657246 0.006872112397104502 0.008112045004963875 0.009375074878334999; 0.0006291478639468551 0.0018979650922119617 0.0031159615609794855 0.004370241891592741 0.005605186801403761 0.006853303872048855 0.008143463172018528 0.009375646710395813; 0.0006291329045780003 0.0018572595436125994 0.003135153092443943 0.004364487715065479 0.005614349152892828 0.006876980420202017 0.00813397578895092 0.009376496076583862; 0.0006129091489128768 0.0018834086367860436 0.003129023825749755 0.0043710400350391865 0.005626615136861801 0.006908732932060957 0.008124017156660557 0.009347565472126007; 0.0006356973317451775 0.0018817156087607145 0.00314999558031559 0.004383346065878868 0.005626708269119263 0.006887498777359724 0.008092492818832397 0.009394727647304535])

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.