Docsity

Programming Assignment 2 - Numerical Analysis and Differential Equations | MATH 5543, Assignments of Mathematics

Toggle sidebar
bg1
Programming assignment 2
1. Write a program for solving the following problem with a periodic boundary condition:
ut+ux= 0 for x∈[0,1], t ∈[0, T ]
u(0, x) = sin(2πx) for x∈[0,1]
u(t, 0) = u(t, 1) for t∈[0, T ]
by the following finite difference schemes
(a) the forward-time backward-space(upwind) scheme;
(b) the Lax-Wendroff scheme.
Compute the error norm at the final time step tN:
Error =k−→
uN−−→
vNkhwhere uN
m=u(tN, xm) and vis the numerical solution.
Complete the following experiments for both schemes:
(1) Fix λ=k/h = 0.9 and T= 0.8, compute the error for h= 1/M,M= 40,50,60,··· ,200.
The error should be of order O(hr). Estimate rusing the data you have collected.
(2) The error also depends on the final time T. Now fix λ= 0.9, h= 1/100, compute the
error for several different values of T, and describe how the error depends on T.
(3) Repeat part (1) with λ= 0.6,0.7,0.8,0.95, and report the asymptotic order r. Is r
effected by λ?
(4) Repeat part (1) for the following initial conditions:
u(0, x) = (x x ≤0.5
1−x x > 0.5, u(0, x) = (0x≤0.25 or x > 0.75
1 0.25 < x ≤0.75
Report the asymptotic order r. Are they different from the result in part (1)?
(5) Set λ= 0.9 and h= 1/100. Plot the solution for initial condition
u(0, x) = (0x≤0.25 or x > 0.75
1 0.25 < x ≤0.75
at time t= 0.2,0.5,1,5,10. Describe the difference between solutions at different time,
and the difference between solutions of the two FD schemes.
2. From Assignment Problem 1(5), you may already observe that the Lax-Wendroff scheme
generates oscillations near discontinuities. This kind of oscillation occurs when schemes of
order greater than 1 are used and the solution has discontinuity (shocks). It will not disappear
even if you refine the grid. This oscillation arises because higher order schemes are not
monotonicity preserving (Godunov’s order barrier theorem).
Many techniques have been developed in order to eliminate the oscillation. One of them is to
use flux limiters. Here we consider the same problem as in Assignment Problem 1(5). Define
δ+fm=fm+1 −fm, δ−fm=fm−fm−1.
1
pf2

Partial preview of the text

Download Programming Assignment 2 - Numerical Analysis and Differential Equations | MATH 5543 and more Assignments Mathematics in PDF only on Docsity!

Programming assignment 2

  1. Write a program for solving the following problem with a periodic boundary condition:

 



ut + ux = 0 for x ∈ [0, 1], t ∈ [0, T ] u(0, x) = sin(2πx) for x ∈ [0, 1] u(t, 0) = u(t, 1) for t ∈ [0, T ]

by the following finite difference schemes

(a) the forward-time backward-space(upwind) scheme; (b) the Lax-Wendroff scheme.

Compute the error norm at the final time step tN :

Error = ‖−→u N^ − −→v N^ ‖h where uNm = u(tN , xm) and v is the numerical solution.

Complete the following experiments for both schemes:

(1) Fix λ = k/h = 0.9 and T = 0.8, compute the error for h = 1/M , M = 40, 50 , 60 , · · · , 200. The error should be of order O(hr). Estimate r using the data you have collected. (2) The error also depends on the final time T. Now fix λ = 0.9, h = 1/100, compute the error for several different values of T , and describe how the error depends on T. (3) Repeat part (1) with λ = 0. 6 , 0. 7 , 0. 8 , 0 .95, and report the asymptotic order r. Is r effected by λ? (4) Repeat part (1) for the following initial conditions:

u(0, x) =

x x ≤ 0. 5 1 − x x > 0. 5

, u(0, x) =

0 x ≤ 0 .25 or x > 0. 75 1 0. 25 < x ≤ 0. 75

Report the asymptotic order r. Are they different from the result in part (1)? (5) Set λ = 0.9 and h = 1/100. Plot the solution for initial condition

u(0, x) =

0 x ≤ 0 .25 or x > 0. 75 1 0. 25 < x ≤ 0. 75

at time t = 0. 2 , 0. 5 , 1 , 5 , 10. Describe the difference between solutions at different time, and the difference between solutions of the two FD schemes.

  1. From Assignment Problem 1(5), you may already observe that the Lax-Wendroff scheme generates oscillations near discontinuities. This kind of oscillation occurs when schemes of order greater than 1 are used and the solution has discontinuity (shocks). It will not disappear even if you refine the grid. This oscillation arises because higher order schemes are not monotonicity preserving (Godunov’s order barrier theorem). Many techniques have been developed in order to eliminate the oscillation. One of them is to use flux limiters. Here we consider the same problem as in Assignment Problem 1(5). Define

δ+fm = fm+1 − fm, δ−fm = fm − fm− 1.

In our example problem the wave speed is a = 1. Show that the Lax-Wendroff scheme (3.1.1) can be rewritten as

un m+1 = unm − λ(unm − unm− 1 ) − λ(1 − λ) 2

(unm+1 + unm− 1 − 2 unm)

= unm − λδ−

unm + 1 − λ 2 δ+unm

= unm − λδ−F (^) mn,

where

F (^) mn = unm + 1 − λ 2

δ+unm

is the so-called Lax-Wendroff flux. The idea of flux limiter is to substitute F (^) mn by

F˜ (^) mn = unm + φ(θnm)^1 −^ λ 2

δ+unm

where

θmn =

unm − unm− 1 unm+1 − unm

and φ(θ) can be chosen as the so-called Superbee limiter:

φ(θ) = max{ 0 , min{ 2 θ, 1 }, min{θ, 2 }}.

Use the new scheme un m+1 = unm − λδ− F˜ (^) mn to repeat Assignment Problem 1(5). Compare the solution with solutions from the upwind scheme and the original Lax-Wendroff scheme. Which one gives the best approximation to the discontinuous solution?

Extra reading about flux limiters:

[1] High Resolution Schemes Using Flux Limiters for Hyperbolic Conservation Laws, P. K. Sweby, SIAM Journal on Numerical Analysis, Vol. 21, No. 5. (Oct., 1984), pp. 995-1011. [2] http://en.wikipedia.org/wiki/Flux limiters