Mandatory exercise 2 MAT-INF3360, Spring 2015

Mandatory exercise 2
MAT-INF3360, Spring 2015
March 10, 2015
Consider the initial-boundary value problem of the form

x ∈ (0, 1), t > 0,

 ut + a(x)ux = 0,
u(0, t) = g(t),
t > 0,


u(x, 0) = f (x),
x ∈ [0, 1].
(1)
where a is a continuous function of x, and f and g are given continuously
differentiable functions.
Problem 1. Assume that a is a positive constant. Use the method of characteristics to show that any solution of (1) satisfies
(
f (x − at) for x > at,
u(x, t) =
(2)
g(t − x/a) for x < at.
Give conditions on f and g at zero such that the the partial derivatives, ut and
ux , of the function u given by (2) are continuous.
Problem 2. Explain why the problem (1) in general has no solution when a < 0.
(Hint: Consider for example the case when a = −1, g(t) = 0 and f (x) > 0 for
x > 0.)
For the rest of the problems below we assume that a(x) ≥ 0. Let ∆t > 0 and
∆x = 1/(n + 1) where n is some natural number. Let tm = m∆t and xj = j∆x.
Consider the explicit finite difference method
m
vjm+1 − vjm
vjm − vj−1
+ a(xj )
= 0,
∆t
∆x
m ≥ 0, j = 1, 2, . . . , n + 1
(3)
with initial conditions vj0 = f (xj ) for j = 0, 1, . . . , n + 1 and v0m = g(tm ) for
m ≥ 1.
Problem 3. It follows immediatly from (2) that the exact solution given there
satisfies
|u(x, t)| ≤ max {|f (x)| , |g(τ )| : x ∈ [0, 1], τ ∈ [0, t]} .
(4)
1
Establish a similar bound on the solution {vjm } of (3) if the stability condition
a(xj )
∆t
≤ 1,
∆x
j = 1, 2, . . . , n + 1
(5)
holds.
Problem 4. Implement the scheme (3). Pick g(t) = 0, f (x) = x(1 − x) and
a(x) = 1. Make a surface plot of the solution for t ∈ [0, 1]. What happens if
you violate (5) slightly?
Problem 5. Consider the corresponding implicit finite difference method
m+1
vjm+1 − vj−1
vjm+1 − vjm
+ a(xj )
= 0,
∆t
∆x
m ≥ 0, j = 1, 2, . . . , n + 1
(6)
with initial conditions vj0 = f (xj ) for j = 0, 1, . . . , n + 1 and v0m = g(tm ) for
m ≥ 1. Show that the solution always satisfies a bound similar to (4), i.e., show
that the stability condition (5) is not necessary in this case.
Problem 6. Implement the implicit scheme (6). Investigate by a few examples if
the solution converges to the exact solution of problem (1) as ∆t and ∆x tends
to zero.
Consider the following related boundary value problem:
 ε
ε
ε
x ∈ (0, 1), t > 0,

 ut + a(x)ux = εuxx ,
ε
ε
u (0, t) = g(t), u (1, t) = h(t),
t > 0,

 ε
u (x, 0) = f (x),
x ∈ [0, 1].
(7)
where ε > 0 is a constant. The maximum principle implies that the solution of
this problem satisfies
|uε (x, t)| ≤ max {|f (x)| , |g(τ )| , |h(τ )| : x ∈ [0, 1], τ ∈ [0, t]} .
(8)
for all ε > 0. For problem (7) we consider first a finite difference scheme based
on central differences for the terms ux and uxx . More precisely, we consider the
scheme:
m+1
m+1
m+1
m+1
vjm+1 − vjm
vj+1
− vj−1
vj+1
− 2vjm+1 + vj−1
+ a(xj )
=ε
,
∆t
2∆x
∆x2
(9)
for m ≥ 0, j = 1, . . . , n. The boundary values are given by vj0 = f (xj ) for
m
j = 0, . . . , n + 1, v0m = g(tm ) for m ≥ 1 and vn+1
= h(tm ) for m ≥ 1.
Problem 7. Suppose h = g = 0. Let v m = (v1m , . . . , vnm ). Find a matrix A such
that the scheme (9) takes the form Av m+1 = v m for m ≥ 0.
2
Problem 8. Implement the scheme (9). Test out different values of ∆x, ∆t,
and ε. Illustrate by an example that for fixed ∆x and ∆t the solution of the
scheme will not satisfy the discrete maximum principle corresponding to (8) for
all ε > 0. (Hint: Check the case when ε is small.)
As an alternative to (9) we will consider an analog of (6), i.e., we will use a one
sided difference approximation of ux . This leads to the scheme:
m+1
m+1
m+1
vjm+1 − vj−1
vj+1
− 2vjm+1 + vj−1
vjm+1 − vjm
,
+ a(xj )
=ε
∆t
∆x
∆x2
(10)
for m ≥ 0, j = 1, . . . , n. The boundary values are given by vj0 = f (xj ) for
m
j = 0, . . . , n + 1, v0m = g(tm ) for m ≥ 1 and vn+1
= h(tm ) for m ≥ 1.
Problem 9. Suppose h = g = 0. Let v m = (v1m , . . . , vnm ). Find a matrix A such
that the scheme (10) takes the form Av m+1 = v m for m ≥ 0.
Problem 10. Implement the scheme (10). Test out different values of ∆x, ∆t,and
ε. Make an experiment comparable to the one above to check if the solution
of (10) satisfy the discrete analog of (8) uniformly in ε > 0. What is your
conclusion?
Problem 11. Prove that the solution of the scheme (10) satisfies a discrete analog
of the maximum principle (8). Furthermore, test by a numerical experiment if
the solution of (10) converges to the corresponding solution of (6) when ε tends
to zero. In other words, consider the case when ∆x and ∆t are fixed and let ε
tends to zero. Check in particular what happens near the boundary x = 1.
3