Description
2. Consider the advection equation:
∂tu + a∂xu = 0, −∞ < x < ∞, t > 0 and u(x, 0) = u0(x), (1)
with a > 0 a constant.
Discretize the x-t plane by choosing a mesh width ∆x and time step
∆t and define the discrete mesh points (xj , tn) by
xj = j∆x, j = …, −1, 0, 1, 2, … and tn = n∆t, n = 0, 1, 2, …
(a) (2 points) Show that the following difference scheme is not stable:
U
n+1
j − U
n
j
∆t
+ a
U
n
j+1 − U
n
j−1
2∆x
= 0. (2)
We will now derive a stable scheme.
(b) (1 point) From (1) it is clear that ∂tu = −a∂xu. Show that ∂ttu = a
2∂xxu.
(c) (2 points) Using the Taylor series expansion of u(x, t + ∆t) around t and question (b),
show that
u(x, t + ∆t) = u(x, t) − ∆ta∂xu(x, t) + 1
2
(∆t)
2
a
2
∂xxu(x, t) + h.o.t. (3)
(h.o.t = higher order terms).
(d) (2 points) Approximating the x-derivatives in (3) by central differences, show that we
obtain the following finite difference scheme:
U
n+1
j = U
n
j −
∆t
2∆x
a
U
n
j+1 − U
n
j−1
+
∆t
2
2∆x
2
a
2
U
n
j+1 − 2U
n
j + U
n
j−1
. (4)
(e) (3 points) Define ν = a∆t/∆x. Using Fourier analysis, find the amplification factor.
Under what condition on ν is the finite difference scheme (4) stable?
(over)
3. Given is the following problem:
∂tu = ∂x (a(x)∂xu), u(0, t) = 0, u(1, t) = 0, u(x, 0) = u0(x), where a(x) > 0. (5)
(a) (2 points) Find the finite difference scheme for (5) using the θ-method in time. You
may use that central differences in space for the ∂x (a(x)∂xu) term is given by
∂x (a(x)∂xu) ≈
aj+1/2
(Uj+1 − Uj ) − aj−1/2
(Uj − Uj−1)
(∆x)
2
. (6)
where aj+1/2 = a(xj+1/2
) and xj+1/2 =
1
2
(xj + xj+1).
(b) (2 points) Show that the maximum principle is satisfied if
2∆t(1 − θ) max
x∈[0,1]
a(x) ≤ (∆x)
2
.
(c) (5 points) Show that (6) is a consistent discretization of ∂x (a(x)∂xu).
4. (4 points) Let 0 < x < 1 and 0 < t < TF and consider the following mixed initial-boundary
value problem:
∂tu = 2∂xxu, u(0, t) = u(1, t) = 1, u(x, 0) = f(x), (7)
where f(x) = 2 if x = 0.5 and f(x) = 1 otherwise.
Suppose the mesh points are chosen to
satisfy
0 = x0 < x1 < x2 < … < xJ−1 < xJ = 1
where xj − xj−1 = ∆x for all j = 1, 2, …, J. Implement the θ-method for problem (7). To
solve the implicit system you need to solve a matrix system of the form AUn+1 = F. Write
down the matrix A and vector F.
Now compute a solution using θ =
1
2
and J = 10. Make two
plots: in the first plot plot the solution at all computed time levels between 0 and TF = 0.07
using ∆t = ∆x
2
(so plot the solution at t = 0, t = ∆t, t = 2∆t, …, t = TF ); in the second plot,
do the same but use ∆t = 0.5∆x
2
.
Explain the difference in solution.
(over)
3
5. Being able to capture boundary layer effects in fluid dynamics is very important and the grid
plays an important role in being able to capture these effects.
Let 0 < x < 1 and 0 < t < 10 and consider the following advection-diffusion problem:
∂tu + ∂xu −
1
Re
∂xxu = 0, (8)
where Re is the Reynolds number. Consider the following boundary conditions u(0, t) = 1
and u(1, t) = 0 and initial condition u(x, 0) = 1 − x. The exact steady-state solution to this
problem is given by
u(x) = exp(Re) − exp(Re x)
exp(Re) − 1
. (9)
To discretize (8), we first use a uniform grid, where
xi = (i − 1)∆x, i = 1, 2, …, N + 1, (10)
where ∆x = 1/N. As finite difference method, we use, for i = 2, 3, …, N,
U
n+1
i = U
n
i −
∆t
∆x
U
n
i − U
n
i−1
+
1
Re
∆t
∆x
2
U
n
i+1 − 2U
n
i + U
n
i−1
, (11)
(a) (5 points) Take Re = 40. Implement the finite difference discretization (11). For this,
take N = 64 and ∆t small enough such that your scheme is stable. In one figure, plot
the exact steady solution given by (9) and the numerical approximation at time t = 10.
At t = 10, compute the error E = maxi=1,…,N |Ui − u(xi)|. Compute this error also
when N = 128. Based on these two errors, what would you say is the order of the finite
difference method given by (11)?
We will now compute the solution on the following non-uniform grid:
xi =
(
2(1 − c)(i − 1)/N, for i = 1, 2, …, N/2 + 1,
1 − c +
2c(i−1−N/2)
N
, for i = N/2 + 1, N/2 + 2, …, N + 1,
(12)
where c = (2/Re) ln(N).
The reason to use this non-uniform grid is that for high Reynolds
numbers Re the solution rapidly changes in a small neighbourhood of the point x = 1. This
non-uniform grid captures these changes better than a uniform grid.
A finite difference approximation to (8), on the non-uniform grid (12), is given by
U
n+1
i = U
n
i −
∆t
∆xi
U
n
i − U
n
i−1
+
1
Re
∆t
∆xi+1
U
n
i+1 − U
n
i
∆xi+1
−
U
n
i − U
n
i−1
∆xi
, (13)
for i = 2, 3, …, N, and where ∆xi = xi − xi−1.
(b) (3 points) Take Re = 40. Implement the finite difference discretization (13). For this,
take N = 64 and ∆t small enough such that your scheme is stable. In one figure, plot
the exact steady solution given in part (a) and the numerical approximation at time
t = 10.
At t = 10, compute the error E = maxi=1,…,N |Ui − u(xi)|. Compute this error
also when N = 128. Based on these two errors, what would you say is the order of the
finite difference method given by (13)?
(c) (1 point) Now take Re = 1000. In the same figure, plot the solution computed on
the uniform grid and the solution on the non-uniform grid. Use N = 64. Explain the
difference.