What's new

Prerequisites

In this tutorial, you will learn the basics of time discretization. Using the Upwind, Central and two Lax-Friedrichs fluxes the tutorial first visualizes the structure of the stiffness matrix and its Eigenvalues. Then the stability regions of explicit time integration schemes, e.g. the explicit Euler method, are considered. Using the fourth order Runge-Kutta scheme the Eigenvalues are studied for different polynomial orders and grid resolutions in order to find the most critical Eigenvalue. Finally, the influence of grid resolution and polynomial degree on the time step size is examined and the stable time step $dt_0$ determined in order to obtain a stable and converging solution.

Problem statement

To keep it simple, the one-dimensional scalar transport equation $$ \frac{\delta g}{\delta t} + \nabla \cdot \left(uc\right) = 0 $$ will be used, where $g=g(x,t) \in \mathbb{R}$ is the unknown concentration and $u=1$ the velocity field in a periodic domain~$\Omega = \left[-\pi,\pi\right]$.

The linear PDE can be written in its semi-discrete form $$ \frac{\delta \vec{g}}{\delta t} + M \, \vec{g} + **\vec b** = 0 $$ with the unknown DG coefficients~$\vec{g}$, the system or stiffness matrix~$M$ and the affine part~$\vec{b}$. The affine part is given by source terms and boundary conditions. In this case, $\vec{b}= 0$.

Solution within the BoSSS Framework

Definition of the operator matrix} \label{sec:scalarConvection_matrix

The function~u is defined for later usage.

The function~GetOperatorMatrix constructs the operator matrix~$M$ corresponding to the semi-discrete ODE system.

Definition of numerical fluxes

As in the previous tutorials, the Upwind flux is used.

Moreover, the Lax-Friedrichs flux with a constant C (here, different values are used) is implemented.

If C equals zero, the Lax-Friedrichs flux is equivalent to the central flux.

In general, the flux implementation is similar to the one in the previous tutorials, but in this case, it is one-dimensional and uses LinearFlux as a base class. This class helps to create the entries of the operator matrix discussed above.

Definition of operators and construction of system matrices

A dictionary is created to access the different fluxes easily.

Some initial configurations (polynomial degree and numberOfCells) are done, as well as defining the system matrices for the above-defined fluxes.

Investigation of operator matrices

The style of the plots is defined.

SetMultiplot enables multiple plots per graphic.

Now, we can see purple and green blocks in the matrix plots. The purple blocks are the diagonal blocks that couple the DOF inside in a cell.

The off-diagonal green blocks define the coupling between neighboring cells.

Moreover, the differences in the matrix structure for the different fluxes,

especially when comparing the upwind and the central flux to the Lax-Friedrichs variants, is investigate

Analysis of the spectrum of common explicit ODE integrators

The discrete spectrum of a linear operator in a periodic domain is given by the eigenvalues of the corresponding system matrix. Here, we will use Matlab to analyze the spectrum for the different fluxes. For the stability analysis, we have to use the standard form:

$$\frac{\delta \vec u}{\delta t} = -M \, \vec u $$

The BatchmodeConnector initializes an interface to Matlab:

We will use the array~eigenValues to store the eigenvalues of the matrix for each flux. The first index corresponds to the flux, the second index to the eigenvalue and the third index to the part of the eigenvalue (0: real part; 1: imaginary part).

Calling Matlab takes some time on most machines, even though the individual calculations are quite fast (suppressing the output). This is due to the slow startup of Matlab...

Now, the eigenvalues are plotted in the complex plane.

We will compare the spectra of the different operator matrices. The spectrum for the central flux case does not contain any negative real parts. Consequently, the solution of the ODE system is unstable in a sense that disturbances (e.g. due to round-off or projection errors) will never be damped. Next, let us have a closer look at the influence of the spectrum of the system matrix on the maximum admissible time step size. The stability can be analyzed by using the so-called stability function~$f(z)$ of an ODE solver. That is, the system is stable if all eigenvalues of $dt \, M$ are located within the stability region $|f(z)| < 1$ of the solver. In the following, we will nvestigate the stability for the case of the Upwind flux.,

The stability function of Runge-Kutta schemes for the orders 1 to 4 are stored in a Dictionary.

We create some sampling nodes for the following plots.

We plot the boundary of the stability regions for the different schemes and orders, respectively.