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.UnitsGrid
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.0Model
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 M². We impose the front on top of a vertical buoyancy gradient N² 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⁻²]")
figSimulation
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 entriesWe 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 KiBNow 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: 20.608 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (10.267 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (3.046 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 7.870 seconds, max(u): (1.293e-01, 1.251e-01, 1.698e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 785.651 ms, max(u): (2.219e-01, 1.835e-01, 2.004e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 783.026 ms, max(u): (2.844e-01, 2.429e-01, 1.797e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 781.253 ms, max(u): (3.374e-01, 3.133e-01, 1.772e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 779.328 ms, max(u): (4.358e-01, 4.329e-01, 1.807e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 1.056 seconds, max(u): (5.864e-01, 6.690e-01, 2.612e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 779.968 ms, max(u): (8.858e-01, 1.040e+00, 3.147e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 773.507 ms, max(u): (1.354e+00, 1.333e+00, 4.919e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 764.883 ms, max(u): (1.455e+00, 1.229e+00, 4.994e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 813.778 ms, max(u): (1.411e+00, 1.343e+00, 4.263e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 872.679 ms, max(u): (1.376e+00, 1.276e+00, 3.667e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 776.944 ms, max(u): (1.387e+00, 1.110e+00, 2.727e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 767.746 ms, max(u): (1.387e+00, 1.273e+00, 2.806e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 755.896 ms, max(u): (1.543e+00, 1.219e+00, 2.698e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 24.900 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 24.918 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 CairoMakieThree-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.grid48×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.0We 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)41Now 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.0Next, 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.00937272235751152 -0.00812711101025343 -0.006871686317026615 -0.005625878926366568 -0.004374908749014139 -0.0031200393568724394 -0.0018749185837805271 -0.0006139319739304483; -0.009366508573293686 -0.008121086284518242 -0.006863318849354982 -0.005610596388578415 -0.004353491123765707 -0.0031192810274660587 -0.0018784288549795747 -0.0006328779854811728; -0.009376032277941704 -0.00812498014420271 -0.0068692429922521114 -0.005600137636065483 -0.004368079826235771 -0.003130296478047967 -0.001855147653259337 -0.0006153510184958577; -0.009369837120175362 -0.008106107823550701 -0.006856683641672134 -0.005599352531135082 -0.004360228776931763 -0.0031279902905225754 -0.0018890085630118847 -0.0006371974595822394; -0.00938475038856268 -0.008122832514345646 -0.006873979698866606 -0.005607612896710634 -0.004390865098685026 -0.0031148905400186777 -0.0018787537701427937 -0.0006372644565999508; -0.009390798397362232 -0.008129400201141834 -0.006899363826960325 -0.005602610297501087 -0.004372455179691315 -0.0031024119816720486 -0.0018725538393482566 -0.0006223280215635896; -0.009392122738063335 -0.008160175755620003 -0.006888591684401035 -0.0056077572517097 -0.004366426263004541 -0.003110691672191024 -0.001878230250440538 -0.0006154002621769905; -0.009345841594040394 -0.008130483329296112 -0.00683886744081974 -0.005647553130984306 -0.004370362497866154 -0.003115400206297636 -0.001882122247479856 -0.0006245424738153815; -0.009355717338621616 -0.008143983781337738 -0.006872702389955521 -0.005625211168080568 -0.004356103483587503 -0.0031281826086342335 -0.001865590107627213 -0.0006215063622221351; -0.009366698563098907 -0.008125168271362782 -0.006866879761219025 -0.005628953687846661 -0.004350051749497652 -0.0031124975066632032 -0.0018835454247891903 -0.0006436467519961298; -0.009382402524352074 -0.0081477714702487 -0.006888683885335922 -0.005612121894955635 -0.004366657696664333 -0.0031090129632502794 -0.0018439856357872486 -0.0006330217001959682; -0.009372883476316929 -0.00811426155269146 -0.006864998955279589 -0.00562156829982996 -0.004352264106273651 -0.00309450039640069 -0.0018891141517087817 -0.0006363600259646773; -0.009387818165123463 -0.00815502367913723 -0.006887227296829224 -0.005648801103234291 -0.004349948838353157 -0.003121279878541827 -0.0018835129449144006 -0.0006112821865826845; -0.009366345591843128 -0.0081147076562047 -0.006883193738758564 -0.0056030359119176865 -0.004352740943431854 -0.003125367918983102 -0.0018720662919804454 -0.0006388546316884458; -0.009389272890985012 -0.008109219372272491 -0.006865194067358971 -0.005621090531349182 -0.004370813257992268 -0.003113067476078868 -0.0018697780324146152 -0.0006015488179400563; -0.009371638298034668 -0.00809681136161089 -0.00685097137466073 -0.005628821440041065 -0.00436737947165966 -0.0031118663027882576 -0.0018752631731331348 -0.0006442388403229415; -0.009366698563098907 -0.008119599893689156 -0.006873796693980694 -0.005627600941807032 -0.004369206726551056 -0.0031097151804715395 -0.001869919360615313 -0.0006311541656032205; -0.00938223022967577 -0.008131593465805054 -0.006883541587740183 -0.005617923568934202 -0.0043769278563559055 -0.0031501613557338715 -0.001863184617832303 -0.0006112936534918845; -0.00936930999159813 -0.008137240074574947 -0.006880481727421284 -0.005630366038531065 -0.0043914844281971455 -0.0031340487767010927 -0.0018498399294912815 -0.000631656323093921; -0.009369445033371449 -0.00811710674315691 -0.006868069525808096 -0.005617691669613123 -0.0043866513296961784 -0.0031176619231700897 -0.0018684513634070754 -0.000609357375651598; -0.009364976547658443 -0.008123788051307201 -0.006866946816444397 -0.005633089225739241 -0.004383375868201256 -0.003121141344308853 -0.001888058497570455 -0.0006162355421110988; -0.009366451762616634 -0.00812230072915554 -0.006854823790490627 -0.005622818134725094 -0.0043692090548574924 -0.0031059924513101578 -0.0018828900065273046 -0.0006347651942633092; -0.007506613619625568 -0.006220455281436443 -0.00499111320823431 -0.0037474273703992367 -0.0025083692744374275 -0.0012548044323921204 -1.439319021301344e-6 0.001249029184691608; -0.005437884014099836 -0.004156024195253849 -0.0029245512560009956 -0.0016758694546297193 -0.00041622392018325627 0.000818201806396246 0.002046808833256364 0.003318520961329341; -0.003321282798424363 -0.002096025738865137 -0.000843490066472441 0.0004024499503429979 0.001657540793530643 0.0029067611321806908 0.0041605825535953045 0.0054370141588151455; -0.001252092537470162 -1.1575132248253794e-6 0.0012416846584528685 0.0025107692927122116 0.00377948977984488 0.005002471152693033 0.006240554619580507 0.007470850832760334; 0.0006270429585129023 0.001883363351225853 0.0031459792517125607 0.0043650539591908455 0.005608703475445509 0.006879169028252363 0.008099776692688465 0.009359714575111866; 0.0006357288220897317 0.001852327724918723 0.003117480082437396 0.004391168709844351 0.005623254459351301 0.006864824797958136 0.008136415854096413 0.009400337003171444; 0.0006262464448809624 0.0018772963667288423 0.00314190611243248 0.004393306560814381 0.005616324953734875 0.006875281222164631 0.008126143366098404 0.009383765049278736; 0.0006181369535624981 0.0018483330495655537 0.003116005565971136 0.004380414262413979 0.005597343668341637 0.006876038853079081 0.00811097677797079 0.00936848297715187; 0.0006315011414699256 0.001870717154815793 0.003122207708656788 0.004366931039839983 0.005623597651720047 0.0068696290254592896 0.008117604069411755 0.009366640821099281; 0.0006133141578175128 0.0018625305965542793 0.003105803392827511 0.0043893614783883095 0.005612173117697239 0.006867974065244198 0.00811777450144291 0.00938746239989996; 0.0006015251856297255 0.0018495217664167285 0.0031107368413358927 0.004366404842585325 0.005603980738669634 0.006883212365210056 0.00810899306088686 0.009378435090184212; 0.0006329697207547724 0.0018509021028876305 0.0031379926949739456 0.004356887191534042 0.005639411974698305 0.006876072380691767 0.00810395646840334 0.00938773900270462; 0.0006115154828876257 0.0018446646863594651 0.0031162695959210396 0.00434395344927907 0.005639403127133846 0.006880681961774826 0.008132153190672398 0.009386886842548847; 0.0006421457510441542 0.0018606808735057712 0.0031449845992028713 0.004359952174127102 0.005614249035716057 0.00684359110891819 0.008120105601847172 0.009403250180184841; 0.0006163034704513848 0.001906523946672678 0.0031404204200953245 0.004364805296063423 0.005637514404952526 0.006883258931338787 0.008126056753098965 0.009367167018353939; 0.0006271895254030824 0.0018784025451168418 0.0031051672995090485 0.004392822273075581 0.005641790106892586 0.0068834261037409306 0.008117574267089367 0.009357052855193615; 0.0006371079944074154 0.0018861449789255857 0.0030993313994258642 0.004366956651210785 0.00566241517663002 0.006858643144369125 0.00813701469451189 0.009377735666930676; 0.0006360240513458848 0.001878703711554408 0.0031315276864916086 0.004410067107528448 0.005650979932397604 0.006872935686260462 0.008121460676193237 0.00935146864503622; 0.000646311033051461 0.0018728917930275202 0.0031232100445777178 0.004371404182165861 0.005636562593281269 0.006873598322272301 0.008099214173853397 0.009359180927276611; 0.0006173781584948301 0.001893930952064693 0.0031226640567183495 0.004353035241365433 0.005621824413537979 0.006857739295810461 0.00813147984445095 0.009356697089970112; 0.0006448556086979806 0.0018861779244616628 0.0031405859626829624 0.004366119857877493 0.005603319965302944 0.006882878951728344 0.008113058283925056 0.009367146529257298; 0.000623330706730485 0.0018853084184229374 0.003109340090304613 0.0043654474429786205 0.005632197950035334 0.006854293867945671 0.008103247731924057 0.009385691955685616; 0.0006151079433038831 0.001883224700577557 0.0031414718832820654 0.004377659875899553 0.005602642428129911 0.006895049475133419 0.008108683861792088 0.009378422051668167; 0.0006258549401536584 0.0018660329515114427 0.003135901875793934 0.004398158751428127 0.005645150784403086 0.006868448108434677 0.008125950582325459 0.009379038587212563; 0.000636078417301178 0.001890901941806078 0.0031078048050403595 0.004365759436041117 0.005612506065517664 0.006870318204164505 0.00812881626188755 0.009352706372737885; 0.0006462588207796216 0.0018572664121165872 0.0031282033305615187 0.004412948153913021 0.005642853211611509 0.006862750742584467 0.0081360824406147 0.009372495114803314])
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
endJulia version and environment information
This example was executed with the following version of Julia:
using InteractiveUtils: versioninfo
versioninfo()Julia Version 1.12.2
Commit ca9b6662be4 (2025-11-20 16:25 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 128 × AMD EPYC 9374F 32-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, znver4)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 128 virtual cores)
Environment:
LD_LIBRARY_PATH =
JULIA_PKG_SERVER_REGISTRY_PREFERENCE = eager
JULIA_DEPOT_PATH = /var/lib/buildkite-agent/.julia-oceananigans
JULIA_PROJECT = /var/lib/buildkite-agent/Oceananigans.jl-27561/docs/
JULIA_VERSION = 1.12.2
JULIA_LOAD_PATH = @:@v#.#:@stdlib
JULIA_VERSION_ENZYME = 1.10.10
JULIA_PYTHONCALL_EXE = /var/lib/buildkite-agent/Oceananigans.jl-27561/docs/.CondaPkg/.pixi/envs/default/bin/python
JULIA_DEBUG = Literate
These were the top-level packages installed in the environment:
import Pkg
Pkg.status()Status `~/Oceananigans.jl-27561/docs/Project.toml`
[79e6a3ab] Adapt v4.4.0
[052768ef] CUDA v5.9.5
[13f3f980] CairoMakie v0.15.8
[e30172f5] Documenter v1.16.1
[daee34ce] DocumenterCitations v1.4.1
[033835bb] JLD2 v0.6.3
[98b081ad] Literate v2.21.0
[da04e1cc] MPI v0.20.23
[85f8d34a] NCDatasets v0.14.10
[9e8cae18] Oceananigans v0.102.5 `~/Oceananigans.jl-27561`
[f27b6e38] Polynomials v4.1.0
[6038ab10] Rotations v1.7.1
[d496a93d] SeawaterPolynomials v0.3.10
[09ab397b] StructArrays v0.7.2
[bdfc003b] TimesDates v0.3.3
[2e0b0046] XESMF v0.1.6
[b77e0a4c] InteractiveUtils v1.11.0
[37e2e46d] LinearAlgebra v1.12.0
[44cfe95a] Pkg v1.12.0
This page was generated using Literate.jl.