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: 19.506 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (10.384 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (2.745 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 7.316 seconds, max(u): (1.243e-01, 1.224e-01, 1.763e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 1.173 seconds, max(u): (2.159e-01, 1.914e-01, 1.958e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 841.070 ms, max(u): (3.031e-01, 2.686e-01, 2.010e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 834.250 ms, max(u): (3.363e-01, 3.388e-01, 1.857e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 826.157 ms, max(u): (4.175e-01, 4.196e-01, 2.089e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 1.065 seconds, max(u): (5.211e-01, 6.773e-01, 2.770e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 773.900 ms, max(u): (6.935e-01, 1.032e+00, 3.508e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 793.226 ms, max(u): (1.120e+00, 1.159e+00, 4.750e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 823.682 ms, max(u): (1.325e+00, 1.135e+00, 5.518e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 906.139 ms, max(u): (1.433e+00, 1.095e+00, 4.176e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 792.532 ms, max(u): (1.448e+00, 1.083e+00, 3.967e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 829.320 ms, max(u): (1.249e+00, 1.043e+00, 2.249e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 875.087 ms, max(u): (1.197e+00, 1.168e+00, 2.460e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 797.578 ms, max(u): (1.328e+00, 1.230e+00, 2.362e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 25.662 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 25.727 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.009387929923832417 -0.008131619542837143 -0.006892180070281029 -0.005607601720839739 -0.004375999793410301 -0.003100088331848383 -0.0018544100457802415 -0.0006422058213502169; -0.009378787130117416 -0.008135751821100712 -0.006873998790979385 -0.00562147656455636 -0.004346175119280815 -0.003142903558909893 -0.0018635031301528215 -0.0006104842177592218; -0.009377124719321728 -0.00812945980578661 -0.006882654037326574 -0.0055857193656265736 -0.0043820966966450214 -0.0031474705319851637 -0.0018871140200644732 -0.0006156288436613977; -0.009372430853545666 -0.008124319836497307 -0.006878132466226816 -0.005629724357277155 -0.004379016347229481 -0.0031400055158883333 -0.0018746567657217383 -0.0006560304318554699; -0.009391561150550842 -0.008129364810883999 -0.0068557774648070335 -0.005586097948253155 -0.004382920451462269 -0.0031186353880912066 -0.0018557298462837934 -0.0006272083264775574; -0.009370016865432262 -0.008115875534713268 -0.0068685077130794525 -0.005618420895189047 -0.00438330415636301 -0.0031445412896573544 -0.0018696506740525365 -0.0006271485472097993; -0.009359658695757389 -0.008142299018800259 -0.006888554897159338 -0.005612238310277462 -0.004363028332591057 -0.0031223823316395283 -0.0018761781975626945 -0.0006017218111082911; -0.00933654885739088 -0.00813821516931057 -0.006878507789224386 -0.005615728907287121 -0.004375278949737549 -0.003155631246045232 -0.001860662130638957 -0.0006077765137888491; -0.009368302300572395 -0.00811666902154684 -0.006875828839838505 -0.005621255375444889 -0.004379133228212595 -0.003121909685432911 -0.001866167993284762 -0.0006319773383438587; -0.009358562529087067 -0.008102044463157654 -0.006879620719701052 -0.005627762526273727 -0.004377877339720726 -0.003126113675534725 -0.0018857383402064443 -0.0006148603861220181; -0.009380127303302288 -0.008142273873090744 -0.006862352602183819 -0.005605480168014765 -0.004402332007884979 -0.0031242023687809706 -0.0018818561220541596 -0.0006300315726548433; -0.009363535791635513 -0.00812568236142397 -0.006877967622131109 -0.0056258682161569595 -0.004374343436211348 -0.0031125107780098915 -0.0018956006970256567 -0.0006339480169117451; -0.009378173388540745 -0.008147439919412136 -0.006866880692541599 -0.005627975799143314 -0.0043539018370211124 -0.0031453086994588375 -0.0018967384239658713 -0.0006128960521891713; -0.009386555291712284 -0.008132338523864746 -0.006890658289194107 -0.0056049758568406105 -0.004377647303044796 -0.0031344869639724493 -0.00186557334382087 -0.0006298957159742713; -0.00936824269592762 -0.008133434690535069 -0.0068846698850393295 -0.00564800389111042 -0.004361655097454786 -0.003139360575005412 -0.001862071454524994 -0.000617488578427583; -0.00937995221465826 -0.008129185996949673 -0.006891120690852404 -0.005644753109663725 -0.004375157877802849 -0.0031170526053756475 -0.0018736862111836672 -0.0006191655993461609; -0.0093932980671525 -0.008129413239657879 -0.00688762404024601 -0.0056333946995437145 -0.00437167240306735 -0.003108713310211897 -0.001889856648631394 -0.000621702813077718; -0.009359878487884998 -0.008120952174067497 -0.006847685668617487 -0.005630257073789835 -0.004394008778035641 -0.0031154504977166653 -0.0018801037222146988 -0.0006341609405353665; -0.009379023686051369 -0.008118072524666786 -0.0068700616247951984 -0.005624570418149233 -0.004352696239948273 -0.003108010161668062 -0.001876780646853149 -0.0006178243784233928; -0.009371624328196049 -0.008130237460136414 -0.006860099267214537 -0.00562274968251586 -0.004360865335911512 -0.003112764796242118 -0.0018563226331025362 -0.0006258395151235163; -0.00938077550381422 -0.008148349821567535 -0.00686474097892642 -0.0056372578255832195 -0.004380248486995697 -0.0031305206939578056 -0.0018639916088432074 -0.0006129552493803203; -0.009389521554112434 -0.008125894702970982 -0.006871020421385765 -0.005609523504972458 -0.004368297290056944 -0.0031356813851743937 -0.0018935450352728367 -0.0006115826545283198; -0.0075081512331962585 -0.0062634204514324665 -0.00502094067633152 -0.0037297396920621395 -0.0025029857642948627 -0.0012462231097742915 2.557629341026768e-5 0.001240895944647491; -0.005404701456427574 -0.004166327882558107 -0.0029079257510602474 -0.001670721103437245 -0.0004233958898112178 0.0008513309876434505 0.0020668499637395144 0.003333982080221176; -0.003359677502885461 -0.0021073578391224146 -0.000856769853271544 0.0004136943316552788 0.0016685654409229755 0.0029447567649185658 0.0041710142977535725 0.005428740754723549; -0.0012536955764517188 1.0733050430644653e-6 0.0012399100232869387 0.002489925129339099 0.003769097151234746 0.004995014984160662 0.006242223549634218 0.007498496677726507; 0.0006263098330236971 0.0018967356299981475 0.0031333162914961576 0.004354607313871384 0.005628489423543215 0.006873042788356543 0.008109216578304768 0.009372654370963573; 0.0006333471974357963 0.001879272167570889 0.003117086598649621 0.0043592387810349464 0.0056428005918860435 0.006858998443931341 0.008120881393551826 0.009382130578160286; 0.0006114138523116708 0.0018895340617746115 0.0031300659757107496 0.004398254677653313 0.005632148124277592 0.006894128862768412 0.008132736198604107 0.009356550872325897; 0.0006321115652099252 0.0018636212917044759 0.003112863516435027 0.004370595794171095 0.005622693803161383 0.006864033639431 0.008123211562633514 0.009392389096319675; 0.0006369989714585245 0.0019079480553045869 0.0031306773889809847 0.00437413714826107 0.00561151560395956 0.0068827299401164055 0.008152066729962826 0.009400580078363419; 0.0006142141646705568 0.0018525399500504136 0.0031040918547660112 0.00437587546184659 0.005614743568003178 0.006858198903501034 0.008131539449095726 0.009379472583532333; 0.0006088956724852324 0.0018560785101726651 0.003123246831819415 0.004375922027975321 0.005600966513156891 0.006880483590066433 0.008129365742206573 0.009395284578204155; 0.0006377493846230209 0.0018757691141217947 0.003093865467235446 0.0043849763460457325 0.005631637293845415 0.006852703634649515 0.008119076490402222 0.009379522874951363; 0.0006297839572653174 0.0018653158331289887 0.0031262170523405075 0.004363997373729944 0.0056306421756744385 0.00686122290790081 0.008120468817651272 0.00935478787869215; 0.0006591718993149698 0.0018823035061359406 0.0031256270594894886 0.004386141896247864 0.005613884888589382 0.006872512400150299 0.008121546357870102 0.009355539456009865; 0.0006422416190616786 0.0018784733256325126 0.0031176141928881407 0.004353031050413847 0.005628605838865042 0.006867572199553251 0.008110933005809784 0.009392902255058289; 0.0006199356867000461 0.0018794809002429247 0.0031125382520258427 0.00437413714826107 0.005623600911349058 0.006878985092043877 0.008126480504870415 0.009404041804373264; 0.0006124177016317844 0.001864900579676032 0.0031099191401153803 0.004381887149065733 0.005642598029226065 0.006839840207248926 0.008121944963932037 0.009374796412885189; 0.0006185907986946404 0.0018770303577184677 0.0031462961342185736 0.004375677090138197 0.0056107789278030396 0.0068683926947414875 0.00810982659459114 0.009358364157378674; 0.0006203782977536321 0.0018734490731731057 0.003101034788414836 0.004359032493084669 0.005650664214044809 0.006864258553832769 0.00812384020537138 0.009382660500705242; 0.0006450981018133461 0.0018723101820796728 0.003100982867181301 0.00439998134970665 0.005634614732116461 0.0068633900955319405 0.008130373433232307 0.009346766397356987; 0.0006013179081492126 0.0018817255040630698 0.0031240666285157204 0.004370369948446751 0.005614078138023615 0.006899471394717693 0.008133145049214363 0.009374592453241348; 0.0006067819194868207 0.0018870843341574073 0.003135727485641837 0.0043629673309624195 0.0056251161731779575 0.0068840645253658295 0.008131729438900948 0.009347544983029366; 0.0006274970364756882 0.0018672328442335129 0.0031100306659936905 0.004367063287645578 0.005656638648360968 0.006876710802316666 0.0081498883664608 0.009379936382174492; 0.0005975324893370271 0.0018455364042893052 0.003142724046483636 0.004386017099022865 0.0056324489414691925 0.006881665904074907 0.00813470222055912 0.009393775835633278; 0.0006280175293795764 0.0018910213839262724 0.0031300708651542664 0.004374884068965912 0.005636093206703663 0.006861784495413303 0.008122364990413189 0.009336581453680992; 0.0006345876026898623 0.0019032647833228111 0.003125363029539585 0.004358794540166855 0.005634668283164501 0.006877090781927109 0.008143450133502483 0.009355402551591396])
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-27825/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-27825/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-27825/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.103.1 `~/Oceananigans.jl-27825`
[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.