The Heat Equation and Diffusion

advertisement
The Heat Equation
and Diffusion
PHYS220 2004
by Lesa Moore
DEPARTMENT OF PHYSICS
Macquarie University 2004
1
Diffusion of Heat



The diffusion of heat through a material
such as solid metal is governed by the
heat equation.
We will not try to derive this equation.
We will compare results from the heat
equation with our studies of the random
walk.
Macquarie University 2004
2
Initial Temperature
Distribution
-3


-2
-1
0
1
2
3
x
Consider diffusion in 1D (let a thin
copper wire represent a onedimensional lattice).
Let u(t,x) be the heat at point x at time
t, with x and t integers, u(t=0,x=0)=1
and u(t=0,x)=0 if x is not zero.
Macquarie University 2004
3
The Partial Differential
Equation

The heat equation is a partial differential
equation (PDE):
2
u
 u
k 2
t
x


k is the diffusion coefficient.
Assume the initial distribution is a spike at
x=0 and is zero elsewhere.
Macquarie University 2004
4
Partial Derivatives


For functions of more than one variable,
the partial derivative is the rate of change
with respect to one variable with the other
variable(s) fixed.
:u (t , x)  lim u (t  t , x)  u(t , x)
t


:
:
t 0
t
u
u (t , x  x)  u (t , x)
(t , x)  lim
x 0
x
x
 2u
(u / x)(t , x  x)  (u / x)(t , x)
(t , x)  lim
2
x 0
x
x
Macquarie University 2004
5
The PDE in full
u
 2u
k 2
t
x

:

: lim

u (t , x  x)  u (t , x) u (t , x)  u (t , x  x) 




u (t  t , x)  u (t , x)

x

x
 k  lim
:lim

t 0
x 0
t

x




u (t  t , x)  u (t , x)
(u / x)(t , x  x)  (u / x)(t , x) 

 k  lim

t 0
t
x
 x0
Macquarie University 2004
6
Converting to a
Difference Equation


Don’t take the limits as intervals approach
zero.
Take finite time steps (t=1) and finite
positions steps (x=1).
u (t , x  x)  u (t , x) u (t , x)  u (t , x  x) 




u (t  t , x)  u (t , x)

x

x
lim
 k  lim

t 0
x 0
t

x




Macquarie University 2004
7
Simplifying …
1
1
u (t , x  x)  u (t , x) u (t , x)  u (t , x  x) 




u (t  t , x)  u (t , x)

x

x
lim
 k  lim

t 0
x 0
t

x




1
Macquarie University 2004
8
Rearranging …

Want all t+1 terms on l.h.s. and
everything else on r.h.s.
u(t  1, x)  u(t, x)  k u(t , x  1)  u(t , x)  u(t, x)  u(t, x 1)
u(t  1, x)  k u(t , x  1)  2u(t, x)  u(t , x 1)  u(t, x)
Macquarie University 2004
9
Modelling in Excel


Columns are x-values.
Rows are t-values.
Y
1
2
3
4
Z
-2
-1
u(t,x-1)
AA
AB
0
u(t,x)
u(t+1,x)
AC
1
2
u(t,x+1)
u(t  1, x)  k u(t , x  1)  2u(t, x)  u(t , x 1)  u(t, x)

The difference equation relates each cell to
three cells in the row above.
Macquarie University 2004
10
The Excel Spreadsheet


The first row (t=0) is all zeros except for the
initial spike: u(t=0,x=0) = 1.
The same formula is entered in every cell
from row 2 down:


A1 holds the value of k (k = 0.1)
AA3=$A$1*(Z2-2*AA2+AB2)+AA2
X
1
2
3
4
5
Y
-3
0
0
0
0.001
Z
-2
0
0
0.01
0.024
AA
-1
0
0.1
0.16
0.195
AB
0
1
0.8
0.66
0.56
AC
1
0
0.1
0.16
0.195
Macquarie University 2004
AD
2
0
0
0.01
0.024
3
0
0
0
0.001
11
Filling the Spreadsheet

In Excel, it is easiest to insert the
formula in the top left cell of the range,
select the range and use Ctrl+R, Ctrl+D
to fill the range:

-20 ≤ x ≤ 20; 0 ≤ t ≤ 60.
Macquarie University 2004
12
Boundary Conditions


What happens at the boundaries?
Setting columns at x=±21 equal to zero
stops the spatial evolution of the model –
is this a problem?


Provided that values in neighbouring
columns (x=±20) are still small at the end of
the simulation, the choice of boundary
conditions is not so important.
u=0 is equivalent to an absorbing boundary.
Macquarie University 2004
13
Snapshots
Spread of Heat in 1D: t = 11
1
1
0.9
0.9
0.8
0.8
0.7
0.7
Measure of heat
Measure of heat
Spread of Heat in 1D: t = 0
0.6
0.5
0.4
0.3
0.6
0.5
0.4
0.3
0.2
0.2
0.1
0.1
0
0
-20
-15
-10
-5
0
5
10
15
20
-20
-15
-10
Space (x) units
0
5
10
15
20
10
15
20
Space (x) units
Spread of Heat in 1D: t = 3
Spread of Heat in 1D: t = 51
1
1
0.9
0.9
0.8
0.8
0.7
0.7
Measure of heat
Measure of heat
-5
0.6
0.5
0.4
0.3
0.6
0.5
0.4
0.3
0.2
0.2
0.1
0.1
0
0
-20
-15
-10
-5
0
5
10
15
20
-20
-15
-10
-5
0
5
Space (x) units
Space (x) units
Macquarie University 2004
14
Plotting the Heat Spread
Spread of Heat in 1D
1
0.9
Measure of heat
0.8
t=1
0.7
t=11
0.6
t=21
0.5
t=31
0.4
t=51
0.3
t=81
0.2
0.1
0
-20
-15
-10
-5
0
5
10
15
20
Space (x) units
Macquarie University 2004
15
Spreadsheet Results

Conservation of heat can be
demonstrated by adding the values in a
row (a row is a time step).



Values in a row should add to 1.
Checking the sum in a row is good test
of numerical accuracy.
Heat diffusion looks like a Gaussian
distribution.
Macquarie University 2004
16
The Distribution


The simulation satisfies conservation of
energy (total heat along a row = 1).
Does the Gaussian distribution satisfy this
condition too (area under curve = 1)?



The initial spike can be thought of as a very
sharp, very narrow Gaussian.
For t>0, need to integrate the Gaussian.
“Normalised” if integral yields unity.
Macquarie University 2004
17
Normalisation of the Gaussian

Formula for Gaussian with m = 0.
f ( x) 

e
 x 2 / 2 2
 2
Use a trick for the integral:






 f ( x)dx   f ( x)  f ( y)dxdy
Macquarie University 2004
18
 The integral becomes
e

  2


 x 2 / 2 2

1
dx 

 2

1

 2

e
 x / 2
2

 
 e

2
e
 y 2 / 2 2
dxdy

 ( x 2  y 2 ) / 2 2
dxdy
  
Macquarie University 2004
19
1
 f ( x)dx   2
1

 2
2


0
0
  dxdy   d  rdr
 But using x 2  y 2  r 2 and

 
2

 d  re
0
 r 2 / 2 2
dr
0

2  re
 r 2 / 2 2
dr
0
Macquarie University 2004
20
 Cancelling

1
 f ( x)dx   2

1


 re

2  re
r 2 / 2 2
dr
0
 r 2 / 2 2
dr
0
Macquarie University 2004
21
 Then use the substitution:
v  r / 2
2
2
dv  (r /  )dr
2
dr  ( / r )dv
2
Macquarie University 2004
22
 And finally:
e

  2


 x 2 / 2 2

dx  1






re
0  r

v
2

dv

dv
e



0
 e
v

v 
0
1
Macquarie University 2004
23

The integral proves that the Gaussian is
normalised to unity – the area under the
curve is one.
u
 u
k 2
t
x
2


f ( x) 
e
 x 2 / 2 2
 2
But the heat equation is a function of x and
t, and uses a constant k.
k and t must be included in the  term of
the Gaussian if we are to say our model
satisfies this distribution.
Macquarie University 2004
24
What is  ?

From the Random Walk, we learned that
 √t.


Try a guess:
  2kt
The Gaussian becomes:
f ( x, t ) 
e
 x / 4 kt
2
4kt
Macquarie University 2004
25
Derivatives of the Gaussian

Space derivatives:
f
x

f
x
2kt
2
2


 f
1 x

 1 f

2
x
2kt  2kt 

The time derivative is left as an exercise …
Macquarie University 2004
26
The Gaussian satisfies the
Heat Equation



It can be shown that
the heat equation
is satisfied by our
guess.
u
 u
k 2
t
x
2
The distribution integrates to unity
(conservation of energy).
The spread of heat is given by  of the
Gaussian (normal) distribution.
Macquarie University 2004
27
Diffusion and the
Random Walk



The initial temperature spike grows into
a Gaussian distribution according to the
1D heat equation.
The width  grows in proportion to the
square root of elapsed time.
Heat and diffusion can be understood in
terms of the “random walk”.
Macquarie University 2004
28
Other Conditions



The initial condition may not be a spike,
but could be some initial distribution:
u(x,0)=g(x).
The boundary conditions may not be
absorbing, but could be continuous.
The thermal diffusivity constant k may
not be constant, but may vary with x or t.
Macquarie University 2004
29
Summary




The heat equation is a PDE.
By separating space and time variables, we see
that a Gaussian that spreads as √t is a solution.
We can model the differential equation as a
difference equation in Excel and see the same
effect.
The spread of heat is a physical example of a
random walk.
Macquarie University 2004
30
Acknowledgements


This presentation was based on lecture
material for PHYS220 presented by Prof.
Barry Sanders, 2000-2003.
Additional Reference:

Folland, Fourier Analysis and its
Applications, 1992.
Macquarie University 2004
31
Download