05-The Wave Equation2

download 05-The Wave Equation2

of 20

Transcript of 05-The Wave Equation2

  • 8/22/2019 05-The Wave Equation2

    1/20

    The Wave Equation: 2

    Solution Using the Finite Difference

    Method

  • 8/22/2019 05-The Wave Equation2

    2/20

    CM3900 Lecture 4 2

    We wish to solve the following problem:

    Wave Equation:

    Boundary Conditions:

    and for all t

    Initial Conditions

    Basic Problem

    2 2

    22 2u uct x

    =

    u(0,t) 0= u(L, t) 0=

    t 0

    u(x,0) f(x)

    u)g(x

    t =

    =

    =

  • 8/22/2019 05-The Wave Equation2

    3/20

    CM3900 Lecture 4 3

    Discretisation MethodWe consider a mesh in one space and one time dimension

    xi

    t

    x

    x1x0 x4x3x2t0

    t1

    t2

    t3

    tj

    t

    x

    xN = L

    i 0x x i x= +

    whereand

    N x L =j 0t t j t= +

    i j i,ju(x ,t ) u=We write

    (x i, tj)

  • 8/22/2019 05-The Wave Equation2

    4/20

    CM3900 Lecture 4 4

    Discretisation of the Equation

    The power series expansion for a function f(x) at the point

    x + h is given by

    and about x - h is

    Adding these two equations and keeping terms to second

    order in h, we obtain

    2

    hf(x h) f(x) h f (x) f (x)2!

    + = + + +K

    2hf(x h) f(x) h f (x) f (x)2! = + +K

    2f(x h) f(x h) 2f(x) h f (x)+ + = +

  • 8/22/2019 05-The Wave Equation2

    5/20

    CM3900 Lecture 4 5

    Discretisation of the Equation

    Hence, we see that an approximation to the second

    derivative is given by

    2

    f(x h) 2f(x) f(x h)f (x)

    h

    + + =

  • 8/22/2019 05-The Wave Equation2

    6/20

    CM3900 Lecture 4 6

    2i j i j i j

    i j2 2

    u(x , t t) 2u(x , t ) u(x , t t)u(x , t )

    t ( t)

    + + =

    Discretisation of the Equation

    We can therefore discretise the second derivatives in the

    wave equation using this formula

    2i,j 1 i,j i,j 1

    i j2 2

    ui.e.

    2u uu(x , t )

    t ( t)

    + + =

  • 8/22/2019 05-The Wave Equation2

    7/20

    CM3900 Lecture 4 7

    2

    i j i j i ji j2 2

    u(x x, t ) 2u(x , t ) u(x x, t )u (x , t )x ( x)

    + + =

    Discretisation of the Equation

    Similarly

    2i 1,j i,j i 1,j

    i j2 2

    u 2u uu(x , t )

    x ( x)

    + + =

  • 8/22/2019 05-The Wave Equation2

    8/20

    CM3900 Lecture 4 8

    Discretisation of the Equation

    So the wave equation , becomes2

    22

    2

    2

    x

    uc

    t

    u

    =

    2

    j,1ij,ij,1i2

    2

    1j,ij,i1j,i

    )x(

    uu2uc

    )t(

    uu2u

    +=

    + ++

    ( )2

    i,j 1 i 1,j i,j i 1,j

    i,j 1 i 1,j i,

    i,j i,j 1

    j i 1,j i,j 1

    c( t)u u 2u u 2u u

    u u (2 2 )u u u

    ( x)

    + +

    + +

    = + +

    = + +

    or

    i.e.2

    x

    tc

    =

    where

  • 8/22/2019 05-The Wave Equation2

    9/20

    CM3900 Lecture 4 9

    Discretisation of the Equation

    ui-1,j ui,j ui+1,j

    ui,j+1

    ui,j-1

    we can construct a diagram to show the relative contribution

    of the preceding points to ui,j+1

    In terms of the mesh points

    t = tj-1

    t = tj

    t = tj+1

    22

    -1

  • 8/22/2019 05-The Wave Equation2

    10/20

    CM3900 Lecture 4 10

    To advance the solution from the tj to the tj+1 time-slice, we

    use the boundary conditions together with the main equation

    There is however a problem with the initial step from t0 to t1.

    Because the wave equation is a p.d.e. which is second order

    in the time variable, the discretised version approximates thefunction at on the next time-slice by using information from

    the preceding, as well as the current time.

    Discretisation of the Equation

    i,j 1 i 1,j i,j i 1,j i,j 1u u (2 2 )u u u+ + = + +

    for i = 1, 2, N 1

  • 8/22/2019 05-The Wave Equation2

    11/20

    CM3900 Lecture 4 11

    Discretisation of the Equation

    At j = 0, the information for this time-slice is provided by the

    initial condition which is discretised to

    Unfortunately there is no previous data corresponding to j = -1.

    However, we do have initial conditions which give the initial

    derivative function

    )x(f)0,x(u = )x(fu i0,i =

    )x(gtu

    0t= =

  • 8/22/2019 05-The Wave Equation2

    12/20

    CM3900 Lecture 4 12

    Discretisation of the Equation

    Discretising this derivative using

    setting j = 0, we get:

    and so

    t2

    uu

    t2

    )tt,x(u)tt,x(u

    )t,x(t

    u

    1j,i1j,i

    jiji

    ji

    =

    +=

    +

    i, 1 i,1 i,1 i

    i,j 0

    uu u 2( t) u 2 t g(x )

    t

    =

    = =

    i,1 i, 1

    i,0

    u uu

    t 2 t

    =

  • 8/22/2019 05-The Wave Equation2

    13/20

    CM3900 Lecture 4 13

    Discretisation of the Equation

    To get started therefore, we have

    Hence

    [ ])x(gt2uu)22()uu(

    uu)22()uu(u

    i1,i0,i0,1i0,1i

    1,i0,i0,1i0,1i1,i

    ++=

    ++=

    +

    +

    { }

    [ ] )x(gtu)1(uu2

    )x(gt2u)22()uu(

    2

    1

    uu)22()uu(u

    i0,i0,1i0,1i

    i0,i0,1i0,1i

    1,i0,i0,1i0,1i1,i

    +++

    =

    +++=

    ++=

    +

    +

    +

  • 8/22/2019 05-The Wave Equation2

    14/20

    CM3900 Lecture 4 14

    Discretisation of the Equation

    The diagram for the initial step is therefore

    1-/2 /2

    t g(xi)

    1

    t = t0

    t = t1

  • 8/22/2019 05-The Wave Equation2

    15/20

    CM3900 Lecture 4 15

    Summary

    For the initial step we use:

    and for subsequent steps

    i,0 i

    i,1 i 1,0 i 1,0 i,0 i

    j 0 : u f(x )

    j 1: u u u (1 )u t g(x )2

    +

    = =

    = = + + +

    i,j 1 i 1,j i,j i 1,j i,j 1j 2,3, : u u (2 2 )u u u+ + = = + + K

  • 8/22/2019 05-The Wave Equation2

    16/20

    CM3900 Lecture 4 16

    Example

    Numerically solve the 1-D wave equation

    with c = 1, subject to

    i) for all t

    ii)

    using x = 0.1 and t = 0.05

    i.e. find u(x, t) for x = 0.0 to 1.0 in steps of 0.1 and t = 0.00to 2.00 in steps of 0.05.

    2 22

    2 2

    u uc

    t x

    =

    u(0, t) u(1, t) 0= =

    t 0

    x 0 x 0.5u(x,0)

    1 x 0.5 x 1

    u0 0 x 1

    t =

  • 8/22/2019 05-The Wave Equation2

    17/20

    CM3900 Lecture 4 17

    Solution

    We first calculate and note that g(x) = 0.

    Initial step:

    4

    1

    x

    tc2

    =

    =

    3/41/8 1/8

    0

    1

    t = t0

    t = t1

  • 8/22/2019 05-The Wave Equation2

    18/20

    CM3900 Lecture 4 18

    Solution

    Subsequently-1

    3/21/4 1/4

    1

  • 8/22/2019 05-The Wave Equation2

    19/20

    CM3900 Lecture 4 19

    x

    SolutionThe calculation can be set out as a table

    0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

    0.05 0.000 0.100 0.200 0.300 0.400 0.500 0.400 0.300 0.200 0.100 0.000

    0.10 0.000 0.100 0.200 0.300 0.400 0.475 0.400 0.300 0.200 0.100 0.000

    0.15 0.000 0.100 0.200 0.300 0.394 0.412 0.394 0.300 0.200 0.100 0.000

    0.20 0.000 0.100 0.200 0.298 0.369 0.341 0.369 0.298 0.200 0.100 0.000

    0.25 0.000 0.100 0.200 0.290 0.319 0.283 0.319 0.290 0.200 0.100 0.000

    0.30 0.000 0.100 0.197 0.266 0.253 0.243 0.253 0.266 0.197 0.100 0.000

    0.35 0.000 0.099 0.187 0.222 0.188 0.208 0.188 0.222 0.187 0.099 0.000

    0.40 0.000 0.096 0.164 0.160 0.136 0.164 0.136 0.160 0.164 0.096 0.000

    0.45 0.000 0.085 0.123 0.094 0.097 0.105 0.097 0.094 0.123 0.085 0.000

    0.50 0.000 0.063 0.065 0.035 0.060 0.042 0.060 0.035 0.065 0.063 0.000

    etc

    t

  • 8/22/2019 05-The Wave Equation2

    20/20

    CM3900 Lecture 4 20

    SolutionThe solution can be graphed for various values of t

    0 0.2 0.4 0.6 0.8 1

    0.5

    0.50.5

    0.5

    u0 i,

    u2 i,

    u5 i,

    u8 i,

    u10 i,

    10 xi