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: 8.453 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (13.280 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (3.400 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 15.258 seconds, max(u): (1.180e-01, 1.320e-01, 1.651e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 786.942 ms, max(u): (2.028e-01, 1.925e-01, 2.198e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 788.198 ms, max(u): (2.733e-01, 2.231e-01, 2.039e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 867.971 ms, max(u): (3.542e-01, 2.988e-01, 1.865e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 761.984 ms, max(u): (4.479e-01, 3.752e-01, 2.245e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 779.181 ms, max(u): (5.991e-01, 6.367e-01, 2.624e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 824.671 ms, max(u): (7.737e-01, 9.972e-01, 3.188e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 775.398 ms, max(u): (1.175e+00, 1.189e+00, 4.423e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 779.451 ms, max(u): (1.375e+00, 1.103e+00, 5.861e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 776.346 ms, max(u): (1.197e+00, 9.907e-01, 3.283e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 808.360 ms, max(u): (1.287e+00, 9.517e-01, 3.071e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 765.535 ms, max(u): (1.484e+00, 1.066e+00, 3.213e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 781.964 ms, max(u): (1.319e+00, 1.091e+00, 2.651e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 774.430 ms, max(u): (1.163e+00, 1.186e+00, 2.291e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 28.074 seconds.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 28.093 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.009344829246401787 -0.008097758516669273 -0.0068611460737884045 -0.00558432936668396 -0.004377901554107666 -0.0031191511079669 -0.0018370371544733644 -0.0006072691758163273; -0.009368875995278358 -0.008131647482514381 -0.006856819614768028 -0.005598879884928465 -0.0043643987737596035 -0.003116479841992259 -0.0018695363542065024 -0.0006133585120551288; -0.009387847036123276 -0.008106186054646969 -0.006869425531476736 -0.005623251665383577 -0.004374300595372915 -0.0031341291032731533 -0.001862457487732172 -0.0006201224168762565; -0.009369280189275742 -0.008130043745040894 -0.006869419943541288 -0.005630539730191231 -0.004405411425977945 -0.0031151152215898037 -0.0018868623301386833 -0.0006009893259033561; -0.009349717758595943 -0.008129455149173737 -0.00686835078522563 -0.005617918446660042 -0.004379658028483391 -0.0031084672082215548 -0.0018796107033267617 -0.0006315099890343845; -0.009377879090607166 -0.008108925074338913 -0.0068733105435967445 -0.0056287809275090694 -0.00438162824138999 -0.003149720374494791 -0.001883188495412469 -0.0006108807865530252; -0.00937141478061676 -0.008150848560035229 -0.006865357980132103 -0.0056316908448934555 -0.004374703858047724 -0.003097312292084098 -0.001872543478384614 -0.0006207888945937157; -0.009378654882311821 -0.00812000222504139 -0.006918279454112053 -0.005624156910926104 -0.004360349848866463 -0.003123344387859106 -0.0018614267464727163 -0.0006281191599555314; -0.009377414360642433 -0.008138950914144516 -0.006864347029477358 -0.005606035701930523 -0.004372547380626202 -0.003141222056001425 -0.0018891340587288141 -0.0006322626140899956; -0.009396543726325035 -0.008139941841363907 -0.006879944819957018 -0.005643986631184816 -0.004364524036645889 -0.003097963286563754 -0.0018792424816638231 -0.000654993113130331; -0.009377555921673775 -0.008135080337524414 -0.006862061098217964 -0.005652741529047489 -0.004367782734334469 -0.0031523106154054403 -0.0018847628962248564 -0.0006342614651657641; -0.009385883808135986 -0.008132689632475376 -0.006863964255899191 -0.005626078229397535 -0.00438691396266222 -0.0031192211899906397 -0.001875131158158183 -0.0006413477822206914; -0.009393072687089443 -0.008131385780870914 -0.006859550718218088 -0.005645803641527891 -0.0043494864366948605 -0.0031172968447208405 -0.001886833575554192 -0.0005954992375336587; -0.009369363076984882 -0.008130185306072235 -0.006873381324112415 -0.005628745071589947 -0.0044059474021196365 -0.0031123568769544363 -0.0018792013870552182 -0.0006245644763112068; -0.00935970339924097 -0.008138452656567097 -0.0068588475696742535 -0.005608034785836935 -0.0043578664772212505 -0.003125521820038557 -0.0018535469425842166 -0.0006113981944508851; -0.009378706105053425 -0.008154485374689102 -0.006864790804684162 -0.005603519268333912 -0.004377467092126608 -0.0031044501811265945 -0.0018850942142307758 -0.0006354518118314445; -0.009359740652143955 -0.008141491562128067 -0.006866871379315853 -0.005618755239993334 -0.004377294331789017 -0.0031179897487163544 -0.001872149296104908 -0.0006402140134014189; -0.009399555623531342 -0.008126523345708847 -0.006865151692181826 -0.005606507416814566 -0.004374999087303877 -0.003099926747381687 -0.001887067686766386 -0.0006309333839453757; -0.009362279437482357 -0.00813607219606638 -0.006909494753926992 -0.005637736059725285 -0.004383149556815624 -0.003125618677586317 -0.0018850520718842745 -0.0006440920406021178; -0.009396923705935478 -0.008102837949991226 -0.006862836889922619 -0.0056108771823346615 -0.0043645864352583885 -0.0031364199239760637 -0.0018781217513605952 -0.0006080911844037473; -0.009353496134281158 -0.008137882687151432 -0.006877389270812273 -0.005637754686176777 -0.004377006087452173 -0.003107930300757289 -0.0018914762185886502 -0.0006183297373354435; -0.009362902492284775 -0.00814323965460062 -0.006894027814269066 -0.005620932672172785 -0.00438174232840538 -0.0031266245059669018 -0.0018770755268633366 -0.0006439390708692372; -0.007483558263629675 -0.006253424566239119 -0.004995637107640505 -0.00372628984041512 -0.0025004190392792225 -0.0012592634884640574 1.5347050066338852e-5 0.001238293363712728; -0.005420357920229435 -0.0041597504168748856 -0.0029224595054984093 -0.0016472174320369959 -0.0004084461252205074 0.000845758244395256 0.0020704816561192274 0.003322661155834794; -0.003326073056086898 -0.002083743456751108 -0.0008467678562738001 0.0004136369389016181 0.0016456969315186143 0.0029408421833068132 0.004156618379056454 0.005407796707004309; -0.0012250643922016025 2.3061160391080193e-5 0.0012441640719771385 0.0024796368088573217 0.0037335152737796307 0.005020481999963522 0.0062423935160040855 0.0074812001548707485; 0.00062452198471874 0.0018449424533173442 0.0030936719849705696 0.004400627687573433 0.005617877002805471 0.00688133342191577 0.008119771257042885 0.009367539547383785; 0.0006168002146296203 0.0018634938169270754 0.003137302817776799 0.004364279098808765 0.005638412199914455 0.006866134703159332 0.008112527430057526 0.009371032938361168; 0.0006481134332716465 0.0018714037723839283 0.0031188928987830877 0.004394108895212412 0.005659259390085936 0.006851586513221264 0.008136824704706669 0.009386680088937283; 0.0006084172637201846 0.0018781085964292288 0.003112790873274207 0.004351236391812563 0.005623280070722103 0.00687053520232439 0.00813307985663414 0.00936809740960598; 0.0006132632261142135 0.001902001560665667 0.0031338499393314123 0.00437350757420063 0.005641626194119453 0.006887990050017834 0.008101211860775948 0.009353342466056347; 0.0006237434572540224 0.00188382004853338 0.0031292219646275043 0.004365882836282253 0.005632399581372738 0.006865514907985926 0.008129896596074104 0.009403275325894356; 0.0006240909569896758 0.0018677301704883575 0.003110363380983472 0.004379570949822664 0.005644119810312986 0.006893515586853027 0.008119795471429825 0.009360670112073421; 0.0006088359514251351 0.001893421751447022 0.0031444327905774117 0.004360389430075884 0.0056458949111402035 0.006878682877868414 0.008118833415210247 0.009381581097841263; 0.0006232298910617828 0.0018875421956181526 0.003136404324322939 0.004367329180240631 0.005625758320093155 0.006886597257107496 0.00811776053160429 0.009381497278809547; 0.0006178233888931572 0.0018881501164287329 0.003110286546871066 0.0043668560683727264 0.0056307134218513966 0.006847095210105181 0.008166219107806683 0.009374668821692467; 0.0006302687106654048 0.0018940308364108205 0.0031375896651297808 0.004376430530101061 0.00561843067407608 0.006862150505185127 0.008106128312647343 0.009367536753416061; 0.0006453857640735805 0.001878441427834332 0.003140657441690564 0.00439919950440526 0.0056112296879291534 0.0068694669753313065 0.008129158057272434 0.009384511038661003; 0.0006387896137312055 0.001879934803582728 0.0031112567521631718 0.004402676597237587 0.005625193938612938 0.0068692052736878395 0.008127668872475624 0.009378526359796524; 0.0006235864711925387 0.001884551253169775 0.0031377431005239487 0.004374595824629068 0.005632063839584589 0.00689332839101553 0.0081058070063591 0.009371517226099968; 0.0006417424883693457 0.0018801447004079819 0.0031230358872562647 0.004366826731711626 0.005617620423436165 0.006882496178150177 0.00811275839805603 0.0093765240162611; 0.0006017957348376513 0.0018718449864536524 0.003133338876068592 0.004370360169559717 0.005623077042400837 0.006875438150018454 0.008090841583907604 0.009357506409287453; 0.0006338438834063709 0.0018895845860242844 0.003136456711217761 0.0044098817743361 0.005637854803353548 0.006904603447765112 0.008107515051960945 0.009360856376588345; 0.000642381957732141 0.0018710745498538017 0.0031171776354312897 0.004369829781353474 0.005611680913716555 0.006868405733257532 0.008127124980092049 0.009384294971823692; 0.0006228690035641193 0.0018860140116885304 0.003126207273453474 0.004379965830594301 0.005623729433864355 0.006868427619338036 0.00814678706228733 0.009387732483446598; 0.0006470850785262883 0.001887345453724265 0.003125372575595975 0.004380271770060062 0.005621267948299646 0.006872218102216721 0.008131231181323528 0.009387701749801636; 0.0006206048419699073 0.001868905615992844 0.0031333700753748417 0.0043948437087237835 0.0056439791806042194 0.006891367956995964 0.008118308149278164 0.009380767121911049; 0.0006123586208559573 0.0018616955494508147 0.003131189150735736 0.004371816758066416 0.005624447017908096 0.006874911021441221 0.008132047019898891 0.009372333995997906])
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:
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-28770/docs/
JULIA_VERSION = 1.12.4
JULIA_LOAD_PATH = @:@v#.#:@stdlib
JULIA_VERSION_ENZYME = 1.10.10
JULIA_PYTHONCALL_EXE = /var/lib/buildkite-agent/Oceananigans.jl-28770/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-28770/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
[63c18a36] KernelAbstractions v0.9.39
[98b081ad] Literate v2.21.0
[da04e1cc] MPI v0.20.23
[85f8d34a] NCDatasets v0.14.10
[9e8cae18] Oceananigans v0.104.2 `..`
[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.