You are on page 1of 3

EXERCISES THAT INVOLVE CODING AND USE OF MATLAB FOR

NUMERICAL INVESTIGATIONS

STEINAR EVJE

Exercise III: Coding related to ”3a-Project-Transport”.

The purpose is to modify the numerical scheme given in ”Case1A” and used to explore the
linear transport equation ut + ux = 0 such that it can compute numerical solutions of related
problems. Before you do the matlab exercise, take a look at the exercises below which deal
with the stability condition and are relevant for the matlab exercise.

(A) Compute numerical solution of the problem ut + xux = 0 (exercise 1.5c without
source term from ”2-Intro-PDE-TW”) with initial data u(x, t = 0) = cos(90x) on a
domain [−0.25, +0.25]. Compute solution at time T = 0.25 and include comparison
of numerical and analytical solution at final time.
a) First formulate a stable upwind based scheme for this advection equation. Note
the shift in sign of the velocity at x = 0. Implement this scheme by modifying
the matlab script for the simpler problem ut + ux = 0.
b) Start with a grid of 100 cells. How many time steps must be chosen to respect
the stability criterion for this problem(*)?
What can you say about the accuracy of the numerical scheme based on the
upwind approach?
c) How many grid cells must be used in order to capture well the exact (analytical)
solution?

(*) Note that the velocity is x in ut + xux = 0 and varies within the domain
[−0.25, 0.25], but it is always true that |x| ≤ 1 in [−0.25, 0.25] so that standard stability
∆t
condition ∆x ≤ 1 should work.

(B) Consider the linear transport equation ut +ux = 0 (studied in”3a-Project-Transport”).


Modify the code from ”Case1A” by extending the domain to be [−2, +2] with initial
data 
1, −0.25 ≤ x ≤ 0.25;
u(x, t = 0) =
0, otherwise.
Compute the solution after a time T = 1.0 and compare with exact solution.
a) What is the exact solution of this problem?
b) Start with a grid of 100 cells. What can you say about the accuracy of the
numerical scheme based on the upwind approach?
c) How many grid cells must be used in order to capture well the exact (analytical)
solution?

1
2 STEINAR EVJE

Three Related Exercises. The following exercises deal with extensions of the stability
criterion that was found for the upwind scheme for ut +ux = 0 with initial data and boundary
data defined by
u(x, t = 0) = u0 (x), u(x = 0, t) = u(x = 1, t) = 0.
The upwind scheme then takes the form:
∆t
un+1
j = unj − λ(unj − unj−1 ), j = 1, . . . , M, λ=
∆x
u0 = uM +1 = 0.
PM PM PM
It was found that 0 ≤ λ ≤ 1 would ensure that 1 |un+1
j |≤ 1 |unj | ≤ . . . ≤ 1 |u0j |.

Exercise 4.1. Consider the linear transport equation


ut − ux = 0, x ∈ (0, 1),
u(0, t) = u(1, t) = 0,
u(x, t = 0) = u0 (x).
a) Follow the approach used in ”3a-Project-Transport” and formulate a discrete scheme
based on an ”up-wind” formulation. Take into account that the flow now is from right
towards left.

b) Demonstrate that we can obtain an estimate of the form


M
X M
X
|unj | ≤ |u0j |.
j=1 j=1

∆t
What is the condition on λ = ∆x we must take into account in order to achieve this
estimate and ensure numerical stability?

Exercise 4.2. Consider the transport equation


ut + aux = 0, a ≥ 0 (a is constant), x ∈ (0, 1).
a) Formulate an upwind based scheme for this transport equation with initial and bound-
ary data as in Exercise I.

b) Demonstrate that we can obtain an estimate of the form


M
X M
X
|unj | ≤ |u0j |.
j=1 j=1

∆t
subject to the stability criterion aλ = a ∆x ≤ 1.
3

Exercise 4.3. Consider the transport equation


ut + a(x)ux = 0, a(x) ≥ 0, x ∈ (0, 1).
a) Formulate an upwind based scheme for this transport equation with initial and bound-
ary data as in Exercise I.

b) Demonstrate that we can obtain an estimate of the form


M
X M
X
|unj | ≤ |u0j |.
j=1 j=1
subject to the stability criterion
∆t
max a(x) · λ = max a(x) · ≤ 1.
[0,1] [0,1] ∆x
and a(x) is a decreasing (or non-increasing) function.

(c) More generally, if a(x) ≥ 0 we can obtain an estimate


M
X M
X
|unj | ≤ exp(KT ) |u0j |,
j=1 j=1

where max[0,1] |a0 (x)| ≤ K and T > 0 is final time. Can you demonstrate this?

Hint: Use that ln(1 + K) ≤ K for K > 0.

You might also like