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 reconstruction order 5
│   └── b: WENO reconstruction 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(y, z, interior(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: 29.3 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: 12.499 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (12.510 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (14.150 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 29.383 seconds, max(u): (1.328e-01, 1.139e-01, 1.456e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 3.843 seconds, max(u): (2.061e-01, 1.742e-01, 1.684e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 3.811 seconds, max(u): (2.756e-01, 2.227e-01, 1.687e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 3.803 seconds, max(u): (3.531e-01, 3.422e-01, 1.784e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 4.353 seconds, max(u): (4.279e-01, 4.356e-01, 1.904e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 3.871 seconds, max(u): (5.281e-01, 6.522e-01, 2.396e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 3.850 seconds, max(u): (7.013e-01, 1.079e+00, 3.235e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 3.825 seconds, max(u): (1.093e+00, 1.271e+00, 4.166e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 3.746 seconds, max(u): (1.330e+00, 1.336e+00, 4.555e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 3.761 seconds, max(u): (1.431e+00, 1.494e+00, 5.911e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 3.826 seconds, max(u): (1.348e+00, 1.386e+00, 4.353e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 3.825 seconds, max(u): (1.433e+00, 1.141e+00, 3.447e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 3.879 seconds, max(u): (1.370e+00, 9.969e-01, 2.441e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 3.807 seconds, max(u): (1.393e+00, 1.031e+00, 1.934e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.415 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.417 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, bottom, 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"),
                  bottom = FieldTimeSeries(slice_filenames.bottom, "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)
z_xy_bottom = z[1] * 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, :),
            bottom = interior(b_timeserieses.bottom[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)
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_bottom ; color = b_slices.bottom, 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.009325397018262556 -0.00810934873494923 -0.006867662116718847 -0.005609923073710381 -0.004394710225229434 -0.0030903246732454895 -0.001886476877004253 -0.0006151594294099002; -0.009355712260356025 -0.008134790618508725 -0.00687554352765066 -0.005620802031873516 -0.0043634027915101835 -0.0031567382925670726 -0.0018653753107351918 -0.0006126716126658975; -0.009381512774109696 -0.008116804292470135 -0.006880688091385911 -0.005619582590876168 -0.00436405426031748 -0.00311639244564046 -0.0018851971739376392 -0.0006165235850521069; -0.009356020368135579 -0.008149632420907844 -0.006889605120193226 -0.005634786470251121 -0.0043918295405710695 -0.0031205115185782635 -0.0018787312026553905 -0.0006309617582156826; -0.009372289293146383 -0.00813508847661497 -0.006859249537392145 -0.0056193385295186665 -0.004374802725260858 -0.003136142750994969 -0.0018697995581479717 -0.0006476414249653624; -0.009371773478080868 -0.008150106859457275 -0.006875054571143843 -0.005645826591348157 -0.004334835680530323 -0.003112735684894816 -0.0018811900914205207 -0.0006047943764218184; -0.009362721707158659 -0.008124467940221368 -0.006893504812656039 -0.0056060682644067114 -0.004340444092034675 -0.0031146122437662577 -0.0019084930022654116 -0.0006411368331096088; -0.009367635694309243 -0.008120886009860996 -0.006870605171531996 -0.005630399898746502 -0.004392515045305276 -0.0031158461263749455 -0.001862170901690171 -0.0006017204147297653; -0.0093806975952924 -0.008111524752219707 -0.0069032296429053916 -0.005621239298894791 -0.004381169319446153 -0.003121187766797165 -0.0018628052734639342 -0.0006268977573819405; -0.009397147805205466 -0.008109345080300312 -0.006869360614839116 -0.005632032279311003 -0.004392085060334541 -0.0031370600280075044 -0.0018660762051606198 -0.000625406509082141; -0.009355080921297698 -0.008162914066516784 -0.006868045241504971 -0.0056289849161923625 -0.004360606329467963 -0.0031196918145297444 -0.0018489155233262248 -0.0006261969259879725; -0.009396429625869063 -0.008138714227181772 -0.006873113760406856 -0.005605843457238015 -0.004396687239913556 -0.003115218560813277 -0.0018729768506787648 -0.0006079265085603949; -0.009373130886583557 -0.008143667999319449 -0.00687406512242824 -0.005599116496322901 -0.004381362074012367 -0.0031241883560509634 -0.0018891589049894048 -0.0006229059072919333; -0.009378709779614537 -0.00813241328757213 -0.006888437359894036 -0.00562936723715441 -0.004391355444214051 -0.003135767864029118 -0.001868122491927805 -0.0006366420167074499; -0.009382763355764732 -0.008121655171170862 -0.006873756756387216 -0.005623647022405867 -0.0044083549148114754 -0.0031335203041903494 -0.0018615141051995443 -0.0006506907397133751; -0.009361925502246739 -0.008122038001114266 -0.00689752964555181 -0.00561611522602664 -0.004381891176641554 -0.0031466143655725387 -0.0018787832833495456 -0.0005882798114597299; -0.00940086172763079 -0.008104326950118826 -0.006862362869444104 -0.005598037254114976 -0.004379643505987507 -0.0031540594737554137 -0.0018582129755500406 -0.0006072888610645714; -0.009359199425008681 -0.00812489800522175 -0.006882346533355603 -0.005625154177506396 -0.004367271558908507 -0.0031235992821343236 -0.0018743983493202249 -0.0006373947205512651; -0.009385884305170867 -0.00810304003656686 -0.006885906336965318 -0.005610181372975403 -0.0043369992354280774 -0.003135842055037575 -0.0018612001167599614 -0.0006359092972262628; -0.009392018714781906 -0.008159018369755666 -0.00691920319578453 -0.005612624760666619 -0.004357475283753516 -0.003114063411101497 -0.0018628916838642222 -0.00059096472672083; -0.009366803187418539 -0.008104367035139035 -0.0069036536752995 -0.005645478239666431 -0.004377351151181578 -0.0031589712849969705 -0.0018954467835863133 -0.0006256552730422017; -0.009382724190407933 -0.008129833437868992 -0.00687578025281303 -0.005641180135369651 -0.004372741084301271 -0.003140857587848666 -0.0018674459990036991 -0.0006062868853839851; -0.007507136636808644 -0.00625563280307439 -0.004974839900130232 -0.0037502856150627567 -0.00248792225366126 -0.0012506424049332353 1.2290424356097192e-5 0.0012443676066626237; -0.0054225155582720355 -0.0041669409908289155 -0.002902114456327619 -0.001671709721334514 -0.0004314043205660164 0.0008383161293840695 0.0020876403912263586 0.0033123969947557405; -0.0033310221597875125 -0.0021002456394344816 -0.000838011841468316 0.000438909704467456 0.001664016877395118 0.002925422650264743 0.004164160054908353 0.0054146221461086495; -0.00125220486529117 -2.7200786513778925e-6 0.0012446208758495679 0.0024993047057618976 0.0037588831335056577 0.005014334174664963 0.006220506927582478 0.007485390852512863; 0.0006275776256538685 0.0018631378956099453 0.003096323294082026 0.00436686582932354 0.005624395254935342 0.0068543074102921904 0.00812150565371675 0.009378798914467877; 0.0006147174196006317 0.0018732396839567656 0.0031321115233015917 0.004365933415668406 0.005657804046859348 0.0068838311647270575 0.008079305155821457 0.009396907258883383; 0.0005995429626648655 0.0018613955823338247 0.003115657191669988 0.00436595806652431 0.005629936389155388 0.006899440303179128 0.008109643828546058 0.009393144568394431; 0.0006144344623627764 0.0018870719763952734 0.0031529634787201915 0.004372994562053759 0.0056373028141778305 0.006890486463594664 0.00813585054399056 0.009388838515643224; 0.000651344302139676 0.00186357094608065 0.003127580267281289 0.004359155520696382 0.005612371240649113 0.0068829625263627315 0.00812088707114574 0.009364667188731609; 0.0006253292786194678 0.0018739793989175947 0.0030900043696147086 0.004369427299621416 0.005624102253273204 0.0068796890276612566 0.0081238267249029 0.00935216306791721; 0.0006256072639543581 0.0018593475588721577 0.0031374437629677204 0.004387497614962057 0.005602616206118971 0.006875533060434556 0.008115649648375875 0.009368159673297108; 0.000625398940981473 0.0018927849119153514 0.003111047720412222 0.004386031985391221 0.0056134736262412575 0.006899672112746123 0.008150018412534037 0.009377177956973225; 0.0005908161461353668 0.001863368018054019 0.003106192558372429 0.004383352070993703 0.0056475322519128806 0.006890821522415082 0.008128351634534446 0.009389255645984229; 0.0006359339637512779 0.0018962689862154828 0.003110840427775556 0.004386356841379596 0.005614625674533883 0.006878005239593375 0.008154662750904018 0.009371922515726896; 0.0006119654946935015 0.0018654145803346249 0.003116953665183759 0.0043588746418352755 0.0056160073459193445 0.006892384331975386 0.00810392858963192 0.009349877024436997; 0.0006109389572265091 0.001884158010197064 0.0031221192056787007 0.004378287478358654 0.005630912440877097 0.006872504406064223 0.008117957191870015 0.009369065984883134; 0.0006408666149329054 0.0018689448035025165 0.0031348242737747126 0.004388854684252908 0.005604540307366863 0.006883193228361454 0.008144396944103911 0.00936270948419919; 0.0006135930761572213 0.001858426660212328 0.0031262911729216156 0.0043788265480452435 0.005620876923405549 0.006886355553713557 0.008140413574933541 0.009395311159276535; 0.0006330951022315415 0.0018762930282236927 0.0031264015251475214 0.004361784623171304 0.0056108454090498736 0.0068841595725728745 0.008124149149031784 0.009391320932975598; 0.0006048499208849193 0.0018960896923360844 0.003112767169424631 0.004363119900411417 0.005618579480781142 0.006867313503977595 0.008150299274437986 0.009369972863887674; 0.0006431066526015402 0.0018814414685010621 0.00312366562565207 0.004384234422774158 0.005628190194352273 0.0068616654749844375 0.008131687782503172 0.009357378927209925; 0.0006459814448718764 0.0018818810935258194 0.003144722979180506 0.004370971231065964 0.005658245660143048 0.006883785379883936 0.008127990955679417 0.00936743736063185; 0.0006323279623673566 0.0018459979560196769 0.0031180537078553568 0.004381022935328945 0.005664093181460681 0.006878369037110113 0.008089387808576052 0.009380414371605713; 0.0006132217505331736 0.0018592151107603625 0.0031668972501260333 0.004358078337421286 0.005636649472436043 0.006881881542789226 0.008121115655992335 0.009372483460985544; 0.0006409747933037985 0.001873587972365447 0.003105429824420159 0.004351544791312161 0.005627092480479069 0.0068704968276567385 0.00813373805888594 0.009375104117302994; 0.0006254934112162448 0.0018822960641631352 0.0031668196172572314 0.004376050118316793 0.005637640510693947 0.0068737349406149595 0.008121580364992343 0.00937098173604576])

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.