pp1

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,t max ). 1. Find u(x, 28) where ∂u ∂t + ∂u ∂x = 0, u(x, 0) = - sin(πx). Use 50 equally spaced grid points and λ t/Δx =0.8. 2. Find u(x, 4) where ∂u ∂t + ∂u ∂x = 0, u(x, 0) = 1 for |x| < 1 3 , 0 for 1 3 < |x| < 1. Use 50 equally spaced grid points and λ =0.8. 3. Find u(x, 4) and u(x, 40) where ∂u ∂t + ∂u ∂x = 0, u(x, 0) = 1 for |x| < 1 3 , 0 for 1 3 < |x| < 1. Use 750 equally spaced grid points and λ =0.8. 4. Find u(x, 0.64) where ∂u ∂t + ( 1 2 u 2 ) ∂x = 0, u(x, 0) = 1 for |x| < 1 3 , 0 for 1 3 < |x| < 1. Use 50 equally spaced points and λ =0.8. 5. Find u(x, 0.32) where ∂u ∂t + ( 1 2 u 2 ) ∂x = 0, u(x, 0) = 1 for |x| < 1 3 , -1 for 1 3 < |x| < 1. Use 50 equally spaced points and λ =0.8. 1

Upload: jev

Post on 25-Sep-2015

212 views

Category:

Documents


0 download

DESCRIPTION

numerical solutions

TRANSCRIPT

  • Math 270D: Programming Project 1Due 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 oftest 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 periodicboundary conditions on a domain (x, t) = [1, 1] (0, tmax).

    1. Find u(x, 28) where

    u

    t+

    u

    x= 0,

    u(x, 0) = sin(pix).

    Use 50 equally spaced grid points and = t/x = 0.8.

    2. Find u(x, 4) where

    u

    t+

    u

    x= 0,

    u(x, 0) ={

    1 for |x| < 13 ,0 for 13 < |x| < 1.

    Use 50 equally spaced grid points and = 0.8.

    3. Find u(x, 4) and u(x, 40) where

    u

    t+

    u

    x= 0,

    u(x, 0) ={

    1 for |x| < 13 ,0 for 13 < |x| < 1.

    Use 750 equally spaced grid points and = 0.8.

    4. Find u(x, 0.64) where

    u

    t+

    ( 12u2)

    x= 0,

    u(x, 0) ={

    1 for |x| < 13 ,0 for 13 < |x| < 1.

    Use 50 equally spaced points and = 0.8.

    5. Find u(x, 0.32) where

    u

    t+

    ( 12u2)

    x= 0,

    u(x, 0) ={

    1 for |x| < 13 ,1 for 13 < |x| < 1.Use 50 equally spaced points and = 0.8.

    1

  • Examine the behavior of the following algorithms on the above test problems by producing a plot of uat 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 statedaccuracy. Compare/constrast the algorithms in regards to performance, implementation cost, computationalcomplexity, use of artifical dissipation, treatment of sonic points, etc . . . Also, please email me a tarball orzip file with the codes you used to calculate the results.

    Remember: We will take the secant approximation to the wave speed a(u) = f (u) on cell boundaries,

    ani+1/2 =

    {f(uni+1)f(uni )

    uni+1uni for uni 6= uni+1,

    a(uni ) for uni = u

    ni+1.

    Feel free to experiment with other combinations, say ani+1/2 = a(uni+1+u

    ni

    2 ) or ani+1/2 =

    a(uni+1)+a(uni )

    2 .The algorithms we wish to examine are:

    1. Lax-Friedrichsfni+1/2 =

    12(f(uni+1) + f(u

    ni ))

    12

    (uni+1 uni )

    2. Local Lax-FriedrichsExcessive amounts of numerical dissipation is an issue with the Lax-Friedrichs scheme. One way toreduce the dissipative nature of the Lax-Friedrichs scheme is to make the amount of numerical viscosityused a locally determined quantity. The resulting method is usually called a local Lax-Friedrichs (LLF)method, with a numerical flux function

    fni+1/2 =12(f(uni+1) + f(u

    ni ))

    12ni+1/2(u

    ni+1 uni ),

    whereni+1/2 = max(|a(uni )|, |a(uni+1)|).

    3. Lax-Wendroff

    fni+1/2 =12(f(uni+1) + f(u

    ni ))

    12(ani+1/2)

    2(uni+1 uni )

    4. Godunov

    fni+1/2 =

    min

    uni uuni+1f(u) if uni uni+1,

    maxuni uuni+1

    f(u) if uni > uni+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 endtime, plus or minus t is fine.

    (b) One can generalize the CIR algorithm to nonlinear problems with the following numerical fluxfunction,

    fni+1/2(uni , u

    ni+1) =

    {min(f(uni ), f(u

    ni+1)) if u

    ni < u

    ni+1,

    max(f(uni ), f(uni+1)) if u

    ni > u

    ni+1.

    This algorithm goes by a variety of names including GCIR, Murman-Cole, and Roes first-orderupwind method. One way to think about this algorithm is that the flux function has been replacedby a locally linearized flux function, flinear(u) = ani+1/2u+ f(u

    ni ). Why would this be useful?

    2

  • 6. Harten upwind schemeThe GCIR algorithm has a problem but it does possess certain computational advantages. Can we fixGCIR in a way that maintains the computational advantages of the algorithm while at the same timecalculates the correct result? Ami Harten did by replacing the linear approximation with a locallyquadratic approximation to the flux function [1]. The resulting numerical flux function is:

    fni+1/2(uni , u

    ni+1) =

    12(f(uni+1) + f(u

    ni ))

    12ni+1/2(u

    ni+1 uni ),

    where

    ni+1/2 =

    (ani+1/2)

    2+(ni+1/2)2

    2ni+1/2

    |ani+1/2| < ni+1/2, a(uni ) 0, and a(uni+1) 0,|ani+1/2| otherwise.

    Quadratic interpolation involves three independent parameters, but we are only fitting the interpolantthrough (uni , f(u

    ni )) and (u

    ni+1, f(u

    ni+1)). Therefore,

    ni+1/2 is a free parameter. By a truncation error

    analysis of the flux function, Van Leer, Lee, and Powell [2] suggested the following form for ni+1/2,

    ni+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 methodfor a(u) > 0 is

    un+1i = uni

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

    +2

    2[ani1/2(f(u

    ni ) f(uni1)) ani3/2(f(uni1) f(uni2))].

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

    un+1i = uni

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

    +2

    2[a+i1/2(f

    +(uni ) f+(uni1)) a+i3/2(f+(uni1) f+(uni2))]

    +

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

    +2

    2[ai+3/2(f

    (uni+2) f(uni+1)) ai+1/2(f(uni+1) f(uni ))],

    where for Burgers equation,

    f+(u) =12max(0, u)u and f(u) =

    12min(0, u)u,

    and

    ai+1/2 =

    {f(uni+1)f(uni )

    uni+1uni uni 6= uni+1,

    (f)(uni ) uni = u

    ni+1.

    3

  • References

    [1] Harten, A., High Resolution Schemes for Hyperbolic Conservation Laws, Journal of ComputationalPhysics, 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 Aero-dynamic Flows, AIAA Journal, v. 14, 1241-1249 (1976).

    4