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.362 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info:     ... simulation initialization complete (24.636 seconds)
[ Info: Executing initial time step...
[ Info:     ... initial time step complete (18.492 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 35.810 seconds, max(u): (1.265e-01, 1.246e-01, 1.549e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 817.968 ms, max(u): (2.324e-01, 2.165e-01, 1.707e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 836.979 ms, max(u): (2.980e-01, 2.940e-01, 1.888e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 815.213 ms, max(u): (3.748e-01, 4.042e-01, 1.858e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 727.716 ms, max(u): (4.914e-01, 5.814e-01, 1.989e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 817.102 ms, max(u): (6.185e-01, 9.100e-01, 2.242e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 723.058 ms, max(u): (8.660e-01, 1.260e+00, 3.983e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 716.496 ms, max(u): (1.231e+00, 1.239e+00, 4.269e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 687.449 ms, max(u): (1.417e+00, 1.264e+00, 5.267e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 789.632 ms, max(u): (1.346e+00, 1.255e+00, 4.865e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 838.407 ms, max(u): (1.358e+00, 1.375e+00, 3.535e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 706.556 ms, max(u): (1.517e+00, 1.408e+00, 3.627e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 764.489 ms, max(u): (1.388e+00, 1.328e+00, 3.927e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 771.242 ms, max(u): (1.546e+00, 1.385e+00, 3.467e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 57.214 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 57.248 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.009381085806993246 -0.008114246783724369 -0.00687148900867883 -0.0056220480194850535 -0.004352746374518957 -0.003130728695327199 -0.0018834658607905508 -0.0006202478929966225; -0.009378480292067249 -0.008116456087629884 -0.006840293034263181 -0.005624428497837523 -0.0043971583708828305 -0.0030992927281428416 -0.0018774123401593516 -0.0006436562212125044; -0.00938019375696882 -0.008141399688911203 -0.0068661426740005945 -0.005598028329134807 -0.004377648125390761 -0.0031252561507763127 -0.0018534329823872008 -0.000643321934532376; -0.009374125633380156 -0.008111135330014537 -0.006896820965931548 -0.005622743764021267 -0.004389583730766942 -0.0031270489913055254 -0.0018806551620804092 -0.0005978790796055741; -0.009373472580867822 -0.008134629746005229 -0.0068883621822730876 -0.00561482932697152 -0.004413494967075987 -0.0030918005364611277 -0.001867004078620564 -0.0006080625778039996; -0.009368303289200366 -0.0081358056297218 -0.006870927160339079 -0.005630685556861671 -0.004351075210759203 -0.0031147982151220163 -0.0018666903860245696 -0.0006191891754101215; -0.00939795343658884 -0.008123656373116316 -0.006864330194131141 -0.005595895786615015 -0.004375709492932015 -0.003115602612923048 -0.0018688321322845576 -0.0006204923279651697; -0.009368868034812601 -0.008118190760749423 -0.006884750507563978 -0.005609110022163359 -0.004365762981803395 -0.0031017731697042116 -0.0018625009830212386 -0.0006104408876863466; -0.009386976531589007 -0.008129255145798677 -0.006896418971914786 -0.005617809235733743 -0.0043665828052803805 -0.0031044569141371477 -0.001858858811145016 -0.0006162354655077233; -0.00939135940841866 -0.008118581247516927 -0.006870688088979365 -0.005626791067539817 -0.0043944683362639346 -0.003134566320354052 -0.0018675783386742902 -0.0006077523263608023; -0.009353024613594208 -0.008109052756803759 -0.006892870676122237 -0.005606733354671089 -0.004393961018740429 -0.003133497037841906 -0.0018721907499503639 -0.00061755200007159; -0.009382155827765588 -0.008088620942035376 -0.0068917710443041 -0.005628462073710948 -0.0043930150852792395 -0.0031293158837573305 -0.0018765505975185746 -0.0006017203216112995; -0.009367498619009701 -0.008127261280070129 -0.006861961507488529 -0.0056353571413777295 -0.004383536472719658 -0.0031405415316526786 -0.0018871698994562113 -0.0006366997128187213; -0.009372680283895414 -0.008113477020932626 -0.006872156848782608 -0.005632563941165951 -0.004358721059271977 -0.0031265784424769003 -0.0018581364153728204 -0.0006307999687632; -0.009383378265515857 -0.008129627984268101 -0.006896949437757298 -0.005627710352970644 -0.004362300277869818 -0.0031207250381732163 -0.0018608979096057887 -0.0006177852562243739; -0.00937556517764545 -0.00812618852952232 -0.006879349080782721 -0.005623187004715297 -0.004381709191410648 -0.003160132034117235 -0.0018741215740951025 -0.0006472581281315605; -0.009390039352371366 -0.008117423393167565 -0.00684796797046362 -0.0056383243382987945 -0.00439868694979115 -0.0031360586466753384 -0.0018745069126493395 -0.0005949280624939894; -0.009363918727450281 -0.008118547932977156 -0.006886778785923669 -0.0056208323898345736 -0.004394266606714883 -0.0031426894133376854 -0.0018666524674959637 -0.0006427895327552946; -0.009384766540959226 -0.008112426482181594 -0.006881158244485892 -0.005590855237635452 -0.004371902892763101 -0.0031138036943793245 -0.0018717240385714567 -0.0006455087956894753; -0.009375510441616141 -0.008119055535038168 -0.006880542181362841 -0.005614480131717188 -0.004374131156132652 -0.0031376460112716533 -0.001856429202112555 -0.0006239360422798385; -0.00936093189569516 -0.008144434359600551 -0.006878228906132784 -0.005606884367217228 -0.004381357997226096 -0.003114418718283956 -0.0018780870633988138 -0.000631681958857868; -0.009373701489670866 -0.008123340948615726 -0.006839652457400941 -0.005622004179693656 -0.004374105487268979 -0.0031483003655047074 -0.0018692924694194396 -0.0006266499472421756; -0.007521194650806543 -0.006255202026823554 -0.004997333035193443 -0.003726985541391744 -0.0025031674013593873 -0.0012350556671225264 1.160954117665071e-5 0.001230772068349246; -0.005427755582510509 -0.004157818572049989 -0.002910514736723369 -0.001680033958154795 -0.0004345922325941611 0.0008223416024911593 0.0020990792669202656 0.0033335507069392014; -0.0033119054975948975 -0.0020874322531180284 -0.0008333360263769428 0.00039028726522316967 0.0016616702787735117 0.002905233914634431 0.004164322984243746 0.005410237722163441; -0.0012577571377949059 -1.9265610955046305e-5 0.00124557886415027 0.0024655003479953576 0.0037534595647972847 0.004982836045565576 0.006250191645440485 0.00748155598191589; 0.0005934238015787907 0.0018804769782246693 0.0031135879953736213 0.004382411574059609 0.005640675294706683 0.006888191365984449 0.008118678665229374 0.009385772850418722; 0.0006223834851816165 0.001853750228605247 0.0031197799398940966 0.00437628825775113 0.0055989253883118395 0.006843830136848611 0.008128898162205854 0.009371565709143612; 0.0006276717850648667 0.001881620594032749 0.00313823555385705 0.004363968751564733 0.00562762110749949 0.006857236707297967 0.008130733647243272 0.009365180480186967; 0.000611024564287753 0.0018840298052394677 0.003129172189245059 0.00438872310985644 0.005621112231670604 0.006863662376216204 0.008137752778157379 0.009379611411006428; 0.000599582255258641 0.0018469429210750297 0.0031264322450980445 0.0044003130913577914 0.005630057857569245 0.006869789400744404 0.008108775552522686 0.00939027318292856; 0.0006107986473505208 0.0018842833986049369 0.0031266769379633933 0.004385508412706549 0.005613972943654943 0.006874389237167773 0.008124510284319125 0.00941425993630644; 0.0006299961312039959 0.0018596678898070561 0.0031506944175304073 0.004377928960185661 0.005614023832364673 0.00688019953480892 0.008136955312343352 0.009376499871777874; 0.0006249556809874065 0.0018687261546942834 0.003115703029868125 0.004385153435114324 0.005628476700228149 0.006891677638184726 0.008139485546112784 0.009368442438281789; 0.0006068702287125202 0.0018722337887575949 0.003096011130774306 0.004355698406939414 0.005644289007923021 0.00687109989076784 0.008121425350718829 0.009376201386754032; 0.0006192973636019978 0.0018527590955928893 0.0031166426951889244 0.004387130657898116 0.00563751405819402 0.006859345761205962 0.00815287719209526 0.00938906163413007; 0.000600507701896547 0.0018586002966993148 0.003115448453577653 0.004414482828387852 0.005633096839176974 0.006889848117155646 0.0081246786507457 0.009372102577187737; 0.0006167974175671394 0.0018764531355016498 0.0031141199404149666 0.004365280072248861 0.005665607976355251 0.006883161505538894 0.008144618426002045 0.009388477960900206; 0.0006095357424712155 0.0018570059712159903 0.0030938204814907667 0.004389807283683892 0.005621023843297052 0.0068768840178547634 0.008115012392428959 0.009392083667756693; 0.0006353524474826722 0.0018752565759131846 0.003134130109421727 0.004368721280420279 0.005617837468140033 0.006880099737542308 0.008137484403163435 0.00941583369324432; 0.0006184843694021758 0.001886348085296651 0.0031264915916373232 0.004337640750034307 0.005626282364075826 0.006858102328093435 0.008099354420112385 0.00937911080801833; 0.000628581142050895 0.0018978909679436193 0.003154585455901533 0.004392146533140728 0.005621676819357488 0.006876741390770447 0.00813973387227651 0.009386170030502447; 0.0006006798510665195 0.0018809985182149274 0.0031401601713969955 0.004385611196673853 0.005624650039846406 0.006874494603087623 0.008141376676161473 0.009362898285727917; 0.0006419615428098751 0.0019014604658527954 0.0030981539321678036 0.004387950856374388 0.0056049338327795704 0.006869391658561884 0.008101356985836574 0.00938857857284208; 0.0006238415564507098 0.0018836063010966794 0.0031258121650107554 0.004383947995724294 0.005629009333710665 0.006868855192764981 0.008126283243405417 0.009356796559388246; 0.0006245227612484873 0.0018669368400831851 0.0031091815971262967 0.004384810803751385 0.005625250051527582 0.006874564989168549 0.008129384344859844 0.009399020679932674; 0.0006430964460522407 0.0018617635353645936 0.003120602538829533 0.004397004234094193 0.005647345511799528 0.006872554389444795 0.00811663022715405 0.009376102806128309; 0.00064651882933128 0.0018800203005525304 0.0031539810984781307 0.004381586628201178 0.005641429413074711 0.006883731094621701 0.008120657279061647 0.009391999465043373])

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.