fd1d_heat_implicit


fd1d_heat_implicit, a MATLAB code which solves the time-dependent 1D heat equation, using the finite difference method (FDM) in space, and a backward Euler method in time.

This program solves

        dUdT - k * d2UdX2 = 0
      
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 MIT 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_ftcs, a MATLAB code 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 FTCS method, forward time difference, centered space difference.

fd1d_burgers_lax, a MATLAB code which applies the finite difference method and the Lax-Wendroff method to solve the non-viscous time-dependent Burgers equation in one spatial dimension.

fd1d_burgers_leap, a MATLAB code which applies the finite difference method and the leapfrog approach to solve the non-viscous time-dependent Burgers equation in one spatial dimension.

fd1d_bvp, a MATLAB code which applies the finite difference method to a two point boundary value problem in one spatial dimension.

fd1d_heat_explicit, a MATLAB code which uses the finite difference method to solve the time dependent heat equation in 1D, using an explicit time step method.

fd1d_heat_implicit_test

fd1d_heat_steady, a MATLAB code which uses the finite difference method to solve the steady (time independent) heat equation in 1D.

fd1d_predator_prey, a MATLAB code which uses finite differences to solve a 1D predator prey problem.

fd1d_wave, a MATLAB code which applies the finite difference method to solve the time-dependent wave equation in one spatial dimension.

fem1d, a MATLAB code which applies the finite element method (FEM), with piecewise linear basis functions, to a linear two point boundary value problem;

fem2d_heat, a MATLAB code which applies the finite element method (FEM) to solve the 2D heat equation.

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:


Last revised on 29 March 2021.