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(order=5)
│   └── b: WENO(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

# 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 => 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
└── 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] = JLD2OutputWriter(model, (; b, ζ);
                                                       filename = filename * "_$(side)_slice",
                                                       schedule = TimeInterval(save_fields_interval),
                                                       overwrite_existing = true,
                                                       indices)
end

simulation.output_writers[:zonal] = JLD2OutputWriter(model, (; b=B, u=U, v=V);
                                                     filename = filename * "_zonal_average",
                                                     schedule = TimeInterval(save_fields_interval),
                                                     overwrite_existing = true)
JLD2OutputWriter 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: 30.667 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (28.521 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (20.934 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 41.078 seconds, max(u): (1.264e-01, 1.209e-01, 1.531e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 925.582 ms, max(u): (2.160e-01, 1.659e-01, 1.805e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 750.056 ms, max(u): (2.921e-01, 2.389e-01, 1.593e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 735.640 ms, max(u): (3.825e-01, 3.162e-01, 1.791e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 666.388 ms, max(u): (4.578e-01, 5.112e-01, 2.175e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 772.330 ms, max(u): (5.942e-01, 8.283e-01, 2.670e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 750.566 ms, max(u): (8.367e-01, 1.178e+00, 3.651e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 802.877 ms, max(u): (1.265e+00, 1.216e+00, 4.201e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 797.745 ms, max(u): (1.550e+00, 1.169e+00, 4.943e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 836.575 ms, max(u): (1.431e+00, 9.246e-01, 3.902e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 888.833 ms, max(u): (1.279e+00, 9.886e-01, 3.125e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 932.472 ms, max(u): (1.101e+00, 1.007e+00, 2.360e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 1.008 seconds, max(u): (1.265e+00, 1.204e+00, 2.439e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 1.072 seconds, max(u): (1.373e+00, 1.382e+00, 2.969e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.089 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.090 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
49-element Vector{Float64}:
 -500.0
 -479.1666666666667
 -458.3333333333333
 -437.5
 -416.6666666666667
 -395.8333333333333
 -375.0
 -354.1666666666667
 -333.3333333333333
 -312.5
 -291.6666666666667
 -270.8333333333333
 -250.0
 -229.16666666666666
 -208.33333333333334
 -187.5
 -166.66666666666666
 -145.83333333333334
 -125.0
 -104.16666666666667
  -83.33333333333333
  -62.5
  -41.666666666666664
  -20.833333333333332
    0.0
   20.833333333333332
   41.666666666666664
   62.5
   83.33333333333333
  104.16666666666667
  125.0
  145.83333333333334
  166.66666666666666
  187.5
  208.33333333333334
  229.16666666666666
  250.0
  270.8333333333333
  291.6666666666667
  312.5
  333.3333333333333
  354.1666666666667
  375.0
  395.8333333333333
  416.6666666666667
  437.5
  458.3333333333333
  479.1666666666667
  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!.

set_theme!(Theme(fontsize=24))

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.009341297671198845 -0.008148089982569218 -0.006891040131449699 -0.005651596002280712 -0.004366385750472546 -0.0031255981884896755 -0.0018751866882666945 -0.0006079798331484199; -0.009386583231389523 -0.00810969341546297 -0.006873781327158213 -0.00563626317307353 -0.004394289571791887 -0.0031175734475255013 -0.001890774117782712 -0.0006438761483877897; -0.009389439597725868 -0.008134550414979458 -0.006880772765725851 -0.0056416490115225315 -0.004368457943201065 -0.003119485918432474 -0.0018792451592162251 -0.0006202383665367961; -0.00935115572065115 -0.008108172565698624 -0.006877049338072538 -0.005621955730021 -0.004374423995614052 -0.0031284792348742485 -0.0018730388255789876 -0.0006167346145957708; -0.009374643675982952 -0.008154680952429771 -0.0068880715407431126 -0.005633361171931028 -0.004369951318949461 -0.003130293684080243 -0.0018718107603490353 -0.0006137826712802052; -0.009355048649013042 -0.008138722740113735 -0.006848213728517294 -0.0056159417144954205 -0.004361442755907774 -0.0031286953017115593 -0.00187576562166214 -0.0006552179111167789; -0.009369926527142525 -0.00812277290970087 -0.006866012699902058 -0.00561616662889719 -0.004399461671710014 -0.003107431810349226 -0.001882697455585003 -0.0006288125296123326; -0.009362616576254368 -0.008122138679027557 -0.006859705317765474 -0.005637833382934332 -0.0043713683262467384 -0.00314071262255311 -0.0018642089562490582 -0.000627060595434159; -0.009358422830700874 -0.008130507543683052 -0.00686882808804512 -0.00560834351927042 -0.004407713655382395 -0.003116725478321314 -0.0018775463104248047 -0.0006181012722663581; -0.009388666599988937 -0.008149917237460613 -0.006869596429169178 -0.005618575494736433 -0.004392439033836126 -0.0031350820790976286 -0.0018899793503805995 -0.0006255232146941125; -0.009386046789586544 -0.008115401491522789 -0.006884268019348383 -0.005624784622341394 -0.00439762556925416 -0.0031227553263306618 -0.001872663153335452 -0.0005970064084976912; -0.009384128265082836 -0.008114621043205261 -0.006901615299284458 -0.005633049178868532 -0.004374929703772068 -0.0031220363453030586 -0.001863352139480412 -0.0006555241416208446; -0.009395577013492584 -0.0081393513828516 -0.006890581920742989 -0.005618030205368996 -0.004368151538074017 -0.003153875470161438 -0.0018754084594547749 -0.0006263527320697904; -0.009385625831782818 -0.008086436428129673 -0.0068747359327971935 -0.0056285192258656025 -0.004360703285783529 -0.003097358625382185 -0.0018678357591852546 -0.0006350634503178298; -0.009369641542434692 -0.008143237791955471 -0.006885796785354614 -0.0056153819896280766 -0.004389017354696989 -0.0031241802498698235 -0.0018876312533393502 -0.0006314708152785897; -0.009386557154357433 -0.008104930631816387 -0.0068786172196269035 -0.005619808100163937 -0.004370441660284996 -0.0031332720536738634 -0.0018697843188419938 -0.0006218912312760949; -0.009380417875945568 -0.008107971400022507 -0.006888620555400848 -0.005640135612338781 -0.0043831560760736465 -0.003099962370470166 -0.0018626035889610648 -0.0006395999807864428; -0.009381414391100407 -0.008109761402010918 -0.00687241367995739 -0.005619941279292107 -0.004370525013655424 -0.0031257502268999815 -0.0018763061380013824 -0.0006381223211064935; -0.009378697723150253 -0.008117394521832466 -0.0068816207349300385 -0.005619045812636614 -0.004365643952041864 -0.0031431992538273335 -0.001874328125268221 -0.0006185059319250286; -0.009357890114188194 -0.008115099743008614 -0.006869079545140266 -0.005627993959933519 -0.004374591633677483 -0.0031158088240772486 -0.0018841505516320467 -0.0006393095827661455; -0.009364618919789791 -0.008125062100589275 -0.006834322586655617 -0.005618907976895571 -0.004354800097644329 -0.003119167173281312 -0.0019076007883995771 -0.0006294568302109838; -0.009370844811201096 -0.008118742145597935 -0.006861505098640919 -0.005614247173070908 -0.0043718647211790085 -0.00312418513931334 -0.0018342596013098955 -0.0005953634390607476; -0.007500427775084972 -0.006252642255276442 -0.0049820393323898315 -0.003757767379283905 -0.0025086626410484314 -0.0012392773060128093 -9.260511433240026e-6 0.001228797947987914; -0.005409108474850655 -0.004192807711660862 -0.002920210361480713 -0.0016439345199614763 -0.00044554800842888653 0.000804265437182039 0.0020815683528780937 0.0033596381545066833; -0.003318543080240488 -0.0020912541076540947 -0.0008346559479832649 0.0004173804190941155 0.0016743006417527795 0.002887391485273838 0.004159688949584961 0.005408101715147495; -0.001258770702406764 -1.1813647688541096e-5 0.001259699696674943 0.0024901889264583588 0.0037123982328921556 0.004975425079464912 0.006262579467147589 0.007484689820557833; 0.0006239593494683504 0.0018819511169567704 0.0031580233480781317 0.004353996366262436 0.005627641920000315 0.006869340315461159 0.008123314008116722 0.009381145238876343; 0.0006217924528755248 0.0018585949437692761 0.003139844862744212 0.004377387929707766 0.005615273490548134 0.006886651739478111 0.00811051670461893 0.009370348416268826; 0.0006253253668546677 0.0018922644667327404 0.0031108087860047817 0.004362304694950581 0.005636381916701794 0.0068687316961586475 0.008137652650475502 0.009382374584674835; 0.0006313353078439832 0.001895782072097063 0.0031269844621419907 0.004369926173239946 0.005626582074910402 0.0068588703870773315 0.008119793608784676 0.009387033991515636; 0.0006206420948728919 0.0018795697251334786 0.0031194172333925962 0.004366645589470863 0.0056209261529147625 0.006883108057081699 0.008119410835206509 0.00936323031783104; 0.0006237534689716995 0.0018972877878695726 0.003128376789391041 0.004369106609374285 0.0056334626860916615 0.006884013768285513 0.008115245960652828 0.00934924092143774; 0.0006431927904486656 0.0018961862660944462 0.003115205094218254 0.0043691531755030155 0.0056181917898356915 0.006895759142935276 0.008114790543913841 0.009391197934746742; 0.0006271548336371779 0.0018764911219477654 0.003114165272563696 0.00438013207167387 0.005603764206171036 0.006877335719764233 0.008093204349279404 0.009380822069942951; 0.0006217264453880489 0.0018622259376570582 0.003111834404990077 0.004375825636088848 0.005637736525386572 0.006864950992166996 0.008099020458757877 0.009378250688314438; 0.0006263175746425986 0.001851871726103127 0.003105128649622202 0.004382889252156019 0.005619626492261887 0.006882344838231802 0.008125456981360912 0.00938069075345993; 0.000620421429630369 0.0018820319091901183 0.003135629463940859 0.004372762981802225 0.005608276929706335 0.006880052387714386 0.00811411626636982 0.009376461617648602; 0.0006211799918673933 0.0018743816763162613 0.003136635757982731 0.00437130918726325 0.005626591853797436 0.006865650415420532 0.00815961230546236 0.0093813082203269; 0.0006343028508126736 0.0018847950268536806 0.0031113901641219854 0.004385704640299082 0.005624845158308744 0.006882897578179836 0.008108534850180149 0.00938260555267334; 0.0006359413382597268 0.0018610057886689901 0.0030841876287013292 0.004354273434728384 0.0056221336126327515 0.00686653982847929 0.008129112422466278 0.00934036448597908; 0.0006145042134448886 0.0018493392271921039 0.003126093652099371 0.004372652154415846 0.005637441761791706 0.006873610895127058 0.008112813346087933 0.009382680058479309; 0.0006289475131779909 0.001882474054582417 0.003105167532339692 0.004360313061624765 0.005647481884807348 0.006851647514849901 0.008118933998048306 0.00936803873628378; 0.0006336364895105362 0.0018711347365751863 0.003121876623481512 0.0043695103377103806 0.005658729933202267 0.006879622582346201 0.008141479454934597 0.009365590289235115; 0.000611090858001262 0.0018547484651207924 0.0031174100004136562 0.004364139400422573 0.005636740941554308 0.006859856192022562 0.008124192245304585 0.009381030686199665; 0.0005913235945627093 0.0018797279335558414 0.003125446615740657 0.004393387585878372 0.00562498951330781 0.006883113645017147 0.008115128614008427 0.009375368244946003; 0.0006046564667485654 0.0018640635535120964 0.003120813751593232 0.004391792695969343 0.005633827298879623 0.006890453398227692 0.008125239051878452 0.009368720464408398; 0.0006312859477475286 0.001886698417365551 0.003140529617667198 0.0043539381586015224 0.005640159361064434 0.006872502155601978 0.00815956573933363 0.009366314858198166; 0.000609188515227288 0.0018754976335912943 0.0031355852261185646 0.004374864045530558 0.005614891182631254 0.0068740625865757465 0.008103444240987301 0.009367230348289013])

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.