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] = 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: 27.768 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (26.223 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (19.100 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 38.388 seconds, max(u): (1.307e-01, 1.146e-01, 1.420e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 603.136 ms, max(u): (2.112e-01, 1.737e-01, 1.715e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 550.391 ms, max(u): (2.705e-01, 2.228e-01, 1.752e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 565.800 ms, max(u): (3.426e-01, 3.038e-01, 1.619e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 565.160 ms, max(u): (3.969e-01, 4.054e-01, 1.707e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 539.811 ms, max(u): (5.292e-01, 5.948e-01, 1.928e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 596.902 ms, max(u): (7.043e-01, 9.537e-01, 2.746e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 563.578 ms, max(u): (1.037e+00, 1.251e+00, 3.819e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 575.462 ms, max(u): (1.426e+00, 1.148e+00, 4.568e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 662.373 ms, max(u): (1.360e+00, 1.228e+00, 5.505e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 627.770 ms, max(u): (1.264e+00, 1.413e+00, 4.279e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 618.483 ms, max(u): (1.396e+00, 1.200e+00, 3.845e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 593.405 ms, max(u): (1.350e+00, 1.218e+00, 3.555e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 532.013 ms, max(u): (1.503e+00, 1.410e+00, 4.057e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 56.853 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 56.882 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
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.009378710761666298 -0.008132082410156727 -0.006849005352705717 -0.00561698479577899 -0.004382934886962175 -0.0031500295735895634 -0.0018715811893343925 -0.0006539808236993849; -0.009381533600389957 -0.008113893680274487 -0.006890332791954279 -0.005639145150780678 -0.0043915086425840855 -0.003130673198029399 -0.001855241833254695 -0.0006037118146196008; -0.009375490248203278 -0.008128768764436245 -0.0069041019305586815 -0.005611781496554613 -0.00436584185808897 -0.0031290582846850157 -0.0018772064941003919 -0.0006075597484596074; -0.009408568032085896 -0.00812826119363308 -0.006862397771328688 -0.005643676966428757 -0.004362916108220816 -0.0031365796457976103 -0.0018774069612845778 -0.0006186985410749912; -0.009374627843499184 -0.00811675377190113 -0.006878458894789219 -0.0056335958652198315 -0.004356923513114452 -0.003126535564661026 -0.0018854838563129306 -0.0005813990137539804; -0.00934422668069601 -0.008135344833135605 -0.006862236652523279 -0.005634282249957323 -0.00439839530736208 -0.003126875963062048 -0.0018863114528357983 -0.0006168875261209905; -0.009384769015014172 -0.008132508024573326 -0.0068786111660301685 -0.005601683631539345 -0.004394393879920244 -0.0031298967078328133 -0.0018799678655341268 -0.000610969087574631; -0.009392432868480682 -0.00813389290124178 -0.006879227701574564 -0.0056297495029866695 -0.004375075455754995 -0.003126849653199315 -0.001884383033029735 -0.0006169750704430044; -0.009368299506604671 -0.008118098601698875 -0.006875983905047178 -0.005596158094704151 -0.004391928669065237 -0.003130668308585882 -0.0018677752232179046 -0.0006119675235822797; -0.009382382966578007 -0.008150282315909863 -0.006834189873188734 -0.005616634152829647 -0.004356647375971079 -0.0031165406107902527 -0.0018724395195022225 -0.000606045126914978; -0.009380004368722439 -0.008132020942866802 -0.0068714856170117855 -0.005643719807267189 -0.004377323668450117 -0.0031454439740628004 -0.0018656087340787053 -0.0006035248516127467; -0.009359634481370449 -0.008123981766402721 -0.0068993703462183475 -0.005616776179522276 -0.004392395261675119 -0.0031466481741517782 -0.0018623325740918517 -0.0006156573654152453; -0.009378451853990555 -0.008113522082567215 -0.006854209583252668 -0.005620099604129791 -0.004381585866212845 -0.0031355645041912794 -0.0018916154513135552 -0.0006433292874135077; -0.009351273067295551 -0.008153489790856838 -0.0068625640124082565 -0.005631704814732075 -0.0043642353266477585 -0.0031152162700891495 -0.0018732845783233643 -0.0006406508036889136; -0.009389485232532024 -0.008085095323622227 -0.0068700662814080715 -0.005612444598227739 -0.004355159588158131 -0.003146689385175705 -0.0018624099902808666 -0.0006268082652240992; -0.009387558326125145 -0.00811807531863451 -0.006888615433126688 -0.005629786290228367 -0.004359844606369734 -0.0031340843997895718 -0.0018906320910900831 -0.0006426647305488586; -0.009389261715114117 -0.008108108304440975 -0.0068893893621861935 -0.005612469278275967 -0.004393385723233223 -0.0031296536326408386 -0.0018807887099683285 -0.0006261572707444429; -0.009365906938910484 -0.008116532117128372 -0.006878731772303581 -0.005651394370943308 -0.004366982728242874 -0.003138535423204303 -0.001859819982200861 -0.0006438226555474102; -0.009383881464600563 -0.008114848285913467 -0.00686729047447443 -0.005661868955940008 -0.0043710810132324696 -0.003136314684525132 -0.001848007901571691 -0.0006533582927659154; -0.009382565505802631 -0.00813660491257906 -0.006891034077852964 -0.005611645523458719 -0.004377866629511118 -0.003104794304817915 -0.0018672411097213626 -0.0006106674554757774; -0.009379505179822445 -0.008109372109174728 -0.0068678054958581924 -0.005601712968200445 -0.004378301557153463 -0.003147523384541273 -0.0018701172666624188 -0.0006439617718569934; -0.009369820356369019 -0.008123940788209438 -0.006870923098176718 -0.00562929455190897 -0.0043852198868989944 -0.0031080967746675014 -0.0018748933216556907 -0.0006408212939277291; -0.007500236853957176 -0.0062512801960110664 -0.00500914454460144 -0.0037608686834573746 -0.002499500522390008 -0.0012622899375855923 6.6680518102657516e-6 0.0012282783864066005; -0.005409632343798876 -0.004158646333962679 -0.0029086433351039886 -0.0016924135852605104 -0.00042176785063929856 0.0008421303937211633 0.0020571390632539988 0.0033103935420513153; -0.0033473323564976454 -0.00208364543505013 -0.0008268786477856338 0.000419736752519384 0.0016593142645433545 0.0028995724860578775 0.004178917966783047 0.0054068295285105705; -0.0012367364251986146 -1.2971970136277378e-5 0.0012540773022919893 0.0025200415402650833 0.0037425528280436993 0.004997518379241228 0.006263228133320808 0.007501337677240372; 0.0006134505965746939 0.0018976327264681458 0.003095725318416953 0.0043901605531573296 0.00561858806759119 0.006878659129142761 0.008117717690765858 0.009371517226099968; 0.0006285369163379073 0.001879134215414524 0.003127526259049773 0.004389684181660414 0.0056490045972168446 0.006884186062961817 0.008118787780404091 0.009382407180964947; 0.0006531079998239875 0.001892217667773366 0.003127721603959799 0.00433805538341403 0.005644052755087614 0.006897266022861004 0.008119666948914528 0.009356232360005379; 0.000615496130194515 0.0018651889404281974 0.003139124484732747 0.004360517952591181 0.00563523406162858 0.006868236698210239 0.00814592745155096 0.009366004727780819; 0.0006065614870749414 0.0018901702715083957 0.003128752578049898 0.004373196512460709 0.005613985005766153 0.006886831950396299 0.008126664906740189 0.009383639320731163; 0.000635506643448025 0.0018859488191083074 0.0031108097173273563 0.004365880507975817 0.005620803218334913 0.006868740543723106 0.008121049031615257 0.009355145506560802; 0.0006361291161738336 0.0018813982605934143 0.0031373652163892984 0.0043734838254749775 0.005624918732792139 0.00692664785310626 0.008097423240542412 0.009404081851243973; 0.0006305281422100961 0.0018792356131598353 0.003121822141110897 0.004366757348179817 0.005640462506562471 0.006879699416458607 0.00815349631011486 0.00938486773520708; 0.0006291460595093668 0.001869330881163478 0.0031323928851634264 0.004387570545077324 0.005630342289805412 0.006908991374075413 0.008104950189590454 0.009373832494020462; 0.000614448101259768 0.0018676690524443984 0.0031120304483920336 0.004368908237665892 0.0056347232311964035 0.006880486384034157 0.008129303343594074 0.009371425025165081; 0.0005931317573413253 0.0018603254575282335 0.0031378089915961027 0.004364688415080309 0.005636224057525396 0.006858868058770895 0.008119979873299599 0.009353398345410824; 0.0006330123287625611 0.0018902152078226209 0.003142131958156824 0.004355757962912321 0.0056271604262292385 0.006863474380224943 0.008120128884911537 0.009396455250680447; 0.0006174268783070147 0.001884509576484561 0.003143044887110591 0.004367783199995756 0.0056264870800077915 0.006882603280246258 0.008120054379105568 0.009341600351035595; 0.0006040209555067122 0.0018754220800474286 0.003119856119155884 0.0043721385300159454 0.0056279851123690605 0.006859239656478167 0.008127672597765923 0.009377101436257362; 0.0006272983737289906 0.00187651626765728 0.003124243812635541 0.0043778023682534695 0.005621681921184063 0.006862219423055649 0.008117776364088058 0.009365478530526161; 0.0006101315375417471 0.001872144523076713 0.0031220007222145796 0.004368165973573923 0.0055964854545891285 0.006880638655275106 0.00811002403497696 0.009348205290734768; 0.0006223514210432768 0.0018743877299129963 0.0031317411921918392 0.004370378330349922 0.0056098694913089275 0.006888884119689465 0.008112442679703236 0.009381757117807865; 0.0006020526052452624 0.0018694513710215688 0.003139480948448181 0.00438728230074048 0.005617983173578978 0.0068788365460932255 0.00814631674438715 0.009401642717421055; 0.0006194672314450145 0.00188513717148453 0.0031264678109437227 0.004380504135042429 0.005630361847579479 0.006886831484735012 0.008110730908811092 0.009380248375236988; 0.0006241388618946075 0.0018817238742485642 0.0031549169216305017 0.004358184989541769 0.005611597094684839 0.006852517835795879 0.008149029687047005 0.009374394081532955; 0.0006337593658827245 0.001888637081719935 0.003112537320703268 0.004398243501782417 0.005614431109279394 0.006893663201481104 0.008134165778756142 0.00934057030826807; 0.0006243633688427508 0.0018601635238155723 0.0031222300603985786 0.004379225429147482 0.005645356141030788 0.006851154379546642 0.008130702190101147 0.009392259642481804])

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.