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{Float64}
├── 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: 26.559 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (24.247 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (17.860 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 40.698 seconds, max(u): (1.267e-01, 1.165e-01, 1.449e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 6.461 seconds, max(u): (2.126e-01, 1.903e-01, 1.742e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 5.796 seconds, max(u): (3.003e-01, 2.583e-01, 1.835e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 6.092 seconds, max(u): (3.748e-01, 3.560e-01, 1.832e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 5.743 seconds, max(u): (4.823e-01, 5.321e-01, 1.925e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 5.439 seconds, max(u): (6.528e-01, 8.049e-01, 2.606e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 5.848 seconds, max(u): (9.466e-01, 1.148e+00, 3.557e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 5.574 seconds, max(u): (1.295e+00, 1.161e+00, 4.720e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 5.582 seconds, max(u): (1.315e+00, 1.058e+00, 4.663e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 5.510 seconds, max(u): (1.283e+00, 1.006e+00, 4.243e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 5.474 seconds, max(u): (1.231e+00, 9.763e-01, 3.012e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 5.680 seconds, max(u): (1.299e+00, 9.726e-01, 3.802e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 5.538 seconds, max(u): (1.428e+00, 1.055e+00, 3.391e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 5.581 seconds, max(u): (1.411e+00, 1.392e+00, 2.234e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 2.135 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 2.136 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.009386568938324886 -0.008126571806102207 -0.0068580194894693166 -0.005638268274011211 -0.004386285063721968 -0.0031200257600244885 -0.0018833865684173376 -0.0006149653284085408; -0.009384682509060419 -0.008121478506041481 -0.006855503213442392 -0.005633053411538996 -0.004393079697913661 -0.003135650933303192 -0.00187690154126347 -0.0006318811360513332; -0.009394829640439169 -0.008151197419056667 -0.006872500042783078 -0.005645156584154471 -0.004368536037902568 -0.0031373255546265516 -0.0018781953632256837 -0.0006067272019761072; -0.009346522339328972 -0.00810195506493547 -0.006864289722873426 -0.0056315300846888254 -0.004376551630565564 -0.0031149932610495795 -0.0018561270768450513 -0.0006158872251095523; -0.009350831780523802 -0.00811458174006868 -0.006859955876922077 -0.0056384507115370824 -0.0043792846891882444 -0.003119966667602211 -0.001883732352357922 -0.0006442202304091056; -0.00937213770335396 -0.00813047805926107 -0.00689428103112275 -0.005625180798378783 -0.004370646645376611 -0.0031398613466087056 -0.001868081416237754 -0.0006090033304086709; -0.009363527991803677 -0.008130029462066786 -0.006875297901342548 -0.0056367250445695715 -0.00435944492954864 -0.003124303503395282 -0.0019019209198537768 -0.0006219639584545302; -0.009388708335834576 -0.008128640323027117 -0.006877813283338834 -0.005645604498242279 -0.004404160103941926 -0.003121701236234308 -0.001860603709977863 -0.0006251104836921376; -0.009402060316308702 -0.00812694004932589 -0.006870132448309477 -0.005637648280179634 -0.004358378948942342 -0.003130302733829886 -0.0018730914326547498 -0.0006250460798656235; -0.009376318313269303 -0.008115990886403728 -0.006881850979748375 -0.005632029847531378 -0.004372899323264702 -0.003125684581717688 -0.001876333404153192 -0.0006173839383873284; -0.009378032131074259 -0.00812951439091933 -0.006878610742687451 -0.005661143264752859 -0.004391407681466825 -0.0031307848724871977 -0.0018662503403848979 -0.0006333119599411029; -0.009387664462366796 -0.00813329129985581 -0.006870805428428353 -0.0056224468619406704 -0.00434944808001063 -0.0031177183789022588 -0.001827705557580792 -0.0006437817105107686; -0.009347924493439031 -0.008141983774756792 -0.00688613080640724 -0.005615177425071072 -0.004396192705654029 -0.0031152733537515354 -0.0018882544252081697 -0.0006053074928757759; -0.009358796358583636 -0.00812072210132884 -0.006880592439631957 -0.005621179137533909 -0.004394400600839767 -0.0031004997091663585 -0.001894830310719315 -0.0006032385835610005; -0.0093868344824559 -0.008147686541499777 -0.006871421729268146 -0.005593531627270289 -0.004370422077887059 -0.0031225292304867098 -0.001874991713487005 -0.000624872365933211; -0.00939148666078689 -0.008168744508694294 -0.006869374928097441 -0.005615117565923401 -0.0043767728904082264 -0.0031198392450911307 -0.0018948254868344503 -0.0005994360338648484; -0.009372570562736318 -0.008161450048485475 -0.006873788819379462 -0.00563335181309214 -0.004383003393490308 -0.003102622297186338 -0.001863842111250186 -0.0006271835972582715; -0.009356251879058067 -0.008124622688737843 -0.006890821768000845 -0.005599059222990866 -0.004382344672899927 -0.0031486525117455214 -0.0018769885855171506 -0.0006234844810332028; -0.009354250472362257 -0.00811387008979908 -0.006865004925059139 -0.005632273834046848 -0.004389861296116414 -0.0031158791033164567 -0.0018628654663818275 -0.0006455596131225241; -0.00938714156761719 -0.008128256521564034 -0.006873326110468807 -0.005633921846068493 -0.004371582838155991 -0.003120631891603054 -0.0018862625055489476 -0.000625566774843022; -0.009396868998638438 -0.008115121850476416 -0.0068784383833099885 -0.005620775131655246 -0.004358823410517544 -0.003110913759777884 -0.001866199142124599 -0.0006207450412714517; -0.009362456250593404 -0.008141691780223627 -0.006889716989848166 -0.00560864568254964 -0.0043448814032809825 -0.003136122012069054 -0.0018661978522099268 -0.0006393280649813122; -0.0075037364688845705 -0.006257423391896615 -0.004988300819442774 -0.0037522825550950125 -0.0024949187100190367 -0.0012566557097249522 -2.2757460992577184e-6 0.0012343073593134646; -0.00540859758400775 -0.00415445044839807 -0.0029234094490424947 -0.0016796375580886383 -0.0004357743585803394 0.0008296598729763581 0.002112047835349954 0.003354891870124692; -0.0033538147974795924 -0.002051615949434225 -0.0008434601897612205 0.00039628852802160437 0.0016474571008555504 0.0029002477199021755 0.004154234326298373 0.005421242341439254; -0.001255525711809425 -7.704048367920503e-6 0.0012665117746112735 0.0025080999314240154 0.0037437367100095153 0.005001968282928871 0.006239554121123379 0.007480452498823657; 0.0006375564889286481 0.0018359632866494415 0.003134005830661503 0.004377966785786199 0.005632484375177493 0.006872686490790204 0.008121770183708625 0.009362652914605418; 0.0005919468625135235 0.0018940095995673596 0.003093255745407399 0.004389949074994056 0.005618191944135191 0.006863560676553933 0.008122631258389433 0.00939144788132667; 0.0006177803607138908 0.0018718090249568633 0.0031290334474270774 0.004380210516101298 0.00562763107671778 0.0068924525717965575 0.008115356521415396 0.009391835432009868; 0.0006069924087586136 0.0018906440788965181 0.0031045963987266774 0.004391186585090654 0.005639132668335426 0.006866281682101814 0.008142195452007958 0.009366431682555767; 0.0006133613108100388 0.0018895142651549522 0.0031162715948105358 0.004381895755824005 0.005626242723653838 0.006879626265795538 0.008125972265208848 0.009380358443467041; 0.000622683955594078 0.00187401810520685 0.003139776104498149 0.004393412625587342 0.005623768936559047 0.006867379574772942 0.008138764641995299 0.009343047617380917; 0.0006452064399320136 0.0018860021027096389 0.0031366640639466973 0.004376972895341109 0.005643578163056561 0.006850980100316852 0.008113865795446687 0.009397551153684245; 0.0006394965265137781 0.00186719219645952 0.003122384952142232 0.004400376049701614 0.005599853497113627 0.00687092149398456 0.008146324226775482 0.009387632186283947; 0.0006774563531284451 0.0018689030848791871 0.0031551009384429445 0.004363068652495948 0.005599822650533315 0.006891262882177615 0.008118016971541726 0.009370734061169847; 0.0006012888938532729 0.0018535352572122174 0.0031343454896708305 0.004365685991085869 0.005634027372179772 0.006868830438806428 0.008131724353620496 0.00940124156275003; 0.0006209492700357601 0.0018595932467215697 0.003120227334361103 0.004380475379691679 0.005647999810946619 0.006895619179962013 0.008122412394940966 0.009385590471270482; 0.0006350899959984332 0.0018745216488235458 0.003093273509116494 0.004375082182658161 0.005596745227976292 0.006875310503949637 0.008127313929536232 0.009370979972462558; 0.0006422988704159548 0.0018539156069481725 0.003109105849092405 0.004363135766391202 0.005619234159772698 0.0068954346392459676 0.008142743585217374 0.009398761999934531; 0.0006223939949895609 0.0018820678054613856 0.0031269239208499733 0.00438440618846157 0.0056294548998521805 0.006899064453101633 0.008100928389727436 0.009387220121481287; 0.0006223173511729078 0.0018825006666206184 0.003109481903103226 0.004363672251102329 0.005645071229307919 0.006874505598169082 0.008131975460027628 0.009371878500215843; 0.0006191659538733924 0.0018765866623136386 0.003132665351593107 0.004349425900054649 0.005604539286050324 0.00688457269434658 0.00812700609147219 0.009378951263022971; 0.0005993013444311872 0.0018773647435926563 0.003117561677102218 0.0043493907175373835 0.005604823182104951 0.006921151689865565 0.008114279535603015 0.009359578644714893; 0.0006088742439547437 0.0018491502256018767 0.0031597668732054386 0.004368619879742678 0.005647724018702879 0.006852962881156486 0.008105896801844186 0.009337476281920458; 0.0006278835108546601 0.0019071770151444175 0.0031389642109143343 0.004380856768003034 0.005637303066685292 0.006897015265097883 0.008118017584116862 0.009385512322820004; 0.0006216215530498474 0.001861388974024542 0.003118255681284055 0.004396437473554073 0.0056165064879883835 0.0068825862174780655 0.008105986965967467 0.009379892939587206; 0.0006348788014758775 0.0018688015483421933 0.0031083277125555186 0.004346239999741259 0.005641715603604686 0.006874463269813869 0.008133840823772812 0.009369082216622951; 0.0006225919804266955 0.0018683165995750834 0.0031227320666890024 0.004382032227275624 0.005640234213982628 0.006887428289559586 0.008145241713474154 0.009356081367582102])

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.