I encourage you to play around with the juptyer notebook for this lecture - you can copy the code with the this notebook button on the side of this page.
Warning
These notes are mainly a record of what we discussed and are not a substitute for attending the lectures and reading books! If anything is unclear/wrong, let me know and I will update the notes.
Assignment 6: You are looking at simple finite difference approximations to the linear transport equation u_t + c u_x = 0. You will see convergence under an assumption on the Courant number\sigma := c\frac{\tau}{h}.
Last time: Convergence of FTCS and BTCS finite difference methods for solving the heat equation u_t - \alpha^2 u_{xx} = 0. For FTCS, we saw that we have convergence when 0 \leq \mu \leq \frac{1}{2} where \mu := \tau (\frac{\alpha}{h})^2 is the diffusion number (and we get faster convergence when \mu = \frac16). Then, we saw that BTCS is unconditionally stable.
where c is the wave speed. (Note: because the equation is second order in time, we require two initial conditions).
Exercise 20.1 (Ignoring the initial and boundary conditions) show that u_0(x \pm c t) solve the \text{(wave)}. That is, the wave equation supports waves travelling in both directions.
20.2 Finite differences
We again consider a uniform mesh:
\begin{align}
x_i &= a + \frac{b-a}{m} i =: a + ih &&\text{for }i=0,\dots,m\nonumber\\
t_j &= \frac{T}{n} j =: j\tau &&\text{for }j=0,\dots,n
\end{align}
and aim to approximate u(x_i,t_j) \approx u_{ij}.
The simplest approximation we can think of is to replace the second derivatives with our usual centred difference:
We can impose the boundary conditions by setting u_{0,j} := g_a(t_j) and u_{m,j} := g_b(t_j).
Exercise 20.2 Write the above as a matrix equation for the numerical solution in the interior mesh points \{ u_{i,j+1} \}_{i=1}^{m-1}.
There is a slight problem here! In order to compute u_{i,j+1} we require the solution at the previous two time steps. In order to start the iteration we therefore need to have \{u_{i,0}\} and \{u_{i,1}\}. As we have done so far, we can set u_{i,0} := u_0(x_i) but we also need to specify \{u_{i,1}\}. We do this by using the other initial condition: u_t(x,0) = v_0(x).
Let u be the exact solution to the wave equation. Then, we have
[ Info: Saved animation to c:\Users\math5\Math 5485\Math5486\pics\wave-3.gif
21 Courant–Friedrichs–Lewy (CFL) condition
Exercise 21.1 Use the change of variables \xi(x,t) := x-ct and \eta(x,t) := x+ct to rewrite the wave equation \square u = 0 as u_{\xi\eta} = 0. Hence, prove the d’Alembert formula:
where \sigma := c\frac{\tau}{h}. What is the numerical domain of dependence at (x_i,t_j) of this method?
The Courant–Friedrichs–Lewy (CFL) condition states that, for a numerical method to converge, the exact domain of dependence must be contained in the numerical domain of dependence as h, \tau \to 0.
Exercise 21.4 Under what condition on \sigma does the numerical scheme satisfy the CFL condition?
Exercise 21.5 Does the CLF condition explain the instability of the method that we noticed above?
Exercise 21.6 Complete the von Neumann stability analysis to determine when the numerical scheme is stable.
Hint: Take u_{i,j-1} = e^{\mathrm{i}kx_i}, u_{i,j} =\lambda e^{\mathrm{i}kx_i}, and u_{i,j+1} =\lambda^2 e^{\mathrm{i}kx_i} and show that \lambda satisfies a quadratic equation giving \lambda = \alpha \pm \sqrt{\alpha^2 - 1}. Show that when \sigma satisfies the CFL condition then |\lambda|=1, and, when \sigma violates the CFL condition then one of the \lambda's has absolute value > 1.
In this case the CFL condition distinguishes between stable and unstable constants \sigma. This is not true in general - see A6.
21.1 Semi-discretisation
In this lecture we have treated time in the same way as space. Another approach is the so called method of lines:
Another general approach is semi-discretisation: we again take x_i := a + \frac{b-a}{m} i and h := \frac{b-a}{m} and now approximate \{u(x_i, t)\}_{i=0}^m with the (time-dependent) vector \bm u(t). (This is known as the semi-discretisation step because we have discretised in space but not time).
Then, if one is interested in solving the heat equation (u_t = \alpha^2 u_{xx}), we can replace this with
where D is a differentiation matrix approximating the second derivative in space. This is a linear, constant coefficient system of ODEs that we can solve directly using techniques from Chapter 1 (also see A2).
Exercise 21.7 Approximate the heat equation \square u := u_{tt} - c^2 u_{xx} = 0 with a linear system of ODEs using the method of lines.
Hint: you could define (i)u_t = y and y_t = c^2 u_{xx} or (ii)u_t = z_x and z_t = c^2 u_{x}. (Here, (ii) gives Maxwell’s equations).
21.2 sine-Gordon
We now look at numerical experiments for the sine-Gordon equation:
Burden, Richard L., Douglas J. Faires, and Annette M. Burden. 2015. Numerical Analysis. 10th ed. CENGAGE Learning.
Driscoll, Tobin A, and Richard J Braun. 2018. Fundamentals of Numerical Computation. https://fncbook.com/.
Olver, Peter J. 2014. Introduction to Partial Differential Equations. Undergraduate Texts in Mathematics. Cham: Springer. https://doi.org/10.1007/978-3-319-02099-0.
Suli, Endre, and David F Mayers. 2012. An Introduction to Numerical Analysis. Cambridge, England: Cambridge University Press.