Problem Set 5 (Numeric PDEs)

1

Consider the 1D wave equation

(a)

Write down the straightforward finite-difference approximation.

(b)

What order approximation is this in time and in space?

Second order in space and time.

(c)

Use the von Neumann stability criterion to find the mode amplitudes.

Start with an ansatz of . (Here the “exponent” on is an index, while the exponent on is an exponent.) Note that (which can be proven by looking at the Taylor expansions), and . Then

where is just defined to avoid rewriting that big subexpression. So by the quadratic formula, the two possible amplitudes for mode are

(e)

Use this to find a condition on the velocity, time step, and space step for stability. (Hint: consider the product of the two amplitude solutions.)

Thus the magnitudes of the two amplitudes (we never said they were real) have to multiply to one. This means that one will be unstable unless both are exactly equal to one.

If , then both amplitudes are real. To be stable, both must be equal to one, which can only be true if , i.e. .

If , then the amplitudes are . In this case , so all solutions have the desired stability.

Thus to have a stable solution, we require that , or . Plugging in the value of ,

In the worst case, , so if we know we’re ok for any . Interestingly, if for a particular mode , the physical velocity can to exceed the simulation velocity by some amount. However due to numeric error we would expect small amounts of other modes to appear at some point, which would then quickly be amplified and explode.

(e)

Do different modes decay at different rates for the stable case?

For any , the amplitude of both solutions must be exactly one. So no modes decay or grow.

(f)

Numerically solve the wave equation for the evolution from an initial condition with except for one nonzero node, and verify the stability criterion.

Rearranging the relation we found in part (a),

where we define . My implementation is here.

(g)

If the equation is replaced by

assume that

and find a relationship between and , and simplify it for small . Comment on the relationship to the preceding question.

Our ansatz is separable.

Plugging in derivatives, the differential equation becomes

Using the quadratic formula,

Manipulating to look like then expanding to first order in ,

This has a real part and an imaginary part. When we plug it into the real part will cause oscillation in time, and the imaginary part will cause the amplitude to decay exponentially in time. (Note the signs; for it can never cause exponential growth). The damping depends on , but also on . So the damping affects high frequencies (thus large ) much more than low ones. In the previous problem there was no damping at all.

(h)

Repeat the numerical solution of the wave equation with the same initial con- ditions, but include the damping term.

I went down a deep but ultimately very productive rabbit hole on the derivation of finite difference schemes. To cut to the chase, I now have a SymPy script that discretizes PDEs for me.

It gives two reasonable options to use for this problem. The first is an explicit scheme that is second order in space, and first order in time.

The second is an implicit scheme that is second order in both space and time.

I used the explicit scheme since it’s faster to implement. I added it to my code from part (f).

8.2

Write a program to solve a 1D diffusion problem on a lattice of 500 sites, with an initial condition of zero at all the sites, except the central site which starts at the value 1.0. Take , and use fixed boundary conditions set equal to zero.

(a)

Use the explicit finite difference scheme, and look at the behavior for , 0.5, and 0.1. What step size is required by the Courant condition?

There are many finite difference schemes one might try. The standard explicit scheme for this problem uses a centered second order approximation for , and a first order backward approximation for .

The leading error terms are

Performing a quick stability analysis, we find that

This is between -1 and 1 when

(b)

Now repeat this using implicit finite differences and compare the stability.

The straightforward scheme here replaces the backward difference with a forward one (for ).

Its leading error terms are

The important difference is that it is stable for any (positive) amount of diffusion.

This is between -1 and 1 when

which reduces to

when we assume the worst case for .

To implement this for fixed boundary conditions, we need to solve a system of linear equations that looks like this (here written for only five samples in , but the structure should be clear).

Where

This is a specific case of the general tridiagonal system.

We can use Gaussian elimination to systematically remove all off-diagonal elements. To start, divide the first row by . Then subtract times the first row from the second. This gets rid of .

Let’s now divide the second row by , so that its leading nonzero term is one.

We can repeat this process until all entries below the diagonal are eliminated, and all diagonal entries are one. The result is

where

Now we remove the entries above the diagonal, starting with . Multiply the last row by and subtract from the fourth. Note that this doesn’t change any diagonal entries. After doing this times we have

where

These are the solutions we wanted.

For our particular system,

We can compute the in advance and reuse them. Then and reduce to

Interestingly, by using a slightly different Gaussian elimination scheme, we can get rid of the auxiliary array of values. I derive this in my notes.