Baroclinic adjustment
In this example, we simulate the evolution and equilibration of a baroclinically unstable front.
Install dependencies
First let's make sure we have all required packages installed.
using Pkg
pkg"add Oceananigans, CairoMakie"using Oceananigans
using Oceananigans.Units
using Random
Random.seed!(8675309) # for reproducible resultsRandom.TaskLocalRNG()Grid
We use a three-dimensional channel that is periodic in the x direction:
Lx = 1000kilometers # east-west extent [m]
Ly = 1000kilometers # north-south extent [m]
Lz = 1kilometers # depth [m]
grid = RectilinearGrid(size = (48, 48, 8),
x = (0, Lx),
y = (-Ly/2, Ly/2),
z = (-Lz, 0),
topology = (Periodic, Bounded, Bounded))48×48×8 RectilinearGrid{Float64, Periodic, Bounded, Bounded} on CPU with 3×3×3 halo
├── Periodic x ∈ [0.0, 1.0e6) regularly spaced with Δx=20833.3
├── Bounded y ∈ [-500000.0, 500000.0] regularly spaced with Δy=20833.3
└── Bounded z ∈ [-1000.0, 0.0] regularly spaced with Δz=125.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, Oceananigans.Utils.BackendOptimizedDivision}(order=5)
│ └── b: WENO{3, Float64, Oceananigans.Utils.BackendOptimizedDivision}(order=5)
├── vertical_coordinate: ZCoordinate
└── coriolis: BetaPlane{Oceananigans.Advection.EnstrophyConserving{Float64}, 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,
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_files = 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_files = true)JLD2Writer scheduled on TimeInterval(12 hours):
├── filepath: baroclinic_adjustment_zonal_average.jld2
├── 3 outputs: (b, u, v)
├── array_type: Array{Float32}
├── including: [: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: 15.407 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (15.876 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (3.478 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 6.956 seconds, max(u): (1.222e-01, 1.284e-01, 1.713e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 210.202 ms, max(u): (2.198e-01, 1.850e-01, 2.041e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 230.654 ms, max(u): (3.441e-01, 2.905e-01, 1.980e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 205.620 ms, max(u): (4.038e-01, 4.260e-01, 2.246e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 200.898 ms, max(u): (5.527e-01, 6.245e-01, 2.479e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 205.963 ms, max(u): (7.043e-01, 9.805e-01, 3.481e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 681.750 ms, max(u): (1.027e+00, 1.151e+00, 4.560e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 215.018 ms, max(u): (1.325e+00, 1.158e+00, 5.992e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 208.655 ms, max(u): (1.443e+00, 1.138e+00, 5.262e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 208.626 ms, max(u): (1.385e+00, 1.065e+00, 4.098e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 205.633 ms, max(u): (1.301e+00, 1.074e+00, 2.936e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 226.551 ms, max(u): (1.191e+00, 1.377e+00, 3.223e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 211.069 ms, max(u): (1.268e+00, 1.242e+00, 3.566e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 209.759 ms, max(u): (1.172e+00, 1.521e+00, 4.077e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 22.863 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 22.877 secondsVisualization
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 0 plots: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 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.009376397356390953 -0.008134252391755581 -0.006870824843645096 -0.005605789367109537 -0.004403211176395416 -0.003128010779619217 -0.0018588732928037643 -0.0006142056081444025; -0.009367594495415688 -0.008145131170749664 -0.006870030891150236 -0.0056360331363976 -0.004368245601654053 -0.003108715871348977 -0.001860339310951531 -0.0006311901961453259; -0.00938462931662798 -0.008101256564259529 -0.006848911289125681 -0.005596284754574299 -0.004368741065263748 -0.0031405161134898663 -0.0018694944446906447 -0.000604101805947721; -0.009381423704326153 -0.008114728145301342 -0.00684902211651206 -0.005606320686638355 -0.004352685995399952 -0.0031107307877391577 -0.0018482672749087214 -0.0006265650154091418; -0.009362025186419487 -0.00811857171356678 -0.006884701084345579 -0.005631664767861366 -0.0043555134907364845 -0.0031202707905322313 -0.001883340417407453 -0.0006323682609945536; -0.009375994093716145 -0.008146677166223526 -0.006878427229821682 -0.0056224968284368515 -0.0044032009318470955 -0.003128504380583763 -0.0018735561752691865 -0.00062215281650424; -0.009407546371221542 -0.008122669532895088 -0.0068834926933050156 -0.0056229024194180965 -0.004369850270450115 -0.0031381649896502495 -0.001882687327452004 -0.000629558926448226; -0.009362121112644672 -0.008119862526655197 -0.006864386610686779 -0.0056291562505066395 -0.004372796975076199 -0.003141536843031645 -0.0019006143556907773 -0.0006404673331417143; -0.009360208176076412 -0.008135611191391945 -0.006876121275126934 -0.005613693967461586 -0.004357239231467247 -0.0030980128794908524 -0.001868081046268344 -0.0006226811092346907; -0.009371252730488777 -0.008151872083544731 -0.006867585238069296 -0.005627763457596302 -0.004351743496954441 -0.0031212770845741034 -0.0018785560969263315 -0.0006327147711999714; -0.009361718781292439 -0.008136547170579433 -0.006884737405925989 -0.005649141501635313 -0.004365067463368177 -0.003149008611217141 -0.0018674039747565985 -0.0006034003454260528; -0.009383969940245152 -0.008121849969029427 -0.006903746630996466 -0.005626073572784662 -0.004354348871856928 -0.0031140295322984457 -0.0018751317402347922 -0.0006562639027833939; -0.009362773969769478 -0.008122773841023445 -0.006896416191011667 -0.0056305741891264915 -0.004370095208287239 -0.0031438020523637533 -0.001878267852589488 -0.000616090081166476; -0.009376744739711285 -0.008102170191705227 -0.00687742605805397 -0.005632778163999319 -0.004376800265163183 -0.0031380821019411087 -0.0018745216075330973 -0.0006254746695049107; -0.009376498870551586 -0.008146543055772781 -0.006876248866319656 -0.005620267242193222 -0.004352640360593796 -0.0031134486198425293 -0.0018892422085627913 -0.000634976546280086; -0.009369492530822754 -0.008124900981783867 -0.00685097323730588 -0.005643542855978012 -0.004372375551611185 -0.0031211741734296083 -0.0018622807692736387 -0.0006071367533877492; -0.00937730073928833 -0.008121917955577374 -0.006891694385558367 -0.005638393573462963 -0.004381110426038504 -0.003135823644697666 -0.001882933545857668 -0.0005921549163758755; -0.009389709681272507 -0.008126303553581238 -0.006884236354380846 -0.005593663547188044 -0.00436782231554389 -0.003123438684269786 -0.0018703695386648178 -0.000611691502854228; -0.00933949463069439 -0.008146516047418118 -0.006858010310679674 -0.00561929028481245 -0.00435783714056015 -0.0031424625776708126 -0.0018723616376519203 -0.0006169581902213395; -0.009376178495585918 -0.00812222808599472 -0.006859973073005676 -0.0055895582772791386 -0.004374610260128975 -0.003125922754406929 -0.001871213549748063 -0.0005964577430859208; -0.009376534260809422 -0.008141333237290382 -0.006891847122460604 -0.005626507569104433 -0.0043753390200436115 -0.0031059505417943 -0.0018717091297730803 -0.0006044306210242212; -0.009370076470077038 -0.008150473237037659 -0.006889839190989733 -0.005600419826805592 -0.004369346424937248 -0.0030852528288960457 -0.0018637028988450766 -0.0005992771475575864; -0.007503792177885771 -0.006242037285119295 -0.005010440479964018 -0.0037291154731065035 -0.0025180880911648273 -0.0012698180507868528 -4.797470410267124e-6 0.0012578762834891677; -0.005436223465949297 -0.00415964936837554 -0.0029085332062095404 -0.0016500722849741578 -0.0004167624283581972 0.0008307190728373826 0.002084361156448722 0.003329264000058174; -0.0033381704706698656 -0.0020806528627872467 -0.0008403204847127199 0.00040526315569877625 0.0016771357040852308 0.0029297955334186554 0.004164620768278837 0.005429024342447519; -0.0012586768716573715 3.380003909114748e-5 0.0012708964059129357 0.002485214499756694 0.003751992015168071 0.004994286689907312 0.006286617834120989 0.007487697526812553; 0.0006366497254930437 0.0018810746259987354 0.0031190773006528616 0.00437897490337491 0.00562072591856122 0.0068409680388867855 0.008125710301101208 0.009412720799446106; 0.0006225071265362203 0.0018563894554972649 0.0031509040854871273 0.004361598752439022 0.005609611514955759 0.0068442318588495255 0.008126071654260159 0.009354309178888798; 0.0006180037744343281 0.0018620555056259036 0.003161646891385317 0.004386747721582651 0.0056081730872392654 0.006874276790767908 0.008122597821056843 0.009350648149847984; 0.0006393339717760682 0.0018753414042294025 0.003123587928712368 0.004363842774182558 0.00558440713211894 0.00688571622595191 0.008107124827802181 0.009386780671775341; 0.0006464191828854382 0.0018648949917405844 0.003140993183478713 0.0043782638385891914 0.005610870663076639 0.006892503704875708 0.008126549422740936 0.009396362118422985; 0.0006295999046415091 0.0018688470590859652 0.0031390816438943148 0.004368530120700598 0.005646770820021629 0.0068748462945222855 0.008097411133348942 0.00935362558811903; 0.0006241750670596957 0.0018854227382689714 0.0031448514200747013 0.004396885167807341 0.005647143814712763 0.006856373976916075 0.008136325515806675 0.009375645779073238; 0.0006111484835855663 0.0018619935726746917 0.0031330324709415436 0.004381699487566948 0.005631568841636181 0.006868345662951469 0.008137593977153301 0.00939292274415493; 0.0006087481160648167 0.0018821591511368752 0.0031085847876966 0.004372021649032831 0.005624950397759676 0.006880040280520916 0.00814846158027649 0.009356319904327393; 0.0006381208659149706 0.0018828986212611198 0.0031493601854890585 0.004369139671325684 0.00559255899861455 0.0068599507212638855 0.008143712766468525 0.009383657947182655; 0.0006364901200868189 0.0018773210467770696 0.0031411312520503998 0.004395251628011465 0.005639171693474054 0.006884158588945866 0.008157843723893166 0.009365525096654892; 0.0006298022344708443 0.0019044307991862297 0.0031225504353642464 0.004364363383501768 0.005614980589598417 0.00687040202319622 0.008107173256576061 0.009378189221024513; 0.0006252250750549138 0.001888203783892095 0.0031152016017585993 0.004375849850475788 0.00559676019474864 0.006891139317303896 0.00813718605786562 0.009351874701678753; 0.0006235059699974954 0.001867119106464088 0.0031038939487189054 0.004362346138805151 0.005617052782326937 0.00685834838077426 0.008111938834190369 0.009369748644530773; 0.0006145191146060824 0.0018566262442618608 0.003127442440018058 0.004368990659713745 0.005626077298074961 0.006889578886330128 0.008121910504996777 0.009365418925881386; 0.0006491171661764383 0.0018970631062984467 0.0031142637599259615 0.00438636913895607 0.005641852505505085 0.006858691573143005 0.008107881993055344 0.009378449991345406; 0.000643245002720505 0.0018672168953344226 0.0031044415663927794 0.0043726773001253605 0.0056092203594744205 0.006858437322080135 0.008149531669914722 0.009348775260150433; 0.0006235174369066954 0.0018990326207131147 0.003149371361359954 0.004357799421995878 0.005627889651805162 0.00685145054012537 0.008134819567203522 0.009389020502567291; 0.0006401894497685134 0.001905091106891632 0.0031403147149831057 0.004380387254059315 0.005622973199933767 0.006874850019812584 0.008127905428409576 0.009375330060720444; 0.000630308932159096 0.0018630929989740252 0.003129490651190281 0.0043808831833302975 0.005608430597931147 0.006882720626890659 0.008120124228298664 0.009407577104866505; 0.0006196072790771723 0.0018833945505321026 0.003125392831861973 0.004379219841212034 0.005616352427750826 0.006879504304379225 0.008109374903142452 0.009374761022627354; 0.0006134605500847101 0.0018720244988799095 0.003141008084639907 0.004388813860714436 0.0056332130916416645 0.006868873722851276 0.008108536712825298 0.009374433197081089])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.4
Commit 01a2eadb047 (2026-01-06 16:56 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:
JULIA_MAX_NUM_PRECOMPILE_FILES = 24
JULIA_PROJECT = /var/lib/buildkite-agent/Oceananigans.jl-33590/docs/
JULIA_DEPOT_PATH = /var/lib/buildkite-agent/.julia:/var/lib/buildkite-agent/.julia/juliaup/julia-1.12.4+0.x64.linux.gnu/local/share/julia:/var/lib/buildkite-agent/.julia/juliaup/julia-1.12.4+0.x64.linux.gnu/share/julia
JULIA_VERSION_ENZYME = 1.11.9
LD_LIBRARY_PATH =
JULIA_PKG_SERVER_REGISTRY_PREFERENCE = eager
JULIA_VERSION = 1.12.4
JULIA_CUDA_USE_COMPAT = false
JULIA_LOAD_PATH = @:@v#.#:@stdlib
JULIA_DEBUG = LiterateThese were the top-level packages installed in the environment:
import Pkg
Pkg.status()Status `~/Oceananigans.jl-33590/docs/Project.toml`
[79e6a3ab] Adapt v4.7.1
⌅ [052768ef] CUDA v6.1.0
[13f3f980] CairoMakie v0.15.14
⌅ [e30172f5] Documenter v1.17.0
[daee34ce] DocumenterCitations v1.5.0
[4710194d] DocumenterVitepress v0.3.6
[033835bb] JLD2 v0.6.6
[63c18a36] KernelAbstractions v0.9.42
[98b081ad] Literate v2.21.0
[da04e1cc] MPI v0.20.27
[85f8d34a] NCDatasets v0.14.15
[9e8cae18] Oceananigans v0.113.0 `..`
[f27b6e38] Polynomials v4.1.3
[6038ab10] Rotations v1.7.1
[d496a93d] SeawaterPolynomials v0.3.10
[09ab397b] StructArrays v0.7.3
[bdfc003b] TimesDates v0.3.3
[0a941bbe] Zarr v0.10.2
[b77e0a4c] InteractiveUtils v1.11.0
[37e2e46d] LinearAlgebra v1.12.0
[44cfe95a] Pkg v1.12.1
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated`This page was generated using Literate.jl.