-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add background zonal flow U
or U(y)
in the SingleLayerQG
module
#360
Conversation
Co-authored-by: Gregory L. Wagner <[email protected]>
I've added a draft of the full functionality with
|
Co-authored-by: Gregory L. Wagner <[email protected]>
Co-authored-by: Gregory L. Wagner <[email protected]>
@mncrowe is it OK if I push few edits? |
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.
@mncrowe this looks very good! Thanks!
I changed the tests for when U is not varying with y to utilize the Rossby wave test.
There are two things left to do:
- remove the
if params.U isa Number ... else ...
statement fromcalc_advection!
https://github.com/mncrowe/GeophysicalFlows.jl/blob/dd3c1ad4b6b3a3b2866525ad3ae993f3f3329270/src/singlelayerqg.jl#L352-L368
which reduces performance; and
- add a test for a background flow U(y). This can be done via the
test_1layerqg_nonlinearadvection
test,
similarly to how this was done for the MultilayerQG module; see
I think I see a minor problem. When I think I'll try to refactor the code to mimic the MultiLayerQG where the background PV gradients include the ∂η/∂x and ∂η/∂y terms and the ∂²U/∂y² (if U is not a constant). |
@mncrowe I think I did everything! Have a look and let me know if you find any issues running the code or if the code is not behaving as you expect? Otherwise I'm happy to merge this! |
I would just appreciate your look on the code. In principle I can approve the PR but it'd be nice if somebody else has a look because I made few changes. |
SingleLayerQG
U
or U(y)
in the SingleLayerQG
module
Thanks for the very thorough reviewing and rewrite. Is there anything outstanding for me to do? |
Does it work as expected? |
A flow at rest advected by a background imposed U=0.5 over some topography. using GeophysicalFlows, GLMakie, Printf
dev = CPU()
n = 256
stepper = "FilteredRK4"
dt = 0.02
nsteps = 4000
nsubs = 5
L = 2π
σx, σy = 0.4, 0.8
topographicPV(x, y) = 3exp(-(x - 1)^2 / 2σx^2 - (y - 1)^2 / 2σy^2) - 2exp(- (x + 1)^2 / 2σx^2 - (y + 1)^2 / 2σy^2)
prob = SingleLayerQG.Problem(dev; nx=n, Lx=L, eta=topographicPV, U=0.5, dt, stepper, aliased_fraction=0)
sol, clock, vars, params, grid = prob.sol, prob.clock, prob.vars, prob.params, prob.grid
x, y = grid.x, grid.y
Lx, Ly = grid.Lx, grid.Ly
q = Observable(Array(vars.q))
fig = Figure(size=(380, 300))
axis_kwargs = (xlabel = "x", ylabel = "y", aspect = 1,
limits = ((-Lx/2, Lx/2), (-Ly/2, Ly/2)))
title_q = Observable("initial vorticity ∂v/∂x-∂u/∂y")
axq = Axis(fig[1, 1]; title = title_q, axis_kwargs...)
hm = heatmap!(axq, x, y, q, colormap = :balance, colorrange = (-5, 5))
Colorbar(fig[1, 2], hm)
contour!(axq, x, y, params.eta;
levels = collect(0.5:1:2.5), linewidth = 2, color = (:black, 0.5))
contour!(axq, x, y, params.eta;
levels = collect(-2.5:1:-0.5), linewidth = 2, color = (:grey, 0.7), linestyle = :dash)
title_q[] = "vorticity, t=" * @sprintf("%.2f", clock.t)
record(fig, "singlelayerqg_topography_U0.mp4", 0:round(Int, nsteps/nsubs), framerate = 40) do j
q[] = irfft(sol, grid.nx)
title_q[] = "vorticity, t=" * @sprintf("%.2f", clock.t)
stepforward!(prob, nsubs)
end singlelayerqg_topography_U0.mp4 |
All my scripts are producing the same results as before, and match my earlier results using Dedalus. |
Nice! I’m merging then. |
[edited] Add a constant background zonal flow in the$U$ which can also be varying in $y$ , i.e., $U(y)$ .$y$ ) it's included in the linear term $y$ it's included in the nonlinear term $\partial_y^2 U$ .
When the background advection is constant (not varying with
L
of the equation; when it's varying withN
alongside with contributions from background PV gradient