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: 2.0 MiB

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: 21.141 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (14.223 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (9.644 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 19.425 seconds, max(u): (1.247e-01, 1.145e-01, 1.606e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 834.921 ms, max(u): (2.168e-01, 1.800e-01, 1.709e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 861.101 ms, max(u): (2.730e-01, 2.322e-01, 1.797e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 811.473 ms, max(u): (3.417e-01, 2.899e-01, 1.752e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 793.664 ms, max(u): (4.273e-01, 3.483e-01, 1.719e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 853.550 ms, max(u): (5.012e-01, 4.585e-01, 2.241e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 817.369 ms, max(u): (6.495e-01, 7.530e-01, 2.475e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 853.206 ms, max(u): (9.680e-01, 1.165e+00, 3.041e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 784.721 ms, max(u): (1.257e+00, 1.336e+00, 4.940e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 815.375 ms, max(u): (1.531e+00, 1.398e+00, 4.311e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 840.981 ms, max(u): (1.493e+00, 1.557e+00, 4.227e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 803.223 ms, max(u): (1.506e+00, 1.145e+00, 3.771e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 812.777 ms, max(u): (1.558e+00, 1.134e+00, 3.506e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 805.801 ms, max(u): (1.673e+00, 1.184e+00, 3.644e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 38.055 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 38.092 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.009394550696015358 -0.008136303164064884 -0.006873874459415674 -0.005624156910926104 -0.0043854196555912495 -0.0031340422574430704 -0.001861388678662479 -0.0006365601439028978; -0.009381656534969807 -0.008135228417813778 -0.00687399273738265 -0.005630748812109232 -0.004391588270664215 -0.0031413116957992315 -0.0018769927555695176 -0.000638601602986455; -0.00937939528375864 -0.008131848648190498 -0.006857001688331366 -0.005629306193441153 -0.004368359688669443 -0.0031009700614959 -0.001866362988948822 -0.0006366219604387879; -0.009373490698635578 -0.008105767890810966 -0.006847370881587267 -0.005636341404169798 -0.00436965050175786 -0.00309997471049428 -0.0018619177863001823 -0.0006254052859731019; -0.009364080615341663 -0.008137454278767109 -0.0068918270990252495 -0.005603320896625519 -0.0044037410989403725 -0.0031266354490071535 -0.00188123295083642 -0.0006422905717045069; -0.00935728196054697 -0.00814362708479166 -0.006854730192571878 -0.005619143135845661 -0.004346990492194891 -0.0031146344263106585 -0.0018747519934549928 -0.0006399921840056777; -0.009411044418811798 -0.008130588568747044 -0.006887999828904867 -0.00561716640368104 -0.004344244487583637 -0.003111220896244049 -0.0018832134082913399 -0.000613394717220217; -0.009372159838676453 -0.00811418890953064 -0.006869256030768156 -0.005632735323160887 -0.004367874935269356 -0.0031346529722213745 -0.0018601980991661549 -0.0006265529664233327; -0.009386710822582245 -0.008116730488836765 -0.006871470715850592 -0.005644528195261955 -0.004360865335911512 -0.0031149107962846756 -0.0018815788207575679 -0.0006023722235113382; -0.009374111890792847 -0.008128884248435497 -0.006881915032863617 -0.005624033976346254 -0.0043695056810975075 -0.0031020676251500845 -0.001865917001850903 -0.0006307167350314558; -0.009369929321110249 -0.008137295953929424 -0.006872227881103754 -0.0056294891983270645 -0.004355587065219879 -0.003137560561299324 -0.0018744560657069087 -0.0006363940774463117; -0.009372510947287083 -0.00811898522078991 -0.006881219334900379 -0.005652836058288813 -0.004364086780697107 -0.003115525934845209 -0.0018944732146337628 -0.0006191712454892695; -0.009377277456223965 -0.008122766390442848 -0.006877037696540356 -0.005602584686130285 -0.0043855165131390095 -0.0031193282920867205 -0.0018550503300502896 -0.0006257150089368224; -0.009376897476613522 -0.008114563301205635 -0.006856209132820368 -0.00558311166241765 -0.004360504914075136 -0.0031337663531303406 -0.0018942785682156682 -0.0006033900426700711; -0.009359401650726795 -0.008114920929074287 -0.006893377285450697 -0.005615888629108667 -0.004339751787483692 -0.0031498055905103683 -0.001898929593153298 -0.0006175888702273369; -0.009365028701722622 -0.008113807067275047 -0.006878342013806105 -0.005624372512102127 -0.004372006747871637 -0.0031325211748480797 -0.0018738213693723083 -0.0006104701315052807; -0.009352619759738445 -0.008122935891151428 -0.006872511934489012 -0.005611772648990154 -0.004382015205919743 -0.0031169187277555466 -0.0019005221547558904 -0.0006240751245059073; -0.009346558712422848 -0.00810714066028595 -0.006896640174090862 -0.005650986451655626 -0.0043807257898151875 -0.0031196228228509426 -0.0018627105746418238 -0.0006249261787161231; -0.009369553998112679 -0.008147927932441235 -0.006879359949380159 -0.005606324411928654 -0.0043698702938854694 -0.00312948995269835 -0.0018726888811215758 -0.0006309836753644049; -0.009354080073535442 -0.008125212043523788 -0.006879136431962252 -0.005626722704619169 -0.004390120971947908 -0.0031498826574534178 -0.0018905865726992488 -0.0006105946958996356; -0.009362775832414627 -0.008152995258569717 -0.006862076930701733 -0.005627013277262449 -0.0044002654030919075 -0.0031309158075600863 -0.0018939319998025894 -0.0006127761444076896; -0.009393793530762196 -0.008148747496306896 -0.006849929224699736 -0.005599105730652809 -0.004383237566798925 -0.0031215879134833813 -0.0018786898581311107 -0.0006202008225955069; -0.007537795230746269 -0.006252000108361244 -0.005002742633223534 -0.003732303623110056 -0.002510165562853217 -0.0012292091269046068 8.72595228429418e-6 0.0012639613123610616; -0.005414437036961317 -0.004170396365225315 -0.0029045992996543646 -0.0016447593225166202 -0.0004009275871794671 0.0008404310792684555 0.002085791900753975 0.003309550229460001; -0.0033134939149022102 -0.0020748248789459467 -0.0008275752188637853 0.00042318267514929175 0.0016799404984340072 0.0029426964465528727 0.004191677086055279 0.005412764847278595; -0.0012447899207472801 -4.4590951802092604e-6 0.0012437911937013268 0.0025210543535649776 0.0037760830018669367 0.00502861849963665 0.0062488061375916 0.007491996977478266; 0.0006088598747737706 0.001877117669209838 0.0031145107932388783 0.004366763401776552 0.005609682761132717 0.006888585165143013 0.008158410899341106 0.009381245821714401; 0.0006476141861639917 0.0018362628761678934 0.0031156877521425486 0.0043799313716590405 0.005602675955742598 0.0068737477995455265 0.008105110377073288 0.009373498149216175; 0.0006079229060560465 0.001861097407527268 0.0031498356256633997 0.004391010385006666 0.005619292613118887 0.006873809266835451 0.00811129529029131 0.009407044388353825; 0.0006274975603446364 0.0018887777114287019 0.0031351782381534576 0.004381449893116951 0.005633894819766283 0.006882555317133665 0.008126008324325085 0.009387490339577198; 0.0006238216301426291 0.0018727121641859412 0.0031232330948114395 0.004383718129247427 0.005628584418445826 0.006868635769933462 0.008119182661175728 0.009364761412143707; 0.0006098240264691412 0.0018889723578467965 0.0031175154726952314 0.004378946032375097 0.005610206630080938 0.006872511934489012 0.00811783503741026 0.00937595684081316; 0.0006318328087218106 0.0018606234807521105 0.0031412977259606123 0.004378656391054392 0.00563778355717659 0.006870335899293423 0.008144672960042953 0.009378246031701565; 0.0006426621694117785 0.0018985867500305176 0.00312087987549603 0.004391829948872328 0.005621838849037886 0.006863802205771208 0.008153622969985008 0.009373207576572895; 0.0006304120761342347 0.0018536483403295279 0.003113129176199436 0.004397235345095396 0.005626758560538292 0.00690870126709342 0.008152448572218418 0.00936695747077465; 0.0006099419551901519 0.0018923013703897595 0.003142384812235832 0.004387729801237583 0.005636201705783606 0.00686789071187377 0.008142683655023575 0.009392748586833477; 0.0006133255083113909 0.0018596516456454992 0.0031276331283152103 0.00435485877096653 0.0056073046289384365 0.006884291302412748 0.00813292060047388 0.00938484538346529; 0.0006278131040744483 0.0018894054228439927 0.0031327917240560055 0.004364896100014448 0.005616331472992897 0.006866844836622477 0.008089748211205006 0.00939380656927824; 0.0006105994107201695 0.0018947160569950938 0.003128788201138377 0.004376888275146484 0.0056317271664738655 0.006875899154692888 0.008110135793685913 0.009379152208566666; 0.0006295764469541609 0.0018652022117748857 0.0031439419835805893 0.004360831808298826 0.005628918297588825 0.0068571786396205425 0.008095392026007175 0.009376609697937965; 0.0006427911575883627 0.0018719759536907077 0.0031390858348459005 0.004370628856122494 0.005616992246359587 0.006885072216391563 0.008137131109833717 0.009388661943376064; 0.000612774514593184 0.0018920177826657891 0.00313016539439559 0.00437658978626132 0.005646293051540852 0.006865480914711952 0.00812009908258915 0.009378641843795776; 0.0006463198224082589 0.0018689811695367098 0.003126660594716668 0.004355544690042734 0.00564588000997901 0.006883236579596996 0.008148754946887493 0.009355452843010426; 0.0006384241278283298 0.0018609483959153295 0.0031253027264028788 0.0043809604831039906 0.005616793408989906 0.006898879539221525 0.00815775990486145 0.009376222267746925; 0.0006166884559206665 0.0018434002995491028 0.0031327649485319853 0.004364779219031334 0.005623475182801485 0.006852729246020317 0.008130235597491264 0.009359696879982948; 0.0006120898178778589 0.001881367526948452 0.003116709180176258 0.0043998523615300655 0.005625216756016016 0.006875567138195038 0.008127248845994473 0.009365645237267017; 0.0006062689353711903 0.0018738879589363933 0.0031016930006444454 0.004348435904830694 0.005614539608359337 0.006885311100631952 0.008113388903439045 0.009381339885294437; 0.0006043382454663515 0.0018739935476332903 0.003117996733635664 0.00438354816287756 0.005633867345750332 0.006864134222269058 0.00810243096202612 0.009375645779073238])

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.