Lab 3

Click here to download this notebook

Important 1:

This notebook is designed to run in Julia. If you are working in Python, create a new .ipynb file to run Python code and copy this file there.

Important 2:

Rename the file as: lastname_firstname_lab_3.ipynb

All the generated code and the presentation must be included in this notebook.

The goal of the assignment is multifaceted:

  1. Become familiar with the wave equation or hyperbolic equations in general.

  2. Get acquainted with finite difference operators of various orders.

  3. Understand the importance of the choice of time integrator.

  4. Qualitatively and quantitatively assess the approximation errors.

  5. Study the convergence of the methods.

  6. Observe the limitations of the method when shock waves are generated.

1) Play with the Wave Equation code:

a) Change the initial conditions; b) Evolve to different times; c) Plot different variables or functions of them; d) Try to plot an animation of the solution; e) Test different spatial and temporal resolutions (what happens if you choose a very large dt?) Explain. Compute the energy of the solution and observe how well it is conserved.

2) Using the BandedMatrices library, create finite difference operators of order 6 and 8. Apply them to the wave equation. Together with the already implemented operators (orders 2 and 4), evolve the equations up to T = 100 and compare the results with the exact solution (after whole periods, the exact solution matches the initial data). Make a plot of the different approximations.

3) Change the time integrator. What happens if you use Euler? Explain.

4) Plot the errors using different resolutions and finite difference schemes.

5) By computing differences between approximations at different resolutions and using appropriate norms, determine the order of convergence of the method.

6) Generate an initial condition in the form of a pulse consisting of the highest-frequency wave supported by the grid, modulated with a smooth compactly supported peak. Observe how this pulse propagates. Estimate its velocity for the different finite difference operators implemented.

7) Implement the Burgers' equation, $\frac{\partial u}{\partial t} = - u \frac{\partial u}{\partial x}$, and evolve it. Describe what happens and explain.

8) For the ambitious:

a) Implement other equations; b) Add Kreiss–Oliger dissipation; c) Incorporate source terms; d) Try to optimize the numerical method to make it more efficient; e) Explore systems with different time scales; f) For the latter case, implement IMEX (implicit–explicit) time integration methods.

An example of a system with multiple time scales is:

\[ \begin{array}{rl} u_t &= v_x \\ v_t &= u_x + \dfrac{1}{\epsilon} (u_x - v) \end{array} \]

with $\epsilon > 0$ very small.