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.889 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (25.565 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (19.330 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 37.201 seconds, max(u): (1.270e-01, 1.184e-01, 1.503e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 943.173 ms, max(u): (2.125e-01, 1.776e-01, 1.823e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 890.325 ms, max(u): (2.835e-01, 2.531e-01, 1.722e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 751.822 ms, max(u): (3.513e-01, 3.690e-01, 1.975e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 819.040 ms, max(u): (4.225e-01, 4.876e-01, 1.828e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 782.465 ms, max(u): (5.506e-01, 7.430e-01, 2.627e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 723.936 ms, max(u): (8.671e-01, 1.096e+00, 3.068e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 790.141 ms, max(u): (1.214e+00, 1.143e+00, 4.167e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 816.019 ms, max(u): (1.332e+00, 1.169e+00, 4.266e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 781.886 ms, max(u): (1.358e+00, 1.126e+00, 5.222e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 944.874 ms, max(u): (1.304e+00, 9.937e-01, 3.234e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 942.264 ms, max(u): (1.288e+00, 1.068e+00, 3.317e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 926.196 ms, max(u): (1.249e+00, 1.145e+00, 2.241e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 785.800 ms, max(u): (1.443e+00, 1.031e+00, 2.199e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.001 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.001 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.009377428920947452 -0.008113730323454612 -0.006886083381772666 -0.005624455204708358 -0.004383116735118301 -0.0031037216245380223 -0.0018740513554809924 -0.0006347733553293782; -0.009383700035578577 -0.00808564360745168 -0.006872128524874608 -0.005637212819218467 -0.004394687952854228 -0.003121090065507618 -0.0018845177506127406 -0.0006040577617603064; -0.009374441787102674 -0.008119704283829585 -0.006875307953039197 -0.005642845820545531 -0.004391273674471958 -0.0031401315624229507 -0.0019009681085153524 -0.000644640435965484; -0.009372723645333127 -0.008161211162523803 -0.006866476230068606 -0.005611194203702488 -0.004365717767421452 -0.003127992733882295 -0.001864462717993321 -0.0006136063123827754; -0.00937405458912985 -0.008099573621989485 -0.006841590443824414 -0.005609297389653721 -0.004374351564046361 -0.003123446923732323 -0.0018830439299793121 -0.0006156675179679707; -0.009381188510493474 -0.008139705146879825 -0.006875679840498826 -0.0056158882233973625 -0.0043918077649019735 -0.0031330912113495123 -0.0018811118594232238 -0.0006150527715083218; -0.00935422848291278 -0.008141312930783351 -0.006874795561930216 -0.005639172873572701 -0.004366412053402315 -0.0031335541923872127 -0.0018645456280655581 -0.0006166956536975978; -0.009386417619600292 -0.008125971188656489 -0.006899041935580201 -0.005623888391214197 -0.004368876107134695 -0.003120840234035025 -0.0018729281302628362 -0.0006453463657553212; -0.009379016437654509 -0.008123307999126595 -0.00688076457913176 -0.005623919448188967 -0.004379335834548551 -0.003128279026026849 -0.0018617914384889635 -0.0006278641704978246; -0.009368640053197394 -0.008115054721682448 -0.006873226468504118 -0.005626804755975976 -0.004347173094336166 -0.0031228743256037582 -0.001865739042913596 -0.0006189060339322916; -0.009349279425479038 -0.00810953848386675 -0.006860990334573468 -0.005623430640976052 -0.004377413729559602 -0.003132426464335881 -0.001867585628894589 -0.0006326752021449819; -0.009388727616766629 -0.008111654530443558 -0.006871908173478397 -0.005626810217574489 -0.004380373580983124 -0.003139311737216604 -0.0018939760793446065 -0.0006127859707847509; -0.009366541892470997 -0.008118132007086989 -0.006879825080098459 -0.005624317650322262 -0.004365714610300649 -0.0030837240879805564 -0.0018779032509217413 -0.0006355797545745438; -0.009392220807091954 -0.008116603456382017 -0.0068694929924672694 -0.005643957809593262 -0.004372136407008425 -0.0031286527180050244 -0.0018508401206652565 -0.0006359466890532221; -0.009363736397679054 -0.008124217044652493 -0.006878520726558633 -0.0056417250658339696 -0.0043465853201084025 -0.0031059688808000793 -0.0018897955220994773 -0.0006243971186721938; -0.009397109384917932 -0.008115477455609124 -0.006880275809525788 -0.0056186148346716175 -0.004394598449105241 -0.00312350489357865 -0.0018946028926822422 -0.000641450005523057; -0.009363806058607356 -0.008102327603568063 -0.006881102572654489 -0.005602168459626275 -0.004392379123007528 -0.0031429431724915025 -0.0018676767138806596 -0.0006091508970520479; -0.009381434032989524 -0.008130597009076363 -0.0068867526993252395 -0.00559832398840768 -0.00436104351212133 -0.003128468448368154 -0.001903877180786024 -0.0006116916557744786; -0.009374348821848214 -0.008112435248353417 -0.006862726243811974 -0.00560695428599397 -0.004369053695847813 -0.003122999350438424 -0.0018799313114538096 -0.0006354359447693461; -0.00937712138362813 -0.008115585295301079 -0.006873675978861497 -0.005628214551974019 -0.004375888798166592 -0.0031058173668600006 -0.0018566852805370767 -0.0006119026446290127; -0.009354215191915857 -0.008114288032580448 -0.006882276106581586 -0.005630405744548814 -0.00434466743801966 -0.0031265173868406213 -0.0018642435461687073 -0.0006245291429367831; -0.009356380042251434 -0.008121305433935917 -0.006865326746660921 -0.005650663142390051 -0.004344078358902116 -0.0031109717090694413 -0.0018842577581750354 -0.0006089172907561697; -0.007505313595981902 -0.006236791307980836 -0.004990932673129066 -0.0037469577940103527 -0.0024908525594992837 -0.0012464389201016547 7.289101431045551e-6 0.0012598490411036862; -0.005410698480625237 -0.004143196687497037 -0.0029157607547559646 -0.00167664817398377 -0.0004141261032611775 0.0008311254849047962 0.002086364885722498 0.0033189835210775654; -0.003363586511275269 -0.0020810621482490964 -0.0008268347217972161 0.0004144593020663748 0.001683191676616515 0.0029143999855663753 0.0041576811390940235 0.005409913463947091; -0.001243925902015645 1.5317488947132503e-5 0.0012602144082938336 0.002497238920219079 0.0037564318769059517 0.00499479588923727 0.006237546395871332 0.007506772024917829; 0.000633439628729624 0.0018856010836301217 0.0031042486098059527 0.004377435709383219 0.00559963505534012 0.006892375686131311 0.008155784295873941 0.00939069966548206; 0.0006427659348337645 0.0018685209235520179 0.0031423033183952663 0.004372921487301749 0.00560777929784826 0.0068931204797378675 0.008116500703134211 0.0093974227350676; 0.0006284039984563142 0.001870027091744663 0.003141769994444954 0.004380869320122637 0.005632213720513366 0.0068872052464926245 0.008126032720694057 0.009372335179445766; 0.0006515202554059383 0.0018507945729048113 0.003112654894436864 0.0043537256889698535 0.005641627242114376 0.006857483323344589 0.008105596570274943 0.009394446180818495; 0.000605987339646799 0.0019055485298823214 0.003152090553419738 0.0043826866374502725 0.005631733620470511 0.006862258981344367 0.008109922385776546 0.00937109611876713; 0.0006252620239212482 0.0018884558915424935 0.0031364993384491147 0.004393814004790703 0.005609347108240185 0.006863070570000851 0.008140840227231648 0.009383542278918928; 0.0006270546546847943 0.0018806903327284385 0.0031105929443098236 0.004381302807509892 0.005637705142829342 0.006868414634449757 0.008114719806859618 0.009389276609294736; 0.0006395003537533793 0.0018805320959762943 0.0031392138387212397 0.0043679295884898025 0.005615405488553441 0.006863029845706535 0.00812062274881737 0.009388184737331108; 0.0006490726482003302 0.0018804116160349316 0.003120765579715388 0.004355770921473478 0.005628410115257931 0.0068859914022773245 0.008098212188092566 0.00937457989152979; 0.0006167100169968886 0.0018652765296030714 0.003103114173204725 0.0043589369021304 0.005624639525935646 0.006836490447103421 0.008147702373079229 0.009363052260343242; 0.0006189245546925322 0.001853570250937395 0.003157349637718628 0.004383594567842686 0.005632969881652375 0.006881710967373393 0.008111629983167298 0.00939746479871832; 0.0006273741876240401 0.001867422251706347 0.0031139803945316354 0.004375838239561148 0.005625434082905449 0.00687005024350307 0.008133834163684428 0.00939344890376525; 0.0006136048040794983 0.0018403316970845207 0.0031262950006181937 0.004352128384438555 0.005619024840448275 0.00686370040797983 0.008122439735594776 0.009392400359459907; 0.0006213350876940292 0.0018971559833172343 0.003118354760693685 0.004343681814847397 0.0056233453640484625 0.0068820996446964456 0.008135323714774274 0.009365080002582998; 0.0006527292235474295 0.0018608987284180502 0.003141911301647362 0.004362640581760252 0.005618053564160328 0.006901047928806733 0.008106530105825344 0.00937530889495754; 0.0006230230577270903 0.0018795827764064097 0.0031266672724216643 0.004372947094387462 0.005625969982111023 0.006850486134629443 0.008116344122275463 0.009366618463242295; 0.0006413102358192486 0.0018533319773314627 0.003136503452570933 0.004397933307503374 0.005617396479907888 0.006864612419207165 0.008137014684206008 0.009388194840893083; 0.0006074694155090376 0.0018608901967552087 0.0031171895920619145 0.004373240009028965 0.005645674865783663 0.0068828314785952735 0.008139026980083739 0.009385346927090232; 0.000642068565879579 0.0018810348870360264 0.0031205066781301856 0.004372152500564624 0.005606903718887252 0.0068793490731016696 0.008115152885535515 0.009379846874776969; 0.0006382829032718554 0.0018646929672118493 0.0031119041924699393 0.004373843749452144 0.005610125720487469 0.006879429705567417 0.008119566300878763 0.009346851642898663; 0.0006270966612496246 0.001860404541116167 0.0031060474445634874 0.004367965452375669 0.0056189562907453154 0.0068582741928561895 0.008129956766474813 0.009378886542404907; 0.0006339153521424987 0.0018722338683275438 0.0031396464314228695 0.004402596230457824 0.005630750332784197 0.006862717145211516 0.008120609453161473 0.009368746131842564])

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.