Closed francispoulin closed 1 year ago
I probably would have to think a bit about it, but aren't baroclinic instabilities developing on the x-y plane? Can you represent a baroclinic instability process with 1 point in the jet direction?
This is a baroclinic jet and you are correct that having a Flat topology prevents any baroclinic instabilities from happening. We are actually studying inertial instabilities, and they can occur in a y-z plane.
One thing that might be easier to ask for help with his, I wanted to print out the norm of the perturbation buoyancy in both cases. When we evolve the perturbation this is easy, but when we evolve the total field, I couldn't figure out how to do it. Do you have a recommendation?
This would be helpful to determine how the norm changes with resolution.
I gues something like this would work
B₀ = CenterField(grid)
set!(B₀, B)
b = model.tracers.b
b′² = Field(Average((b - B₀)^2))
Thanks for the suggestion @simone-silvestri .
Building on your suggestion, what I tried below seemd to do the trick.
Cheers!
B_background = CenterField(grid)
set!(B_background, B)
function progress(sim)
umax = maximum(abs, sim.model.velocities.u)
bmax = maximum(abs, sim.model.tracers.b - B_background)
@info @sprintf("Iter: %d, time: %.2e, max|u|: %.2e, max|b|: %.2e",
iteration(sim), time(sim), umax, bmax)
return nothing
end
@simone-silvestri , thanks to your help I am now able to print out the norms of the perturbation buoyancy in the case when we evolve the total fields.
The error that arises in this case, but not when we evolve the perturbation fields, decreases quadratically with increasing resolution. I could pick a resolution where this is small but in the first hour the norm or buoyancy grows by three orders of magnitude, which looks like an instability. It is not noisy and very well resolved, it can't be a baroclinic instability and does not look anything like an inertial instability.
Is it because your initial condition is only geostrophically balanced in the continuous limit? You may need to compute the velocity field that's in discrete geostrophic balance with your initial buoyancy field.
You are using analytical formula for both U
and B
:
U(x, y, z) = Umax / cosh(y/Lⱼ)^2 * exp(-(z-z0)^2/D^2)
B(x, y, z) = N² * z + 2*f*Umax*Lⱼ/D^2 * (tanh(y/Lⱼ)) * (z-z0) * exp(-(z-z0)^2/D^2)
but to satisfy the discrete geostrophic balance you would have to compute one of those fields from the other one, in a manner consistent with how Coriolis forces are implemented.
Something like this might work:
B(x, y, z) = N² * z + 2*f*Umax*Lⱼ/D^2 * (tanh(y/Lⱼ)) * (z-z0) * exp(-(z-z0)^2/D^2)
set!(model, b=B) # this calls `update_state!`, and thus calculates the hydrostatic pressure associated with buoyancy
f = model.coriolis.f
ph = model.pressures.pHY′
U = - ∂y(ph) / f
set!(model, u=U)
Curious to see if that solves it.
And just for sanity we can look into the source to ensure that the hydrostatic pressure is indeed calculated during set!
:
Not a terrible idea to plot model.tracers.b
, ph
, and U
too (for that you'll need to write U = compute!(- ∂y(ph) / f)
).
Thanks @glwagner for the suggestion. We will try this out and see if we can improve our results, and if this instability disappears.
Actually, we found that the Hydrostatic model suffers from the same problem, and since it solves for the total field that is maybe not surprising. So confirming the hydrostatic pressure is a very good idea!
@glwagner : I was able to get your suggestion working very easily, thanks again.
Unfortuantely it doesn't help is removing the error that is introduced in the centre or the fact that it grows exponentially (I am guessing).
I have looked at the pressure and it looks smooth but I suppose looking at the pertrubation pressure might be more telling.
Can you confirm that there is hydrostatic balance at the discrete level? It might help to plot the deviation from thermal wind, for example, to get a clue as to what's going on.
PS can we convert this to a discussion? I very much doubt this is a bug in the source code and it might be nice to have the discussion format to organize our ideas to solve this problem
PS can we convert this to a discussion? I very much doubt this is a bug in the source code and it might be nice to have the discussion format to organize our ideas to solve this problem
I was thinking the same!
Thank you for the great suggestions so far. I see no problem with converting this thread to a discussion.
Although the problem is not solved yet, we have done some investigation around it: 1) Increasing the precision of the output to Float64 eliminates the initial error seen at the first few frames of the animation.
2) Using a barotropic version of the jet
U(x, y, z) = Umax / cosh(y/Lⱼ)^2
B(x, y, z) = N² * z
leads to no perturbation when evolving the total fields.
3) Using a discretized version of the thermal wind balance is a sound suggestion, but it does not explain why the error only appears when evolving the total fields.
Using a discretized version of the thermal wind balance is a sound suggestion, but it does not explain why the error only appears when evolving the total fields.
Why not? When evolving the total fields, the condition of geostrophic balance is computed during the prognostic evolution of the total variables. When evolving just the perturbation, the algorithm for mean-perturbaiton decomposition assumes that the mean fields are balanced. There is no need to worry about the tiny difference between discrete and continuous balance in the case that you only evolve perturbations. But if you want to evolve the geostrophically balanced state, you must ensure that it is perfectly balanced to within machine precision, or you will have an adjustment. That's the basis for my suggestion. I'm not sure the computation I recommended achieves numerical balance (something might be missing) --- that should be checked.
Increasing the precision of the output to Float64 eliminates the initial error seen at the first few frames of the animation.
I'm not sure I understand. The error is only associated with post-processing and not with the actual simulation?
@glwagner : did you want to convert this to a discussion before we go further in our chat?
Yes if youre ok with that I will
@m3azevedo and me are doing a simulation of an unstable baroclinic jet in the context of the Nonhydrostatic model and having some success but some difficulties as well.
We have tried two different approaches:
Method 1: define the jet and stratification to be part of the background field and evolve the perturbations.
Method 2: define the jet and stratification as part of the initial conditons and evolve the total field.
These are mathematically equivalent and should both yield the same results, but we are finding a difference and believe there is a problem with method 2 (evolving the total fields).
When pick there to be zero perturbations, the jet is an exact solution to the governing equations (even though it is an unstable one) and it should persist, until perturbations arise because of numerical errors.
The good news is that when we use method 1, evolve the perturbations, when we pick zero perturbations, no pertrubations develop for a long time.
The not so good news, is that when we use method 2, evolve the total field, a distrubance develops right away,in the center of the jet that spans the entire depth, and this seems to radiate gravity waves to the left and right. The amplitude of the distrubance is small and it does decrease with increasing resolution but it seems problematic.
I am going to include an animation that shows the problem that develops in the first 6 hours and the two codes, which are almost identical. Is there something that we are doing wrong here? @glwagner ?
Method 1: Evolve perturbations
Method 2: evolve total field