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

FD1D_HEAT_IMPLICIT is a FORTRAN90 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.

### Languages:

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

### Related Data and Programs:

FD1D_BURGERS_LAX, a FORTRAN90 program 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 FORTRAN90 program 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 FORTRAN90 program which applies the finite difference method to a two point boundary value problem in one spatial dimension.

FD1D_HEAT_EXPLICIT, a FORTRAN90 program which uses the finite difference method to solve the time dependent heat equation in 1D, using an explicit time step method.

FD1D_HEAT_STEADY, a FORTRAN90 program which uses the finite difference method to solve the steady (time independent) heat equation in 1D.

FD1D_PREDATOR_PREY, a FORTRAN90 program which uses finite differences to solve a 1D predator prey problem.

FD1D_WAVE, a FORTRAN90 program which applies the finite difference method to solve the time-dependent wave equation utt = c * uxx in one spatial dimension.

FEM_50_HEAT, a MATLAB program which applies the finite element method to solve the 2D heat equation.

FEM1D, a FORTRAN90 program which applies the finite element method, with piecewise linear basis functions, to a linear two point boundary value problem;

FEM2D_HEAT, a FORTRAN90 program which applies the finite element method to solve the 2D heat equation.

HOT_PIPE, a MATLAB program which uses FEM_50_HEAT to solve a heat problem in a pipe.

HOT_POINT, a MATLAB program which uses FEM_50_HEAT to solve a heat problem with a point source.

### Reference:

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

### Examples and Tests:

• x.txt a file containing the spatial coordinates.
• t.txt a file containing the times.
• u.txt a file containing the values of the computed solution at each point X and time T.
• solution.png a PNG image of the MATLAB graphics created by the commands:
```            x = load ( 'x.txt' );
t = load ( 't.txt' );
u = load ( 'u.txt' );
[ xg, tg ] = meshgrid ( x, t );
mesh ( xg, tg, u );
```

### List of Routines:

• MAIN is the main program for FD1D_HEAT_IMPLICIT.
• F returns the right hand side of the heat equation.
• GET_UNIT returns a free FORTRAN unit number.
• R83_NP_FA factors an R83 matrix without pivoting.
• R83_NP_SL solves an R83 system factored by R83_NP_FA.
• TIMESTAMP prints the current YMDHMS date as a time stamp.
• U0 returns the initial condition at the starting time.
• UA returns the Dirichlet boundary condition at the left endpoint.
• UB returns the Dirichlet boundary condition at the right endpoint.

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

Last revised on 30 May 2009.