In a previous post we have shown how to use series expansion to analyze the numerical viscosity(i.e. dissipation).

Today we will revise our Mathematica code and give intuitive running results to visualize the effects of dissipation and dispersion.

First we introduce a new Mathematica function expandToOrder. We will use it to expand a function to a desired order.

For example, if we want to expand function u to the second order, we can write:

The result us2 is a function of expansion location.

Dissipation

In the section 4.3.2 of book1 it states that the even-order spatial derivative contributes to the dissipation effect. We will give an second order example to visualize that.

First let’s examine the modified PDE.

The first line gets the series expansion to the second order; and then we compute the finite difference scheme fds, which is forward in time and backward in space. Finally we substitute the series expansion into this finite difference scheme and get:

The left hand side is the original PDE we want to solve. However dissipation is introduced by a second order spatial derivative due to the truncation error.

We will use a concrete example in numpy to illustrate how it impacts the result:

Dispersion

On the other hand the dispersion is introduced by odd order spatial derivative. This time we use a finite difference scheme which is central in time and space.

By similar Mathematica code,

we get

We can see the spatial truncation error is dominated by a third order term. Again there is an example in numpy to illustrate the effect of dispersion:

References

1. Zikanov, Oleg. Essential computational fluid dynamics. John Wiley & Sons, 2010.