-
Notifications
You must be signed in to change notification settings - Fork 241
Add optional vertical Coriolis term to hydrostatic pressure integral #4594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glwagner
wants to merge
5
commits into
main
Choose a base branch
from
glw/quasi-hydrostatic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+149
−33
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c6361c7
Add vertical Coriolis to hydrostatic pressure integral
glwagner 20ca296
clean up
glwagner 0c27226
Update src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl
navidcy d4de022
add an example with the nontraditional Coriolis term
francispoulin b4592a0
Update src/Models/NonhydrostaticModels/update_hydrostatic_pressure.jl
glwagner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using Oceananigans | ||
using Printf | ||
using CairoMakie | ||
using NCDatasets | ||
using Statistics | ||
|
||
grid = RectilinearGrid(CPU(), | ||
size=(32, 32), halo=(7, 7), | ||
y = (0, 1), | ||
z = (0, 1), | ||
topology=(Flat, Bounded, Bounded)) | ||
|
||
|
||
const N² = 1.0 | ||
const fz = 0.1 | ||
const fy = 0.1 | ||
const β = 0.0 | ||
const γ = 0.0 | ||
const radius = 1.0 | ||
|
||
const shear_y = 1e-2 | ||
const shear_z = 1e-2 | ||
|
||
B(y, z) = -(shear_y*fz + shear_z*fy)*y + N²*z | ||
U(y, z) = (shear_y*y + shear_z*z) | ||
|
||
coriolis = NonTraditionalBetaPlane(fz=fz, fy=fy, β=β, γ=γ, radius=radius) | ||
model = HydrostaticFreeSurfaceModel(; grid, | ||
coriolis = coriolis, | ||
buoyancy = BuoyancyTracer(), | ||
momentum_advection = WENO(), | ||
tracer_advection = WENO(), | ||
tracers = (:b,)) | ||
set!(model, u = U, b = B) | ||
|
||
xu, yu, zu = nodes(model.velocities.u) | ||
xb, yb, zb = nodes(model.tracers.b) | ||
|
||
function progress(sim) | ||
umax = maximum(abs, sim.model.velocities.u) | ||
bmax = maximum(sim.model.tracers.b) | ||
@info @sprintf("Iter: %d, time: %.2e, max|u|: %.2e. max b: %.2e", | ||
iteration(sim), time(sim), umax, bmax) | ||
|
||
return nothing | ||
end | ||
|
||
simulation = Simulation(model; Δt=1e-3, stop_time=10.0) | ||
simulation.callbacks[:p] = Callback(progress, IterationInterval(100)) | ||
|
||
u, v, w = model.velocities | ||
b = model.tracers.b | ||
outputs = (; u, b) | ||
|
||
simulation.output_writers[:fields] = NetCDFWriter(model, outputs; | ||
filename = "linear_shear.nc", | ||
schedule = TimeInterval(0.1), | ||
overwrite_existing = true) | ||
|
||
run!(simulation) | ||
|
||
ds = NCDataset(simulation.output_writers[:fields].filepath, "r") | ||
|
||
fig = Figure(size = (800, 600)) | ||
|
||
axis_kwargs = (xlabel = "y", | ||
ylabel = "z", | ||
limits = ((0, grid.Lx), (0, grid.Lz)), | ||
) | ||
|
||
ax_u = Axis(fig[2, 1]; title = "meridional velocity", axis_kwargs...) | ||
ax_b = Axis(fig[3, 1]; title = "buoyancy - N²*z", axis_kwargs...) | ||
|
||
n = Observable(1) | ||
|
||
u = @lift ds["u"][:, :, $n] | ||
v = @lift ds["b"][:, :, $n] - N²*zb | ||
|
||
hm_u = heatmap!(ax_u, yu, zu, u, colormap = :balance) | ||
Colorbar(fig[2, 2], hm_u) | ||
|
||
hm_b = heatmap!(ax_b, yb, zb, b, colormap = :balance) | ||
Colorbar(fig[3, 2], hm_b) | ||
|
||
times = collect(ds["time"]) | ||
title = @lift "t = " * string(prettytime(times[$n])) | ||
fig[1, :] = Label(fig, title, fontsize=20, tellwidth=false) | ||
|
||
fig | ||
|
||
frames = 1:length(times) | ||
|
||
record(fig, "linear_shear_nontraditional.mp4", frames, framerate=12) do i | ||
n[] = i | ||
end | ||
|
||
close(ds) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Does
z_f_cross_U
need to be defined anywhere or is it already computed?