Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Math 270D: Programming Project 1

Due Date: Friday, February 14, 2003

In order to gain a feeling about the behavior of an algorithm, it is usually best to try it out on a series of
test problems. This series of test problems examine the behavior of an algorithm in the presence of shocks,
contact, expansion fans, sonic points, and smooth regions. To keep things simple, we shall assume periodic
boundary conditions on a domain (x, t) = [1, 1] (0, tmax ).
1. Find u(x, 28) where
u u
+
= 0,
t
x
u(x, 0) = sin(x).
Use 50 equally spaced grid points and = t/x = 0.8.
2. Find u(x, 4) where
u u
+
t
x

0,


1
0

for |x| < 13 ,


for 13 < |x| < 1.

= 0,

1
u(x, 0) =
0

for |x| < 13 ,


for 13 < |x| < 1.

u(x, 0) =
Use 50 equally spaced grid points and = 0.8.
3. Find u(x, 4) and u(x, 40) where
u u
+
t
x

Use 750 equally spaced grid points and = 0.8.


4. Find u(x, 0.64) where
u ( 12 u2 )
+
x
t

= 0,

1 for |x| < 13 ,
u(x, 0) =
0 for 13 < |x| < 1.

Use 50 equally spaced points and = 0.8.


5. Find u(x, 0.32) where
u ( 12 u2 )
+
t
x

u(x, 0)

0,


Use 50 equally spaced points and = 0.8.

1
1

for |x| < 13 ,


for 13 < |x| < 1.

Examine the behavior of the following algorithms on the above test problems by producing a plot of u
at the specified times for each of the test problems. (Note: for test problem 3, overlay u(x, 4) and u(x, 40)
on the same graph and please plot both the numerical result and the exact solution on the same graph.)
Succinctly discuss the properties of the algorithm (diffusion, dispersion, oscillatory behavior, accuracy,
etc . . . ). Feel free to perform a grid refinement study to see if an algorithm is living up to its stated
accuracy. Compare/constrast the algorithms in regards to performance, implementation cost, computational
complexity, use of artifical dissipation, treatment of sonic points, etc . . . Also, please email me a tarball or
zip file with the codes you used to calculate the results.
Remember: We will take the secant approximation to the wave speed a(u) = f 0 (u) on cell boundaries,
( f (un )f (un )
i+1
i
for uni 6= uni+1 ,
n
n
un
i+1 ui
ai+1/2 =
n
a(ui )
for uni = uni+1 .
Feel free to experiment with other combinations, say ani+1/2 = a(
The algorithms we wish to examine are:
1. Lax-Friedrichs

n
un
i+1 +ui
)
2

or ani+1/2 =

n
a(un
i+1 )+a(ui )
.
2

1
1 n
n
fi+1/2
= (f (uni+1 ) + f (uni ))
(u
uni )
2
2 i+1

2. Local Lax-Friedrichs
Excessive amounts of numerical dissipation is an issue with the Lax-Friedrichs scheme. One way to
reduce the dissipative nature of the Lax-Friedrichs scheme is to make the amount of numerical viscosity
used a locally determined quantity. The resulting method is usually called a local Lax-Friedrichs (LLF)
method, with a numerical flux function
1
1
n
fi+1/2
= (f (uni+1 ) + f (uni )) ni+1/2 (uni+1 uni ),
2
2
where
ni+1/2 = max(|a(uni )|, |a(uni+1 )|).
3. Lax-Wendroff
1
1
n
fi+1/2
= (f (uni+1 ) + f (uni )) (ani+1/2 )2 (uni+1 uni )
2
2
4. Godunov
n
fi+1/2
=

min n f (u) if uni uni+1 ,


un uu
i

i+1

max n f (u) if uni > uni+1


un uu
i

i+1

5. CIR/Generalized CIR
(a) Examine the performance of CIR on just test problems 1 and 2 with tmax = 28 for both problems.
Besides taking = 0.8, take = 10.0 and = 10.5. There is no need to solve to the exact end
time, plus or minus t is fine.
(b) One can generalize the CIR algorithm to nonlinear problems with the following numerical flux
function,

min(f (uni ), f (uni+1 )) if uni < uni+1 ,
n
fi+1/2
(uni , uni+1 ) =
max(f (uni ), f (uni+1 )) if uni > uni+1 .
This algorithm goes by a variety of names including GCIR, Murman-Cole, and Roes first-order
upwind method. One way to think about this algorithm is that the flux function has been replaced
by a locally linearized flux function, flinear (u) = ani+1/2 u + f (uni ). Why would this be useful?
2

6. Harten upwind scheme


The GCIR algorithm has a problem but it does possess certain computational advantages. Can we fix
GCIR in a way that maintains the computational advantages of the algorithm while at the same time
calculates the correct result? Ami Harten did by replacing the linear approximation with a locally
quadratic approximation to the flux function [1]. The resulting numerical flux function is:
1
1
n
fi+1/2
(uni , uni+1 ) = (f (uni+1 ) + f (uni )) ni+1/2 (uni+1 uni ),
2
2
where
ni+1/2

2
n
2
(an
i+1/2 ) +(i+1/2 )
n
2i+1/2
|ani+1/2 |

n
|ani+1/2 | < i+1/2
, a(uni ) 0, and a(uni+1 ) 0,

otherwise.

Quadratic interpolation involves three independent parameters, but we are only fitting the interpolant
n
through (uni , f (uni )) and (uni+1 , f (uni+1 )). Therefore, i+1/2
is a free parameter. By a truncation error
n
analysis of the flux function, Van Leer, Lee, and Powell [2] suggested the following form for i+1/2
,
n
i+1/2
= o (a(uni+1 ) a(uni )),

with 1 o 2. We will take o = 1.


7. Beam-Warming
In the quest for higher accuracy while maintaining the shock capturing properties of upwind methods,
Warming and Beam [3] proposed a second order accurate upwind method. The Beam-Warming method
for a(u) > 0 is

(3f (uni ) 4f (uni1 ) + f (uni2 ))


2
2
+ [ani1/2 (f (uni ) f (uni1 )) ani3/2 (f (uni1 ) f (uni2 ))].
2

un+1
= uni
i

One can write a similar scheme for a(u) < 0. Warming and Beam also stated a method to handle
the case when a(u) = 0. One way to derive this method is through a flux splitting approach. Flux
splitting is somewhat analogous to the wave splitting method discussed in class. By treating the flux
as f (u) = f + (u) + f (u), where df + /du 0 and df /du 0, we can utilize the previously described
Beam-Warming scheme for linear advection. The method we end up with is:

(3f + (uni ) 4f + (uni1 ) + f + (uni2 ))


2
2
+ n
+ n
+ [a+
(f + (uni ) f + (uni1 )) a+
i3/2 (f (ui1 ) f (ui2 ))]
2 i1/2

+ (3f (uni ) 4f (uni+1 ) + f (uni+2 ))


2
2
n
n
+ [ai+3/2 (f (uni+2 ) f (uni+1 )) a
i+1/2 (f (ui+1 ) f (ui ))],
2

un+1
= uni
i

where for Burgers equation,


f + (u) =

1
max(0, u)u
2

and

and

( f (un
a
i+1/2

f (u) =

n
i+1 )f (ui )
n
un
u
i
i+1
(f )0 (uni )

1
min(0, u)u,
2

uni 6= uni+1 ,
uni = uni+1 .

References
[1] Harten, A., High Resolution Schemes for Hyperbolic Conservation Laws, Journal of Computational
Physics, v. 49, 357-393 (1983).
[2] Van Leer, B., Lee, W.-T., and Powell, K.G., Sonic-Point Capturing, AIAA Paper 89-1945, (1989).
[3] Warming, R.F. and Beam, R.M., Upwind Second-Order Difference Schemes and Applications in Aerodynamic Flows, AIAA Journal, v. 14, 1241-1249 (1976).

You might also like