Baroclinic adjustment

In this example, we simulate the evolution and equilibration of a baroclinically unstable front.

Install dependencies

First let's make sure we have all required packages installed.

using Pkg
pkg"add Oceananigans, CairoMakie"
using Oceananigans
using Oceananigans.Units

Grid

We use a three-dimensional channel that is periodic in the x direction:

Lx = 1000kilometers # east-west extent [m]
Ly = 1000kilometers # north-south extent [m]
Lz = 1kilometers    # depth [m]

grid = RectilinearGrid(size = (48, 48, 8),
                       x = (0, Lx),
                       y = (-Ly/2, Ly/2),
                       z = (-Lz, 0),
                       topology = (Periodic, Bounded, Bounded))
48×48×8 RectilinearGrid{Float64, Periodic, Bounded, Bounded} on CPU with 3×3×3 halo
├── Periodic x ∈ [0.0, 1.0e6)          regularly spaced with Δx=20833.3
├── Bounded  y ∈ [-500000.0, 500000.0] regularly spaced with Δy=20833.3
└── Bounded  z ∈ [-1000.0, 0.0]        regularly spaced with Δz=125.0

Model

We built a HydrostaticFreeSurfaceModel with an ImplicitFreeSurface solver. Regarding Coriolis, we use a beta-plane centered at 45° South.

model = HydrostaticFreeSurfaceModel(; grid,
                                    coriolis = BetaPlane(latitude = -45),
                                    buoyancy = BuoyancyTracer(),
                                    tracers = :b,
                                    momentum_advection = WENO(),
                                    tracer_advection = WENO())
HydrostaticFreeSurfaceModel{CPU, RectilinearGrid}(time = 0 seconds, iteration = 0)
├── grid: 48×48×8 RectilinearGrid{Float64, Periodic, Bounded, Bounded} on CPU with 3×3×3 halo
├── timestepper: QuasiAdamsBashforth2TimeStepper
├── tracers: b
├── closure: Nothing
├── buoyancy: BuoyancyTracer with ĝ = NegativeZDirection()
├── free surface: ImplicitFreeSurface with gravitational acceleration 9.80665 m s⁻²
│   └── solver: FFTImplicitFreeSurfaceSolver
├── advection scheme: 
│   ├── momentum: WENO(order=5)
│   └── b: WENO(order=5)
└── coriolis: BetaPlane{Float64}

We start our simulation from rest with a baroclinically unstable buoyancy distribution. We use ramp(y, Δy), defined below, to specify a front with width Δy and horizontal buoyancy gradient . We impose the front on top of a vertical buoyancy gradient and a bit of noise.

"""
    ramp(y, Δy)

Linear ramp from 0 to 1 between -Δy/2 and +Δy/2.

For example:
```
            y < -Δy/2 => ramp = 0
    -Δy/2 < y < -Δy/2 => ramp = y / Δy
            y >  Δy/2 => ramp = 1
```
"""
ramp(y, Δy) = min(max(0, y/Δy + 1/2), 1)

N² = 1e-5 # [s⁻²] buoyancy frequency / stratification
M² = 1e-7 # [s⁻²] horizontal buoyancy gradient

Δy = 100kilometers # width of the region of the front
Δb = Δy * M²       # buoyancy jump associated with the front
ϵb = 1e-2 * Δb     # noise amplitude

bᵢ(x, y, z) = N² * z + Δb * ramp(y, Δy) + ϵb * randn()

set!(model, b=bᵢ)

Let's visualize the initial buoyancy distribution.

using CairoMakie

# Build coordinates with units of kilometers
x, y, z = 1e-3 .* nodes(grid, (Center(), Center(), Center()))

b = model.tracers.b

fig, ax, hm = heatmap(view(b, 1, :, :),
                      colormap = :deep,
                      axis = (xlabel = "y [km]",
                              ylabel = "z [km]",
                              title = "b(x=0, y, z, t=0)",
                              titlesize = 24))

Colorbar(fig[1, 2], hm, label = "[m s⁻²]")

fig

Simulation

Now let's build a Simulation.

simulation = Simulation(model, Δt=20minutes, stop_time=20days)
Simulation of HydrostaticFreeSurfaceModel{CPU, RectilinearGrid}(time = 0 seconds, iteration = 0)
├── Next time step: 20 minutes
├── Elapsed wall time: 0 seconds
├── Wall time per iteration: NaN days
├── Stop time: 20 days
├── Stop iteration: Inf
├── Wall time limit: Inf
├── Minimum relative step: 0.0
├── Callbacks: OrderedDict with 4 entries:
│   ├── stop_time_exceeded => Callback of stop_time_exceeded on IterationInterval(1)
│   ├── stop_iteration_exceeded => Callback of stop_iteration_exceeded on IterationInterval(1)
│   ├── wall_time_limit_exceeded => Callback of wall_time_limit_exceeded on IterationInterval(1)
│   └── nan_checker => Callback of NaNChecker for u on IterationInterval(100)
├── Output writers: OrderedDict with no entries
└── Diagnostics: OrderedDict with no entries

We add a TimeStepWizard callback to adapt the simulation's time-step,

conjure_time_step_wizard!(simulation, IterationInterval(20), cfl=0.2, max_Δt=20minutes)

Also, we add a callback to print a message about how the simulation is going,

using Printf

wall_clock = Ref(time_ns())

function print_progress(sim)
    u, v, w = model.velocities
    progress = 100 * (time(sim) / sim.stop_time)
    elapsed = (time_ns() - wall_clock[]) / 1e9

    @printf("[%05.2f%%] i: %d, t: %s, wall time: %s, max(u): (%6.3e, %6.3e, %6.3e) m/s, next Δt: %s\n",
            progress, iteration(sim), prettytime(sim), prettytime(elapsed),
            maximum(abs, u), maximum(abs, v), maximum(abs, w), prettytime(sim.Δt))

    wall_clock[] = time_ns()

    return nothing
end

add_callback!(simulation, print_progress, IterationInterval(100))

Diagnostics/Output

Here, we save the buoyancy, $b$, at the edges of our domain as well as the zonal ($x$) average of buoyancy.

u, v, w = model.velocities
ζ = ∂x(v) - ∂y(u)
B = Average(b, dims=1)
U = Average(u, dims=1)
V = Average(v, dims=1)

filename = "baroclinic_adjustment"
save_fields_interval = 0.5day

slicers = (east = (grid.Nx, :, :),
           north = (:, grid.Ny, :),
           bottom = (:, :, 1),
           top = (:, :, grid.Nz))

for side in keys(slicers)
    indices = slicers[side]

    simulation.output_writers[side] = JLD2OutputWriter(model, (; b, ζ);
                                                       filename = filename * "_$(side)_slice",
                                                       schedule = TimeInterval(save_fields_interval),
                                                       overwrite_existing = true,
                                                       indices)
end

simulation.output_writers[:zonal] = JLD2OutputWriter(model, (; b=B, u=U, v=V);
                                                     filename = filename * "_zonal_average",
                                                     schedule = TimeInterval(save_fields_interval),
                                                     overwrite_existing = true)
JLD2OutputWriter scheduled on TimeInterval(12 hours):
├── filepath: baroclinic_adjustment_zonal_average.jld2
├── 3 outputs: (b, u, v)
├── array type: Array{Float32}
├── including: [:grid, :coriolis, :buoyancy, :closure]
├── file_splitting: NoFileSplitting
└── file size: 32.5 KiB

Now we're ready to run.

@info "Running the simulation..."

run!(simulation)

@info "Simulation completed in " * prettytime(simulation.run_wall_time)
[ Info: Running the simulation...
[ Info: Initializing simulation...
[00.00%] i: 0, t: 0 seconds, wall time: 27.534 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (25.311 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (19.293 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 36.707 seconds, max(u): (1.283e-01, 1.167e-01, 1.503e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 598.099 ms, max(u): (2.290e-01, 1.683e-01, 1.705e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 666.016 ms, max(u): (3.344e-01, 2.563e-01, 1.702e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 637.668 ms, max(u): (3.855e-01, 3.807e-01, 1.787e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 573.668 ms, max(u): (5.293e-01, 6.141e-01, 2.058e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 649.346 ms, max(u): (6.851e-01, 9.562e-01, 2.963e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 670.057 ms, max(u): (9.874e-01, 1.132e+00, 4.567e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 583.555 ms, max(u): (1.301e+00, 1.089e+00, 4.504e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 607.261 ms, max(u): (1.423e+00, 1.057e+00, 4.895e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 623.671 ms, max(u): (1.368e+00, 9.442e-01, 2.978e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 610.380 ms, max(u): (1.328e+00, 8.257e-01, 2.493e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 636.527 ms, max(u): (1.153e+00, 1.012e+00, 1.833e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 548.270 ms, max(u): (1.193e+00, 1.084e+00, 2.041e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 669.466 ms, max(u): (1.115e+00, 1.170e+00, 2.145e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 56.527 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 56.556 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.009384283795952797 -0.00814062263816595 -0.006863083224743605 -0.0056365737691521645 -0.004383147228509188 -0.003118387656286359 -0.001868515508249402 -0.0006423303857445717; -0.009360875934362411 -0.00812850333750248 -0.006875972729176283 -0.005625957157462835 -0.004380092490464449 -0.003114321269094944 -0.0018993034027516842 -0.0006352548371069133; -0.009359629824757576 -0.00814114697277546 -0.006859960500150919 -0.0056118895299732685 -0.004360153805464506 -0.0031354508828371763 -0.0018868994666263461 -0.0005931041669100523; -0.009351043030619621 -0.008103365078568459 -0.006871884223073721 -0.00562681071460247 -0.004379650577902794 -0.0031463983468711376 -0.0018638228066265583 -0.0006287836004048586; -0.00938338227570057 -0.008158650249242783 -0.006905341520905495 -0.0056226528249681 -0.004381080623716116 -0.0031222854740917683 -0.0018780374666675925 -0.0005986004252918065; -0.009395227767527103 -0.008110987022519112 -0.006888994015753269 -0.005614571273326874 -0.004360567312687635 -0.0031336864922195673 -0.00186622841283679 -0.0006295994389802217; -0.009371154010295868 -0.008119802922010422 -0.006862269248813391 -0.0056244563311338425 -0.004372673574835062 -0.0031332734506577253 -0.0018855426460504532 -0.0006418221164494753; -0.009363807737827301 -0.008113325573503971 -0.006900110747665167 -0.005638436879962683 -0.004388664849102497 -0.003115215105935931 -0.001886514131911099 -0.0006281643873080611; -0.009360485710203648 -0.008108978159725666 -0.0068560317158699036 -0.005631063599139452 -0.004375159740447998 -0.0031154199969023466 -0.0018831734778359532 -0.0006301255198195577; -0.009404543787240982 -0.008135722950100899 -0.006877202074974775 -0.005616530776023865 -0.004389769863337278 -0.003118337830528617 -0.0018719241488724947 -0.0006147954845800996; -0.009366502985358238 -0.008169671520590782 -0.006888103671371937 -0.0056013017892837524 -0.004383285995572805 -0.0031503753270953894 -0.0018778590019792318 -0.0006023526657372713; -0.009376395493745804 -0.008127574808895588 -0.006875957828015089 -0.005616575479507446 -0.004398064222186804 -0.0030909967608749866 -0.00188359001185745 -0.0006256721680983901; -0.009354286827147007 -0.008095922879874706 -0.006862640380859375 -0.005621827207505703 -0.00436950521543622 -0.0031271246261894703 -0.001873029163107276 -0.0006270570447668433; -0.009385247714817524 -0.008130714297294617 -0.006872921250760555 -0.005644933320581913 -0.00439313193783164 -0.0031291660852730274 -0.0018798579694703221 -0.0006458929856307805; -0.009366623125970364 -0.008101115003228188 -0.006868982221931219 -0.005624989978969097 -0.004370749928057194 -0.003119498724117875 -0.0018899020506069064 -0.000646449567284435; -0.00938658881932497 -0.008127844892442226 -0.006889226380735636 -0.005621802993118763 -0.004367141053080559 -0.003146297996863723 -0.0018470361828804016 -0.0006497989525087178; -0.00938345491886139 -0.008113776333630085 -0.006868406198918819 -0.0056279003620147705 -0.004360987339168787 -0.003126820083707571 -0.0018670570570975542 -0.0006059952429495752; -0.009360422380268574 -0.008097712881863117 -0.006873657461255789 -0.005651478655636311 -0.004411472473293543 -0.0031131324358284473 -0.0018972666002810001 -0.0006471791421063244; -0.009380782023072243 -0.008123267441987991 -0.0068619148805737495 -0.005626766476780176 -0.00438895495608449 -0.003099912777543068 -0.0018742270767688751 -0.0006281069363467395; -0.009362755343317986 -0.008128306828439236 -0.006872033700346947 -0.005595115479081869 -0.004384413827210665 -0.0031333675142377615 -0.0018660321366041899 -0.000642885803245008; -0.009365078993141651 -0.008105190470814705 -0.006873254664242268 -0.005630561150610447 -0.004385479725897312 -0.0031309013720601797 -0.0018749451264739037 -0.0006157895550131798; -0.009371655061841011 -0.008093729615211487 -0.0068951756693422794 -0.005642406176775694 -0.004379843361675739 -0.003103440860286355 -0.0018810317851603031 -0.0006265282281674445; -0.007497767452150583 -0.006254234351217747 -0.005006569437682629 -0.0037709721364080906 -0.002515677362680435 -0.0012601148337125778 8.131127287924755e-6 0.0012648417614400387; -0.005412881262600422 -0.0041931141167879105 -0.0029286302160471678 -0.0016601020470261574 -0.00042822567047551274 0.0008233055705204606 0.002071246737614274 0.003345387289300561; -0.003348889295011759 -0.0020734688732773066 -0.0008392109884880483 0.0004076490877196193 0.0016624776180833578 0.002915678545832634 0.004166880156844854 0.005446897819638252; -0.001234979135915637 -1.610176514077466e-5 0.0012430320493876934 0.0025129530113190413 0.003771939780563116 0.005015126895159483 0.006273407023400068 0.007521594874560833; 0.0006213351152837276 0.001863903016783297 0.003115494502708316 0.004373778123408556 0.005620705895125866 0.006859669461846352 0.008123129606246948 0.009387458674609661; 0.0006287973374128342 0.001869094674475491 0.00311701325699687 0.004385939799249172 0.005616941023617983 0.00689335772767663 0.008129176683723927 0.009367436170578003; 0.0006402941071428359 0.0018715864280238748 0.003134214086458087 0.004384451080113649 0.005629849620163441 0.006872383877635002 0.008114788681268692 0.009383278898894787; 0.0006277217762544751 0.0018592501292005181 0.0030928426422178745 0.004368651658296585 0.0056341360323131084 0.006878145970404148 0.008115392178297043 0.00938343070447445; 0.0006169262924231589 0.0018679621862247586 0.003138753352686763 0.004380804020911455 0.005639177281409502 0.006861856672912836 0.00810747966170311 0.009386122226715088; 0.0006200603093020618 0.0018548830412328243 0.0031017176806926727 0.004375280812382698 0.005616713780909777 0.006865343544632196 0.00812546443194151 0.009373266249895096; 0.0006312175537459552 0.0018517115386202931 0.0031480584293603897 0.00436341343447566 0.0055986568331718445 0.006874709855765104 0.008119028992950916 0.009395566768944263; 0.0006291774334385991 0.0018380674300715327 0.0031189904548227787 0.004357734229415655 0.005627298727631569 0.006904867943376303 0.00812236312776804 0.009367077611386776; 0.0006380052072927356 0.0018683691741898656 0.0031493345741182566 0.004393668379634619 0.0056238071992993355 0.006858226377516985 0.008130300790071487 0.009402809664607048; 0.0006301194080151618 0.0018834453076124191 0.003116792533546686 0.00437944196164608 0.005630145315080881 0.0068575358018279076 0.008108294568955898 0.009370358660817146; 0.0006518657901324332 0.0019065929809585214 0.003128307405859232 0.004380052909255028 0.005644524469971657 0.006907261908054352 0.008145404048264027 0.009371628053486347; 0.0006142737111076713 0.0018807420274242759 0.0031288699246942997 0.0043425001204013824 0.005602098535746336 0.0069052306935191154 0.008111118339002132 0.009388170205056667; 0.0006141558988019824 0.0018748623551800847 0.0031190388835966587 0.004378601908683777 0.005631472449749708 0.006878482643514872 0.008118723519146442 0.009378458373248577; 0.0006303197587840259 0.0018557554576545954 0.0031320496927946806 0.004380839876830578 0.005627498030662537 0.0068694776855409145 0.008132535964250565 0.009369316510856152; 0.0006197299808263779 0.0018655668245628476 0.0031251537147909403 0.004373675212264061 0.005611758679151535 0.006874985992908478 0.00815016683191061 0.009358531795442104; 0.0006451900699175894 0.0018617598107084632 0.0031042424961924553 0.004348215647041798 0.005640747491270304 0.006898908410221338 0.008103708736598492 0.00938827358186245; 0.0006546627264469862 0.0019023461500182748 0.003131801960989833 0.0043733809143304825 0.005625673104077578 0.006867977790534496 0.008122219704091549 0.009375391528010368; 0.0006291346508078277 0.0018614513101056218 0.003107227385044098 0.004357071593403816 0.005640706978738308 0.006873009726405144 0.008131692185997963 0.009356538765132427; 0.0006347366725094616 0.0018654082668945193 0.0031445911154150963 0.004364969674497843 0.0056452020071446896 0.006883610039949417 0.008133938536047935 0.009375903755426407; 0.0006449148058891296 0.0018619645852595568 0.003111738245934248 0.004394986666738987 0.005607909057289362 0.006862907204777002 0.008120977319777012 0.009390798397362232; 0.0006190778221935034 0.0018856227397918701 0.003092955332249403 0.0044005271047353745 0.005650536622852087 0.0068647172302007675 0.008130673319101334 0.009354756213724613; 0.000617175130173564 0.0018585454672574997 0.0031166994012892246 0.00438618054613471 0.005635812412947416 0.00686004851013422 0.008143071085214615 0.009374404326081276])

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.