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)
├── vertical_coordinate: ZCoordinate
└── 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
├── run_wall_time: 0 seconds
├── run_wall_time / 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 => Callback of stop_time_exceeded on IterationInterval(1)
│   ├── stop_iteration_exceeded => Callback of stop_iteration_exceeded on IterationInterval(1)
│   ├── wall_time_limit_exceeded => Callback of wall_time_limit_exceeded on IterationInterval(1)
│   └── nan_checker => Callback of NaNChecker for u on IterationInterval(100)
└── output_writers: 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: 19.276 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (13.511 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (9.515 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 20.248 seconds, max(u): (1.302e-01, 1.115e-01, 1.526e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 1.852 seconds, max(u): (2.217e-01, 1.690e-01, 1.915e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 1.756 seconds, max(u): (2.921e-01, 2.297e-01, 1.829e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 1.886 seconds, max(u): (3.709e-01, 2.802e-01, 1.788e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 1.796 seconds, max(u): (4.397e-01, 3.471e-01, 1.866e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 1.865 seconds, max(u): (5.498e-01, 5.271e-01, 2.157e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 1.967 seconds, max(u): (7.044e-01, 7.589e-01, 2.839e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 1.882 seconds, max(u): (1.117e+00, 1.060e+00, 3.242e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 1.940 seconds, max(u): (1.343e+00, 1.238e+00, 4.721e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 1.834 seconds, max(u): (1.463e+00, 1.135e+00, 5.379e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 1.928 seconds, max(u): (1.469e+00, 1.068e+00, 4.087e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 1.793 seconds, max(u): (1.290e+00, 9.572e-01, 3.069e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 1.801 seconds, max(u): (1.330e+00, 9.710e-01, 2.574e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 1.884 seconds, max(u): (1.129e+00, 9.980e-01, 1.981e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 52.037 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 52.056 seconds

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.009359498508274555 -0.008127288892865181 -0.006871423684060574 -0.00560703594237566 -0.0043651992455124855 -0.0031442767940461636 -0.0018956799758598208 -0.0006427154876291752; -0.009402507916092873 -0.00813196785748005 -0.00687958300113678 -0.005624857265502214 -0.00439730379730463 -0.0031232021283358335 -0.0018734335899353027 -0.0005952148349024355; -0.00936916284263134 -0.008154339157044888 -0.006873009260743856 -0.005593138746917248 -0.004378724377602339 -0.003143470035865903 -0.0018713403260335326 -0.0006220389623194933; -0.009372194297611713 -0.008137495256960392 -0.006876656319946051 -0.005604491103440523 -0.0043760077096521854 -0.003115827916190028 -0.0018636878812685609 -0.0006270540761761367; -0.009388549253344536 -0.008134168572723866 -0.006892339792102575 -0.005610007327049971 -0.0043686493299901485 -0.0031310953199863434 -0.0019066801760345697 -0.0006339792162179947; -0.009350508451461792 -0.00812343880534172 -0.006850040517747402 -0.005631249397993088 -0.004374428186565638 -0.003121511312201619 -0.001892183325253427 -0.0006204634555615485; -0.009387975558638573 -0.00811196118593216 -0.006892985198646784 -0.005592718254774809 -0.004393135197460651 -0.0031163517851382494 -0.001892763189971447 -0.000595119025092572; -0.00938848964869976 -0.008106510154902935 -0.006878308951854706 -0.005638862494379282 -0.004381463397294283 -0.003125720424577594 -0.0018574093701317906 -0.0006211500731296837; -0.009379967115819454 -0.008096198551356792 -0.006873834412544966 -0.005623109173029661 -0.004370842594653368 -0.0031256803777068853 -0.0018768166191875935 -0.0006280510569922626; -0.00937378779053688 -0.008149398490786552 -0.0068803164176642895 -0.005642005708068609 -0.004379668273031712 -0.0031167943961918354 -0.001872895285487175 -0.0006215717294253409; -0.009375447407364845 -0.008101258426904678 -0.006866708863526583 -0.00561159010976553 -0.004380655940622091 -0.00313499104231596 -0.001873634522780776 -0.0006367677706293762; -0.00938158668577671 -0.008132043294608593 -0.006866490934044123 -0.005624762736260891 -0.004379322286695242 -0.0031436700373888016 -0.0018775399075821042 -0.0006294408231042325; -0.009346295148134232 -0.008129368536174297 -0.006895121186971664 -0.005630618892610073 -0.004388042725622654 -0.0031357500702142715 -0.001885867677628994 -0.0006219453644007444; -0.00939389131963253 -0.008113115094602108 -0.006888513918966055 -0.005612050648778677 -0.004356803372502327 -0.0031149934511631727 -0.001874336157925427 -0.0006403705920092762; -0.009386589750647545 -0.008116481825709343 -0.00687373848631978 -0.0056234318763017654 -0.0043479157611727715 -0.0031303665600717068 -0.00188257428817451 -0.0006222693482413888; -0.009384924545884132 -0.008121399208903313 -0.006883738562464714 -0.005619946867227554 -0.004370790906250477 -0.003111691912636161 -0.0018825158476829529 -0.0006428643246181309; -0.009385361336171627 -0.008128910325467587 -0.006873325910419226 -0.005654658190906048 -0.00437188521027565 -0.003108420642092824 -0.001867399550974369 -0.0006331955664791167; -0.00935860350728035 -0.008116391487419605 -0.006863504182547331 -0.005631354637444019 -0.004392607603222132 -0.003124368144199252 -0.0019024605862796307 -0.0006344817811623216; -0.009380674920976162 -0.008130399510264397 -0.00688427546992898 -0.005605344660580158 -0.004373224452137947 -0.0031345468014478683 -0.001877394737675786 -0.0005982027505524457; -0.009372415021061897 -0.008132071234285831 -0.006896709557622671 -0.005598763003945351 -0.004370483569800854 -0.0031116579193621874 -0.0018657653126865625 -0.0006450344226323068; -0.009367152117192745 -0.008137485943734646 -0.006869635544717312 -0.0056252568028867245 -0.0043631368316709995 -0.0031068380922079086 -0.001880671945400536 -0.0006229643477126956; -0.009376857429742813 -0.008136159740388393 -0.006917715538293123 -0.005621859338134527 -0.004384875297546387 -0.003136266488581896 -0.0018579303286969662 -0.0006100175087340176; -0.007508930750191212 -0.006248124409466982 -0.004998133517801762 -0.0037616505287587643 -0.0025071625132113695 -0.0012482642196118832 -3.0261865049396874e-6 0.0012323401169851422; -0.005391701124608517 -0.004151348955929279 -0.002917962148785591 -0.0016838088631629944 -0.00042979003046639264 0.0008149953209795058 0.00207923143170774 0.0033151269890367985; -0.003331450978294015 -0.00209839828312397 -0.0008317221654579043 0.00040983344661071897 0.0016504068626090884 0.0029151681810617447 0.004164555110037327 0.005431555211544037; -0.0012614068109542131 3.348486188770039e-6 0.0012451495276764035 0.0025021147448569536 0.0037368349730968475 0.004985891282558441 0.0062539600767195225 0.007482379674911499; 0.0006231294828467071 0.0018859830452129245 0.003124755807220936 0.004396518692374229 0.0056267064064741135 0.006845708005130291 0.008155688643455505 0.009380095638334751; 0.0006265100673772395 0.0018601238261908293 0.0031297148671001196 0.004398240242153406 0.005642339121550322 0.006862235255539417 0.00812817644327879 0.009370498359203339; 0.0006284710252657533 0.001883049146272242 0.003104418283328414 0.004376176279038191 0.005625850521028042 0.006878083571791649 0.008100498467683792 0.009401720948517323; 0.0006150428671389818 0.001906975987367332 0.0031228112056851387 0.0043845647014677525 0.005616753362119198 0.006865347269922495 0.008151955902576447 0.009367343038320541; 0.0006375036318786442 0.001879819668829441 0.003155436599627137 0.00436777388677001 0.005644615739583969 0.00686668511480093 0.00812519434839487 0.009351497516036034; 0.0006233665626496077 0.0018982939654961228 0.0031296515371650457 0.004359265323728323 0.005625916179269552 0.006871678866446018 0.008124757558107376 0.009372974745929241; 0.0006615609163418412 0.0018974365666508675 0.0031297600362449884 0.004379286430776119 0.00562521954998374 0.006878822110593319 0.008147996850311756 0.00936275813728571; 0.0006258240318857133 0.0018790574977174401 0.0031040115281939507 0.004361140541732311 0.0056249480694532394 0.00688142329454422 0.008130227215588093 0.009368598461151123; 0.0006245965487323701 0.0018772069597616792 0.0030940277501940727 0.004385900218039751 0.005635743495076895 0.006880612578243017 0.008149711415171623 0.009369791485369205; 0.0006293319165706635 0.001878014882095158 0.0031239695381373167 0.004366501700133085 0.0056258137337863445 0.006874526850879192 0.008122860454022884 0.009374050423502922; 0.0006507312646135688 0.0018830965273082256 0.0031135817989706993 0.00438421918079257 0.005633354652673006 0.00686988141387701 0.008151211775839329 0.009364654310047626; 0.000606901419814676 0.0018796484218910336 0.0031655889470130205 0.0043860264122486115 0.005621671676635742 0.006869364529848099 0.008129763416945934 0.00938111636787653; 0.0006224183598533273 0.0019039908656850457 0.003134622238576412 0.00437800120562315 0.005601958371698856 0.006875695660710335 0.008126274682581425 0.009350896812975407; 0.0006251708837226033 0.001890239305794239 0.003111351979896426 0.00437686825171113 0.005604862701147795 0.006890443153679371 0.008130598813295364 0.009370917454361916; 0.0006049580406397581 0.001861559459939599 0.0031209413427859545 0.004350840114057064 0.005618836265057325 0.006881251931190491 0.00809362530708313 0.00937954057008028; 0.0006237710476852953 0.0018657972104847431 0.00312985060736537 0.004393139388412237 0.005632677115499973 0.0068619586527347565 0.008113803341984749 0.009374026209115982; 0.0006139934412203729 0.0018648843979462981 0.0030995181296020746 0.004363397601991892 0.0056382897309958935 0.006872204132378101 0.008128316141664982 0.00934617593884468; 0.0006332212942652404 0.001880379975773394 0.003104232018813491 0.004392338916659355 0.0056429672986269 0.006870318204164505 0.008146420121192932 0.0093818549066782; 0.0006230059079825878 0.001892360276542604 0.00313343177549541 0.0043704453855752945 0.005635610781610012 0.00686792004853487 0.008135161362588406 0.00935829896479845; 0.0006285107228904963 0.0018708723364397883 0.00313797895796597 0.004386955872178078 0.005625754129141569 0.006872458383440971 0.00814075767993927 0.009382438845932484; 0.0006179038900882006 0.0018937564454972744 0.0031245111022144556 0.004376884084194899 0.005591795779764652 0.006893815938383341 0.008145635016262531 0.0093796756118536; 0.0006278863293118775 0.0018768672598525882 0.003127612639218569 0.0043831514194607735 0.005605553742498159 0.006883938331156969 0.00810080673545599 0.009385739453136921])

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.