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: 34.320 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (36.790 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (24.774 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 51.906 seconds, max(u): (1.308e-01, 1.143e-01, 1.560e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 966.121 ms, max(u): (2.146e-01, 1.726e-01, 2.040e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 1.041 seconds, max(u): (3.044e-01, 2.522e-01, 1.740e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 940.156 ms, max(u): (3.958e-01, 3.250e-01, 1.782e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 812.927 ms, max(u): (4.640e-01, 4.688e-01, 1.789e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 2.500 seconds, max(u): (6.066e-01, 8.053e-01, 2.678e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 5.612 seconds, max(u): (8.515e-01, 1.225e+00, 3.638e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 1.361 seconds, max(u): (1.231e+00, 1.150e+00, 4.410e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 1.713 seconds, max(u): (1.362e+00, 1.183e+00, 4.156e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 1.378 seconds, max(u): (1.334e+00, 1.038e+00, 4.131e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 1.244 seconds, max(u): (1.325e+00, 9.497e-01, 3.363e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 2.191 seconds, max(u): (1.307e+00, 1.256e+00, 3.294e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 1.191 seconds, max(u): (1.193e+00, 1.274e+00, 2.750e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 894.126 ms, max(u): (1.343e+00, 1.271e+00, 2.096e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 0 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.485 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.009362572804093361 -0.008146636188030243 -0.006888723466545343 -0.005641540512442589 -0.004365142900496721 -0.003124629845842719 -0.0018713070312514901 -0.0006281596142798662; -0.00935435015708208 -0.008128335699439049 -0.0069078621454536915 -0.0056557729840278625 -0.004387554246932268 -0.0031262687407433987 -0.001851006061770022 -0.0006328606395982206; -0.00936480239033699 -0.008114124648272991 -0.00688694603741169 -0.0056268866173923016 -0.004365948494523764 -0.0031237585935741663 -0.00187977054156363 -0.0006072106771171093; -0.009366871789097786 -0.008134583942592144 -0.006905505433678627 -0.0056328438222408295 -0.004350525792688131 -0.0031112818978726864 -0.0018416432430967689 -0.0006128526292741299; -0.009387277998030186 -0.008115630596876144 -0.006867970339953899 -0.005646060220897198 -0.004402572754770517 -0.003119866829365492 -0.0018813024507835507 -0.000619900063611567; -0.009359556250274181 -0.008099854923784733 -0.006877161096781492 -0.00562459509819746 -0.004363491199910641 -0.0031260126270353794 -0.0018594509456306696 -0.000614094256889075; -0.009390492923557758 -0.00811027642339468 -0.006872374564409256 -0.005652002990245819 -0.004404911771416664 -0.0031113866716623306 -0.0018586094956845045 -0.0006360167753882706; -0.009380592033267021 -0.008087139576673508 -0.006873337086290121 -0.005609339568763971 -0.004383835010230541 -0.0031370604410767555 -0.001842570141889155 -0.000633512157946825; -0.009365125559270382 -0.008147922344505787 -0.006887452211230993 -0.005647573620080948 -0.004385589621961117 -0.003111820435151458 -0.001886262558400631 -0.0006320200045593083; -0.009339411742985249 -0.008126091212034225 -0.006861818488687277 -0.005623381119221449 -0.004387741442769766 -0.0031162267550826073 -0.0018684108508750796 -0.0006238266942091286; -0.009364455938339233 -0.008142209611833096 -0.0068789394572377205 -0.005632483400404453 -0.004396981559693813 -0.00310760666616261 -0.0018749836599454284 -0.0006278472137637436; -0.009381230920553207 -0.008096686564385891 -0.006882143206894398 -0.005588873289525509 -0.0043801781721413136 -0.0031025258358567953 -0.0018720267107710242 -0.0006174196023494005; -0.009357553906738758 -0.008156821131706238 -0.006851494777947664 -0.00562982028350234 -0.004382110200822353 -0.003143452573567629 -0.001892184023745358 -0.0006125840009190142; -0.009367127902805805 -0.008115272037684917 -0.006867653224617243 -0.0056273434311151505 -0.004380411934107542 -0.0031218635849654675 -0.0018731155432760715 -0.0006427498301491141; -0.009365188889205456 -0.008112754672765732 -0.006879785563796759 -0.005627313628792763 -0.004343071021139622 -0.003125398186966777 -0.0018731175223365426 -0.0006359885446727276; -0.009382740594446659 -0.008136425167322159 -0.006856183055788279 -0.005648691672831774 -0.004355688579380512 -0.0031309095211327076 -0.0018869880586862564 -0.0006194179877638817; -0.009391004219651222 -0.008130387403070927 -0.006891242228448391 -0.005576011724770069 -0.004383534658700228 -0.003104778239503503 -0.0018674307502806187 -0.0006264896364882588; -0.009375515393912792 -0.008146761916577816 -0.006884270813316107 -0.005629349034279585 -0.0043753087520599365 -0.003148231189697981 -0.0018729413859546185 -0.0006398434634320438; -0.009373103268444538 -0.008108746260404587 -0.006868823431432247 -0.005634427536278963 -0.004383719060570002 -0.003097556298598647 -0.0018803330603986979 -0.0006084302440285683; -0.009357672184705734 -0.008131121285259724 -0.006873542908579111 -0.005613542161881924 -0.004369776230305433 -0.003122176742181182 -0.0018883203156292439 -0.0006100768805481493; -0.009360391646623611 -0.008100822567939758 -0.006860764231532812 -0.005608199629932642 -0.00436409842222929 -0.0031423429027199745 -0.001892870175652206 -0.0006107318331487477; -0.0093768909573555 -0.00813507754355669 -0.006877788808196783 -0.005598465446382761 -0.004413490649312735 -0.003093938808888197 -0.0018697738414630294 -0.0006068190559744835; -0.007495217490941286 -0.00624624639749527 -0.004984509199857712 -0.003764642868191004 -0.0025017550215125084 -0.0012772250920534134 3.2944455597316846e-5 0.0012178522301837802; -0.005404412746429443 -0.004172442015260458 -0.0029157577082514763 -0.0016617609653621912 -0.000420465279603377 0.0008310573175549507 0.002089311368763447 0.0033230893313884735; -0.0033301347866654396 -0.002117084339261055 -0.0008059182437136769 0.0004306348564568907 0.0016592151951044798 0.0029114072676748037 0.004157630261033773 0.005395166575908661; -0.00126303406432271 -1.1549299415491987e-5 0.0012541933683678508 0.0024926874320954084 0.0037695288192480803 0.004976934287697077 0.006265072152018547 0.007518352475017309; 0.000638827565126121 0.0018867413746193051 0.0031477296724915504 0.0043871235102415085 0.005632066633552313 0.006862441543489695 0.008128674700856209 0.009389265440404415; 0.0005963376024737954 0.001877181581221521 0.003134613623842597 0.004381001926958561 0.0056367781944572926 0.006868664640933275 0.00814227294176817 0.009378482587635517; 0.0006119216559454799 0.001874779351055622 0.003134140744805336 0.004366426728665829 0.005604286212474108 0.006887093652039766 0.00814315676689148 0.009364818222820759; 0.0006008651107549667 0.0018996786093339324 0.0031512826681137085 0.004376077093183994 0.0056351362727582455 0.0068845381028950214 0.008104292675852776 0.009383494965732098; 0.0006361320847645402 0.0018665394745767117 0.0031412839889526367 0.004389410372823477 0.0056319162249565125 0.006867812480777502 0.008115671575069427 0.00937083549797535; 0.0006479115691035986 0.0019112222362309694 0.0031322166323661804 0.0043707904405891895 0.005612088833004236 0.006859140936285257 0.008111322298645973 0.009382830932736397; 0.0006290693418122828 0.0018515363335609436 0.0031029009260237217 0.004375530406832695 0.005624951329082251 0.006878796499222517 0.00811783503741026 0.009358993731439114; 0.0006352952914312482 0.0018572078552097082 0.003140811575576663 0.004379814490675926 0.00562960235401988 0.006890036165714264 0.008113520219922066 0.00939035601913929; 0.0006183404475450516 0.0018818916287273169 0.003113038605079055 0.004376882687211037 0.005618141498416662 0.006888918578624725 0.008104097098112106 0.0093611441552639; 0.000617462326772511 0.0018787861336022615 0.0031093149445950985 0.00434846943244338 0.005637406371533871 0.00685591297224164 0.008120405487716198 0.009377209469676018; 0.000638855854049325 0.0018548595253378153 0.0031159131322056055 0.004371135961264372 0.005612585227936506 0.006872853729873896 0.008137536235153675 0.009389041922986507; 0.0006352119380608201 0.0018795563373714685 0.003127141622826457 0.004353375639766455 0.0056408969685435295 0.006884937174618244 0.008114932104945183 0.009397076442837715; 0.0006275837658904493 0.0018585722427815199 0.00313646555878222 0.004359172657132149 0.005628836341202259 0.00686260499060154 0.008127612993121147 0.009378906339406967; 0.0006070230156183243 0.0018597844755277038 0.0031641796231269836 0.004387956112623215 0.005624879151582718 0.00687040202319622 0.008142994716763496 0.009376056492328644; 0.0006360973929986358 0.0018574859714135528 0.003123937640339136 0.0043665748089551926 0.005631041247397661 0.006870961282402277 0.008133948780596256 0.009378217160701752; 0.0006120808538980782 0.0018847245955839753 0.0031202048994600773 0.004365398548543453 0.0056124404072761536 0.0068694185465574265 0.008103596977889538 0.009366834536194801; 0.0006335204816423357 0.0019003080669790506 0.0031161033548414707 0.004369071219116449 0.005629774183034897 0.006898136809468269 0.008152002468705177 0.009369973093271255; 0.0006289417506195605 0.001871932065114379 0.0031216780189424753 0.004350979346781969 0.005613467190414667 0.006871337536722422 0.008121790364384651 0.009368768893182278; 0.000613185518886894 0.0018727215938270092 0.0031206777784973383 0.004376389551907778 0.0056236968375742435 0.006864218041300774 0.008132226765155792 0.009351277723908424; 0.0006311779725365341 0.0018794004572555423 0.0031212710309773684 0.004335561767220497 0.00562190730124712 0.006891734432429075 0.008157528005540371 0.009381367824971676; 0.0006113280542194843 0.0018804408609867096 0.0031279788818210363 0.0043764919973909855 0.005610374268144369 0.006848787888884544 0.008138826116919518 0.009398032911121845; 0.0006267099524848163 0.0018871654756367207 0.003143973182886839 0.004363215062767267 0.005607307888567448 0.006857061292976141 0.008107482455670834 0.009353217668831348])

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.