Oceananigans.jl icon indicating copy to clipboard operation
Oceananigans.jl copied to clipboard

(0.91.1) Remove instances of `previous_Δt` and fix a bug setting `last_Δt` in RK3

Open glwagner opened this issue 9 months ago • 7 comments

This PR fixes a bug where last_Δt was incorrect for RK3. This bug was found by @tomchor, cc @jagoosw

Also it removes previous_Δt from the QuasiAdamsBashforth2 time-stepper. Note, this affects checkpointing. I also correctly restore last_Δt from the checkpoint.

I also updated some docstrings just so we have uniform language, replacing "previous" with "last" in a few places.

glwagner avatar May 09 '24 19:05 glwagner

Do we not want the substep length rather than the total time step length? For example on the cases where we're explicitly stepping a boundary condition they're getting stepped every substep.

jagoosw avatar May 10 '24 14:05 jagoosw

Do we not want the substep length rather than the total time step length? For example on the cases where we're explicitly stepping a boundary condition they're getting stepped every substep.

It's not a question of having one or the other. The question is whether "last_Δt" means "last time step".

We need to save the previous time step for various reasons --- for AB2 it's needed to decide whether to re-initialize with an Euler step.

If we need the previous substep that was taken during RK3 multi-stage stepping, that's fine. It's the road to insanity if last_Δt means "last substep" in some cases, and "last time step" in others. Given the choice, why deliberately drive ourselves insane when we can simply save both the substep and the total time step?

glwagner avatar May 10 '24 16:05 glwagner

I guess it is also worth nothing that in principle the substep could be inferred from the stage and total time-step. I guess. Perhaps it's better to save the whole time-step though.

I wonder if the clock even needs to know what type of time stepping scheme is being used, in fact, but we can do one thing at a time.

glwagner avatar May 10 '24 16:05 glwagner

So just to clarify @jagoosw can you confirm that you would like the clock to record substep intervals? I will implement that if so and call it something like last_stage_Δt (as a nod to the stage property that the clock has already). We can flag this PR as a breaking change, as well.

glwagner avatar May 10 '24 16:05 glwagner

Yeah this makes sense, and yes, I think in some cases we will need the last substep interval yes.

jagoosw avatar May 11 '24 15:05 jagoosw

So that we can write code that works with both timesteppers I think it would make sense for last_\Delta t to be filled for AB2 as well?

jagoosw avatar May 14 '24 14:05 jagoosw

So that we can write code that works with both timesteppers I think it would make sense for last_\Delta t to be filled for AB2 as well?

Yes, we do that here https://github.com/CliMA/Oceananigans.jl/blob/02549527330b48ef7e1023e0fc8de191b3d66b6c/src/TimeSteppers/quasi_adams_bashforth_2.jl#L94

glwagner avatar May 14 '24 17:05 glwagner

@glwagner merge?

tomchor avatar Jun 18 '24 17:06 tomchor