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: 0 bytes (file not yet created)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: 18.198 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (15.741 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (2.923 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 7.268 seconds, max(u): (1.196e-01, 1.308e-01, 1.849e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 783.425 ms, max(u): (2.203e-01, 2.007e-01, 1.971e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 788.005 ms, max(u): (2.912e-01, 2.712e-01, 1.905e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 783.292 ms, max(u): (3.567e-01, 4.156e-01, 2.266e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 786.236 ms, max(u): (4.833e-01, 6.206e-01, 2.395e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 870.543 ms, max(u): (6.579e-01, 8.865e-01, 3.404e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 774.197 ms, max(u): (1.035e+00, 1.216e+00, 4.424e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 761.463 ms, max(u): (1.375e+00, 1.287e+00, 5.123e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 756.206 ms, max(u): (1.432e+00, 1.221e+00, 5.418e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 822.212 ms, max(u): (1.400e+00, 1.162e+00, 4.498e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 766.639 ms, max(u): (1.288e+00, 1.031e+00, 3.559e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 761.531 ms, max(u): (1.345e+00, 1.069e+00, 1.996e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 759.895 ms, max(u): (1.221e+00, 1.218e+00, 2.120e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 771.633 ms, max(u): (1.189e+00, 1.154e+00, 2.066e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 29.916 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 29.935 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.009354307316243649 -0.008110594004392624 -0.006895474158227444 -0.005620528012514114 -0.004392945673316717 -0.003102188929915428 -0.0018768495647236705 -0.0006094732088968158; -0.009381375275552273 -0.008145942352712154 -0.006862744223326445 -0.005643583368510008 -0.00437348335981369 -0.0031460144091397524 -0.001862629665993154 -0.0006266972632147372; -0.00937975849956274 -0.008108913898468018 -0.006865293253213167 -0.0056244079023599625 -0.004353228956460953 -0.0031003598123788834 -0.0018354192143306136 -0.0006269427831284702; -0.009357673116028309 -0.008118001744151115 -0.006876775063574314 -0.005621491931378841 -0.004361364524811506 -0.003123420989140868 -0.0018999403109773993 -0.0006356301018968225; -0.009353306144475937 -0.008107222616672516 -0.006893569137901068 -0.0056249587796628475 -0.004385688342154026 -0.0031329509802162647 -0.0018704228568822145 -0.0006200710777193308; -0.009370733983814716 -0.008128670044243336 -0.006878454703837633 -0.005618193652480841 -0.004379175137728453 -0.0031375237740576267 -0.0018761653918772936 -0.0006113202543929219; -0.009382013231515884 -0.008112768642604351 -0.006865276023745537 -0.005647159647196531 -0.004372616298496723 -0.0031425082124769688 -0.0018655043095350266 -0.0006076951394788921; -0.009391956962645054 -0.008121979422867298 -0.006883456837385893 -0.005615604110062122 -0.004357513040304184 -0.0031338755507022142 -0.0018897528061643243 -0.0006394516676664352; -0.00937890075147152 -0.008126896806061268 -0.00686640664935112 -0.005636023357510567 -0.004379165358841419 -0.0031260985415428877 -0.00187105278018862 -0.0006323802517727017; -0.009385326877236366 -0.008113090880215168 -0.006884847301989794 -0.0056418743915855885 -0.004376282915472984 -0.003136933082714677 -0.0018754142802208662 -0.0006049151415936649; -0.009384741075336933 -0.008138617500662804 -0.006891589146107435 -0.005609548185020685 -0.004360093269497156 -0.0031326678581535816 -0.0018793267663568258 -0.0006246979464776814; -0.009342199191451073 -0.008121662773191929 -0.006883388850837946 -0.005602903198450804 -0.004382662940770388 -0.0031178416684269905 -0.001886509358882904 -0.0006299752276390791; -0.009366418235003948 -0.008135472424328327 -0.0068727582693099976 -0.005628237500786781 -0.0043993666768074036 -0.003142189932987094 -0.0018485295586287975 -0.0006301248795352876; -0.009383290074765682 -0.008121936582028866 -0.006874080281704664 -0.005634509027004242 -0.004383268300443888 -0.00312960147857666 -0.0019010714022442698 -0.000617176468949765; -0.009386668913066387 -0.008133628405630589 -0.006887091789394617 -0.005616471637040377 -0.004366515204310417 -0.0031359358690679073 -0.0018785831052809954 -0.0006507242214865983; -0.009383452124893665 -0.008135275915265083 -0.0068709393963217735 -0.005625628866255283 -0.004385709762573242 -0.003126489697024226 -0.0018772876355797052 -0.000624306034296751; -0.00936710275709629 -0.008151634596288204 -0.006878608372062445 -0.005631663370877504 -0.0043541183695197105 -0.0031372837256640196 -0.0018741418607532978 -0.0006180453347042203; -0.009380065836012363 -0.008126202039420605 -0.0068642450496554375 -0.0056152502074837685 -0.00437816372141242 -0.0031390893273055553 -0.0018958335276693106 -0.0005988148041069508; -0.009408914484083652 -0.008128582499921322 -0.006891414523124695 -0.005610879044979811 -0.004371455404907465 -0.0031350520439445972 -0.001874585635960102 -0.0006189577397890389; -0.009364524856209755 -0.008107120171189308 -0.006871088407933712 -0.0056301262229681015 -0.004378548823297024 -0.003109878394752741 -0.0018696780316531658 -0.0006050149677321315; -0.009376230649650097 -0.00812949426472187 -0.00685677956789732 -0.005631911568343639 -0.004386473912745714 -0.003117281012237072 -0.0018593472195789218 -0.0006259976071305573; -0.009356731548905373 -0.00812400970607996 -0.006888014264404774 -0.005613579414784908 -0.004357079043984413 -0.0031239010859280825 -0.0018622446805238724 -0.0006305732531473041; -0.007499732077121735 -0.006254302803426981 -0.0049856663681566715 -0.003760997438803315 -0.002506646793335676 -0.0012568688252940774 8.664173947181553e-6 0.0012387036113068461; -0.0054203420877456665 -0.004154403228312731 -0.0029081241227686405 -0.0016560603398829699 -0.00040264931158162653 0.0008167785708792508 0.0020558827091008425 0.0033187803346663713; -0.0033280656207352877 -0.0020631751976907253 -0.0008414520416408777 0.0004170970350969583 0.0016780683072283864 0.002920361002907157 0.004174655303359032 0.00543538574129343; -0.0012570887338370085 -9.032779416884296e-6 0.0012596447486430407 0.002523298840969801 0.003770912764593959 0.005001728888601065 0.006249090190976858 0.007485989015549421; 0.0006069425726309419 0.001869047642685473 0.003126319497823715 0.004355320241302252 0.005632766988128424 0.006891811732202768 0.00813378393650055 0.009364843368530273; 0.0006263427203521132 0.0018449034541845322 0.0031435887794941664 0.004394429735839367 0.005621734540909529 0.0068662529811263084 0.008121661841869354 0.009367354214191437; 0.0006313172634691 0.001886188518255949 0.0031203916296362877 0.004377450793981552 0.005624489393085241 0.006867754738777876 0.008143083192408085 0.00938780140131712; 0.0006408719345927238 0.0018506571650505066 0.003139013424515724 0.004355819430202246 0.005609351210296154 0.006870533339679241 0.008140282705426216 0.009378715418279171; 0.0006106998771429062 0.0018950247904285789 0.0031240698881447315 0.004385712556540966 0.005616394802927971 0.006851522251963615 0.008123165927827358 0.009395640343427658; 0.0006317478837445378 0.001877875765785575 0.0031280338298529387 0.004350762348622084 0.005619507748633623 0.006861846894025803 0.008133120834827423 0.009353936649858952; 0.0006099159363657236 0.001877958420664072 0.0031367712654173374 0.004374183714389801 0.005623634438961744 0.0068687028251588345 0.008120903745293617 0.00936251413077116; 0.0006222351803444326 0.0018776535289362073 0.0031348306220024824 0.004368199501186609 0.005622502416372299 0.0068982006050646305 0.008109747432172298 0.009366066195070744; 0.0006197383627295494 0.001866367063485086 0.003121312940493226 0.004350841511040926 0.0056495266035199165 0.006886937655508518 0.008148742839694023 0.009361285716295242; 0.0006286680581979454 0.0018995122518390417 0.0031058904714882374 0.004392010159790516 0.005603081546723843 0.0068728444166481495 0.008109339512884617 0.009384626522660255; 0.0006248573190532625 0.0018789074383676052 0.0031193161848932505 0.00437802542001009 0.005599940195679665 0.006891287863254547 0.008133345283567905 0.009386049583554268; 0.0006087961373850703 0.0018651614664122462 0.0031168668065220118 0.00436674477532506 0.005618890281766653 0.006873962469398975 0.008139712736010551 0.00936158001422882; 0.00059816415887326 0.0018839110853150487 0.003119388595223427 0.004378912970423698 0.005615468602627516 0.006880581378936768 0.008135172538459301 0.009370507672429085; 0.000651483132969588 0.001877577742561698 0.0031184644903987646 0.004372157156467438 0.005636315792798996 0.006899459287524223 0.008126790635287762 0.009383300319314003; 0.0006358719547279179 0.0018682723166421056 0.003129011020064354 0.00437887292355299 0.005621628370136023 0.006878220941871405 0.008136066608130932 0.00935938861221075; 0.000625982997007668 0.001866140984930098 0.0031117910984903574 0.00437077134847641 0.005635912995785475 0.0068863979540765285 0.008136595599353313 0.009369788691401482; 0.0006350278854370117 0.001877791015431285 0.0031107838731259108 0.004376924596726894 0.005635964218527079 0.006868385244160891 0.008134208619594574 0.009391145780682564; 0.0006356775411404669 0.0018831950146704912 0.0031241129618138075 0.0043797604739665985 0.005619904492050409 0.006879040040075779 0.00808613933622837 0.009353355504572392; 0.0006530756945721805 0.0018912761006504297 0.0031161783263087273 0.004397979937493801 0.005616111680865288 0.006856539286673069 0.008144333958625793 0.009367230348289013; 0.0006361466366797686 0.0018845527665689588 0.0031120674684643745 0.004368980415165424 0.005636312998831272 0.006859333720058203 0.00813480094075203 0.009395596571266651; 0.0006227783742360771 0.0018615915905684233 0.003100483911111951 0.0043923878110945225 0.005612911190837622 0.0068785338662564754 0.008149084635078907 0.009363469667732716; 0.0006057061837054789 0.0018716600025072694 0.003132645273581147 0.004404588136821985 0.005616887006908655 0.006868876516819 0.008122522383928299 0.00941397249698639])
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.3
Commit 966d0af0fdf (2025-12-15 11:20 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-28209/docs/
JULIA_VERSION = 1.12.3
JULIA_LOAD_PATH = @:@v#.#:@stdlib
JULIA_VERSION_ENZYME = 1.10.10
JULIA_PYTHONCALL_EXE = /var/lib/buildkite-agent/Oceananigans.jl-28209/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-28209/docs/Project.toml`
[79e6a3ab] Adapt v4.4.0
[052768ef] CUDA v5.9.6
[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.104.0 `~/Oceananigans.jl-28209`
[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.1
This page was generated using Literate.jl.