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
├── 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: 31.6 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: 25.244 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (22.894 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (17.884 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 33.793 seconds, max(u): (1.261e-01, 1.175e-01, 1.536e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 740.709 ms, max(u): (2.223e-01, 1.807e-01, 1.784e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 760.303 ms, max(u): (3.026e-01, 2.566e-01, 1.764e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 721.205 ms, max(u): (3.970e-01, 3.939e-01, 1.988e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 641.028 ms, max(u): (5.251e-01, 5.511e-01, 2.289e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 747.175 ms, max(u): (6.636e-01, 7.969e-01, 2.981e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 807.368 ms, max(u): (9.965e-01, 1.120e+00, 3.422e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 704.717 ms, max(u): (1.292e+00, 1.184e+00, 4.756e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 705.091 ms, max(u): (1.351e+00, 1.023e+00, 4.476e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 782.385 ms, max(u): (1.411e+00, 1.021e+00, 3.182e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 800.640 ms, max(u): (1.251e+00, 1.031e+00, 2.813e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 791.144 ms, max(u): (1.233e+00, 9.799e-01, 3.850e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 790.298 ms, max(u): (1.116e+00, 1.243e+00, 2.723e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 661.801 ms, max(u): (1.066e+00, 1.203e+00, 2.355e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 54.244 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 54.277 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.00936463359070138 -0.008133006161782233 -0.006860863732171228 -0.005640712404179804 -0.0043919678244504 -0.0031062494027518915 -0.0018733164787262731 -0.000645779367183227; -0.009367361187588906 -0.008124480080971235 -0.00689502712138914 -0.005618251068738017 -0.004354754466306541 -0.0031260822982412547 -0.0018532175686356712 -0.0005966333353002412; -0.009377364208675465 -0.00811941040112578 -0.006881918403642544 -0.005608818258515183 -0.004368523375731097 -0.0031205877409521874 -0.0018858668784934429 -0.0006448535266560863; -0.009388285769002394 -0.008114022820528208 -0.006848170918749045 -0.005643307817321454 -0.004353135034967968 -0.003128129658402857 -0.0018667690953788534 -0.0006089893335844208; -0.009383126273790553 -0.008134076975944008 -0.006887454479948288 -0.0056377119914606645 -0.004397062189266705 -0.0031313001561663867 -0.001859336618788971 -0.0006467179458250989; -0.009395123905050961 -0.008107100457542836 -0.006881384061480298 -0.005642942751475086 -0.004383841229912402 -0.003115143362992062 -0.0018627057629178468 -0.0006121693055112743; -0.009389144057212393 -0.008098156207480521 -0.006847842263826309 -0.0056052476589983635 -0.004383808400326968 -0.0031231915886906804 -0.0018856842502489217 -0.0006434481169201494; -0.009353176981776422 -0.00814049227830881 -0.006855096991714952 -0.00560075243950293 -0.00437493729371877 -0.0031372774557654882 -0.001880011593776331 -0.0006532073268948768; -0.009374403438197615 -0.00812905527673851 -0.006873543362737611 -0.0056515697576908636 -0.004386529722988196 -0.0031191355470416514 -0.0018728879122713842 -0.0006407033503725972; -0.009368502142186671 -0.008127497553745786 -0.006900283769177474 -0.005623067422032884 -0.004359724077836015 -0.003105740979718389 -0.0018570351745205715 -0.0005981424708578256; -0.009394590091284002 -0.00811091508238874 -0.006876097335849779 -0.005616909642013228 -0.004387592713587524 -0.0031361877559528527 -0.0018814023235502887 -0.0006219738599437984; -0.009395398797501892 -0.008134097297602186 -0.006892892862382714 -0.00563076815128576 -0.004398816974556939 -0.003131278210222594 -0.0019035381426464085 -0.0006206373936195486; -0.009373705265104148 -0.00813179578648818 -0.006873091104992739 -0.0056429659219145315 -0.004386298710290226 -0.0031218981994097783 -0.0019128435998853465 -0.0006276641231768896; -0.009365593656546156 -0.008147532946952139 -0.006874188116522338 -0.00566183608485258 -0.004374602987035339 -0.0031231913395905106 -0.0018713047197784361 -0.00061638390371686; -0.009385173954575323 -0.008138086255863706 -0.006900722699190273 -0.0056191295270153095 -0.004377771061395739 -0.0031374163787281652 -0.0018604413569808381 -0.0006187537975461042; -0.009366997761189216 -0.008121150801113622 -0.006864708918811827 -0.005637233441954974 -0.0043636357566828295 -0.0031182744483168024 -0.001848396883798735 -0.0006451787868441845; -0.009382947281731101 -0.00811929278620912 -0.006873055100149963 -0.005617634368042207 -0.004364056707020538 -0.0031086237708703077 -0.0018703535450099046 -0.0006095965171645766; -0.0093695045147568 -0.00813166650045316 -0.006865629914567263 -0.005658079191722474 -0.0043610557929561165 -0.003134065089077281 -0.001846059849108606 -0.0006427142905210618; -0.009405487069541007 -0.008105387997716184 -0.00688272937550434 -0.005621817839812293 -0.004347241458462491 -0.0031434496069992616 -0.00188994367521359 -0.0006154529533135949; -0.009375795018891813 -0.008115422211607243 -0.006873957056010737 -0.005623874839967335 -0.004354803878582889 -0.0031281907183062355 -0.0018885818223781468 -0.000609354881477127; -0.009346162038354186 -0.008132488450147517 -0.0068527666453948805 -0.005647506615392352 -0.004346637529466812 -0.0031423401717754797 -0.0018674207837631976 -0.000651446611876516; -0.00937860301705259 -0.008118143618702417 -0.006881282596622888 -0.005632649042809715 -0.0043704429439020195 -0.0031067392122147513 -0.001867374227593515 -0.0006123014566635472; -0.007496205402345798 -0.006264000090892685 -0.004976953737323706 -0.0037734054877065835 -0.0025044500413661437 -0.0012392605354641798 1.7685758643351964e-6 0.0012507520695793529; -0.005419973468569597 -0.004162364015741884 -0.0029064224542491245 -0.0016556216486855108 -0.0004439201860240571 0.0008242695954143979 0.0020830730164066607 0.0033228775893319913; -0.0033263777748396644 -0.0020831051777907734 -0.000811776264838535 0.00041749962525190466 0.00165941044300173 0.0029154103570717556 0.00415453057034385 0.005415801104189471; -0.0012397090292915966 2.4774004998522362e-5 0.0012273219823126496 0.0025217277778505492 0.003768677294725927 0.004997888451235367 0.00627524152739553 0.007501577778492215; 0.0006201465068808782 0.0018444878456332916 0.0031667429593949456 0.004373364190371353 0.005623041882688397 0.0068655752603533765 0.008154181142547987 0.009399748163045611; 0.0006372795372086299 0.001869735631716867 0.0031542986932839145 0.004364852395589708 0.005614991223959424 0.006876101319558052 0.008143631494556942 0.009365185898186341; 0.0006398602638976042 0.0018545443436278322 0.0031347730775847086 0.004361295676766284 0.005619363063313651 0.006848707816532283 0.008137369497046359 0.00936869898102873; 0.0006446922969461699 0.0018827347315000208 0.0031410420499317 0.004364794061415953 0.005614788644583896 0.00685224155911348 0.00814761017783417 0.009395151124056521; 0.0006047521883644971 0.0018827102527312304 0.0031155945396913413 0.004363536792514367 0.0056332752557566165 0.006839885756815714 0.008116028955362344 0.009353148057418215; 0.0006520012107916863 0.0018793173597110313 0.0031125123606577654 0.0043575803073671975 0.0056455990637344885 0.00684285483513751 0.008128558178382811 0.009385193247731271; 0.0006210964987370362 0.0018779141476923695 0.0031219671575081092 0.004364804330754895 0.005651521701889354 0.006871514095169268 0.008121751411616002 0.009389985114584989; 0.0006262162341097672 0.0018775458020075261 0.0031144922286411793 0.0043615732513439046 0.00560601964722685 0.006863797497722426 0.008120565435590602 0.009386462679873366; 0.0006099224790428542 0.001888352210933036 0.003121550369968361 0.004375711091811083 0.005648918494099102 0.006887916838315709 0.008140638553005912 0.00936018878836311; 0.0006199318555325895 0.001857938532009761 0.003116550450441342 0.004370165191508689 0.005600065761854363 0.006862662295744639 0.008119992293370423 0.009379006961836965; 0.0006306476814995003 0.0018917651578356526 0.0031285047631471885 0.0043623373192589925 0.005634766370649298 0.0068799037598214485 0.00813197730327799 0.009390080697473803; 0.0006155326456340893 0.0018950945024754293 0.003134344964701307 0.004377465436240366 0.005621622919265705 0.006856103390532242 0.008123647107902117 0.009350026166481099; 0.0006402900560034089 0.001875510600402022 0.003145306772886093 0.004383727585128106 0.005640398540177308 0.006872297098383992 0.008113497958333521 0.00939108926208545; 0.0006215763926384469 0.0018963931130295542 0.003110256855868228 0.004383648123546073 0.0056187621228897785 0.00690447944979265 0.00810416592934978 0.009386310517656885; 0.0006365526299838623 0.0018928692319736193 0.003135107379456161 0.004406900359926307 0.005649389748633407 0.006872104501896267 0.008114695674996437 0.009360460324969537; 0.0006417806428398836 0.0018491772191356268 0.003118001754332906 0.00437334162246658 0.00560661451787204 0.006861591577914736 0.008108285451366465 0.009377102646858631; 0.0006209691013580393 0.0018936027508547938 0.0031204097439543753 0.004388075800602599 0.005640265715887075 0.006870347353751495 0.008141509955922553 0.009397455028065304; 0.000605619215446963 0.0018697575232854934 0.003105737040938548 0.00435581164874144 0.005606599145455231 0.006859937801846433 0.008130773179543381 0.009352181103457874; 0.0006366558406838131 0.001863225250768973 0.0031432864924751196 0.004361398839465926 0.005639047662650933 0.006890277825142672 0.008136358882428042 0.009377233801144313; 0.0006026263354267862 0.0018822233576272472 0.003131441223180944 0.00437679205489448 0.005624118419291964 0.0068694012701301125 0.008136050656467561 0.009353473176912581; 0.0006248709713101834 0.001874613599114093 0.003135453566310891 0.004370251494455149 0.0056134568131106545 0.006866867279435044 0.008155940091973702 0.009364421739703145; 0.0006257462735390399 0.001904327397583996 0.003123361769027392 0.004393029740604252 0.005621870184366512 0.006887628901538114 0.008134981994694432 0.009375458922871794])

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.