Sample solution to exercise set 3

Sample solution to exercise set 3
Numerical Methods for Hyperbolic Partial Differential Equations
D-MATH, FS-2015
Lecturer: Prof. Dr. Siddhartha Mishra
Problem 3.1
Gudonov scheme for Burgers’ equation
Consider Burgers’ equation in one dimension:
Ut + (U 2 /2)x = 0
(x, t) ∈ D × R+ ,
where D = (−1, 3) with the following initial conditions
(
1 if x < 0;
U (x, 0) =
0 otherwise
(
0 if x < 0;
U (x, 0) =
1 otherwise
(
1 if x ∈ (0, 1);
U (x, 0) =
0 otherwise
(1)
(2)
(3)
(4)
a) Write a finite volume MATLAB code for the Burgers equation (1) using the Godunov flux functions. Compute the numerical solution for the initial conditions (2), (3) and (4), using outflow boundary conditions.
Plot the solutions at appropiate time T (when the solution structure is well developed).
Solution. From the theory in the lecture notes, we know that the Godunov scheme is on the form
∆t n
n
Ujn+1 = Ujn −
Fj+1/2 − Fj−1/2
∆x
where Ujn is an approximation to the cell average of cell (i, n) and (at least in the case of the Burgers’
equation, by eq. (4.15))
n
n
n
Fj+1/2
= F (Ujn , Uj+1
) = max(f (max(Ujn , 0)), f (min(Uj+1
, 0))
(since the flux in the case of Burgers has a unique minimum at u = 0).
We write the following MATLAB program, see Figure 1
1
3
5
f u n c t i o n [ u , x ] = ex31 (N, T, u0 )
% Compute t h e s o l u t i o n t o t h e B u r g e r s e q u a t i o n a t time T
% u s i n g t h e Godunov f l u x
%
N t h e number o f s p a t i a l c e l l s t o u s e
%
T t h e f i n a l time .
%
u0 t h e i n i t i a l v a l u e
7
9
11
% This i s t h e B u r g e r s f l u x
f = @( u ) ( 0 . 5 ∗ u . ˆ 2 ) ;
% The d i f f e r e n t i a l o f t h e B u r g e r s f l u x
Df = @( u ) ( u ) ;
13
15
% The Gudonov f l u x
F = @(U, V) max( f (max(U, 0 ) ) , f ( min (V, 0 ) ) ) ;
17
19
% We a r e computing on t h e i n t e r v a l [ x1 , x2 ] :
x1 = 0 ;
x2 = 1 ;
21
1
23
% C r e a t e t h e g r i d , n o t i c e we w i l l u s e g h o s t c e l l s , s o we j u s t pad t h e
% x a r r a y a t both ends with t h e p r e v i o u s v a l u e .
x = [ x1 l i n s p a c e ( x1 , x2 , N) x2 ] ;
25
d e l t a X = x ( 3 )−x ( 2 ) ;
27
29
31
33
35
% Setup a r r a y t o s t o r e s o l u t i o n .
u = zeros ( size (x) ) ;
u P r e v i o u s = u0 ( x ) ;
% Need t o obey t h e CFL c o n d i t i o n :
% ( Note : This must be updated e v e r y t i m e s t e p ! )
% ( Note : We u s e max ( 1 , . . . ) t o e n s u r e we don ’ t d i v i d e by 0 ) .
d e l t a T = 0 . 5 ∗ d e l t a X / (max ( 1 , max( abs ( Df ( u P r e v i o u s ) ) ) ) ) ;
37
t = 0;
39
41
43
w h i l e t <= T
% Update t h e i n t e r n a l v a l u e s o f u
u ( 2 : end −1) = u P r e v i o u s ( 2 : end −1) . . .
− d e l t a T / d e l t a X ∗ (F( u P r e v i o u s ( 2 : end −1) , u P r e v i o u s ( 3 : end ) )
− F( u P r e v i o u s ( 1 : end −2) , u P r e v i o u s ( 2 : end −1) ) ) ;
45
47
% Update boundary with o u t f l o w
u ( end )=u ( 2 ) ;
u ( 1 )=u ( end −1) ;
49
51
% Find new CFL c o n d i t i o n
d e l t a T = 0 . 5 ∗ d e l t a X / (max ( 1 , max( abs ( Df ( u P r e v i o u s ) ) ) ) ) ;
53
% Update t h e c u r r e n t time
t = t + deltaT ;
55
57
uPrevious = u ;
59
end
ex31.m
2
...
(a) T = 0.8, N = 500, u0 (x) = 1(−∞,0] (x)
(b) T = 0.8, N = 500, u0 (x) = 1(0,∞) (x)
(c) T = 0.8, N = 500, u0 (x) = 1[0,1] (x)
Figure 1: Simulation results
3
b) Use the exact solution to calculate L1 (D) and L∞ (D) errors. Plot L1 (D) and L∞ (D) errors vs numbers
of cells (with number of cells 100, 200, 400, 800, 1600).
Solution. We know that the solution of (2) is a moving shock
(
1 x < 1/2t
u(x, t) =
0 otherwise.
and for (3) we get a rarefaction wave


x<0
0
u(x, t) = x/t 0 < x < t < 2 ,


1
otherwise.
and for (4) we get the solution from the previous exercise set (2.3d) that

0
x<0



x/t 0 < x < t
t<2
u(x, t) =

1
t < x < 1 + t/2



0
otherwise.
and the solution after t = 2 will be
t>2


0
u(x, t) = x/t


0
x<0
0 < x < (2t)1/2
otherwise.
We use the following code and obtain the figures shown in Figure 2.
2
f u n c t i o n ex31b ( u0 , u , T)
% Compute c o n v e r g e n c e r a t e s f o r
% time T
i n i t i a l data u0 and e x a c t s o l u t i o n u , a t
4
6
% These a r e t h e r e s o l u t i o n s we a r e g o i n g t o compute f o r
r e s o l u t i o n s = [ 1 0 0 200 400 800 1 6 0 0 ] ;
8
10
% W i l l i n t h e end c o n t a i n t h e e r r o r s f o r each r e s o l u t i o n
errorL1 = [ ] ;
errorLinf = [ ] ;
12
14
for resolution = resolutions
[ uApproximate , x ] = ex31 ( r e s o l u t i o n , T, u0 ) ;
16
dx = x ( 3 )−x ( 2 ) ;
18
e x a c t = u ( x , T) ;
20
e r r o r L 1 = [ e r r o r L 1 sum ( dx∗ abs ( uApproximate−e x a c t ) ) ] ;
22
e r r o r L i n f = [ e r r o r L i n f max( abs ( uApproximate−e x a c t ) ) ] ;
24
end
26
l o g l o g ( r e s o l u t i o n s , e r r o r L 1 , ’ b∗− ’ )
h o l d ( ’ on ’ )
l o g l o g ( r e s o l u t i o n s , e r r o r L i n f , ’ r .− ’ )
l e g e n d ( ’ L 1 ’ , ’ Lˆ\ i n f t y ’ ) ;
xlabel ( ’ resolution ’ ) ;
ylabel ( ’ error ’ ) ;
28
30
ex31b.m
we run this as
4
1
ex31b (@( x ) x <0 , @( x , t ) x < ( 0 . 5 . ∗ t ) , 1 ) % s h o c k
ex31b (@( x ) x >0 , @( x , t ) ( x>0) . ∗ ( x<t ) . ∗ ( x/ t ) + ( x>t ) , 1 ) % r a r e f a c t i o n
3
5
% L a s t one i s r a r e f a c t i o n and shock , where we assume t <2.
ex31b (@( x ) ( x>0) . ∗ ( x<1)
, @( x , t ) ( x>0) . ∗ ( x<t ) . ∗ ( x/ t ) + ( x>=t ) . ∗ ( x<1+t / 2 ) , 1 )
5
(a) T = 1, u0 (x) = 1(−∞,0] (x)
(b) T = 1, u0 (x) = 1(0,∞) (x)
(c) T = 1, u0 (x) = 1[0,1] (x)
Figure 2: Convergence results
6
Problem 3.2
Numerical experiments with fluxes
Consider the one-dimensional Burgers equation
Ut + (U 2 /2)x = 0
(x, t) ∈ D × R+ ,
here D = (−2, 3) (NOT the same as in previous exercise) for the following initial conditions:


−2 if x < 0;
U (x, 0) = 2
if 0 < x < 1;


0
if x > 1.
(5)
(6)
Use outflow boundary conditions.
a) Compute the numerical solution using the finite volume scheme with Godunov, Roe, Lax-Friedrichs,
Rusanov and Engquist-Osher fluxes. Use the Compack package or write your own MATLAB code.
Plot the solution at appropriate time T . Describe the results: what kind of waves are generated? Which
scheme produces the most accurate results, which fails?
Solution. We use the following two code pieces to generate the solution from Compack, the results are
shown in Figure 3. As we see, the Roe flux fails in this example, and the Lax-Friedrich flux produces a
smeared out result of the shock. We get a combination of a Rarefaction wave and a moving shock, and
after t = 1/2 these two will combine to form a rarefaction wave.
1
3
f u n c t i o n [ uApprox , mesh , r u n t i m e ] = e x 3 2 a s o l v e r ( s o l v e r T y p e , p l o t S o l u t i o n , r e s o l u t i o n )
%% S e t c o n f i g u r a t i o n s
conf = Configuration () ;
5
7
9
11
13
15
c o n f . model = Model . B u r g e r s ;
conf . s o l v e r = solverType ;
c o n f . t i m e I n t = @ T i m e I n t e g r a t i o n . FE ;
c o n f . tMax = 0 . 2 ;
c o n f . CFL = 0 . 4 ;
c o n f . bc = Mesh .BC. Neumann ;
c o n f . mesh = Mesh . C a r t e s i a n ( [ − 2 , 3 ] , r e s o l u t i o n ) ;
c o n f . i n i t i a l = @( x ) −2∗(x<0) + 2 ∗ ( x>0) . ∗ ( x<1) ;
17
19
21
%% Run s o l v e r
t i c ; % Start timer
soln = runSolver ( conf ) ;
r u n t i m e = t o c ; % end t i m e r
if
23
25
27
plotSolution
%% D i s p l a y data
Plot . p lo t So lu ti o n ( soln ) ;
end
[ t , U] = s o l n . g e t F i n a l ( ) ;
uApprox = c o n f . model . g e t V a r i a b l e ( s o l n , U, 1 ) ;
29
mesh = c o n f . mesh ;
31
end
ex32a solver.m
1
3
% L i s t o f s o l v e r s we w i l l run f o r
s o l v e r s = { Flux . B u r g e r s . Godunov , Flux . B u r g e r s . Roe , Flux . LaxFr , . . .
Flux . Rusanov , Flux . B u r g e r s . EngOsh } ;
5
7
f o r n=1: l e n g t h ( s o l v e r s )
e x 3 2 a s o l v e r ( s o l v e r s {n } , 1 , 1 0 0 ) ;
end
7
ex32a.m
8
(a) Godunov flux
(b) Roe flux
(c) Lax-Friedrich flux
(d) Rusanov flux
(e) Engquist-Osher flux
Figure 3: Plots for the Burgers’ equation with different numerical fluxes at T = 0.20 with 100 mesh points.
9
b) Plot L1 (D) and L∞ (D) errors versus numbers of cells and versus computational time. Which of the fluxes
is the most efficient?
Solution. We first find that the exact solution to this initial value problem (for t < 1/2) is given as

−2 x < −2t



x/t −2t < x < 2t < 1
u(x, t) =
(x, t) ∈ D × [0, 1/2).

2
2t ≤ x < t + 1



0
otherwise
We use the following two programs to generate the error convergence
1
3
5
7
function ex32b solver ( solver )
% Compute c o n v e r g e n c e r a t e with t h e g i v e n s o l v e r a t time T=0.2
T = 0.2;
% Our c o m p u t a t i o n a l domain [ a , b ]
a = −2;
b = 3;
9
11
% These a r e t h e r e s o l u t i o n s we a r e g o i n g t o compute f o r
r e s o l u t i o n s = [ 1 0 0 200 400 800 1 6 0 0 ] ;
13
15
% Exact s o l u t i o n , a s computed by hand f o r t <0.5
u = @( x , t ) −2 ∗ ( x<−2∗t ) + ( x . / t ) . ∗ ( x>=−2∗t ) . ∗ ( x<2∗ t ) + 2 ∗ ( x>= 2∗ t ) . ∗ ( x<t +1) ;
17
19
% W i l l i n t h e end c o n t a i n t h e e r r o r s f o r each r e s o l u t i o n
errorL1 = [ ] ;
errorLinf = [ ] ;
21
23
25
% W i l l a t t h e end c o n t a i n t h e run t i m e s
runTimes = [ ] ;
for resolution = resolutions
[ uApproximate , mesh , runTime ] = e x 3 2 a s o l v e r ( s o l v e r , 0 , r e s o l u t i o n ) ;
27
dx = ( b−a ) / r e s o l u t i o n ;
29
% We f i r s t u s e t h e b u i l t i n f u n c t i o n e va lF unc t o e v a l u a t e t h e e x a c t
% s o l u t i o n on t h e mesh , then we remove t h e e x t r a g h o s t c e l l s . Both
% o f t h e s e f u n c t i o n s a r e a p a r t o f Compack
e x a c t = mesh . r e m o v e G h o s t C e l l s ( mesh . eva lF un c (@( x ) u ( x , T) , 1 ) ) ;
31
33
e r r o r L 1 = [ e r r o r L 1 sum ( dx∗ abs ( uApproximate−e x a c t ) ) ] ;
35
e r r o r L i n f = [ e r r o r L i n f max( abs ( uApproximate−e x a c t ) ) ] ;
37
runTimes = [ runTimes runTime ] ;
39
end
41
l o g l o g ( r e s o l u t i o n s , e r r o r L 1 , ’ b∗− ’ )
h o l d ( ’ on ’ )
l o g l o g ( r e s o l u t i o n s , e r r o r L i n f , ’ r .− ’ )
l e g e n d ( ’ L 1 ’ , ’ Lˆ\ i n f t y ’ ) ;
xlabel ( ’ resolution ’ ) ;
ylabel ( ’ error ’ ) ;
t i t l e ( s o l v e r . name )
43
45
47
49
% For o p t i o n a l fun , we d e t e r m i n e t h e c o n v e r g e n c e r a t e
p o l y f i t ( log ( r e s o l u t i o n s ) , log ( errorL1 ) , 1)
51
53
55
57
figure ()
l o g l o g ( runTimes , e r r o r L 1 , ’ b∗− ’ )
h o l d ( ’ on ’ )
l o g l o g ( runTimes , e r r o r L i n f , ’ r .− ’ )
l e g e n d ( ’ L 1 ’ , ’ Lˆ\ i n f t y ’ ) ;
10
59
x l a b e l ( ’ ru n t i m e ’ ) ;
ylabel ( ’ error ’ ) ;
t i t l e ( s o l v e r . name )
ex32b solver.m
2
4
6
8
% L i s t o f s o l v e r s we w i l l run f o r
s o l v e r s = { Flux . B u r g e r s . Godunov , Flux . B u r g e r s . Roe , Flux . LaxFr , . . .
Flux . Rusanov , Flux . B u r g e r s . EngOsh } ;
f o r n=1: l e n g t h ( s o l v e r s )
figure ()
e x 3 2 b s o l v e r ( s o l v e r s {n } ) ;
end
ex32b.m
and get the plots in figure Figure 4 and Figure 5
11
(a) Godunov flux
(b) Roe flux
(c) Lax-Friedrich flux
(d) Rusanov flux
(e) Engquist-Osher flux
Figure 4: Convergence plots for the Burgers’ equation with different numerical fluxes at T = 0.20.
12
(a) Godunov flux
(b) Roe flux
(c) Lax-Friedrich flux
(d) Rusanov flux
(e) Engquist-Osher flux
Figure 5: Convergence plots vs runtime for the Burgers’ equation with different numerical fluxes at T = 0.20.
13
Problem 3.3
Non-convex flux
Consider the nonlinear scalar conservation law
(x, t) ∈ D × R+ ,
Ut + f (U )x = 0
(7)
in the domain D = (−3, 3), with the Buckley-Leverett flux function
f (U ) =
U2
U 2 + (1 − U )2
for the following initial conditions:
(
U0 (x) =
0.1 if x < 0;
0.9 if x > 0.
(8)
Boundary conditions: Outflow.
a) Using the finite volume scheme for the equation (7) with the Godunov, Roe, Lax-Friedrichs, Rusanov and
Engquist-Osher numerical flux functions, compute the numerical solution for the given initial conditions.
Plot the solutions at different times to illustrate the development of compound waves. Describe your
results. You may use the Compack package for this.
Solution. We will make our implementation in Compack. First we create the new model class to define
the flux:
1
c l a s s d e f B u c k l e y L e v e r e t t < Model . ModelBase
%Flux f o r E x e r c i s e 3 . 3
3
5
p r o p e r t i e s ( SetAccess = private )
name = ’ B u c k l e y L e v e r e t t ’
nelem = 1
7
end
9
11
13
methods
f u n c t i o n r e t = f ( obj , U, d )
% Evaluate f
r e t = U. ˆ 2 . / (U.ˆ2+(1 −U) . ˆ 2 ) ;
end
15
f u n c t i o n r e t = d f ( obj , U, d )
% This w i l l compute t h e d e r i v a t i v e o f f ,
% i t w i l l make our l i v e s e a s i e r
r e t = ( 2 ∗U . ∗ ( ( U.ˆ2+(1 −U) . ˆ 2 ) )−U. ˆ 2 . ∗ ( 2 ∗ U−2∗(1−U) ) ) . / ( ( U.ˆ2+(1 −U. ˆ 2 ) ) . ˆ 2 ) ;
end
17
19
21
end
methods ( A c c e s s=p r o t e c t e d )
f u n c t i o n r e t = maxEigRect ( obj , U, d )
% In the s c a l a r case , t h i s should r e t u r n the a b s o l u t e
% value of the d i f f e r e n t i a l of the f l u x f u n c t i o n
23
25
27
r e t = abs ( 2 ∗ (U−1) . ∗U. / ( 2 ∗U.ˆ2 −2∗U+1) . ˆ 2 ) ;
29
d i s p ( s p r i n t f ( ’%f \n ’ , max( r e t ) ) ) ;
31
end
33
35
37
end
end
BuckleyLeverett.m
We make the following program to test all the different numerical fluxes:
14
1
3
f u n c t i o n e x 3 3 a s o l v e r ( solverType , r e s o l u t i o n )
%% S e t c o n f i g u r a t i o n s
conf = Configuration () ;
5
7
9
11
13
15
c o n f . model = B u c k l e y L e v e r e t t ;
conf . s o l v e r = solverType ;
c o n f . t i m e I n t = @ T i m e I n t e g r a t i o n . FE ;
c o n f . tMax = 0 . 8 ;
c o n f . CFL = 0 . 2 ;
c o n f . bc = Mesh .BC. Neumann ;
c o n f . mesh = Mesh . C a r t e s i a n ( [ − 3 , 3 ] , r e s o l u t i o n ) ;
c o n f . i n i t i a l = @( x ) 0 . 1 ∗ ( x<0) + . 9 ∗ ( x>=0) ;
17
19
%% Run s o l v e r
soln = runSolver ( conf ) ;
21
Plot . p lo t So lu ti on ( soln ) ;
23
end
ex33a solver.m
Compack has a standard implementation for Lax-Friedrich numerical flux, and the Rusanov flux, which
means that they will work out of the box for this non-convex flux.
Godunov
For the Godunov scheme,
n
Fj+1/2
=F
n
Ujn , Uj+1
=


min n f (θ)
U n ≤θ≤U
n
if Ujn ≤ Uj+1

f (θ)
U n max
≤θ≤U n
n
if Uj+1
≤ Ujn .
j
j+1
j+1
j
we note that the flux implemented in Compack for Burgers’ equation:
2
4
6
8
10
12
c l a s s d e f Godunov < Flux . NumFlux
%GODUNOV
Godunov f l u x f o r Burgers ’ e q u a t i o n
properties
name = ’ Godunov ’
end
methods
f u n c t i o n r e t = F( obj , d , Ul , Ur , v a r a r g i n )
r e t = max( o b j . f (max( Ul , 0 ) , d ) , o b j . f ( min ( Ur , 0 ) , d ) ) ;
end
end
end
BurgersGodunov.m
relies on Exercise 4.1 in the notes:
Exercise 4.1
Computing the flux (9) can be complicated, since an optimization problem has to be
solved. Show that in the special case where the flux function f has a single minimum at
the point ω and no local maxima,
the formula (9) can be simplified to
,
n
n
n
n
n
Fj+1/2 = F (Uj , Uj+1 ) = max f max Uj , ω , f min Uj+1 , ω
.
Note that strictly convex functions have this property. The formulas for the case of a flux
with a single maximum and no minima are obtained analogously.
15
(9)
Figure 6: The non-convex flux f . Notice that it has a local maxima at 1, but that within the region [0.1, 0.9]
we have no local maxima.0
where the minima of the flux for Burgers is at 0. However, our flux function does have a local maxima
at 1 (see Figure 6). However, notice that our initial data is in the interval [0.1, 0.9], so we know that the
solution should be within [0.1, 0.9] for the standard L∞ bounds for entropy solutions (Thm 3.9). Hence
we may use exercise 4.1 directly, and hence the Godunov flux for Burgers equation. 1
1 One could also argue physically that the Buckeley-Leverett flux represents some sort of concentration, and hence the values
must be within [0, 1].
16
Roe
The Roe numerical flux is given as
(
n
Fj+1/2
=F
Roe
n
Ujn , Uj+1
where
=
f (Ujn )
n
f (Uj+1
)
( f (U n
Âj+1/2 =
n
j+1 )−f (Uj )
n
n
Uj+1 −Uj
f 0 (Ujn )
if Âj+1/2 ≥ 0
if Âj+1/2 < 0.
(10)
n
if Uj+1
6= Ujn
n
if Uj+1
= Ujn .
here we implement this into Compack in the following way:
1
c l a s s d e f B u c k l e y L e v e r e t t R o e < Flux . NumFlux
%ROE
Roe f l u x f o r t h e B u c k l e y L e v e r e t t f l u x i n ex . 3 . 3 a
3
5
properties
name = ’ B u c k l e y L e v e r e t t R o e ’
end
7
9
11
13
15
methods
f u n c t i o n r e t = F( obj , d , Ul , Ur , v a r a r g i n )
% F i r s t we must compute A:
i f Ul == Ur
A = o b j . d f ( Ul , d ) ;
else
A = ( o b j . f ( Ur , d ) − o b j . f ( Ul , d ) ) / ( Ur − Ul ) ;
end
% Then we have t h e two c a s e s we must c h e c k .
i f A >= 0
r e t = o b j . f ( Ul , d ) ;
else
r e t = o b j . f ( Ur , d ) ;
end
17
19
21
23
25
end
end
end
BuckleyLeverettRoe.m
Engquist-Osher
The Engquist-Osher scheme is given as
n
n
Fj+1/2
= F EO Ujn , Uj+1
n
f (Ujn ) + f (Uj+1
)
1
=
−
2
2
Z
n
Uj+1
|f 0 (θ)| dθ.
(11)
Ujn
Now, we can use the simplified version in eq. (4.35) in the notes, which reads
n
n
F EO Ujn , Uj+1
= f + Ujn + f − Uj+1
.
as for our initial data f has only a single minima and no local maxima A quick look at the implementation
for Burgers’ in Compack, we see that it also uses this form, so we may use this implementation.
We use the following program to run all the fluxes and get the output in Figure 7. Notice that we get a
compound wave structure, with a shock followed by a rarefaction wave.
17
(a) Godunov flux
(b) Roe flux
(c) Lax-Friedrich flux
(d) Rusanov flux
(e) Engquist-Osher flux
Figure 7: Plots for the Godunov flux with different numerical fluxes at T = 0.20.
18
b) Prove that if the flux function f is monotone on some interval [UL , UR ] then the Godunov, Roe and
Engquist-Osher numerical flux approximations are equivalent.
Solution. For the rest of the argument, we assume f is non-decreasing, the other case is treated in a
similar fashion.
First we look at the Godunov scheme. If f is monotone, then again we may appeal to exercise 4.1 to see
that the numerical flux is given as
FG = F (UL , UR ) = max f (max (UL , ω)) , f (min (UR , ω)) .
If UL > UR , then also UL ≥ ω (since f (UR ) ≤ f (UL )), and we are left with
FG = f (UL )
if UR > UL , then UR > ω, so min(UR , ω) = ω, and since ω is the minima for f , we know that f (UL ) ≥ f (ω)
and we are left with
FG = f (UL )
also in this case.
The Roe numerical flux is given as
(
FRoe = F Roe UL , UR ) =
where
(
Âj+1/2 =
f (UL ) if Âj+1/2 ≥ 0
f (UR ) if Âj+1/2 < 0.
f (UR )−f (UL )
UR −UL
f 0 (UL )
(12)
if UR 6= UL
if UR = UL .
If UL = UR , then Âj+1/2 = f 0 (UL ), and since f was non-decreasing, we know that Âj+1/2 ≥ 0, hence we
get
FRoe = f (UL )
(UL )
Otherwise Âj+1/2 = f (UURR)−f
≥ 0 since f is non-decreasing (either UL > UR , then one gets a negative
−UL
sign in both part of the fraction, hence positive, or UR > UL in which case both parts are positive), and
we are again left with
FRoe = f (UL ).
For Engquist-Osher, the scheme is given as
F EO UL , UR = f (max (UL , ω)) + f (min (UR , ω)) − f (ω).
Assume UL ≤ UR , then ω = UL (since it will be a minima), and
F EO UL , UR = f (max (UL , ω)) + f (min (UR , ω)) − f (ω) = f (ω) + f (ω) − f (ω) = f (ω) = f (UL ).
and similarly if UR < UL we have that UR = ω, and
F EO UL , UR = f (max (UL , ω)) + f (min (UR , ω)) − f (ω) = f (UL ) + f (ω) − f (ω) = f (UL ).
So all the numerical fluxes reduces to the same value, and that was what we wanted.
Problem 3.4
Monotonicity
State (with proof) which of the following fluxes are monotone
1. Lax-Friedrich
2. Engquist-Osher
19
3. Roe
for the conservation law
(x, t) ∈ R × R+
ut + f (u)x = 0
assuming the CFL condition
∆t
≤ 1.
∆x
The Lax-Friedrich flux is given as
max |f 0 (u)|
Solution. Lax-Friedrich:
n
f (Ujn ) + f (Uj+1
)
∆x
n
n
−
U n − Ujn .
Fj+1/2
= F LxF Ujn , Uj+1
=
2
2∆t j+1
Differentiating, we find
∂F LxF
f 0 (a)
∆x
(a, b) =
+
,
∂x1
2
2∆t
and
∂F LxF
f 0 (b)
∆x
(a, b) =
−
.
∂x1
2
2∆t
Inserting into the requirements (??), we have
0
f (b)
∂F
∆x ∂x1 (b, c) = 2 + 2∆t now, assume f 0 (b) ≥ 0, the case for f 0 (b) < 0 is treated in a similar way, hence
0
∂F
f (b)
∆x f 0 (b)
∆x
∂x1 (b, c) = 2 + 2∆t = 2 + 2∆t
for the second term, we first see that by the CFL assumption
max |f 0 (u)|
∆t
∆x
≤ 1 ⇔ max |f 0 (u)| ≤
∆x
∆t
so in particular, f 0 (b) ≤ ∆x/∆t, hence
0
0
∂F
f (b)
∆x f (b)
∆x
−
∂x2 (a, b) = 2 − 2∆t = −
2
2∆t
adding the two together, we get
∂F
∂F
∆x
∂x1 (b, c) + ∂x2 (a, b) = ∆t
which was what we wanted.
Now we have to show that
We will show that
∂F
∂x1
≥ 0 and
a 7→ F (a, b)
is non-decreasing for fixed b,
b 7→ F (a, b)
is non-increasing for fixed a,
∂F
∂x2
≤ 0. We compute
∆t
∂F
= f 0 (a)/2 +
∂x1
2∆x
If f 0 (a) ≥ 0 then we are done, otherwise the CFL condition implies that
−f 0 (a) = |f 0 (a)| ≤
∆t
2∆x
hence we get
f 0 (a)/2 +
∆t
≥ 0.
2∆x
20
(13)
∂F
is treated similarly.
The case for ∂x
2
Engquist-Osher: The Engquist-Osher flux is given as
n
n
Fj+1/2
= F EO Ujn , Uj+1
=
and
n
Uj+1
(14)
|f 0 (θ)| dθ.
Ujn
∂F EO
(a, b) = f 0 (b)/2 − |f 0 (b)|/2
∂x1
To see that
∂F
∂x1
Z
∂F EO
(a, b) = f 0 (a)/2 + |f 0 (a)|/2
∂x1
and
EO
n
f (Ujn ) + f (Uj+1
)
1
−
2
2
∂F EO
∂x1 (a, b)
≥ 0, observe that if f 0 (a) ≥ 0, then this clearly holds, otherwise |f 0 (a)| = −f 0 (a) so
(a, b) = 0. Again, the case for
∂F EO
∂x2 (a, b)
is treated in a similar way. To see that (??) holds, we get:
∂F
∂F
0
0
0
0
∂x1 (b, c) + ∂x2 (a, b) = |f (a)/2 + |f (a)|/2| + |f (a)/2 − |f (a)|/2|.
Now, notice that in the above expression, only one of the terms will be non-zero for a fixed a (if f 0 (a) ≥ 0, then
the second term vanishes, otherwise the first term vanishes). So we are left with
|f 0 (a)/2 + |f 0 (a)|/2| + |f 0 (a)/2 − |f 0 (a)|/2| ≤ |f 0 (a)| ≤
∆t
∆x
Roe Here the Roe scheme is given as
( f (U n
Âj+1/2 =
n
j+1 )−f (Uj )
n −U n
Uj+1
j
f 0 (Ujn )
and
n
n
Fj+1/2
= F Roe Ujn , Uj+1
n
if Uj+1
6= Ujn
n
if Uj+1
= Ujn .
(
f (Ujn )
=
n
f (Uj+1
)
if Âj+1/2 ≥ 0
if Âj+1/2 < 0.
(15)
(16)
and the update function is given as
H(a, b, c) = b −
∆t Roe
(F
(b, c) − F Roe (a, b)).
∆x
Recall that a scheme is monotone if H is non-decreasing in each of its arguments. To see that this in general is
not non-decreasing, let f (u) = u2 /2, and let 0 > a > b > c, then A(b, c) > 0 and A(a, b) > 0 so
∂F Roe
(b, c) = f 0 (b) = b
∂x1
and
So
∂F Roe
(a, b) = f 0 (b) = b
∂x2
∂H
(a, b, c) < 0
∂c
hence not non-decreasing in c.
21