FD1D_HEAT_IMPLICIT
Finite Difference Solution of the
Time Dependent 1D Heat Equation
using Implicit Time Stepping


FD1D_HEAT_IMPLICIT is a Python program which solves the time-dependent 1D heat equation, using the finite difference method in space, and an implicit version of the method of lines to handle integration in time.

This program solves

        dUdT - k * d2UdX2 = F(X,T)
      
over the interval [A,B] with boundary conditions
        U(A,T) = UA(T),
        U(B,T) = UB(T),
      
over the time interval [T0,T1] with initial conditions
        U(X,T0) = U0(X)
      

A second order finite difference is used to approximate the second derivative in space.

The solver applies an implicit backward Euler approximation to the first derivative in time.

The resulting finite difference form can be written as

       U(X,T+dt) - U(X,T)                     ( U(X-dx,+dtT) - 2 U(X,+dtT) + U(X+dx,+dtT) )
       ------------------  = F(X,T+dt) + k *  ---------------------------------------------
                dt                                   dx * dx
      
or, assuming we have solved for all values of U at time T, we have
            -     k * dt / dx / dx   * U(X-dt,T+dt)
      + ( 1 + 2 * k * dt / dx / dx ) * U(X,   T+dt)
            -     k * dt / dx / dx   * U(X+dt,T+dt)
      =               dt             * F(X,   T+dt)
      +                                U(X,   T)
      
which can be written as A*x=b, where A is a tridiagonal matrix whose entries are the same for every time step.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

FD1D_HEAT_IMPLICIT is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

FD1D_ADVECTION_LAX_WENDROFF, a Python program which applies the finite difference method (FDM) to solve the time-dependent advection equation ut = - c * ux in one spatial dimension, with a constant velocity, using the Lax-Wendroff method to treat the time derivative.

FD1D_HEAT_EXPLICIT, a Python library which uses the finite difference method (FDM) and explicit time stepping to solve the time dependent heat equation in 1D.

FD2D_HEAT_STEADY, a Python program which uses the finite difference method (FDM) to solve the steady (time independent) heat equation in 2D.

Reference:

  1. George Lindfield, John Penny,
    Numerical Methods Using MATLAB,
    Second Edition,
    Prentice Hall, 1999,
    ISBN: 0-13-012641-1,
    LC: QA297.P45.

Source Code:

Examples and Tests:

TEST01 runs with initial condition 50 everywhere, boundary conditions of 90 on the left and 70 on the right, and no right hand side source term.

TEST02 uses an exact solution of g(x,t) = exp ( - t ) .* sin ( sqrt ( k ) * x ).

TEST03 runs on the interval -5 <= X <= 5, with initial condition 15 on the entire left and 25 on the entire right. The solution should settle down to a straight line from the left boundary to the right.

You can go up one level to the Python source codes.


Last revised on 17 November 2014.