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: 18.924 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (9.789 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (2.853 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 7.464 seconds, max(u): (1.227e-01, 1.241e-01, 1.773e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 796.935 ms, max(u): (2.093e-01, 1.869e-01, 1.927e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 800.195 ms, max(u): (2.669e-01, 2.367e-01, 1.926e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 1.042 seconds, max(u): (3.389e-01, 2.934e-01, 1.820e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 769.476 ms, max(u): (4.093e-01, 4.403e-01, 1.776e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 805.955 ms, max(u): (5.405e-01, 6.300e-01, 2.383e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 793.422 ms, max(u): (6.975e-01, 9.451e-01, 3.306e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 917.952 ms, max(u): (1.049e+00, 1.170e+00, 4.261e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 776.768 ms, max(u): (1.287e+00, 1.230e+00, 5.634e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 768.032 ms, max(u): (1.393e+00, 1.189e+00, 4.610e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 793.184 ms, max(u): (1.263e+00, 1.280e+00, 5.156e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 806.076 ms, max(u): (1.371e+00, 1.190e+00, 3.599e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 774.538 ms, max(u): (1.313e+00, 1.246e+00, 3.219e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 768.687 ms, max(u): (1.404e+00, 1.478e+00, 3.781e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 24.344 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 24.363 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.009381791576743126 -0.008099867030978203 -0.006860154680907726 -0.00563149806112051 -0.004376789554953575 -0.0031271593179553747 -0.0018678129417821765 -0.0006255115731619298; -0.009380916133522987 -0.008130943402647972 -0.006860667373985052 -0.0056148553267121315 -0.004375896882265806 -0.0031291237100958824 -0.001883582677692175 -0.0006261265370994806; -0.009381954558193684 -0.008137490600347519 -0.0068581742234528065 -0.005641557276248932 -0.004398424178361893 -0.003129944670945406 -0.0018899838905781507 -0.0006373281357809901; -0.009375719353556633 -0.0081119230017066 -0.006884905509650707 -0.005651925224810839 -0.004404970444738865 -0.0031329758930951357 -0.0018454386154189706 -0.0006227533449418843; -0.009359514340758324 -0.008152755908668041 -0.006864463910460472 -0.005642628762871027 -0.004373990930616856 -0.003122129011899233 -0.0018743574619293213 -0.0006451591034419835; -0.009360265918076038 -0.00813065841794014 -0.006856115069240332 -0.00560867041349411 -0.004370532464236021 -0.0031226826831698418 -0.0018658312037587166 -0.000637578428722918; -0.00939122959971428 -0.008150414563715458 -0.006882440764456987 -0.0056204963475465775 -0.004379211459308863 -0.0031249788589775562 -0.0018897107802331448 -0.0006175416056066751; -0.009373608976602554 -0.008125148713588715 -0.006886547897011042 -0.005651222076267004 -0.004399774130433798 -0.0031274461653083563 -0.0018706453265622258 -0.0006225011311471462; -0.009372795931994915 -0.00812431238591671 -0.006862896028906107 -0.005618036724627018 -0.004368077032268047 -0.0031220342498272657 -0.0018685554387047887 -0.000627176312264055; -0.009355916641652584 -0.00815191026777029 -0.006861431989818811 -0.005614953115582466 -0.004407452419400215 -0.0031053218990564346 -0.0018768067238852382 -0.0006602130015380681; -0.009372802451252937 -0.008159319870173931 -0.006882340647280216 -0.005620747338980436 -0.004387661349028349 -0.003118520835414529 -0.0018750757444649935 -0.0006074258126318455; -0.009398113936185837 -0.008122563362121582 -0.006875892169773579 -0.0056222775019705296 -0.00435218308120966 -0.0031049870885908604 -0.001870843698270619 -0.0006477214628830552; -0.009388204663991928 -0.008149665780365467 -0.006897271610796452 -0.005648251622915268 -0.0043661706149578094 -0.0031169389840215445 -0.0018598330207169056 -0.0006123163038864732; -0.009366628713905811 -0.008101505227386951 -0.006895677652209997 -0.005633947905153036 -0.00436305720359087 -0.0031243744306266308 -0.0018657958135008812 -0.0006395736709237099; -0.009377643465995789 -0.008117170073091984 -0.006866044830530882 -0.005622650496661663 -0.004396812990307808 -0.00312629877589643 -0.0018603233620524406 -0.0005933885695412755; -0.009396124631166458 -0.00814321544021368 -0.006859354674816132 -0.005655682645738125 -0.00439671752974391 -0.0031319998670369387 -0.0018920220900326967 -0.0006243205280043185; -0.009386278688907623 -0.008123254403471947 -0.0068667237646877766 -0.005604374688118696 -0.0043692076578736305 -0.003131328849121928 -0.0018774608615785837 -0.0006093060947023332; -0.009373432025313377 -0.008074654266238213 -0.0068573858588933945 -0.005613165441900492 -0.0043882280588150024 -0.0031161336228251457 -0.0018694289028644562 -0.0006504089687950909; -0.00939135905355215 -0.00812313612550497 -0.006884261034429073 -0.005636817775666714 -0.004399233963340521 -0.0031333996448665857 -0.001872820546850562 -0.0006126064108684659; -0.009377152658998966 -0.008123268373310566 -0.00685254717245698 -0.00562865287065506 -0.0043610199354588985 -0.0031255644280463457 -0.0018583425553515553 -0.0006154652219265699; -0.009374617598950863 -0.00811484083533287 -0.0068674106150865555 -0.005613029934465885 -0.004395624157041311 -0.0031121019273996353 -0.0018644502852112055 -0.0006100102327764034; -0.009374360553920269 -0.008141997270286083 -0.006865971256047487 -0.00561949610710144 -0.004373496398329735 -0.003122036112472415 -0.0018832172499969602 -0.0006236681947484612; -0.007500641979277134 -0.006243265233933926 -0.004980513826012611 -0.0037741237320005894 -0.0025010446552187204 -0.0012696301564574242 -1.1407334568502847e-5 0.0012206065002828836; -0.005437574349343777 -0.004159519448876381 -0.0029133062344044447 -0.001677394611760974 -0.0003945743665099144 0.0008434816263616085 0.0020852836314588785 0.0033539843279868364; -0.0033521701116114855 -0.002103395527228713 -0.0008223572513088584 0.00043579385965131223 0.0016795857809484005 0.002931977855041623 0.004175887908786535 0.005412908736616373; -0.0012625079834833741 -6.880996352265356e-6 0.0012426215689629316 0.002517129760235548 0.003755848854780197 0.0050098174251616 0.006243197247385979 0.007497784215956926; 0.0006150059634819627 0.0018560634925961494 0.00313208089210093 0.00439858715981245 0.005628043320029974 0.006867005489766598 0.008124365471303463 0.009386573918163776; 0.0006468315841630101 0.001871404005214572 0.003109572920948267 0.004376851487904787 0.005636629182845354 0.00686469953507185 0.008155393414199352 0.00936195533722639; 0.0006384655134752393 0.0018586642108857632 0.003158183302730322 0.00438346341252327 0.005636383313685656 0.006881068926304579 0.00812567863613367 0.009387222118675709; 0.0006340011022984982 0.001870051957666874 0.003117359010502696 0.004388701170682907 0.005632918793708086 0.006884677801281214 0.008108288049697876 0.009374764747917652; 0.0006352636846713722 0.0018756671342998743 0.0031184719409793615 0.004381588660180569 0.005629774648696184 0.0068740444257855415 0.008129427209496498 0.00936053041368723; 0.0006411743233911693 0.0018774184864014387 0.003123680129647255 0.004375786054879427 0.005619227420538664 0.006865211762487888 0.008148911409080029 0.009382973425090313; 0.0006203408120200038 0.0018918967107310891 0.003115318017080426 0.004372954834252596 0.0056070866994559765 0.006860009860247374 0.00809854082763195 0.009364129975438118; 0.0006108557572588325 0.0018884788732975721 0.0031432518735527992 0.004397443495690823 0.005644266027957201 0.0068598403595387936 0.008155034855008125 0.009367055259644985; 0.0006228649872355163 0.0018513145623728633 0.0031056138686835766 0.0043565272353589535 0.005610387772321701 0.006859550718218088 0.008129339665174484 0.00937637034803629; 0.0006189136765897274 0.0018375194631516933 0.0031302906572818756 0.004384336527436972 0.00562689546495676 0.006885575596243143 0.008115514181554317 0.009412134997546673; 0.0006222536321729422 0.001868136110715568 0.0031318850815296173 0.004390249960124493 0.00564772542566061 0.006832389160990715 0.008130609057843685 0.009385887533426285; 0.0006082787294872105 0.00188900763168931 0.003154200268909335 0.004392928909510374 0.0056348033249378204 0.0068689328618347645 0.008118881843984127 0.009388846345245838; 0.0006248667486943305 0.0019048750400543213 0.0031239772215485573 0.004369721282273531 0.005628126207739115 0.006892102304846048 0.008122911676764488 0.00938884075731039; 0.0006385199376381934 0.001892943400889635 0.0031397417187690735 0.004386488348245621 0.005615628324449062 0.006878875195980072 0.00813001487404108 0.009360920637845993; 0.000606060610152781 0.001891814055852592 0.0031458353623747826 0.0043646711856126785 0.005625560879707336 0.006889593321830034 0.008128592744469643 0.009384086355566978; 0.0006248196004889905 0.0018884935416281223 0.003108429489657283 0.004395105876028538 0.005638908129185438 0.006881370209157467 0.00813439954072237 0.009375478141009808; 0.000641604361589998 0.0018735884223133326 0.0031370767392218113 0.004365469329059124 0.005625796038657427 0.00686438474804163 0.008103078231215477 0.009374654851853848; 0.0006398066179826856 0.0018630133708938956 0.00311041041277349 0.004364159423857927 0.005636159330606461 0.006882148329168558 0.008118771016597748 0.00939230713993311; 0.0006064099725335836 0.0018717447528615594 0.003133702790364623 0.004350730683654547 0.005605694837868214 0.006873848382383585 0.008135069161653519 0.00937110185623169; 0.000598206534050405 0.0018882800359278917 0.0031104821246117353 0.0043741874396800995 0.00563964806497097 0.006865461822599173 0.008109057322144508 0.00936652161180973; 0.0006180233904160559 0.0018651554128155112 0.003112942213192582 0.004377544391900301 0.005620879586786032 0.00688835047185421 0.008140350691974163 0.00936508271843195; 0.0006371317431330681 0.0018698034109547734 0.0031233017798513174 0.00433714734390378 0.005617856979370117 0.006884399335831404 0.008118817582726479 0.00938360020518303])
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-27500/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-27500/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-27500/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.4 `~/Oceananigans.jl-27500`
[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.