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: 19.218 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (16.174 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (2.778 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 7.800 seconds, max(u): (1.194e-01, 1.253e-01, 1.750e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 858.231 ms, max(u): (2.127e-01, 1.873e-01, 1.999e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 896.271 ms, max(u): (3.018e-01, 2.599e-01, 1.912e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 1.038 seconds, max(u): (3.792e-01, 3.873e-01, 2.111e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 960.261 ms, max(u): (5.053e-01, 5.990e-01, 2.248e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 1.324 seconds, max(u): (6.667e-01, 8.403e-01, 3.249e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 916.534 ms, max(u): (1.024e+00, 1.101e+00, 3.823e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 940.925 ms, max(u): (1.244e+00, 1.287e+00, 5.505e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 903.210 ms, max(u): (1.208e+00, 1.163e+00, 4.628e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 1.053 seconds, max(u): (1.257e+00, 1.099e+00, 5.233e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 958.124 ms, max(u): (1.343e+00, 1.113e+00, 4.302e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 1.075 seconds, max(u): (1.440e+00, 1.093e+00, 5.120e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 1.010 seconds, max(u): (1.509e+00, 1.283e+00, 4.599e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 1.083 seconds, max(u): (1.639e+00, 1.317e+00, 4.265e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 33.671 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 33.692 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.00938186515122652 -0.008121222257614136 -0.006848079618066549 -0.005624710116535425 -0.004392265807837248 -0.003122225170955062 -0.001876726862974465 -0.0006379919941537082; -0.00935985054820776 -0.008115630596876144 -0.006867566611617804 -0.005626946687698364 -0.00438120448961854 -0.0031364946626126766 -0.0018716809572651982 -0.0006187487160786986; -0.009402230381965637 -0.008130859583616257 -0.006882937625050545 -0.005623614881187677 -0.004349758382886648 -0.0031108453404158354 -0.0018678102642297745 -0.0006362207932397723; -0.009363723918795586 -0.008131790906190872 -0.006891035940498114 -0.0056075784377753735 -0.0043748305179178715 -0.0031012066174298525 -0.0018870317144319415 -0.0006135166622698307; -0.00936841033399105 -0.008126449771225452 -0.006894375663250685 -0.005642412696033716 -0.004388654604554176 -0.003144800430163741 -0.001882526557892561 -0.0006170207052491605; -0.009393401443958282 -0.00814041681587696 -0.006872700992971659 -0.005585957318544388 -0.004361756145954132 -0.003131737234070897 -0.0018839002586901188 -0.0006182922516018152; -0.009383921511471272 -0.008113937452435493 -0.00688248360529542 -0.005599347874522209 -0.004342019557952881 -0.0031270519830286503 -0.0018823464633896947 -0.0006381574203260243; -0.009369329549372196 -0.00811055302619934 -0.006860042456537485 -0.005623262841254473 -0.004388601519167423 -0.0031384469475597143 -0.0018832581117749214 -0.0006274175830185413; -0.009366544894874096 -0.008148386143147945 -0.00686253234744072 -0.005648734048008919 -0.00441009970381856 -0.003121743444353342 -0.0018673265585675836 -0.0006256008637137711; -0.009374156594276428 -0.008110307157039642 -0.006886149290949106 -0.0056254202499985695 -0.004404220264405012 -0.0031417531426995993 -0.0018922890303656459 -0.0006084152264520526; -0.009363677352666855 -0.008112676441669464 -0.006906062830239534 -0.005624754820019007 -0.0043615479953587055 -0.003120430512353778 -0.0018586055375635624 -0.0006267102435231209; -0.009354628622531891 -0.008133169263601303 -0.006884826347231865 -0.005626118276268244 -0.004387537948787212 -0.003110057208687067 -0.0018609565449878573 -0.0006365556037053466; -0.009376828558743 -0.008125051856040955 -0.006839354522526264 -0.00563049828633666 -0.004361208528280258 -0.0031376199331134558 -0.001862644450739026 -0.0006416269461624324; -0.009382669813930988 -0.008117283694446087 -0.006884400267153978 -0.005611197557300329 -0.004351886920630932 -0.0031037863809615374 -0.0018726231064647436 -0.0006219036295078695; -0.009372344240546227 -0.008146842010319233 -0.006863489281386137 -0.005626211408525705 -0.004407908767461777 -0.0031437405850738287 -0.0018978085136041045 -0.0006034637335687876; -0.009368381462991238 -0.008126798085868359 -0.0068947565741837025 -0.005621904507279396 -0.00441948464140296 -0.0031353801023215055 -0.0018586361547932029 -0.0006249548750929534; -0.009389746934175491 -0.008114250376820564 -0.006872978527098894 -0.005627026781439781 -0.0043589468114078045 -0.0031209506560117006 -0.0018867077305912971 -0.0006608155672438443; -0.009386548772454262 -0.008138656616210938 -0.006855614483356476 -0.00562435295432806 -0.004399314522743225 -0.003150787902995944 -0.0018908947240561247 -0.0006116006406955421; -0.00934837106615305 -0.008113293908536434 -0.006905419752001762 -0.005602257791906595 -0.0043345121666789055 -0.0031010988168418407 -0.00185792101547122 -0.0006325532449409366; -0.009351519867777824 -0.008151913061738014 -0.006874704733490944 -0.005626200698316097 -0.004368285182863474 -0.0031223169062286615 -0.001874500303529203 -0.0006331970798783004; -0.00938593689352274 -0.00813739001750946 -0.006880553439259529 -0.0056382897309958935 -0.00436463113874197 -0.0031233534682542086 -0.001873740111477673 -0.000623580941464752; -0.00939088687300682 -0.008126535452902317 -0.006891515571624041 -0.005632228683680296 -0.0043824054300785065 -0.0031285083387047052 -0.001868878840468824 -0.0006374455406330526; -0.007486829534173012 -0.0062652938067913055 -0.00500666256994009 -0.003757449332624674 -0.002504922915250063 -0.0012772602494806051 -7.826760338502936e-6 0.0012334341881796718; -0.0054189302027225494 -0.004164508543908596 -0.002926014130935073 -0.0016591573366895318 -0.0004288906347937882 0.0008147342596203089 0.0020966404117643833 0.0033463379368185997; -0.0033240404445677996 -0.00210772268474102 -0.0008106630994006991 0.0004516086191870272 0.001648938050493598 0.0029231293592602015 0.004159946460276842 0.005436282604932785; -0.001240916084498167 1.172021347883856e-5 0.001243575825355947 0.002520084846764803 0.0037550057750195265 0.00500409584492445 0.006245684809982777 0.00750690558925271; 0.0006265490665100515 0.0018892204388976097 0.003120774868875742 0.00438619963824749 0.005648273974657059 0.006847795564681292 0.008120423182845116 0.009383570402860641; 0.0006252105231396854 0.001860187854617834 0.003123633796349168 0.0043738535605371 0.00561921950429678 0.006873222999274731 0.00814356654882431 0.00937741156667471; 0.0006140035693533719 0.0018730529118329287 0.003115968545898795 0.004373748321086168 0.0056394790299236774 0.006862320005893707 0.008124244399368763 0.009360412135720253; 0.0006325033609755337 0.0018715810729190707 0.0031366178300231695 0.0043798694387078285 0.005604897625744343 0.006902777589857578 0.008125821128487587 0.009383280761539936; 0.0006377549725584686 0.0018617907771840692 0.003118215361610055 0.004394845571368933 0.0056422702036798 0.00686584273353219 0.008126388303935528 0.009385284967720509; 0.0006480253068730235 0.0018696844344958663 0.0031307407189160585 0.004372648429125547 0.0056367842480540276 0.006869076751172543 0.008084993809461594 0.009358180686831474; 0.0006193470326252282 0.0018607493257150054 0.003117068437859416 0.004365237895399332 0.005604363512247801 0.006891407072544098 0.008116958662867546 0.009362251497805119; 0.0006255258340388536 0.0018505266634747386 0.0031189089640975 0.004389764275401831 0.005628159735351801 0.006880468688905239 0.00810262281447649 0.009375127032399178; 0.0006304440903477371 0.0018919948488473892 0.003127157920971513 0.004366194363683462 0.005657769739627838 0.006874755024909973 0.008132987655699253 0.009387112222611904; 0.0006168989348225296 0.0018798481905832887 0.003129778429865837 0.004374634008854628 0.005649389233440161 0.006876376457512379 0.008122416213154793 0.009386129677295685; 0.0006264454568736255 0.0018569531384855509 0.003086482174694538 0.004403447266668081 0.0056528267450630665 0.006880214437842369 0.008125006221234798 0.009403714910149574; 0.0006139968754723668 0.0019064833177253604 0.003112860256806016 0.004388747271150351 0.005628932733088732 0.0068670292384922504 0.008093462325632572 0.009389319457113743; 0.0006425193860195577 0.0018872561631724238 0.003125319257378578 0.0044039650820195675 0.005615930072963238 0.006890288554131985 0.008139170706272125 0.009349278174340725; 0.0006231112638488412 0.0018693212186917663 0.0031222286634147167 0.004377623554319143 0.00563618540763855 0.0068753850646317005 0.008137565106153488 0.009354355745017529; 0.0006238581845536828 0.0019047869136556983 0.003138306550681591 0.004375015385448933 0.005629159510135651 0.006877198349684477 0.008141282014548779 0.009371565654873848; 0.0006202008225955069 0.0018951970851048827 0.0031246792059391737 0.004367002286016941 0.0056366403587162495 0.006866461597383022 0.008153174072504044 0.009336927905678749; 0.0006213798769749701 0.0018889826023951173 0.0031207457650452852 0.004377096425741911 0.005600447300821543 0.006875904276967049 0.008141554892063141 0.009380137547850609; 0.0006227304693311453 0.0018959419103339314 0.0031150865834206343 0.004378520883619785 0.005610853899270296 0.006858566775918007 0.008131091482937336 0.009377865120768547; 0.0006221549701876938 0.0018799178069457412 0.0031213960610330105 0.00438030157238245 0.005624409765005112 0.006875594146549702 0.008124255575239658 0.009372489526867867; 0.0006106089567765594 0.0018813373753800988 0.003123037051409483 0.004368677735328674 0.005620324984192848 0.0068779378198087215 0.008125378750264645 0.009387893602252007; 0.0006654034950770438 0.001885628909803927 0.003123480360955 0.004377047065645456 0.005627437029033899 0.006866691168397665 0.008118848316371441 0.009387741796672344; 0.000638104451354593 0.0018314941553398967 0.00313427927903831 0.004366206005215645 0.005631427280604839 0.006885261740535498 0.008130301721394062 0.009401998482644558])
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-28050/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-28050/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-28050/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.104.0 `~/Oceananigans.jl-28050`
[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.