Skip to content
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

MPData advection scheme #3434

Draft
wants to merge 148 commits into
base: main
Choose a base branch
from
Draft

MPData advection scheme #3434

wants to merge 148 commits into from

Conversation

simone-silvestri
Copy link
Collaborator

@simone-silvestri simone-silvestri commented Jan 19, 2024

This PR implements a three-dimensional positivity preserving advection scheme called multidimensional positive definite advection transport algorithm (MPDATA), which follows this paper.

We don't need to merge this PR, but I'll leave it here in case, in the future, we need a multidimensional positivity-preserving advection scheme (for example for wetting and drying).

@simone-silvestri simone-silvestri added 🚨 DO NOT MERGE 🚨 IN BIG BOLD RED CAPS WITH FLASHING SIRENS numerics 🧮 So things don't blow up and boil the lobsters alive labels Jan 19, 2024
architecture :: Arch
underlying_grid :: G
immersed_boundary :: I
interior_active_cells :: M

surface_active_cells :: S
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what surface is this, top, bottom, north, south?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is meant to be the top boundary. It comes from PR #3404. I have to correct it there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, to be precise, it's the active map of reduced fields in the z-direction

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is only relevant for the hydrostatic model right? It wouldn't apply to the non-hydrostatic model, or probably other models that are isotropic and 3D.

@francispoulin
Copy link
Collaborator

@simone-silvestri Have you already done tests to ensure that it is positive preserving?

@simone-silvestri
Copy link
Collaborator Author

Indeed, it is positivity preserving. Not bounds preserving though. And it seems to be too diffusive.

@francispoulin
Copy link
Collaborator

Indeed, it is positivity preserving. Not bounds preserving though. And it seems to be too diffusive.

That's a big step forward! I know there are ways to iterate to improve the accuracy. I presume your test was the low order option?

Do you think we should try more iterations to improve the upper bound and general accuracy?

@simone-silvestri
Copy link
Collaborator Author

I have introduced the option to iterate as well an option to use the formulation that assumes infinite iterations (iterations = nothing). If you want to give it a try for a simple configuration that would be nice!

example:

grid = RectilinearGrid(size = (10, 10, 10), extent = (1, 1, 1))

advection = MPData(grid; iterations = 1) # equivalent to UpwindBiased(; order = 1)
advection = MPData(grid; iterations = 3) # 3 corrective iterations
advection = MPData(grid; iterations = nothing) # ∞ iterations (a little more expensive)

@simone-silvestri
Copy link
Collaborator Author

This is the output of the 1D advection test in validation/advection/simple_one_dimensional_advection.jl

Screenshot 2024-02-13 at 12 41 25 PM

@simone-silvestri
Copy link
Collaborator Author

with a 10 times smaller time step
Screenshot 2024-02-13 at 12 45 03 PM

@@ -104,6 +105,8 @@ function time_step!(model::AbstractModel{<:RungeKutta3TimeStepper}, Δt; callbac
calculate_pressure_correction!(model, first_stage_Δt)
pressure_correct_velocities!(model, first_stage_Δt)

correct_advection!(model, Δt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's wrong about it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that it is only upwind first order, definitely incorrect 😄

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe "refine advective tendencies" is the right word?

@francispoulin
Copy link
Collaborator

Thanks for sharing the plots @simone-silvestri!

There does not seem to be much improvement between 2 and 5 iterations. In the coarser case they look the same and in the finer case the more iterations has a higher maximum.

The method is not supposed to preserve a maximum is it?

@simone-silvestri
Copy link
Collaborator Author

Nono, it is not bounds preserving. It is only intended for positive definite quantities and prevents negative values.

@francispoulin
Copy link
Collaborator

I produced a few more figures that might be of interest.

First, it's the same plot as @simone-silvestri produced but with fifth order upwinding.

N100

@francispoulin
Copy link
Collaborator

The second is with double the spatial resolution, and therefore halving the time step.
N200

@francispoulin
Copy link
Collaborator

The third and final one is with doubling the spatial resolution again (total of x4) and calculating the time step in the same way as usual.

N400

@francispoulin
Copy link
Collaborator

Some thoughts:

The first case (N=100) doesn't look great but it shows that the MPData schemes do not differ very much whether we have 2 or 5 iteractions, and they are somewhere between 1st and 3rd order upwinding.

The second case (N=200) looks better and I can't really see any difference between 2 and 5 iterations.

The third case (N=400) has all the schemes performing well, even first order upwinding. Again we can't differentiate between the two MPData schemes and it's even hard to differentiate between 3rd and 5th order upwinding.

I lesson that I learned from here is to use as much spatial resolution as we can as this does much more compared to the number of iterations.

@simone-silvestri : do you think we should do a similar comparison for 2D advection?

@simone-silvestri
Copy link
Collaborator Author

Thanks for running these tests. It would be nice to see how MPData performs in a 2D flow.

It's interesting that tweaking the number of iterations doesn't seem to make much difference. I'm a bit skeptical about this scheme though; it seems pretty diffusive and doesn't even beat third-order upwind which is way simpler. I might have introduced a bug although I went through the code again and it looks correct to me.

Another possibility is that the high diffusivity is the trade-off for keeping the scheme positivity-preserving?
Godunov's theorem sets some tough standards -- it's not possible to obtain monotonic advection with a linear scheme beyond first order.

@francispoulin
Copy link
Collaborator

I looked into MPData a long time ago and I recall it being very diffusive, so it might be the nature of the beast. It beats first order upwinding, which is also positive preserving, but not by much.

The WENO schemes seem to be a more complicated way to ensure positivity more accurately but I remember you saying there were problems doing this properly in multiple dimensions. There is no perfect scheme for sure.

This is a paper that presents a positive preserving WENO scheme for population models. Example 3 is a 2D problem but the plots are only 1D. How similar is this to what you have tried already?

@francispoulin
Copy link
Collaborator

This paper presents a maximum principle preserving flux limiter for FD RK-WENO schemes and has applications to incompressible flows in 2D. They claim to maintain accuracy and not have as small a time step as other approaches.

I'm not sure of the details thought but I thought I would share, in case it was of interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 DO NOT MERGE 🚨 IN BIG BOLD RED CAPS WITH FLASHING SIRENS numerics 🧮 So things don't blow up and boil the lobsters alive
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants