# Unconditionally stable numerical solution of advection equation

**URL:** https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935
**Category:** Numerics
**Tags:** diffeq, pde
**Created:** [February 7, 2022, 7:25am UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935 "2022-02-07T07:25:06Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)
#### Post date: [February 7, 2022, 7:25am UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/1 "2022-02-07T07:25:07Z")

</div>

Hello,

Can you please recommend me some method (preferably unconditionally stable) of solving an advection equation of the following type:

\displaystyle \frac{\partial u}{\partial t} + a(x,t) \frac{\partial u}{\partial x} = f(u,x,t)

In my case the a(x,t) coefficient changes it sign in time t, so I can not apply the [upwind (downwind) scheme](https://en.wikipedia.org/wiki/Upwind_scheme). Right now I use the [method of lines](https://en.wikipedia.org/wiki/Method_of_lines) to convert this equation into a system of ODEs and solve it with standard RK-like method. But again, due to the time-dependent a(x,t) the Courant number C=|a(x,t)|\Delta t/\Delta x is also time-dependent and does not allow to implement an adaptive time step. Are there any methods which allow to overcome these issues? And in general, what are the current standard methods for solving advection equations numerically?

---

<div class="post-metadata">

### Author: ![luraess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luraess/32/16189_2.png) [@luraess](https://discourse.julialang.org/u/luraess)
#### Post date: [February 7, 2022, 9:54am UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/2 "2022-02-07T09:54:01Z")

</div>

Hi,  
(since not specified, I assume you are using FD with Cartesian domain) if you want to stick to upwind type-of scheme, you could check the sign (thus direction) of your advection velocity `a(x,t)` and “stagger” the advection terms upwind or downwind accordingly (see [here](https://github.com/omlins/ParallelStencil.jl/blob/a5b9ed5526e71a53be7e7cec4cc8039cd8831925/miniapps/ThermalConvection2D.jl#L53-L57) for a 2D case applied to thermal convection). Same should work with RK-like methods. Alternatively, you could go with method of characteristics (see e.g. [here](https://github.com/utkinis/NavierStokes.jl/blob/87458870da838b7da165d71ae495cefac3f0bd48/scripts/NavierStokes.jl#L206-L223)) or semi-Langrangian advection schemes.

---

<div class="post-metadata">

### Author: ![josuagrw](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josuagrw/32/1015_2.png) [@josuagrw](https://discourse.julialang.org/u/josuagrw)
#### Post date: [February 7, 2022, 9:56am UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/3 "2022-02-07T09:56:43Z")

</div>

What are your boundary conditions? If they are periodic you could easily discretize the spatial dimension in Fourier space. Notably, that would diagonalize the derivative w.r.t. x.

---

<div class="post-metadata">

### Author: ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)
#### Post date: [February 7, 2022, 12:23pm UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/4 "2022-02-07T12:23:15Z")

</div>

Thank you for the links.

> [@luraess](#):
>
> I assume you are using FD with Cartesian domain

Yes, I use standard Cartesian grid.

What about the stability of the method of characteristics and semi-Lagrangian scheme?

In any case, do you maybe know some review that compares different methods for the advection equation. I am a bit confused about the reasons for choosing one method over the other.

---

<div class="post-metadata">

### Author: ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)
#### Post date: [February 7, 2022, 12:24pm UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/5 "2022-02-07T12:24:09Z")

</div>

Oh, thank you for the idea. Yes, my boundary conditions are indeed periodic.

---

<div class="post-metadata">

### Author: ![luraess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luraess/32/16189_2.png) [@luraess](https://discourse.julialang.org/u/luraess)
#### Post date: [February 7, 2022, 2:00pm UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/6 "2022-02-07T14:00:13Z")

</div>

> What about the stability of the method of characteristics and semi-Lagrangian scheme?

Semi-Lagrangian schemes may introduce quite some numerical diffusion. For unconditionally stable schemes avoiding numerical diffusion, marker methods (PIC/FLIP) may be among the best options.

> […] compares different methods for the advection […]

Chapter 8 of [that book](http://jupiter.ethz.ch/%7Etgerya/Book), e.g., provides some basics, refs and comparisons on upwind and marker-based methods.

---

<div class="post-metadata">

### Author: ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)
#### Post date: [February 7, 2022, 2:23pm UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/7 "2022-02-07T14:23:44Z")

</div>

Thank you very much.

---

<div class="post-metadata">

### Author: ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)
#### Post date: [February 8, 2022, 3:15pm UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/8 "2022-02-08T15:15:04Z")

</div>

There is a reasonably(?) elementary introduction to time stepping for advection problems in [this chapter](http://tobydriscoll.net/fnc-julia/advection/overview.html) of a forthcoming textbook.

---

<div class="post-metadata">

### Author: ![fedoroff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fedoroff/32/53209_2.png) [@fedoroff](https://discourse.julialang.org/u/fedoroff)
#### Post date: [February 9, 2022, 6:58am UTC](https://discourse.julialang.org/t/unconditionally-stable-numerical-solution-of-advection-equation/75935/9 "2022-02-09T06:58:58Z")

</div>

Thank you. Looks interesting.
