Heat Eq 1-D V2

You might also like

You are on page 1of 9

One Dimensional Diffusion Equation - Introduction

The heat equation is a classic equation of mathematical physics. This spreadsheet solves the onedimensional heat equation using a explicit (forward difference) method. This is a more simple than
an implicit method, but only stable under some conditions.
We will use the General Formulation:
u= general dependant variable
= diffusivity

2 u
u
=
2
t
x
Initial Conditions and Boundary Values

The spreadsheet has a numerical method that generally solves:


U(x,t=0) = F(x)
U(x=X1,t)=P(t)

initial condition

U(x=X2,t)=Q(t)

Boundary Condition 2

Boundary Condition 1

Here are 3 examples of how this equation may be applied:


For Heat Transfer, the one-dimensional, heat diffusion equation for an isotropic homogeneous
media is:

T
c T
=
k t
x2

Where,
T = Temperature
x = distance
t = time
c = volumetric heat capacity
k = thermal conductivity

The constants are often grouped together as = k/c,


where is the thermal diffusivity.
For Mass Transfer, this is Fick's Second Law in one-dimension as follows:

2 C A
x2

CA
=D A
t

Where,
C= Concentration
D = diffusion coefficient
A= Component of a mixture, subscript

For Flow through Porous Media (specifically hydrology)

h
S h
=
x2 T t

Where,
h = hydraulic head
S = Storage coefficient

T = Transmissivity

Finite Difference Method - Explicit Forward Difference


Finite Difference uses the approximation

u u( x , t +k )u( x , t )

t
k
2

u u( x+ h , t )2 u( x ,t )+u (x h , t )

x2
h2

h = interval spacing for x-dimension


k = time interval spacing

central difference for uxx

plug the two finite difference approximations back into the general partial differential equation
and substitute

r = k/h2
we get,

un,,j+1 =
This is stable for:
r<=1/2

r [un+1,j - 2un,,j + un-1,,j] + un,j

One Dimensional Heat Diffusion Equation - Calculation Sheet


Input Range
tinitial=

0
0
1
1

x1=
x2=

initial time
starting distance
ending distance
diffusivity

Tmax=

0.5
n=
10
h=
0.1
k= 0.001667
r= 0.166667
pi= 3.141593

ending time
number of distance intervals
distance interval, (x2-x1)/n
time step
must be <0.5 to be stable
pi

Recommend:

k= 0.001667
300 time int.

Do not change the location of the cells in the input range or those shaded in yellow. The VB program looks
in those cells for the appropriate values. Input to yellow shaded cells. If r is greater than 0.5, either use a
smaller time step (k) or fewer distance intervals (n).
Click here to execute the program
Run Finite
Difference
Program

Change Initial or
Boundary
Conditions

Clear Output
Range

Output Range
x
time
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
iterations:

600

U(x)
0
0.00000
30.39755
57.81958
79.58183
93.55405
98.36855
93.55405
79.58183
57.81958
30.39755
0.00000

U(x)
0.1
0.00000
4.22271
8.03207
11.05520
12.99617
13.66498
12.99617
11.05520
8.03207
4.22271
0.00000

U(x)
0.2
0.00000
0.58660
1.11578
1.53575
1.80538
1.89829
1.80538
1.53575
1.11578
0.58660
0.00000

U(x)
0.3
0.00000
0.08149
0.15500
0.21334
0.25080
0.26370
0.25080
0.21334
0.15500
0.08149
0.00000

U(x)
0.4
0.00000
0.01132
0.02153
0.02964
0.03484
0.03663
0.03484
0.02964
0.02153
0.01132
0.00000

U(x)
final
0
0.0016
0.00304
0.00419
0.00492
0.00517
0.00492
0.00419
0.00304
0.0016
0

120.00000
100.00000
U(x,t)

80.00000
60.00000
40.00000
20.00000
0.00000

0.2

0.4

0.6
time

0.8

1.2

0
0.1
0.2
0.3
0.4
final

Example 1
Solve

u
u
=
t
x2

Initial Condition:
Boundary Condition 1
Boundary Condition 2

for 0<x<1, t>0

u(x,0)=100sin(pi*x)
u(0,t)=0
u(1,t)=0

for 0<x<1
for t>0
for t>0

These conditions would be typical of a large slab or cylinder with a heated core that is allowed to cool off. This
solution is obtained by running the program several times. The length and time dimensions would be
normalized.

u(x,0)

u(x,0.1)

0
0.0000
0.1 30.9017
0.2 58.7785
0.3 80.9017
0.4 95.1057
0.5 100.0000
0.6 95.1057
0.7 80.9017
0.8 58.7785
0.9 30.9017
1
0.0000

u(x,0.2)

0.0000
11.5175
21.9076
30.1532
35.4473
37.2715
35.4473
30.1532
21.9076
11.5175
0.0000

0.0000
4.2927
8.1653
11.2386
13.2117
13.8916
13.2117
11.2386
8.1653
4.2927
0.0000

u(x,0.3)
0.0000
1.6000
3.0433
4.1888
4.9242
5.1776
4.9242
4.1888
3.0433
1.6000
0.0000

u(x,0.4)
0.0000
0.5963
1.1343
1.5612
1.8353
1.9298
1.8353
1.5612
1.1343
0.5963
0.0000

u(x,0.5)
0.0000
0.2223
0.4228
0.5819
0.6841
0.7193
0.6841
0.5819
0.4228
0.2223
0.0000

Example 1
Solution

120.0000
100.0000
t=0
t=0.1
t=0.2
t=0.3
t=0.4
t=0.5

u(x)

80.0000
60.0000
40.0000
20.0000
0.0000
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
X

Example 2
Solve

u
u
=
t
x2

Initial Condition:
Boundary Condition 1
Boundary Condition 2

u(x,0)
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1

0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000
0.0000

for 0<x<1, t>0

u(x,0)=0
u(0,t)=sin(t)
u(1,t)=1

for 0<x<1
for t>0
for t>0

u(x,0.2)

u(x,0.4)

u(x,0.6)

u(x,0.8)

u(x,1)

u(x,1.2)

u(x,1.4)

0.198669
0.225907
0.264399
0.315361
0.379559
0.457149
0.547558
0.649441
0.760709
0.878629
1.000000

0.389418
0.420132
0.459560
0.507144
0.562237
0.624083
0.691806
0.764411
0.840790
0.919743
1.000000

0.564642
0.583133
0.609237
0.642264
0.681477
0.726090
0.775276
0.828169
0.883871
0.941462
1.000000

0.717356
0.724299
0.737701
0.756999
0.781571
0.810752
0.843834
0.880076
0.918711
0.958952
1.000000

0.841471
0.840218
0.844049
0.852577
0.865353
0.881868
0.901571
0.923868
0.948138
0.973735
1.000000

0.932039
0.926577
0.924626
0.925997
0.930429
0.937599
0.947131
0.958605
0.971564
0.985529
1.000000

0.985450
0.979977
0.976301
0.974441
0.974337
0.975862
0.978832
0.983014
0.988138
0.993906
1.000000

Example 2
Solution

1.200000
1.000000

u(x)

0.800000
0.600000
0.400000
0.200000
0.000000

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


X

t=0.2
t=0.4
t=0.6
t=0.8
t=1.0
t=1.2
t=1.4

0.200000
0.000000

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


X

t=1.0
t=1.2
t=1.4

You might also like