Finite-Di erence Approximations to the Heat Equation · 2021. 1. 26. · Finite Di erence Method We...

18
Finite-Difference Approximations to the Heat Equation From notes by Gerald W. Recktenwald Finite-Difference Approximations to the Heat Equation

Transcript of Finite-Di erence Approximations to the Heat Equation · 2021. 1. 26. · Finite Di erence Method We...

  • Finite-Difference Approximations to the HeatEquation

    From notes by Gerald W. Recktenwald

    Finite-Difference Approximations to the Heat Equation

  • The Heat Equation

    ∂φ

    ∂t= α

    ∂2φ

    ∂x2

    with 0 ≤ x ≤ L, t ≥ 0.

    We assume that we are given

    φ(0, t) = φ0, φ(L, t) = φL, φ(x , 0) = f0(x)

    Finite-Difference Approximations to the Heat Equation

  • Finite Difference Method

    We replace all he derivatives by discrete approximations.

    In the heat equation there are derivatives wrt time and space.

    We need to choose how we approximate the derivatives usingpoints on the mesh.

    Then, convergence has to be addressed (as ∆x and ∆t go to0).

    Finite-Difference Approximations to the Heat Equation

  • Finite Difference Method

    Finite-Difference Approximations to the Heat Equation

  • Mesh

    We divide the space as follows:

    xi = (i − 1)∆x where 1 ≤ i ≤ N (for 0 ≤ x ≤ L).tm = (m − 1)∆t where 1 ≤ m ≤ M (for 0 ≤ t ≤ tmax).

    Finite-Difference Approximations to the Heat Equation

  • Mesh

    Finite-Difference Approximations to the Heat Equation

  • Mesh

    Finite-Difference Approximations to the Heat Equation

  • Finite Difference Approximations

    Notation: φi = φ(xi ), φi+1 = φ(xi + ∆x).

    First Order Forward Approximation:

    ∂φ

    ∂x

    ∣∣∣∣xi

    ≈ φi+1 − φi∆x

    +∆x2

    2

    ∂2φ

    ∂x2

    ∣∣∣∣ξ

    Also, we can write

    ∂φ

    ∂x

    ∣∣∣∣xi

    =φi+1 − φi

    ∆x+ O(∆x)

    First Order Backward Approximation:

    ∂φ

    ∂x

    ∣∣∣∣xi

    =φi − φi−1

    ∆x+ O(∆x)

    Finite-Difference Approximations to the Heat Equation

  • Finite Difference Approximations

    First Order Central Approximation:

    ∂2φ

    ∂x2

    ∣∣∣∣xi

    =φi+1 − φi−1

    2∆x+ O(∆x2)

    Second Order Central Approximation:

    ∂φ

    ∂x

    ∣∣∣∣xi

    =φi+1 − 2φi + φi−1

    ∆x2+ O(∆x2)

    Finite-Difference Approximations to the Heat Equation

  • Schemes for the Heat Equation. FTCS

    ∂φ

    ∂t

    ∣∣∣∣tm,xi

    =φm+1i − φmi

    ∆t+ O(∆t)

    Then, combining it with the second order, central approximationfor x :

    φm+1i − φm+1i

    ∆t= α

    φmi+1 − 2φmi + φmi−1∆x2

    + O(∆x2) + O(∆t)

    Then, we can solve for φm+1 (advance in time):

    φm+1i = φmi + α∆t

    φmi+1 − 2φmi + φmi−1∆x2

    + O(∆x2) + O(∆t)

    Finite-Difference Approximations to the Heat Equation

  • Schemes for the Heat Equation. FTCS

    Notice that the system we obtained is easy to solve since we cansolve for the φm+1s one at the time(explicit).

    However, the obtained solutions (to the discrete system, soapproximations to the real solutions) can be unstable unlessr = α∆t∆x <

    12 .

    Solving that system is equivalent to solving φ(m+1) = Aφ(m) where:

    A =

    1 0 0 0 0 0r (1 − 2r) r 0 0 00 r (1 − 2r) r 0 0

    . . . . . . . . . . . . . . . . . .0 0 0 r (1 − 2r) r0 0 0 0 0 1

    Finite-Difference Approximations to the Heat Equation

  • Schemes for the Heat Equation. BTCS

    If we use the backward approximation for the t derivative:

    ∂φ

    ∂t

    ∣∣∣∣tm,xi

    =φmi − φ

    m−1i

    ∆t+ O(∆t)

    We obtain a different scheme.

    It is more complicated to solve.

    We can’t solve one-by-one.

    These type of schemes is called implicit.

    Finite-Difference Approximations to the Heat Equation

  • Schemes for the Heat Equation. Crank-Nicolson

    The time-truncation in both schemes turns out to be O(∆t).

    Combining the derivatives at the current and previous times for ximproves it to O(∆t2).

    φmi − φm−1i

    ∆t= α

    1

    2(φmi+1 − 2φmi + φmi−1

    ∆x2+φm−1i+1 − 2φ

    m−1i + φ

    m−1i−1

    ∆x2)

    Finite-Difference Approximations to the Heat Equation

  • Error Orders

    Finite-Difference Approximations to the Heat Equation

  • Stencils

    Finite-Difference Approximations to the Heat Equation

  • Stencils

    Finite-Difference Approximations to the Heat Equation

  • FTCS

    Finite-Difference Approximations to the Heat Equation

  • BTCS

    Finite-Difference Approximations to the Heat Equation