-
Notifications
You must be signed in to change notification settings - Fork 186
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
Velocity blowup in channel model? #579
Comments
Thanks for reporting this @masonrogers14! In this case the I'm somewhat concerned that this issue may be related to PRs #572 and #573 so we should definitely investigate. |
Whats the stability condition associated with diffusivity for this problem? |
I get julia> Δz = 4e3 / 32
125.0
julia> ν = 100
100
julia> Δt = Δz^2 / ν
156.25 So your time-step has to be substantially smaller than 156 s to be stable. 90 s may be pushing it... does reducing the maximum time-step size stabilize the problem? |
Yes we tried reducing the time step to a constant It blows up in ~20 iterations so |
@glwagner suggested that recomputing w from continuity could be an issue here. We should try time-stepping w explicitly and running the example again. |
Reducing time steps for the example I shared solved the problem but fails for a more authentic example. Here is a better example, where I (very loosely) have a 2D y-z model with x-wind forcing in the southern hemisphere:
@glwagner -- explicitly timestepping w unfortunately did not solve the problem, but I'll keep looking into it |
Don't know if this is the problem, but the wind stress wind_stress_bf = BoundaryFunction{:z, Face, Cell}(wind_stress) This is because the |
Note there are also a few changes to the script that would need to be made if the intention is to run on the GPU. |
Thanks @glwagner, I fixed the |
I think I might be narrowing down the issue to implementation of boundary conditions. Perhaps I'm misunderstanding how
It fails after 10 iterations or so with .001s time steps when the |
Holy shit this is a horrible alias! |
Yeah so you were correctly setting it up but apparently this alias meant that we were unknowingly applying horizontally periodic boundary conditions which would be incompatible with the pressure solver. Makes sense that it blew up very quickly no matter what. Changing to boundary_conditions = ChannelSolutionBCs(b=buoyancy_bcs, u=velocity_bcs) fixed it for me and now your example time steps fine on my laptop. |
This is the box model modified to use the correct using Printf
using Oceananigans
using Oceananigans.Diagnostics
using Oceananigans: Cell, Face
Nx = 1
Ny = 256
Nz = 32
Lx = 1000e3
Ly = 1000e3
Lz = 4e3
N² = 1e-5
end_time = 10day
# ## Creating boundary conditions
wind_stress(x,y,t) = -1e-5*sin(2π*y/Ly) * (y<0)
wind_stress_bf = BoundaryFunction{:z, Face, Cell}(wind_stress)
velocity_bcs = ChannelBCs(top=BoundaryCondition(Flux,wind_stress_bf))
buoyancy_bcs = ChannelBCs(bottom=BoundaryCondition(Gradient, N²))
## Instantiate the model
model = Model(
grid = RegularCartesianGrid(size = (Nx, Ny, Nz), x = (0, Lx), y = (-Ly/2, Ly/2), z=(-Lz, 0)),
closure = ConstantIsotropicDiffusivity(ν=100, κ=100),
coriolis = FPlane(f=1e-5),
tracers = (:b,),
buoyancy = BuoyancyTracer(),
boundary_conditions = ChannelSolutionBCs(b=buoyancy_bcs, u=velocity_bcs)
)
## Set initial condition.
b₀(x, y, z) = N² * z
set!(model, b=b₀)
## A wizard for managing the simulation time-step.
wizard = TimeStepWizard(cfl=0.2, Δt=1.0, max_change=1.1, max_Δt=20.0)
cfl = AdvectiveCFL(wizard)
dcfl = DiffusiveCFL(wizard)
while model.clock.time < end_time
update_Δt!(wizard, model)
time_step!(model; Δt=wizard.Δt, Nt=10)
u, v, w = model.velocities
u_max = maximum(abs, interior(u))
v_max = maximum(abs, interior(v))
w_max = maximum(abs, interior(w))
t = model.clock.time
@printf("Time: %s, Δt: %.2e CFL: %.2e, dCFL: %.2e, max (u, v, w): (%.2e, %.2e, %.2e)\n",
prettytime(model.clock.time), wizard.Δt, cfl(model), dcfl(model), u_max, v_max, w_max)
end |
@masonrogers14 Just expanding on an earlier note by @glwagner on
In practice you'll want |
@ali-ramadhan Thanks so much! I'm inclined to say the problem is resolved and will do more tests to make sure. Also the stability condition makes sense; I wasn't sure what the time stepper handled and what one has to address explicitly in the model |
Awesome! I'll close this issue then.
The |
I'm trying to code a simple 2D channel model in v0.17.0 where the periodic dimension is the flat dimension. I keep experiencing seemingly spontaneous velocity blowup during spin-up despite changing parameters/removing most forcing. Here is an example:
The text was updated successfully, but these errors were encountered: