Solving the 1D Heat Equation Using Finite Differences

The Heat Equation describes how temperature changes through a heated or cooled medium over time and space.  In one dimension, the heat equation is

1D Heat Equation
This post explores how you can transform the 1D Heat Equation into a format you can implement in Excel using finite difference approximations, together with an example spreadsheet. If you just want the spreadsheet, click here, but please read the rest of this post so you understand how the spreadsheet is implemented.

We will model a long bar of length 1 at an initial uniform temperature of 100 C, with one end kept at 100 C.


Finite Difference Approximations
The central and forward difference approximations for the 1st derivative wrt time and the 2nd derivative wrt space are

Forward and central difference approximations
Substituting these relationships into the heat equation and rearranging gives an equation that describes the temperature u at position x along the bar and time t+Δt. 

Equation 1
Equation 1 is in a form that can be implemented in Excel.  Note that we only need to know the temperature of the bar at time t to know the state at time t+dt, as illustrated below.

Boundary Conditions
Now lets define the initial and boundary conditions. The left-hand side (i.e. x=0) of the bar is kept at a fixed temperature of 100 C , while the initial temperature is 0 C.

We also need a boundary condition on the right hand side of the bar at x=1.  The rate of change of temperature with respect to distance on right hand side of the bar is 0.

A central difference approximation to this boundary condition is

Rearranging this gives
Equation 2

Now, Equation 1 on the right-hand boundary (at x=1) can be rewritten

Equation 3
 Substituting Equation 2 into Equation 3 so that we eliminate u(1+Δx, t) we get

Equation 4

Equation 4 describes the boundary condition on the right-hand side of the bar in a form that can implemented in Excel

Excel Implementation
To summarize, now we have
  • Equation 1 - the finite difference approximation to the Heat Equation
  • Equation 4 - the finite difference approximation to the right-hand boundary condition
  • The boundary condition on the left u(1,t) = 100 C
  • The initial temperature of the bar u(x,0) = 0 C
This is all we need to solve the Heat Equation in Excel.  This screengrab represents how the system can be implemented, and is color coded according to the legend below.

Rows represents the distance along the bar, with time increasing as you go down.

If you want the Mathcad implementation, then click here.


politicamenteINCORRECTO said...

Very Elegant and useful work !!

cherryhub said...

Sorry I have a problem with your finite difference derivative approximation with respect to space (delta x). Could you please prove how this equation is obtained through differentiation of the function du/dt (when the function u is not physically-stated in the first instance)?

podrag said...

Hey! I've noticed when you make the diffusity too high of the timesteps too small or too large it starts to behave funny. May I ask why this is as I'm not learned enough to understand. Thanks.

podrag said...


Post a Comment