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{3, Float64, Float32}(order=5)
│   └── b: WENO{3, Float64, Float32}(order=5)
├── vertical_coordinate: ZCoordinate
└── 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
set_theme!(Theme(fontsize = 20))

# 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
├── run_wall_time: 0 seconds
├── run_wall_time / 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

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] = JLD2Writer(model, (; b, ζ);
                                                 filename = filename * "_$(side)_slice",
                                                 schedule = TimeInterval(save_fields_interval),
                                                 overwrite_existing = true,
                                                 indices)
end

simulation.output_writers[:zonal] = JLD2Writer(model, (; b=B, u=U, v=V);
                                               filename = filename * "_zonal_average",
                                               schedule = TimeInterval(save_fields_interval),
                                               overwrite_existing = true)
JLD2Writer 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.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: 21.736 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (9.621 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (2.840 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 8.117 seconds, max(u): (1.344e-01, 1.232e-01, 1.560e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 771.277 ms, max(u): (2.255e-01, 1.856e-01, 1.781e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 805.680 ms, max(u): (2.959e-01, 2.533e-01, 1.920e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 859.123 ms, max(u): (3.592e-01, 3.108e-01, 1.852e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 770.046 ms, max(u): (4.294e-01, 3.760e-01, 1.903e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 1.033 seconds, max(u): (5.211e-01, 5.318e-01, 1.925e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 810.855 ms, max(u): (7.095e-01, 8.278e-01, 2.374e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 2.090 seconds, max(u): (1.038e+00, 1.108e+00, 3.582e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 871.892 ms, max(u): (1.200e+00, 1.086e+00, 4.118e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 917.560 ms, max(u): (1.388e+00, 1.096e+00, 4.583e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 887.998 ms, max(u): (1.528e+00, 1.172e+00, 4.314e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 874.734 ms, max(u): (1.436e+00, 1.266e+00, 3.298e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 952.502 ms, max(u): (1.410e+00, 1.448e+00, 2.413e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 897.839 ms, max(u): (1.365e+00, 1.224e+00, 2.760e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 26.490 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 26.511 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 with 12 plots:
 ┣━ Poly{Tuple{GeometryBasics.Polygon{2, Float64}}}
 ┣━ Poly{Tuple{GeometryBasics.Polygon{2, Float64}}}
 ┣━ Poly{Tuple{GeometryBasics.Polygon{2, Float64}}}
 ┣━ LineSegments{Tuple{Base.ReinterpretArray{Point{3, Float64}, 1, Tuple{Point{3, Float64}, Point{3, Float64}}, Vector{Tuple{Point{3, Float64}, Point{3, Float64}}}, false}}}
 ┣━ LineSegments{Tuple{Base.ReinterpretArray{Point{3, Float64}, 1, Tuple{Point{3, Float64}, Point{3, Float64}}, Vector{Tuple{Point{3, Float64}, Point{3, Float64}}}, false}}}
 ┣━ LineSegments{Tuple{Vector{Point{3, Float64}}}}
 ┣━ LineSegments{Tuple{Base.ReinterpretArray{Point{3, Float64}, 1, Tuple{Point{3, Float64}, Point{3, Float64}}, Vector{Tuple{Point{3, Float64}, Point{3, Float64}}}, false}}}
 ┣━ LineSegments{Tuple{Base.ReinterpretArray{Point{3, Float64}, 1, Tuple{Point{3, Float64}, Point{3, Float64}}, Vector{Tuple{Point{3, Float64}, Point{3, Float64}}}, false}}}
 ┣━ LineSegments{Tuple{Vector{Point{3, Float64}}}}
 ┣━ LineSegments{Tuple{Base.ReinterpretArray{Point{3, Float64}, 1, Tuple{Point{3, Float64}, Point{3, Float64}}, Vector{Tuple{Point{3, Float64}, Point{3, Float64}}}, false}}}
 ┣━ LineSegments{Tuple{Base.ReinterpretArray{Point{3, Float64}, 1, Tuple{Point{3, Float64}, Point{3, Float64}}, Vector{Tuple{Point{3, Float64}, Point{3, Float64}}}, false}}}
 ┗━ LineSegments{Tuple{Vector{Point{3, Float64}}}}

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
-500.0:20.833333333333332: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!.

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.009372214786708355 -0.008122825995087624 -0.006883904803544283 -0.0056336866691708565 -0.004375913180410862 -0.0031221809331327677 -0.0018853578949347138 -0.0006404357845894992; -0.009372640401124954 -0.008137820288538933 -0.006874716840684414 -0.005613670684397221 -0.004392117727547884 -0.0031010534148663282 -0.0018770023016259074 -0.0006225963588804007; -0.009357225149869919 -0.00810737069696188 -0.006852148100733757 -0.005630791187286377 -0.004390352871268988 -0.003133874386548996 -0.0018584133358672261 -0.0006286039133556187; -0.00936964713037014 -0.008134140633046627 -0.0068929847329854965 -0.005608076695352793 -0.004376587923616171 -0.003127747680991888 -0.0018905620090663433 -0.0006161797791719437; -0.0093583008274436 -0.008128265850245953 -0.006874671671539545 -0.005635675508528948 -0.0043911500833928585 -0.0031192670576274395 -0.0018922253511846066 -0.0006432391819544137; -0.009369886480271816 -0.008113322779536247 -0.006898276042193174 -0.0056076194159686565 -0.0043745930306613445 -0.003124760463833809 -0.0018826373852789402 -0.0006041316664777696; -0.009381921961903572 -0.008146007545292377 -0.006899841595441103 -0.0056217689998447895 -0.004377053119242191 -0.0031091293785721064 -0.0018589141545817256 -0.0006199258496053517; -0.0093677444383502 -0.008138640783727169 -0.006909362506121397 -0.005641990341246128 -0.004373748786747456 -0.003127756528556347 -0.0018843214493244886 -0.0006311433389782906; -0.009399155154824257 -0.008131441660225391 -0.006866846699267626 -0.005642137955874205 -0.00440050708130002 -0.00310995033942163 -0.001883401651866734 -0.0005911840125918388; -0.009359203279018402 -0.00809964444488287 -0.0068837720900774 -0.005656377878040075 -0.0043652900494635105 -0.0031386325135827065 -0.0018882895819842815 -0.0006488499930128455; -0.009362953715026379 -0.008162397891283035 -0.00687960023060441 -0.005593608133494854 -0.004378281533718109 -0.0031161203514784575 -0.0018859354313462973 -0.0006029157666489482; -0.009374743327498436 -0.008123776875436306 -0.00685353297740221 -0.005631924141198397 -0.0043854136019945145 -0.003106611082330346 -0.0018701187800616026 -0.0006073928088881075; -0.009367180056869984 -0.008110319264233112 -0.00686638243496418 -0.005616375245153904 -0.00436061667278409 -0.0031231502071022987 -0.0018757948419079185 -0.0006257342756725848; -0.00936933420598507 -0.00810734461992979 -0.0068635232746601105 -0.00561224389821291 -0.0043922970071434975 -0.003140485379844904 -0.0019049923866987228 -0.0006266370182856917; -0.00935389380902052 -0.008124453946948051 -0.00687662698328495 -0.005599050782620907 -0.0043712579645216465 -0.003125491552054882 -0.0018642321228981018 -0.0006240876391530037; -0.00937161035835743 -0.008138511329889297 -0.006897464394569397 -0.005627622827887535 -0.004392076749354601 -0.00312324077822268 -0.0018675888422876596 -0.0006501738098450005; -0.009375988505780697 -0.008096715435385704 -0.006890322081744671 -0.0056339409202337265 -0.004370091948658228 -0.0031385126058012247 -0.0018726742127910256 -0.0006069184164516628; -0.009344435296952724 -0.008114383555948734 -0.006876053288578987 -0.005615187343209982 -0.004364128690212965 -0.0031186165288090706 -0.0018625068478286266 -0.0006295781931839883; -0.009375856257975101 -0.008124219253659248 -0.006901520770043135 -0.0056353467516601086 -0.004377312492579222 -0.003147043287754059 -0.0018834888469427824 -0.0006337522063404322; -0.009385664016008377 -0.008098402060568333 -0.006880422122776508 -0.005630104336887598 -0.0043756901286542416 -0.0031469303648918867 -0.0018676440231502056 -0.0006211496074683964; -0.009387625381350517 -0.008128204382956028 -0.006866191513836384 -0.005641215480864048 -0.004353283438831568 -0.0031463371124118567 -0.0018643991788849235 -0.0006448056665249169; -0.009401015937328339 -0.008133979514241219 -0.0068809050135314465 -0.0056029693223536015 -0.0043367971666157246 -0.0031074960716068745 -0.0018825643928721547 -0.0006428122287616134; -0.007491131313145161 -0.006280841771513224 -0.00497849564999342 -0.0037177707999944687 -0.002524592215195298 -0.0012420332059264183 5.563993568102887e-7 0.0012572419364005327; -0.005406141746789217 -0.004156785551458597 -0.002911018906161189 -0.0016885010991245508 -0.00039103371091187 0.0008382895030081272 0.0021023028530180454 0.0033340738154947758; -0.003322939621284604 -0.0020766444504261017 -0.0008227358921431005 0.00040830668876878917 0.0016645698342472315 0.002933866810053587 0.00418819859623909 0.005403389688581228; -0.001260335324332118 4.6584131041527144e-7 0.0012478259159252048 0.002475554356351495 0.003739904146641493 0.005008535925298929 0.00624233391135931 0.007467061281204224; 0.0006081812316551805 0.0018871878273785114 0.0031612219754606485 0.004362814594060183 0.00564173748716712 0.00687653012573719 0.008131254464387894 0.009385296143591404; 0.0006188529077917337 0.0018668206175789237 0.0031066080555319786 0.004369442816823721 0.005607221741229296 0.0068584587424993515 0.008140485733747482 0.00939477514475584; 0.0006219864590093493 0.0018653601873666048 0.0031101598870009184 0.004344029352068901 0.005590342450886965 0.006880675442516804 0.008111361414194107 0.009404318407177925; 0.000637029530480504 0.0018723933026194572 0.0031238410156220198 0.004409352317452431 0.005627922248095274 0.006878152024000883 0.008135511539876461 0.00935378111898899; 0.0006175313610583544 0.0018672803416848183 0.00313377077691257 0.004374191630631685 0.005640530493110418 0.00689315889030695 0.008128312416374683 0.009370884858071804; 0.0006112981936894357 0.0018951985985040665 0.0031169806607067585 0.004357160534709692 0.005618697497993708 0.006904396694153547 0.008119759149849415 0.009371993131935596; 0.0006147470558062196 0.0018774964846670628 0.0031169287394732237 0.004365085624158382 0.005629705730825663 0.006855303421616554 0.008111868053674698 0.009373740293085575; 0.0006165618542581797 0.0018431968055665493 0.0031329025514423847 0.004374868236482143 0.005620160140097141 0.006887660827487707 0.008131726644933224 0.00938369520008564; 0.0006262521492317319 0.001862487755715847 0.0031127282418310642 0.004379640333354473 0.005617326591163874 0.00686856172978878 0.008135278709232807 0.009366150945425034; 0.0006469726213254035 0.0018602475756779313 0.003132990561425686 0.004371802322566509 0.005593386013060808 0.006879867520183325 0.00813011359423399 0.009371592663228512; 0.0006002126610837877 0.0018810458714142442 0.003136854153126478 0.004348847549408674 0.005608194041997194 0.006875260733067989 0.008128443732857704 0.009360412135720253; 0.0006032665842212737 0.0018705929396674037 0.003121631219983101 0.004396353382617235 0.005632601212710142 0.006868520751595497 0.008108530193567276 0.009386253543198109; 0.0006342569249682128 0.001878571230918169 0.003124529030174017 0.004388812463730574 0.005627087317407131 0.006859383080154657 0.008118011057376862 0.009357263334095478; 0.0006288104923442006 0.0018886115867644548 0.0031377163249999285 0.004368916619569063 0.00558842858299613 0.006895639467984438 0.008100158534944057 0.009369130246341228; 0.0006156362360343337 0.0018774427007883787 0.0031113557051867247 0.004382218234241009 0.005622124765068293 0.006852210499346256 0.008105231449007988 0.009363939054310322; 0.0006140545592643321 0.0018908812198787928 0.003117525950074196 0.004367775283753872 0.0056073712185025215 0.0069044362753629684 0.008131131529808044 0.009383796714246273; 0.0006366192828863859 0.0018652323633432388 0.003086357144638896 0.004351281560957432 0.005635291803628206 0.006871681194752455 0.008114520460367203 0.009389002807438374; 0.0006412320653907955 0.0018704653484746814 0.003149920841678977 0.004359982907772064 0.0056168800219893456 0.006886483170092106 0.008126604370772839 0.00939714815467596; 0.0006312914774753153 0.001869777450338006 0.00314281415194273 0.004375537857413292 0.0056243413127958775 0.006871387828141451 0.008135790005326271 0.009360873140394688; 0.000623640778940171 0.0018623749492689967 0.0031084369402378798 0.004381321836262941 0.005623257253319025 0.006890631280839443 0.008105560205876827 0.009392397478222847; 0.000635020958725363 0.0018845804734155536 0.0031104576773941517 0.004373527597635984 0.005620268173515797 0.006880462169647217 0.00812620297074318 0.009383621625602245; 0.000611039693467319 0.0018921223236247897 0.003103869268670678 0.004386649001389742 0.005627449601888657 0.006885513197630644 0.008112568408250809 0.009366602636873722])

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.