Inertial Oscillations Simulation #3635
Unanswered
claudioiturra
asked this question in
Computational science!
Replies: 1 comment 3 replies
-
Here's some code to simulate a pure inertial wave (this is often called an "inertial oscillation", but "wave" is definitely a better term): using Oceananigans
using Oceananigans.Units
using GLMakie
Nz = 100
Lz = 400
f = 1e-4
grid = RectilinearGrid(size=Nz, z=(-Lz, 0), topology=(Flat, Flat, Bounded))
coriolis = FPlane(; f)
model = HydrostaticFreeSurfaceModel(; grid, coriolis, tracers=(), buoyancy=nothing)
h = 50 # vertical scale of the inertial wave
uᵢ(z) = exp(-z^2 / 2h^2)
set!(model, u=uᵢ)
T = 2π / f # inertial period
Δt = 1e-2 * T
simulation = Simulation(model; Δt, stop_time=4T)
data = []
function save_data!(sim)
u, v, w = sim.model.velocities
ui = interior(u, 1, 1, :)
vi = interior(v, 1, 1, :)
push!(data, (t=time(sim), u=deepcopy(ui), v=deepcopy(vi)))
return nothing
end
add_callback!(simulation, save_data!, TimeInterval(0.02T))
run!(simulation)
fig = Figure()
ax = Axis(fig[1, 1], xlabel="Velocities", ylabel="z (m)")
Nt = length(data)
n = Observable(1)
un = @lift data[$n].u
vn = @lift data[$n].v
tn = @lift data[$n].t
z = znodes(model.velocities.u)
lines!(ax, un, z, label="u")
lines!(ax, vn, z, label="v")
xlims!(ax, -1.1, 1.1)
axislegend(ax, position=:rb)
record(fig, "inertial_oscillation.mp4", 1:Nt, framerate=24) do nn
n[] = nn
end which produces inertial_oscillation.mp4To simulate the vertical propagation of a near-inertial wave in a stratified fluid, you'll need to make the simulation 2D, add some horizontal structure (for example |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'm new to Oceananigans trying to simulates inertial oscillations (wind induced-inertial oscillation) to evaluate propagation depending on stratification. I will extremely appreciate any advice on how to start with this journey, I will appreciate any comments. Thanks to all
Beta Was this translation helpful? Give feedback.
All reactions