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
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.0
Model
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⁻²]")
fig
Simulation
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
├── Elapsed wall time: 0 seconds
├── Wall time per 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 => 4
│ ├── stop_iteration_exceeded => -
│ ├── wall_time_limit_exceeded => e
│ └── nan_checker => }
├── Output writers: OrderedDict with no entries
└── Diagnostics: OrderedDict with no entries
We add a TimeStepWizard
callback to adapt the simulation's time-step,
conjure_time_step_wizard!(simulation, IterationInterval(20), cfl=0.2, max_Δt=20minutes)
Also, we add a callback to print a message about how the simulation is going,
using Printf
wall_clock = Ref(time_ns())
function print_progress(sim)
u, v, w = model.velocities
progress = 100 * (time(sim) / sim.stop_time)
elapsed = (time_ns() - wall_clock[]) / 1e9
@printf("[%05.2f%%] i: %d, t: %s, wall time: %s, max(u): (%6.3e, %6.3e, %6.3e) m/s, next Δt: %s\n",
progress, iteration(sim), prettytime(sim), prettytime(elapsed),
maximum(abs, u), maximum(abs, v), maximum(abs, w), prettytime(sim.Δt))
wall_clock[] = time_ns()
return nothing
end
add_callback!(simulation, print_progress, IterationInterval(100))
Diagnostics/Output
Here, we save the buoyancy, $b$, at the edges of our domain as well as the zonal ($x$) average of buoyancy.
u, v, w = model.velocities
ζ = ∂x(v) - ∂y(u)
B = Average(b, dims=1)
U = Average(u, dims=1)
V = Average(v, dims=1)
filename = "baroclinic_adjustment"
save_fields_interval = 0.5day
slicers = (east = (grid.Nx, :, :),
north = (:, grid.Ny, :),
bottom = (:, :, 1),
top = (:, :, grid.Nz))
for side in keys(slicers)
indices = slicers[side]
simulation.output_writers[side] = JLD2Writer(model, (; b, ζ);
filename = filename * "_$(side)_slice",
schedule = TimeInterval(save_fields_interval),
overwrite_existing = true,
indices)
end
simulation.output_writers[:zonal] = JLD2Writer(model, (; b=B, u=U, v=V);
filename = filename * "_zonal_average",
schedule = TimeInterval(save_fields_interval),
overwrite_existing = true)
JLD2Writer scheduled on TimeInterval(12 hours):
├── filepath: baroclinic_adjustment_zonal_average.jld2
├── 3 outputs: (b, u, v)
├── array_type: Array{Float32}
├── including: [:grid, :coriolis, :buoyancy, :closure]
├── file_splitting: NoFileSplitting
└── file size: 32.5 KiB
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: 45.371 seconds, max(u): (0.000e+00, 0.000e+00, 0.000e+00) m/s, next Δt: 20 minutes
[ Info: ... simulation initialization complete (38.249 seconds)
[ Info: Executing initial time step...
[ Info: ... initial time step complete (29.576 seconds).
[06.94%] i: 100, t: 1.389 days, wall time: 57.411 seconds, max(u): (1.322e-01, 1.206e-01, 1.512e-03) m/s, next Δt: 20 minutes
[13.89%] i: 200, t: 2.778 days, wall time: 790.070 ms, max(u): (2.333e-01, 1.931e-01, 1.802e-03) m/s, next Δt: 20 minutes
[20.83%] i: 300, t: 4.167 days, wall time: 860.191 ms, max(u): (3.103e-01, 3.059e-01, 1.901e-03) m/s, next Δt: 20 minutes
[27.78%] i: 400, t: 5.556 days, wall time: 767.367 ms, max(u): (3.695e-01, 4.129e-01, 2.065e-03) m/s, next Δt: 20 minutes
[34.72%] i: 500, t: 6.944 days, wall time: 792.900 ms, max(u): (4.691e-01, 5.942e-01, 2.402e-03) m/s, next Δt: 20 minutes
[41.67%] i: 600, t: 8.333 days, wall time: 782.384 ms, max(u): (6.666e-01, 9.316e-01, 3.226e-03) m/s, next Δt: 20 minutes
[48.61%] i: 700, t: 9.722 days, wall time: 745.754 ms, max(u): (1.112e+00, 1.087e+00, 4.349e-03) m/s, next Δt: 20 minutes
[55.56%] i: 800, t: 11.111 days, wall time: 871.555 ms, max(u): (1.267e+00, 1.095e+00, 4.858e-03) m/s, next Δt: 20 minutes
[62.50%] i: 900, t: 12.500 days, wall time: 996.342 ms, max(u): (1.429e+00, 1.007e+00, 4.193e-03) m/s, next Δt: 20 minutes
[69.44%] i: 1000, t: 13.889 days, wall time: 919.381 ms, max(u): (1.353e+00, 1.013e+00, 3.363e-03) m/s, next Δt: 20 minutes
[76.39%] i: 1100, t: 15.278 days, wall time: 828.917 ms, max(u): (1.238e+00, 9.257e-01, 2.655e-03) m/s, next Δt: 20 minutes
[83.33%] i: 1200, t: 16.667 days, wall time: 783.043 ms, max(u): (1.166e+00, 9.201e-01, 2.533e-03) m/s, next Δt: 20 minutes
[90.28%] i: 1300, t: 18.056 days, wall time: 1.079 seconds, max(u): (1.277e+00, 1.049e+00, 2.858e-03) m/s, next Δt: 20 minutes
[97.22%] i: 1400, t: 19.444 days, wall time: 828.037 ms, max(u): (1.429e+00, 1.150e+00, 3.328e-03) m/s, next Δt: 20 minutes
[ Info: Simulation is stopping after running for 1.411 minutes.
[ Info: Simulation time 20 days equals or exceeds stop time 20 days.
[ Info: Simulation completed in 1.411 minutes
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 CairoMakie
Three-dimensional visualization
We load the saved buoyancy output on the top, north, and east surface as FieldTimeSeries
es.
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.grid
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.0
We 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()
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 Observable
s, check out Makie.jl's Documentation.
n = length(times)
41
Now 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.0
Next, 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.009349772706627846 -0.008126134984195232 -0.006880820728838444 -0.005631745792925358 -0.004352971445769072 -0.0031226647552102804 -0.0018684149254113436 -0.0005845059640705585; -0.009385952726006508 -0.00813688151538372 -0.006877207662910223 -0.005620905663818121 -0.0043918718583881855 -0.003114451887086034 -0.001877320697531104 -0.0006370220798999071; -0.009400583803653717 -0.008125665597617626 -0.006880662869662046 -0.005631625186651945 -0.00438279751688242 -0.003109939629212022 -0.0018804734572768211 -0.0006500610616058111; -0.009397704154253006 -0.008112659677863121 -0.006841734517365694 -0.005623423960059881 -0.004380050580948591 -0.0031313125509768724 -0.001900525065138936 -0.0006299094529822469; -0.009391744621098042 -0.008128110319375992 -0.006870787590742111 -0.005614939611405134 -0.004391093272715807 -0.0031175066251307726 -0.0018786812433972955 -0.0006239382200874388; -0.009373674169182777 -0.008129640482366085 -0.0068563916720449924 -0.005613447166979313 -0.004381976090371609 -0.0031416681595146656 -0.0018598407041281462 -0.0005969894118607044; -0.009387116879224777 -0.00813979934900999 -0.006860201712697744 -0.005631231237202883 -0.004378940910100937 -0.0030965779442340136 -0.0018325052224099636 -0.0006512923282571137; -0.009385854005813599 -0.008111761882901192 -0.006886456161737442 -0.005609368905425072 -0.004389018286019564 -0.0031516295857727528 -0.0018637181492522359 -0.0006296330248005688; -0.009378159418702126 -0.008121279999613762 -0.006865707691758871 -0.005626108963042498 -0.004380646161735058 -0.003123230766505003 -0.001874370500445366 -0.0006136202719062567; -0.009379788301885128 -0.008121350780129433 -0.006875130347907543 -0.0056275539100170135 -0.004352681804448366 -0.0031186589039862156 -0.0018932855455204844 -0.0006272158352658153; -0.009375099092721939 -0.008124476298689842 -0.006853603292256594 -0.005606857128441334 -0.0043789236806333065 -0.0031255832873284817 -0.0018835884984582663 -0.0006454971735365689; -0.009335636161267757 -0.008129253052175045 -0.006863143760710955 -0.005652995314449072 -0.004386200103908777 -0.0031505851075053215 -0.0018717588391155005 -0.000616220582742244; -0.009393484331667423 -0.00811825506389141 -0.006862865760922432 -0.005632278975099325 -0.004376139026135206 -0.003135595703497529 -0.0018813047790899873 -0.0006256079068407416; -0.009367537684738636 -0.008122576400637627 -0.0069017568603158 -0.005631991662085056 -0.0043935696594417095 -0.0031277602538466454 -0.0018428136827424169 -0.0006318131345324218; -0.009356141090393066 -0.008132022805511951 -0.00687857111915946 -0.0056333583779633045 -0.004346901550889015 -0.0031111331190913916 -0.001865048659965396 -0.0006128287059254944; -0.009352851659059525 -0.008136413060128689 -0.006873891223222017 -0.005632512737065554 -0.004366962239146233 -0.003126793075352907 -0.0019002269254997373 -0.000618354941252619; -0.009388343431055546 -0.008139792829751968 -0.006849689409136772 -0.005594242829829454 -0.004363595508038998 -0.0031311672646552324 -0.0018685732502490282 -0.0006276117637753487; -0.009388790465891361 -0.008138278499245644 -0.006854182109236717 -0.005628131330013275 -0.004369460977613926 -0.003138306550681591 -0.0018727723509073257 -0.0006017857231199741; -0.009409351274371147 -0.008121899329125881 -0.006894132122397423 -0.005623329896479845 -0.0043881600722670555 -0.0031231199391186237 -0.0018462719162926078 -0.000645912834443152; -0.009390207938849926 -0.00814808253198862 -0.006870605517178774 -0.005618994124233723 -0.004363363608717918 -0.003124988405033946 -0.0018338925438001752 -0.00063992670038715; -0.009371209889650345 -0.008120586164295673 -0.0068749357014894485 -0.005641245283186436 -0.004369466099888086 -0.0031239353120326996 -0.0018862795550376177 -0.0006095783901400864; -0.009364557452499866 -0.008124793879687786 -0.006856812629848719 -0.005620471201837063 -0.004386128857731819 -0.003117454471066594 -0.0018793975468724966 -0.0006139632896520197; -0.007491693366318941 -0.006241605617105961 -0.00501062348484993 -0.0037570293061435223 -0.0024926792830228806 -0.0012433953816071153 -3.308147643110715e-5 0.0012644408270716667; -0.005397542845457792 -0.004165291786193848 -0.002925444860011339 -0.0016679998952895403 -0.0004244913870934397 0.0008283471106551588 0.002080185804516077 0.003314198460429907; -0.00331702153198421 -0.0020795646123588085 -0.0008254798012785614 0.00042466187733225524 0.001666948082856834 0.0029196767136454582 0.004179605282843113 0.005427323281764984; -0.001240618759766221 4.672036538977409e-6 0.0012267500860616565 0.002493106760084629 0.003732770448550582 0.005014234688133001 0.006257079541683197 0.00751029746606946; 0.0006512270192615688 0.0018866130849346519 0.0031114756129682064 0.0043615312315523624 0.005588369909673929 0.006855825427919626 0.008131006732583046 0.009378890506923199; 0.0006409850320778787 0.0018620961345732212 0.0031062853522598743 0.004358383826911449 0.005636055488139391 0.006873732432723045 0.008111245930194855 0.009393068961799145; 0.0006310850731097162 0.0018935439875349402 0.0031296759843826294 0.0043753827922046185 0.005619049537926912 0.006879871245473623 0.0081320283934474 0.00939800776541233; 0.0006463021854870021 0.0018848869949579239 0.003123924834653735 0.004394667688757181 0.005597923416644335 0.006870271638035774 0.0081364456564188 0.00936603732407093; 0.0005975939566269517 0.0018553443951532245 0.0031354185193777084 0.004370444919914007 0.005633546505123377 0.0069064428098499775 0.008097722195088863 0.009364722296595573; 0.0006299669039435685 0.0018757532816380262 0.00310304993763566 0.004390652757138014 0.005633087363094091 0.006867644842714071 0.008117854595184326 0.00938759371638298; 0.0006367043242789805 0.0018643095390871167 0.0031050650868564844 0.004382388200610876 0.005627279635518789 0.006885188166052103 0.008130907081067562 0.009384962730109692; 0.0006443389574997127 0.0018913832027465105 0.0031071556732058525 0.004363997373729944 0.005607870407402515 0.006868959404528141 0.008109314367175102 0.009374809451401234; 0.0006054863915778697 0.0018707439303398132 0.0031353048980236053 0.004383475054055452 0.0056344373151659966 0.006854478735476732 0.008128326386213303 0.009338093921542168; 0.0006152846035547554 0.0018707166891545057 0.003111650235950947 0.004359591286629438 0.0056265853345394135 0.0068800305016338825 0.008135590702295303 0.009353836067020893; 0.000603983411565423 0.0018708657007664442 0.00312968622893095 0.004393354523926973 0.00563254626467824 0.006875208113342524 0.00813277903944254 0.009374910965561867; 0.0006174382288008928 0.0018531179521232843 0.0031244580168277025 0.004400391597300768 0.005632447544485331 0.006874964572489262 0.008123885840177536 0.00937565416097641; 0.0006355447694659233 0.0018858186667785048 0.003149812575429678 0.004388893023133278 0.005637351423501968 0.006873112637549639 0.008128655143082142 0.00937421340495348; 0.0006047626957297325 0.0018843996804207563 0.003114422783255577 0.004378712736070156 0.005632166285067797 0.006879626773297787 0.008126464672386646 0.009369438514113426; 0.000626268913038075 0.00186616787686944 0.00311095267534256 0.004381842911243439 0.005632124841213226 0.006878978572785854 0.00817065965384245 0.0093702906742692; 0.0005996081163175404 0.0018885346362367272 0.0031064199283719063 0.004360532853752375 0.005616154987365007 0.00687152985483408 0.008132298476994038 0.0093820346519351; 0.0006185267120599747 0.001868338556960225 0.0031504526268690825 0.004378595855087042 0.0056276400573551655 0.006899270694702864 0.008113236166536808 0.009380122646689415; 0.0006203214870765805 0.0018805117579177022 0.0031574133317917585 0.004369379486888647 0.005588945467025042 0.006882323417812586 0.008122120052576065 0.00938613060861826; 0.0006205362733453512 0.0018660789355635643 0.0031363333109766245 0.004386257845908403 0.005618419963866472 0.00688349362462759 0.008119551464915276 0.00939775537699461; 0.00062111287843436 0.001864441903308034 0.0031149685382843018 0.004376094322651625 0.005610077641904354 0.00686440197750926 0.008122262544929981 0.009358400478959084; 0.0006123174098320305 0.0018788756569847465 0.003124058712273836 0.0043839337304234505 0.005625758320093155 0.006858691573143005 0.008105882443487644 0.009354708716273308; 0.000618032761849463 0.0018497324781492352 0.003094291314482689 0.004379792604595423 0.005622719880193472 0.006908212322741747 0.008110078051686287 0.009365875273942947])
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
end
This page was generated using Literate.jl.