CS520: Discontinuous solutions (Ch. 10)ascher/520/chapt10.pdf · 2014. 10. 15. · Discontinuous...

21

Transcript of CS520: Discontinuous solutions (Ch. 10)ascher/520/chapt10.pdf · 2014. 10. 15. · Discontinuous...

  • CS520: Discontinuous solutions (Ch. 10)

    Uri Ascher

    Department of Computer ScienceUniversity of British Columbia

    [email protected]

    people.cs.ubc.ca/∼ascher/520.html

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 1 / 16

  • Discontinuous solutions

    Outline

    These slides cover a highly abbreviated version of Chapter 10.

    We’ll consider, mainly by examples:

    Constant coefficient hyperbolic PDEsConservations laws: approximating the Burgers equationWhat sort of schemes are there?

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 2 / 16

  • Discontinuous solutions Constant coefficient advection

    Constant coefficient advection

    Recall that a discontinuity in initial value function u0(x) propagatesalong characteristic in (t, x).

    We saw various methods:

    Lax-WendroffLeap-frogdissipated Leap-frogLax-FriedrichsUpwind

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 3 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: ut = ux with u0 a square wave

    u0 square wave on [.25, .75], k = .5h, h = .01π.

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−0.5

    0

    0.5

    1

    1.5u

    ExactLax−FriedrichsLax−Wendroff

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−0.5

    0

    0.5

    1

    1.5

    x

    u

    ExactLeap−frogDissipated LF, ε=.5

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 4 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: ut = ux with u0 a square wave

    u0 square wave on [.25, .75], k = .5h, h = .001π.

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−0.5

    0

    0.5

    1

    1.5u

    ExactLax−FriedrichsLax−Wendroff

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−0.5

    0

    0.5

    1

    1.5

    x

    u

    ExactLeap−frogDissipated LF, ε=.5

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 5 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: ut = ux with u0 a square wave

    u0 square wave on [.25, .75], k = .5h, h = .01π, .001π.

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−0.5

    0

    0.5

    1

    1.5u

    ExactUpwind

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−0.5

    0

    0.5

    1

    1.5

    x

    u

    ExactUpwind

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 6 / 16

  • Discontinuous solutions Constant coefficient advection

    Observations

    Both dissipative and non-dissipative schemes of order (2,2) displayannoying overshoots. (Note Gibbs phenomenon).

    The large error in the dissipative ones is more localized.

    These overshoots can become much more troublesome for nonlinearproblems.

    Both Lax-Friedrichs and upwind are monotone and there are noovershoots.

    However, monotone schemes are only 1st order accurate and featuresignificant artificial viscosity/diffusion, especially Lax-Friedrichs.

    Observe similar behaviour for parabolic problems with small diffusionterm (“almost hyperbolic”).

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 7 / 16

  • Discontinuous solutions Constant coefficient advection

    Observations

    Both dissipative and non-dissipative schemes of order (2,2) displayannoying overshoots. (Note Gibbs phenomenon).

    The large error in the dissipative ones is more localized.

    These overshoots can become much more troublesome for nonlinearproblems.

    Both Lax-Friedrichs and upwind are monotone and there are noovershoots.

    However, monotone schemes are only 1st order accurate and featuresignificant artificial viscosity/diffusion, especially Lax-Friedrichs.

    Observe similar behaviour for parabolic problems with small diffusionterm (“almost hyperbolic”).

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 7 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: ut + aux = σuxx with 0 < σ ≪ 1

    σ = 1.e-3, a = -1; u(t,−π) = 1, u(t, π) = 0;u0 = 1 if x ≤ 0, u0 = 0 otherwise .Crank-Nicolson (CN), k = .0001, h = .0001π.

    0

    0.2

    0.4

    0.6

    0.8

    1

    −4−2

    02

    4

    −0.5

    0

    0.5

    1

    1.5

    xt

    u

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 8 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: ut + aux = σuxx with 0 < σ ≪ 1

    σ = 1.e-3, a = -1; u(t,−π) = 1, u(t, π) = 0;u0 = 1 if x ≤ 0, u0 = 0 otherwise .CN, k = .01, h = .01π.

    0

    0.2

    0.4

    0.6

    0.8

    1

    −4−2

    02

    4

    −0.5

    0

    0.5

    1

    1.5

    xt

    u

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 9 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: ut + aux = σuxx with 0 < σ ≪ 1

    σ = 1.e-3, a = -1; u(t,−π) = 1, u(t, π) = 0;u0 = 1 if x ≤ 0, u0 = 0 otherwise .Upwind, k = .01, h = .01π.

    0

    0.2

    0.4

    0.6

    0.8

    1

    −4−2

    02

    4

    −0.5

    0

    0.5

    1

    1.5

    xt

    u

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 10 / 16

  • Discontinuous solutions Constant coefficient advection

    Constant coefficient system

    ut + Aux = 0,

    where A is diagonalizable with real eigenvalues

    T−1

    AT = Λ = diag(λ1, . . . , λs).

    Lax-Friedrichs can be extended directly.Define |Λ| = diag (|λ1|, |λ2|, . . . , |λs |), and then |A| = T |Λ|T

    −1.The upwind method can be written as

    vn+1j = vnj −

    µ

    2A(vnj+1 − v

    nj−1) +

    µ

    2|A|(vnj+1 − 2v

    nj + v

    nj−1).

    Alternatively for upwind,

    vn+1j = vnj − µ[A

    +D−+ A−D+]v

    nj , where

    A+ =

    1

    2(A+ |A|), A− =

    1

    2(A− |A|).

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 11 / 16

  • Discontinuous solutions Constant coefficient advection

    Constant coefficient system

    ut + Aux = 0,

    where A is diagonalizable with real eigenvalues

    T−1

    AT = Λ = diag(λ1, . . . , λs).

    Lax-Friedrichs can be extended directly.Define |Λ| = diag (|λ1|, |λ2|, . . . , |λs |), and then |A| = T |Λ|T

    −1.The upwind method can be written as

    vn+1j = vnj −

    µ

    2A(vnj+1 − v

    nj−1) +

    µ

    2|A|(vnj+1 − 2v

    nj + v

    nj−1).

    Alternatively for upwind,

    vn+1j = vnj − µ[A

    +D−+ A−D+]v

    nj , where

    A+ =

    1

    2(A+ |A|), A− =

    1

    2(A− |A|).

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 11 / 16

  • Discontinuous solutions Constant coefficient advection

    Constant coefficient system

    ut + Aux = 0,

    where A is diagonalizable with real eigenvalues

    T−1

    AT = Λ = diag(λ1, . . . , λs).

    Lax-Friedrichs can be extended directly.Define |Λ| = diag (|λ1|, |λ2|, . . . , |λs |), and then |A| = T |Λ|T

    −1.The upwind method can be written as

    vn+1j = vnj −

    µ

    2A(vnj+1 − v

    nj−1) +

    µ

    2|A|(vnj+1 − 2v

    nj + v

    nj−1).

    Alternatively for upwind,

    vn+1j = vnj − µ[A

    +D−+ A−D+]v

    nj , where

    A+ =

    1

    2(A+ |A|), A− =

    1

    2(A− |A|).

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 11 / 16

  • Discontinuous solutions Constant coefficient advection

    Constant coefficient system

    ut + Aux = 0,

    where A is diagonalizable with real eigenvalues

    T−1

    AT = Λ = diag(λ1, . . . , λs).

    Lax-Friedrichs can be extended directly.Define |Λ| = diag (|λ1|, |λ2|, . . . , |λs |), and then |A| = T |Λ|T

    −1.The upwind method can be written as

    vn+1j = vnj −

    µ

    2A(vnj+1 − v

    nj−1) +

    µ

    2|A|(vnj+1 − 2v

    nj + v

    nj−1).

    Alternatively for upwind,

    vn+1j = vnj − µ[A

    +D−+ A−D+]v

    nj , where

    A+ =

    1

    2(A+ |A|), A− =

    1

    2(A− |A|).

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 11 / 16

  • Discontinuous solutions Constant coefficient advection

    Example: two advection equations mixed

    Λ =

    (

    −1 00 −0.1

    )

    , T =

    (

    cos(π/3) − sin(π/3)sin(π/3) cos(π/3)

    )

    , A = TΛT−1.

    Periodic BC on [−π, π] and initial conditions u0 = Tw0, with

    w10 (x) =

    {

    1 .25 ≤ x < .75

    0 otherwise, w20 (x) =

    {

    2 .5 ≤ x < .7

    0 otherwise

    −2 −1.5 −1 −0.5 0 0.5 1 1.5 2−2.5

    −2

    −1.5

    −1

    −0.5

    0

    0.5

    1

    1.5

    2

    2.5

    x

    u1

    exactLFUpwind

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 12 / 16

  • Discontinuous solutions Conservation laws

    Outline

    These slides cover a highly abbreviated version of Chapter 10.

    We’ll consider, mainly by examples:

    Constant coefficient hyperbolic PDEsConservations laws: approximating the Burgers equationWhat sort of schemes are there?

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 13 / 16

  • Discontinuous solutions Conservation laws

    The inviscid Burgers equation

    ut +1

    2(u2)x = 0,

    is a scalar conservation law with f (u) = 12u2, a(u) = u.

    −3 −2 −1 0 1 2 3−0.5

    0

    0.5

    1

    1.5

    t

    Characteristics

    −3 −2 −1 0 1 2 3−1.5

    −1

    −0.5

    0

    0.5

    1

    1.5

    x

    u 0

    Initial values

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 14 / 16

  • Discontinuous solutions Conservation laws

    Upwind discretization

    ut +1

    2(u2)x = 0,

    hence f (u) = 12u2, a(u) = u. Characteristic curves are straight lines, but

    where they meet a shock discontinuity forms.

    Discretize conservation form!

    vn+1j = v

    nj −

    µ

    2

    {

    [(vnj+1)2 − (vnj )

    2] if vnj < 0

    [(vnj )2 − (vnj−1)

    2] if vnj ≥ 0.

    Do not discretize “advection form”

    vn+1j = v

    nj − µv

    nj

    {

    [vnj+1 − vnj ] if v

    nj < 0

    [vnj − vnj−1] if v

    nj ≥ 0

    .

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 15 / 16

  • Discontinuous solutions Conservation laws

    Upwind discretization

    ut +1

    2(u2)x = 0,

    hence f (u) = 12u2, a(u) = u. Characteristic curves are straight lines, but

    where they meet a shock discontinuity forms.

    Discretize conservation form!

    vn+1j = v

    nj −

    µ

    2

    {

    [(vnj+1)2 − (vnj )

    2] if vnj < 0

    [(vnj )2 − (vnj−1)

    2] if vnj ≥ 0.

    Do not discretize “advection form”

    vn+1j = v

    nj − µv

    nj

    {

    [vnj+1 − vnj ] if v

    nj < 0

    [vnj − vnj−1] if v

    nj ≥ 0

    .

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 15 / 16

  • Discontinuous solutions Conservation laws

    Example

    Shock may be located at wrong place unless discretizing conservation form:

    −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.5

    0

    0.5

    1

    1.5

    uLax−Friedrichs scheme: conservative form

    −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.5

    0

    0.5

    1

    1.5

    u

    Lax−Friedrichs scheme: non−conservative form

    −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.5

    0

    0.5

    1

    1.5

    u

    Upwind scheme: conservative form

    −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1−0.5

    00.5

    11.5

    x

    u

    Upwind scheme: non−conservative form

    Uri Ascher (UBC) CPSC 520: Discontinuous solutions Fall 2012 16 / 16

    Discontinuous solutionsConstant coefficient advectionConservation laws