Problem 1: 1D Heat Equation - Dirichlet BC (30%)
Consider the following PDE:
ut = 0.5 · u xx ,
( x, t) ∈ [0, 1] × [0, T ]; (the heat equation)
u(0, t) = u(1, t) = 0, t ≥ 0; (boundary condition)
u( x, 0) = −2 sin(4πx ) + 5 sin(9πx ), x ∈ [0, 1]. (initial condition)
(1)
1.1. Find parameters D and ck (k = 1, . . . , n, . . . ) in the formula
∞
∑ ck e−k π Dt sin(kπx),
2 2
u( x, t) =
k =1
so that it represents the solution of (1) (check your answer!).
[5 marks]
1.2. Derive the Forward Differences (FD) explicit scheme for this problem.
[5 marks]
1.3. Define the space and time points x0 = 0, . . . , xm = 1 and t0 = 0, . . . , tn = n∆t = 1.
For a given m ≥ 2, find the values of n ensuring the stability of the method.
[5 marks]
1.4. For a fixed spatial resolution ∆x = 0.01, evaluate and compare results obtained
from Forward difference (FD), Backward differences (BD) and Crank-Nicholson (CN)
numerical schemes. Address the stability and precision of each method.
The analytical solution may be used as a benchmark.
[10 marks]
Hint: For calibration, you could use the graphs:
Figure 1: Numerical and analytical solution u( x, t) at t = 0.05 obtained for the step
values (a) ∆x = 0.1 and ∆t = 0.005 (left); (b) ∆x = 0.05 and ∆t = 0.001 (right).
1.5. Implement a FD scheme solving the problem with the boundary conditions:
u(0, t) = 20 sin 2023 t; u(1, t) = 3t, t ≥ 0.
[5 marks]
3
Problem 2: 1D Heat Equation - Neumann BC (20%)
Consider the following parabolic PDE:
ut = 0.25 · u xx ,
( x, t) ∈ [0, 1] × [0, T ]; (the heat equation)
u(0, t) = u x (1, t) = 0, t ≥ 0; (boundary condition)
u( x, 0) = 4 sin 2 x − 3 sin 7π
5π
2 x , x ∈ [0, 1]. (initial condition)
(2)
2.1. Find the distinct parameter values A, B, C, D, E in the equation below
Bt 5π
u( x, t) = Ae sin x + Ce Dt sin( Ex ),
2
so that it represents the solution of (2) (check your answer!).
[5 marks]
2.2. Write the Forward Difference (FD) formulae for this problem.
[5 marks]
2.3. Illustrate the accuracy and stability of the FD approximation.
[5 marks]
Hint: For calibration, you could use the graph:
Figure 2: Graph of u( x, t) obtained for ∆x = 0.02 and ∆t = 0.002 at t = 25∆t.
2.4. Discuss the absolute and relative error of the numerical method over the grid
defined by ∆x = 0.02 and ∆t = 0.002, for ( x, t) ∈ [0, 1] × [0, 25∆t].
[5 marks]
4
Problem 3: 2D Elliptic Equation (30%)
Consider the following Poisson Equation
u xx ( x, y) + uyy ( x, y) = g( x, y) = 2xy; (3)
( x, y) ∈ D (interior of the contour).
Figure 3: Elliptic Poisson problem with Dirichlet and Neumann BC on a domain D.
3.1. Consider the Dirichlet boundary conditions:
u( x, y) = 1 (on the top/right boundaries);
u(0, y) = y2 , u( x, 0) = x3 . (4)
Using finite differences and ∆x = ∆y = h = 0.2, the discrete vertical and horizontal
coordinates are x1 = 0, . . . , x6 = 1 and y1 = 0, . . . , y6 = 1.
The discretization of the Laplacian is:
ui−1,j + ui+1,j − 4ui,j + ui,j−1 + ui,j+1
(u xx + uyy ) x=xi ,y=y j = = gij = g( xi , y j ). (5)
h2
(a) Write the equations at the coordinates (i, j): (3, 2), (5, 2), (4, 3) and (2, 5).
[6 marks]
(b) Write the system (5) in matrix form.
You could use Au = b, u = (u22 , u32 , u42 , u52 , u23 , u33 , u43 , u24 , u34 , u25 ) T .
[6 marks]
(c) Solve the system for ui,j and plot your results.
[8 marks]
3.2. Solve equation (3) when the lower boundary is insulating:
uy ( x, 0) = 0. (6)
The domain, as well as the lower and upper boundaries are the same. Plot your results.
Hint: Update the system with the extra points u21 , u31 , u41 , u51 .
[10 marks]
5
Problem 4: 1D Hyperbolic Equation (20%)
2
∂ u ∂2 u
∂t 2 = 4 ∂x2
( x, t) ∈ [0, 1] × [0, T ]; (the wave equation)
u(0, t) = u(1, t) = 0; (boundary condition)
(7)
u( x, 0) = f ( x ) = 3 sin(πx ) − 4 sin3 (πx ); (initial condition 1)
∂u( x,0) = g( x ) = 0.
(initial condition 2)
∂t
4.1. Evaluate and discuss the analytical solution of the PDE (7).
[5 marks]
4.2. Solve the PDE numerically using a Forward Differences (FD) explicit scheme.
In what follows the spatial resolution is fixed to ∆x = 0.005.
(a) Write the FD iteration in matrix form and compute the eigenvalues of the matrix.
[2 marks]
(b) Find the maximum allowable time step ∆tr which ensures the stability of FD.
[3 marks]
(c) Illustrate the accuracy and stability of the numerical FD scheme.
[5 marks]
Hint: For calibration, you could use the graph below.
Figure 4: Solution u( x, t) obtained for ∆x = 0.005 and ∆t = ∆tr , evaluated at t = 0.1.
∂u
4.3. Solve (7) exactly and numerically if the second initial condition is ∂t ( x, 0)
= 3.
[5 marks]