Exercises
Exercises#
1. Conservative vs. non-conservative form:
Let’s consider a finite difference approximation to Burgers’ equation. For simplicity, let’s assume that \(u > 0\) always. We can discretize it to first-order accuracy using upwinding in conservation form:
\[\frac{u_i^{n+1} - u_i^n}{\Delta t} = \frac{1}{\Delta x} \left (\frac{1}{2} (u_i^n )^2 - \frac{1}{2} (u_{i-1}^n)^2 \right )\]
or in the original differential form as:
\[\frac{u_i^{n+1} - u_i^n}{\Delta t} = u_i^n \frac{u_i^n - u_{i-1}^n}{\Delta x}\]
Now consider the follow set of initial conditions:
\[\begin{split}u(x, t=0) = \left \{ \begin{array}{c} 2 & \mbox{if}~ x < 1/2 \\
1 & \mbox{if}~ x \ge 1/2 \end{array} \right .\end{split}\]
This will drive a rightward moving shock with a speed \(S = 3/2\).
Code up both of the above discretizations and measure the speed of the shock—which method gets it correct?