Week 15 - Explicit vs Implicit

Embed Size (px)

Citation preview

  • 8/13/2019 Week 15 - Explicit vs Implicit

    1/7

    12/19/2

    Computational Fluid Dynamics

    Implicit method19-Dec-13

    21

    2

    2

    x

    u

    t

    u

    Therefore parabolic equation can be written as:

    2

    1

    1

    11

    1

    1 2

    x

    uuu

    t

    uu n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    2

    1

    1

    11

    1

    1 )2(x

    truuuuru

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    Difference equation is:

    Time (n+1) Time (n)

    SCHEME is ORDER (t, x2)

    t

    uu n

    i

    n

    i

    1

    2

    1

    1

    11

    1 2

    x

    uuu n

    i

    n

    i

    n

    i

    Requires Matrix Solvers.

    Known as the Fully Implicit Method.

    Computational Fluid Dynamics

    Crank Nicholson

    Approximating the derivatives at mid-point intime (n+0.5, i) with half the time step, wehave:

    LHS:

    RHS:

    19-Dec-13

    22

    2

    2

    x

    u

    t

    u

    t

    uu n

    i

    n

    i

    5.02

    5.05.05.05.0

    2

    1

    1

    11

    1

    2

    11 22

    2

    1

    x

    uuu

    x

    uuu n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    2

    1

    11211

    211

    1121 22

    x

    uuuuuu n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    2

    5.0

    1

    5.05.0

    1 2

    x

    uuu n

    i

    n

    i

    n

    i

    t

    uu n

    i

    n

    i

    5.02

    1

  • 8/13/2019 Week 15 - Explicit vs Implicit

    2/7

    12/19/2

    Computational Fluid Dynamics

    Crank Nicholson

    Crank Nicholson in 1947 proposed this method to allowgreater time steps in their calculations.

    The resulting difference equation is:

    In this case we have three unknowns on the RHS of theequation.

    Therefore the new value +1 is not given directly in

    terms of known values as is the case of the Explicitmethod.

    19-Dec-13

    23

    Time (n+1) Time (n)

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i ruurruruurru 111

    1

    11

    1 )22()22(

    2x

    tr

    SCHEME is ORDER (t2, x2)

    Computational Fluid Dynamics

    Explicit vs Implicit19-Dec-13

    24

    i-1 i i+1i-1 i i+1

    n-1

    n

    n+

    1

    i-1 i i+1

    Explicit Crank-Nicholson Fully Implicit

    O(t, x2) O(t, x2)O(t2, x2)

    Computational moleculesshow differences between the schemes

    If there is more than one node at timestep n+1 the scheme is implicit

    n-1

    n

    n+1

    n-

    1

    n

    n+1

  • 8/13/2019 Week 15 - Explicit vs Implicit

    3/7

    12/19/2

    Computational Fluid Dynamics

    Comparison

    Explicit method

    Unknown values atcurrent time step dependonly on known values atprevious time step

    Advantage:Easy to implement insoftware and solve

    Disadvantage:

    Restrictions on time stepfor stability.

    Implicit method

    Unknown values atcurrent time step dependon known values atprevious time step and oneach other Disadvantage:

    Requires solution ofsystem of equations

    Advantage:

    No restrictions on time step

    19-Dec-13

    25

    Computational Fluid Dynamics

    Example

    Consider heat loss from a heated rod subject

    to the above equations:

    Use the explicit scheme with mesh spacing0.1 and timestep 0.001 to obtain

    approximate values for u(x,0.03).

    Now change the timestep to 0.01. What

    happens?

    19-Dec-13

    28

    ICEICE

    0),1(),0( tutu102

    2

    x

    x

    u

    t

    u

    xxu sin)0,(

  • 8/13/2019 Week 15 - Explicit vs Implicit

    4/7

    12/19/2

    Computational Fluid Dynamics

    Solution

    The problem is set up as follows

    19-Dec-13

    29

    =sin(*c24)

    )2( 111 n

    i

    n

    i

    n

    i

    n

    i

    n

    i uuuruu

    Explicit Equation:

    = C25+rr*(D25-2*C25+B25)

    Name rr

    =B22/B21^2

    Computational Fluid Dynamics

    19-Dec-13

    30

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10.00 0 0.31 0.59 0.81 0.95 1.00 0.95 0.81 0.59 0.31 0

    0.01 0 0.28 0.53 0.73 0.86 0.90 0.86 0.73 0.53 0.28 0

    0.02 0 0.25 0.48 0.66 0.77 0.81 0.77 0.66 0.48 0.25 0

    0.03 0 0.23 0.43 0.59 0.70 0.73 0.70 0.59 0.43 0.23 0

    0.04 0 0.20 0.39 0.54 0.63 0.66 0.63 0.54 0.39 0.20 0

    0.05 0 0.18 0.35 0.48 0.57 0.60 0.57 0.48 0.35 0.18 0

    0.06 0 0.17 0.32 0.44 0.51 0.54 0.51 0.44 0.32 0.17 0

    0.07 0 0.15 0.29 0.39 0.46 0.49 0.46 0.39 0.29 0.15 0

    0.08 0 0.14 0.26 0.35 0.42 0.44 0.42 0.35 0.26 0.14 0

    0.09 0 0.12 0.23 0.32 0.38 0.40 0.38 0.32 0.23 0.12 0

    0.10 0 0.11 0.21 0.29 0.34 0.36 0.34 0.29 0.21 0.11 0

    0.11 0 0.10 0.19 0.26 0.31 0.32 0.31 0.26 0.19 0.10 0

    0.12 0 0.09 0.17 0.24 0.28 0.29 0.28 0.24 0.17 0.09 0

    0.13 0 0.08 0.15 0.21 0.25 0.26 0.25 0.21 0.15 0.08 0

    0.14 0 0.07 0.14 0.19 0.22 0.24 0.22 0.19 0.14 0.07 0

    0.15 0 0.07 0.13 0.17 0.20 0.21 0.20 0.17 0.13 0.07 0

    0.16 0 0.06 0.11 0.16 0.18 0.19 0.18 0.16 0.11 0.06 0

    0.17 0 0.05 0.10 0.14 0.17 0.17 0.17 0.14 0.10 0.05 0

    0.18 0 0.05 0.09 0.13 0.15 0.16 0.15 0.13 0.09 0.05 0

    0.19 0 0.04 0.08 0.11 0.13 0.14 0.13 0.11 0.08 0.04 00.20 0 0.04 0.07 0.10 0.12 0.13 0.12 0.10 0.07 0.04 0

    0.21 0 0.04 0.07 0.09 0.11 0.11 0.11 0.09 0.07 0.04 0

    0.22 0 0.03 0.06 0.08 0.10 0.10 0.10 0.08 0.06 0.03 0

    0.23 0 0.03 0.05 0.08 0.09 0.09 0.09 0.08 0.05 0.03 0

    0.24 0 0.03 0.05 0.07 0.08 0.08 0.08 0.07 0.05 0.03 00.25 0 0.02 0.04 0.06 0.07 0.08 0.07 0.06 0.04 0.02 0

    0.26 0 0.02 0.04 0.06 0.07 0.07 0.07 0.06 0.04 0.02 0

    0.27 0 0.02 0.04 0.05 0.06 0.06 0.06 0.05 0.04 0.02 0

    0.28 0 0.02 0.03 0.05 0.05 0.06 0.05 0.05 0.03 0.02 0

    0.29 0 0.02 0.03 0.04 0.05 0.05 0.05 0.04 0.03 0.02 0

    0.30 0 0.01 0.03 0.04 0.04 0.05 0.04 0.04 0.03 0.01 0

  • 8/13/2019 Week 15 - Explicit vs Implicit

    5/7

    12/19/2

    Computational Fluid Dynamics

    Results for dt=0.00119-Dec-13

    31

    Computational Fluid Dynamics

    Results for dt=0.0119-Dec-13

    32

  • 8/13/2019 Week 15 - Explicit vs Implicit

    6/7

    12/19/2

    Computational Fluid Dynamics

    Example

    Solve the same equation as the previousexample, but use the Crank-Nicholson

    scheme to obtain approximate values for

    with the time step 0.001.

    Now change the time step to 0.01. What

    happens?

    19-Dec-13

    33

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i ruurruruurru

    11

    1

    1

    11

    1

    )22()22(

    2x

    tr

    Computational Fluid Dynamics

    Solution

    The problem is set up as follows:

    19-Dec-13

    34

    1111111 )22()22(

    1

    ni

    n

    i

    n

    i

    n

    i

    n

    i

    n

    i rururuurru

    ru 2

    x

    tr

    Name FLAG

    0: Initialize

    1: Iterate (solve)

    Implicit Equation

    =IF(FLAG=0,0,(rr*B25+(2-2*rr)*C25+rr*D25+rr*B26+rr*D26)/(2+2*rr))

    [B26 & D26 are at current time-step]

    Name rr

    =B22/B21^2

    Iteration counter

    =IF(FLAG=0,0,E19+1))

  • 8/13/2019 Week 15 - Explicit vs Implicit

    7/7

    12/19/2

    Computational Fluid Dynamics

    Results

    For dt = 0.001, courant number = 0.1 andafter 7 iterations.

    19-Dec-13

    35

    Computational Fluid Dynamics

    Results

    For dt = 0.01, courant number = 1 and after

    20 iterations, with convergence.

    19-Dec-13

    36