Méthodes numériques pour les EDP instationnaires

TP1 - Transport equation with constant coefficients

Julien Guillod, Sorbonne Université, Licence CC BY-NC-ND

1. Numerical Analysis

This exercice is solved at once, without following the proposed steps.

Main implementation

In order to allow time-stepping methods to store pre-computed values, it is convinient to define the following class:

For time-stepping methods that do not require initialisation, the following decorator transforms a function of u,cfl into a NumericalMethod object:

The following class is used to initalize and run a problem:

The previous general class is explicited for the transport equation, with the corresponding schemes:

Tests

Definitions of the functions for the initial data:

Testing the Lax-Wendroff scheme:

Comparaison between the implementation of Lax-Wendroff with slicing and with a for loop:

Conclusion: avoid for loop as much as possible!

Convergence tests

Get errors at $t=T$ for various Nx:

Compare convergence for various spatial discretizations for the smooth initial data u01:

Compare the convergence for various spatial discretizations for non-smooth initial data u02:

2. Numerical modeling

Let $\sigma>0$. The exact solution when $d(n)=\sigma n$ is given by $$ n(t,a) = \begin{cases} e^{-\sigma t} n_0(a-t) & \text{for}\, t<a \,, \\ 0 & \text{for}\, t\geq a \,. \\ \end{cases} $$ Obviously the function $a \mapsto n(t,a)$ is never zero for any $t>0$.

For $d(n) = \sigma \sqrt{n_+}$, one can look at the solution under the form $n(t,a) = \varphi(t,a)$. In this case, the exact solution is given by $$ n(t,a) = \begin{cases} \bigl( \sqrt{n_0(a-t)} - \frac{\sigma t}{2} \bigr)_+^2 & \text{for}\, t<a \,, \\ 0 & \text{for}\, t\geq a \,. \\ \end{cases} $$ In particular if $M=\sup_{a} n_0(a) < \infty$, then the function $a \mapsto u(t,a)$ is trivial for $t>\frac{2\sqrt{M}}{\sigma}$.

The introduction of a non-zero birth coefficient makes the analysis more complicated, see for exemple Theory of Nonlinear Age-Dependent Population Dynamics by G.F. Webb.

Define the upwind scheme with RHS and boundary condition at $a=a$:

Subclass for a boundary condition given by $$ n(t,0) = \int_0^\infty b(a)n(t,a) d a $$ by default with $b=0$:

Define the RHS and corresponding exact solution with zero birth coefficient respectivly for $d(n)=-\sigma n$ and $d(n) = \sigma \sqrt{n_+}$:

Representation of the solutions for $b=0$ starting from some initial data:

Adding a non-zero birth condition: