MFlowCode / MFC

Exascale simulation of multiphase/physics fluid dynamics
https://mflowcode.github.io
MIT License
142 stars 65 forks source link

Adaptive time stepping with embedded Runge-Kutta and/or CFL #298

Closed sbryngelson closed 3 weeks ago

sbryngelson commented 8 months ago

Adaptive time stepping with embedded Runge-Kutta. RK23 most likely - computing RHSs for RK3 then using them to compute the update for RK2 and RK3 (2nd and 3rd order accurate versions of RK), then the difference between them is a measure of time step error. Involves a tuning parameter that has to be added to the inputs.

sbryngelson commented 5 months ago

@anandrdbz I think you had something like this? or maybe @lee-hyeoksu? or @wilfonba? I cannot remember. This would be separate from the sub-grid bubble case and just for general simulations.

hyeoksu-lee commented 5 months ago

@sbryngelson I implemented adaptive time stepping in s_compute_bubble_source. It would be possible to implement the adaptive time stepping for general simulations in a similar way. But before working on it, I would like to understand the needs of adaptive time stepping.

In sub-grid bubble simulation, especially where the convective time scale is much larger than the bubble response time scale, the adaptive time stepping is needed to run simulation efficiently. In this case, we can set the default dt that corresponds to CFL = 0.7 or something, no matter how small dt the sub-grid bubble requires.

Other than sub-grid bubble simulation, what kinds of simulation do you expect to get benefits from adaptive time stepping?

sbryngelson commented 5 months ago

@lee-hyeoksu many possibilities here.

One possibility is that the CFL condition is simply not strict enough to keep the simulation stable. In this case, our simulations just crash. But, if the user allows for adaptive time steps, they can get smaller and perhaps prevent crashes. I know for many such (resolved) multiphase simulations we require CFL -> 0.1 or 0.05 or so to maintain stability.

Another case is that one could set a very conservative CFL condition (or incorrectly set it, unbeknownst to them), but the adaptive stepper would allow for appropriately large time steps.

Of course, the 'most appropriate' use would be a case where the CFL condition somehow varies over the course of the simulation. This is somewhat less realistic for us, but different regimes of multiphase flow dynamics do require drastically different time step sizes, so some amount of adaptivity seems very helpful (@wilfonba will definitely attest to this).

I think @anandrdbz may have already implemented something like this, but it was in a very old version of the code, so I'm not sure if it's useful, and I don't think it is on GitHub.

hyeoksu-lee commented 5 months ago

@sbryngelson I got it. Thanks for explanation. If no one has done it so far, I would do it.

sbryngelson commented 5 months ago

That would be great!