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: 54.627 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (46.329 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (29.134 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 1.038 minutes, max(u): (1.361e-01, 1.112e-01, 1.591e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 1.173 seconds, max(u): (2.147e-01, 1.636e-01, 1.703e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 1.370 seconds, max(u): (2.879e-01, 2.398e-01, 1.630e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 1.095 seconds, max(u): (3.703e-01, 3.710e-01, 1.682e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 1.011 seconds, max(u): (4.639e-01, 5.741e-01, 2.016e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 1.360 seconds, max(u): (6.370e-01, 9.326e-01, 2.997e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 1.358 seconds, max(u): (1.037e+00, 1.165e+00, 4.009e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 1.659 seconds, max(u): (1.386e+00, 1.115e+00, 4.946e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 1.798 seconds, max(u): (1.354e+00, 1.168e+00, 4.349e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 1.397 seconds, max(u): (1.333e+00, 1.177e+00, 3.648e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 1.508 seconds, max(u): (1.278e+00, 1.178e+00, 3.482e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 1.106 seconds, max(u): (1.317e+00, 1.297e+00, 3.814e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 1.063 seconds, max(u): (1.505e+00, 1.255e+00, 3.856e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 1.193 seconds, max(u): (1.422e+00, 1.513e+00, 3.332e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.659 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.660 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.009377689100801945 -0.008133362047374249 -0.006877342704683542 -0.005616857670247555 -0.004400319419801235 -0.0031244722194969654 -0.0018962485482916236 -0.0006189281702972949; -0.009381496347486973 -0.008121749386191368 -0.006884319242089987 -0.005628672894090414 -0.004360737279057503 -0.0031125713139772415 -0.0018857424147427082 -0.000595233344938606; -0.009380108676850796 -0.00812084786593914 -0.006906077265739441 -0.005635540001094341 -0.004380017053335905 -0.003142724744975567 -0.001834255876019597 -0.0006176218739710748; -0.009407591074705124 -0.008104714564979076 -0.006878997199237347 -0.005639214999973774 -0.00438542990013957 -0.0031250142492353916 -0.0018803953425958753 -0.0006352597265504301; -0.009367678314447403 -0.008109655231237411 -0.006875720340758562 -0.005621795076876879 -0.004373867530375719 -0.003143673064187169 -0.0018838600954040885 -0.0005980174173600972; -0.009380437433719635 -0.008157568983733654 -0.006886849645525217 -0.005612126551568508 -0.004380851052701473 -0.0031401440501213074 -0.0018790489993989468 -0.0006318767555058002; -0.00938133429735899 -0.00814749300479889 -0.006863489281386137 -0.005648518446832895 -0.004390927962958813 -0.003102176357060671 -0.0018661563517525792 -0.0006196973845362663; -0.009373451583087444 -0.00811486691236496 -0.006874491926282644 -0.005608493462204933 -0.004362175706773996 -0.0031513040885329247 -0.0018560083117336035 -0.0006328386371023953; -0.009379647672176361 -0.008129377849400043 -0.006872459314763546 -0.0056338063441216946 -0.004375244956463575 -0.0031346450559794903 -0.001865460304543376 -0.0006216360488906503; -0.009362957440316677 -0.008124791085720062 -0.006867345422506332 -0.005613487213850021 -0.004360999446362257 -0.0031234791968017817 -0.0018581374315544963 -0.0006267817225307226; -0.009378522634506226 -0.008132903836667538 -0.006896152161061764 -0.005620380397886038 -0.004381671082228422 -0.003083149204030633 -0.0018702808301895857 -0.0005916474619880319; -0.00938777718693018 -0.008111183531582355 -0.006909055169671774 -0.0055924952030181885 -0.004387388005852699 -0.003116006264463067 -0.0018823494901880622 -0.0006262533715926111; -0.009368847124278545 -0.008094627410173416 -0.006853030528873205 -0.005628249607980251 -0.004366978537291288 -0.0031029798556119204 -0.0018670083954930305 -0.0006345658330246806; -0.009359280578792095 -0.00813127402216196 -0.006889756303280592 -0.005630087107419968 -0.004373330622911453 -0.0031121009960770607 -0.0018806795123964548 -0.0006032789824530482; -0.009371246211230755 -0.00810667872428894 -0.00686252024024725 -0.005631536711007357 -0.004368648398667574 -0.003109643468633294 -0.0018599614268168807 -0.0006093303672969341; -0.009388045407831669 -0.00812322087585926 -0.006871598772704601 -0.005620679818093777 -0.004397608805447817 -0.003127336036413908 -0.0018855526577681303 -0.0006374756922014058; -0.009377408772706985 -0.008140236139297485 -0.006876025814563036 -0.005614061839878559 -0.004353527445346117 -0.0031147447880357504 -0.0018611836712807417 -0.0006233478197827935; -0.009395693428814411 -0.00813076738268137 -0.006869491655379534 -0.005612778011709452 -0.004372238181531429 -0.003135955659672618 -0.0018860313575714827 -0.000615029945038259; -0.009379000402987003 -0.00813208520412445 -0.006899980362504721 -0.005633688997477293 -0.00439104437828064 -0.003121953224763274 -0.0018751188181340694 -0.0006175207090564072; -0.00938593689352274 -0.008137292228639126 -0.006872158031910658 -0.0056524984538555145 -0.004390542861074209 -0.003102001966908574 -0.00188242900185287 -0.0006271894671954215; -0.009382089599967003 -0.008116202428936958 -0.006872026715427637 -0.005602169316262007 -0.004379577469080687 -0.0031430674716830254 -0.0018541718600317836 -0.0006079076556488872; -0.009417355060577393 -0.008114978671073914 -0.006882945541292429 -0.00560860987752676 -0.004370687995105982 -0.0031340450514107943 -0.0018564254278317094 -0.0006398000405170023; -0.007500785868614912 -0.006260101683437824 -0.005004019942134619 -0.0037467912770807743 -0.002502084244042635 -0.0012744468403980136 -2.1868120825274673e-7 0.0012476202100515366; -0.005413264501839876 -0.004162237513810396 -0.002894539851695299 -0.0016512955771759152 -0.00043021878809668124 0.0008459546370431781 0.0020519450772553682 0.003338376758620143; -0.003316010581329465 -0.002101622987538576 -0.0008394779870286584 0.0004340565646998584 0.0016497797332704067 0.0029162478167563677 0.004162435885518789 0.005415730178356171; -0.0012822969583794475 2.7144520572619513e-5 0.0012400122359395027 0.002509088022634387 0.0037633185274899006 0.00500080082565546 0.006263000424951315 0.007497197017073631; 0.0006360531551763415 0.0018633793806657195 0.003124208189547062 0.004355594515800476 0.00563557306304574 0.006866344716399908 0.008112961426377296 0.00938000064343214; 0.000600503059104085 0.0018689495045691729 0.0031259176321327686 0.004359659738838673 0.005645417608320713 0.006869441829621792 0.008124953135848045 0.009400215931236744; 0.0006193309091031551 0.0018491690279915929 0.0031188796274363995 0.004380771890282631 0.005637520924210548 0.006857398897409439 0.00812604185193777 0.009362972341477871; 0.0006372949574142694 0.0018733094912022352 0.0031140181235969067 0.004358754027634859 0.005640955176204443 0.006875946186482906 0.008129823952913284 0.009407608769834042; 0.0006216351175680757 0.0018641931237652898 0.0031290568877011538 0.004369772970676422 0.005652713589370251 0.0068902019411325455 0.008121088147163391 0.009365017525851727; 0.0006253147730603814 0.0018833773210644722 0.00310590211302042 0.004372579511255026 0.0056204237043857574 0.006862071342766285 0.008128585293889046 0.009383128024637699; 0.000647466629743576 0.0019134526373818517 0.0031379053834825754 0.004386980552226305 0.005627210717648268 0.006876171566545963 0.008109155111014843 0.009368203580379486; 0.0006214982131496072 0.0019069903064519167 0.0031249939929693937 0.004383569583296776 0.005624955520033836 0.006896393373608589 0.008120037615299225 0.009346469305455685; 0.0005884171696379781 0.0018661803333088756 0.003110928228124976 0.00437697721645236 0.005610337480902672 0.006850090343505144 0.008122200146317482 0.009382699616253376; 0.0006184161175042391 0.001850989181548357 0.0031118334736675024 0.00435181288048625 0.005649894941598177 0.006887003779411316 0.00814099982380867 0.009387174621224403; 0.0006400773418135941 0.0019051515264436603 0.0031487001106142998 0.004362917970865965 0.005604469683021307 0.006901010870933533 0.008117801509797573 0.009390980005264282; 0.0006126037915237248 0.0018975338898599148 0.0030962571036070585 0.004379169549793005 0.0056455666199326515 0.006875196471810341 0.008134507574141026 0.009382983669638634; 0.0006294550257734954 0.0018547734944149852 0.0031218251679092646 0.004392644390463829 0.005637511610984802 0.0068649956956505775 0.00812438689172268 0.00937203411012888; 0.0006248704739846289 0.0018778506200760603 0.0031131862197071314 0.004391366150230169 0.005648932419717312 0.0068936944007873535 0.00811010878533125 0.009362242184579372; 0.0006143531063571572 0.0018785428255796432 0.0031254063360393047 0.00437846640124917 0.0056152925826609135 0.006867408752441406 0.008128952234983444 0.009364567697048187; 0.0006311913602985442 0.001879470539279282 0.0031199029181152582 0.004383627790957689 0.005622494965791702 0.006902311462908983 0.00812614057213068 0.009357350878417492; 0.0006145597435534 0.001877170754596591 0.0031068522948771715 0.004367998335510492 0.005623905919492245 0.006870330777019262 0.008124066516757011 0.009378092363476753; 0.0006502459291368723 0.0018802218837663531 0.0031188055872917175 0.004372832365334034 0.005645507946610451 0.0068857078440487385 0.008136430755257607 0.009351412765681744; 0.0006103077903389931 0.001875579939223826 0.0031148537527769804 0.004378156736493111 0.005639358889311552 0.006855676881968975 0.008125931024551392 0.009388037025928497; 0.0005899106035940349 0.0018792084883898497 0.0031197345815598965 0.004360324237495661 0.005638312082737684 0.0068734316155314445 0.00811112392693758 0.009366432204842567; 0.0006613619043491781 0.001889434875920415 0.0031445373315364122 0.0043386435136199 0.005612123291939497 0.006876302883028984 0.00813782587647438 0.00936355721205473; 0.0006392365321516991 0.0018608872778713703 0.003137310966849327 0.00438179075717926 0.005629283841699362 0.006894854828715324 0.008118969388306141 0.009396770969033241])

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.