You are on page 1of 23

The diffusion PDE

1D Diffusion PDE
Introduction to Partial Differential Equations
part of EM, Scalar and Vector Fields module (PHY2064)

Richard Sear

November 17, 2017

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension

This lecture
Diffusion PDE in 1D
Method of Separation of Variables to solve diffusion PDE
Particular solution with just one wavevector k
Particular solutions using Fourier series
Particular solution that is a Gaussian function

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension


The one-dimensional diffusion equation, for a function P(x, t), is
∂ 2 P(x, t) 1 ∂P(x, t)
2
=
∂x D ∂t
or equivalently
∂P(x, t) ∂ 2 P(x, t)
=D
∂t ∂x 2
where D is the diffusion constant. The larger the value of D the
faster is diffusion. D has units of length squared over time. Note
that it is a linear homogeneous PDE, and that it is very similar to
the wave PDE except that the time derivative is first order not
second order.
P could be, for example, the concentration of say sugar molecules
in water. Thermal energy also diffuses, so P could also be
temperature. Other conserved quantities can also diffuse, so it
some circumstances a component of the momentum will also obey
this PDE.
Richard Sear 1D Diffusion PDE
The diffusion PDE

Diffusion equation in one dimension: Standing wave


solutions via method of separation of variables

The main technique we will use for solving the wave, diffusion and
Laplace’s PDEs is the method of Separation of Variables. For the
diffusion equation in 1D this works as follows.

We know the solution will be a function of two variables: x and t,


P(x, t). We assume it has a specific form, namely that it is the
product of a function only of x, X (x), times a function only of t,
T (t).
P(x, t) = X (x)T (t)
Using this we can break the PDE into a pair of ODEs, each of
which is much easier to solve than the PDE.
Note that this assumption is wrong for most functions of x and t,
e.g., P(x, t) = x + t cannot be written in the form of X (x)T (t).

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Standing wave


solutions via method of separation of variables

Because the assumption P(x, t) = X (x)T (t) is not correct in most


cases it will give us a solution but usually not the particular
solution that is consistent with the boundary conditions.

This is where Fourier series come in. We will find that X can be a
sine and a cosine, and from the mathematics of Fourier series we
know we can write essentially any function as a sum of sines and
cosines. Because we can write any function as a Fourier series, we
can use a Fourier series to satisfy any set of BCs.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Standing wave and


travelling wave solutions

The one-dimensional diffusion equation, for a function P(x, t), is

∂ 2 P(x, t) 1 ∂P(x, t)
2
=
∂x D ∂t
If we substitute P(x, t) = X (x)T (t) into the one-dimensional wave
equation we get

∂ 2 X (x)T (t) 1 ∂X (x)T (t)


2
=
∂x D ∂t

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Standing wave


solutions

Because we can take T out of the x differentiation as it is


independent of x, and similarly we can take X out of the t
differentiation, this becomes

d2 X (x) 1 dT (t)
T (t) = X (x)
dx 2 D dt
If we divide both sides by XT , we get

1 d2 X (x) 1 1 dT (t)
2
=
X (x) dx D T (t) dt

Now, we notice that the left-hand side is a function of x but not of


t while the right-hand side is a function of t but not of x.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Standing wave


solutions
So the LHS tells us that the equation does not depend on t (the
only function of t is T and that is not present on the LHS), and
the RHS tells us that it does not depend on x. Therefore it cannot
depend on either x or t, and so must be a constant. At the
moment we don’t know what this constant is and so could call it
C . But as we’ll see we’ll need it to be negative, and it will help if
is squared, so we will call this constant −k 2 .

So we have
1 d2 X (x) 1 1 dT (t)
2
= = −k 2
X (x) dx D T (t) dt
which gives us the two ODEs
d2 X (x) dT (t)
= −k 2 X (x) and = −k 2 DT (t)
dx 2 dt
Richard Sear 1D Diffusion PDE
The diffusion PDE

Diffusion equation in one dimension: Standing wave


solutions
Revision The ODE for X is just the ODE for SHM
d2 X (x)
= −k 2 X (x)
dx 2
as for the wave PDE but the ODE for T is the same as ODE that
describes radioactive decay
dT (t)
= −k 2 DT (t)
dt
The solutions of these ODEs are
X (x) = A cos(kx) + B sin(kx) and T (t) = C exp(−k 2 Dt)
Note that these are the general solutions to these ODEs, because
the solution to the second order ODE has two unknown constants
(A and B), while that for the first-order ODE has one unknown
constant (C ).
Richard Sear 1D Diffusion PDE
The diffusion PDE

Why the minus sign?

We choose the − sign as we wanted sine and cosine functions for


X (x) and a decaying exponential for T (t).

If we picked a + sign, we would get exponentials for X (x), plus an


increasing exponential for T (t). The increasing exponential for
T (t) would give solutions where diffusion, a spontaneous process,
makes molecules more localised. This violates the 2nd Law of
Thermodynamics becuase it reduces the entropy, so is not
physically allowed.

The fact that k is squared is because if we do this we get that k is


just the standard wavevector a wave, i.e., k = 2π/λ, for λ the
wavelength of the wave.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Standing wave


solution

We can multiply X and T together and get the solution for P

P(x, t) = X (x)T (t) = [A cos(kx) + B sin(kx)] C exp(−k 2 Dt)

P(x, t) = AC cos(kx) exp(−k 2 Dt) + BC sin(kx) exp(−k 2 Dt)


or defining the two new constants F = AC and E = BC

P(x, t) = F cos(kx) exp(−k 2 Dt) + E sin(kx) exp(−k 2 Dt)

This solution has two terms: an exponentially decaying cosine


wave and an exponentially decaying sine wave.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Boundary conditions and particular solutions

As always, determining the particular solution requires not just


solving the PDE, but imposing the BCs. Three types of particular
solution:
Solution with just one wavevector k, i.e., P(x, t) consists of
terms with only one wavelength.
Fourier series solution: gives general solution of diffusion PDE.
Gaussian solution: Roughly speaking these are used when we
start with whatever is diffusing localised at a point. Then the
Gaussian describes how whatever is diffusing spreads out.
Note that a Fourier series gives a general solution but that if whatever is
diffusing (molecules, electrons, thermal energy, etc) starts off
concentrated at a point (i.e., for that initial BC) the solution can more
easily be written as a Gaussian.

Richard Sear 1D Diffusion PDE


The diffusion PDE

BCs for example with only one wavevector k

A possible solution of the wave function consists of cosine and sine


standing waves of amplitudes F and E

P(x, t) = F cos(kx) exp(−k 2 Dt) + E sin(kx) exp(−k 2 Dt)

Because the diffusion equation is first order with respect to the


time derivative, BCs that are initial BCs need to specify only the
profile P(x, t) at t = 0, e.g., via a BC

P(x, t = 0) = 10 cos(0.75x)

this is different from the wave PDE, because the wave PDE is
second order in time.

Richard Sear 1D Diffusion PDE


The diffusion PDE

BCs for example with only one wavevector k

If we impose this BC, we get

P(x, t = 0) = 10 cos(0.75x) = F cos(kx) exp(0) + E sin(kx) exp(0)

or
10 cos(0.75x) = F cos(kx) + E sin(kx)
so we must have that k = 0.75, F = 10 and E = 0. The solution
then becomes

P(x, t) = 10 cos(0.75x) exp(−0.5625Dt)

Richard Sear 1D Diffusion PDE


The diffusion PDE

BCs for example with only one wavevector k


As the particular solution is
P(x, t) = 10 cos(0.75x) exp(−0.5625Dt)
It is just an exponentially decaying single cosine wave, see below
for plots of P(x, t = 0) (thick green curve), P(x, t = 1) (medium
red) and P(x, t = 3) (thin blue).

10
P (x, t = constant)

−10
0 5 10 15
x
Richard Sear 1D Diffusion PDE
The diffusion PDE

Diffusion equation in one dimension: Fourier series solution

We can write any periodic solution with any BCs, of the diffusion
PDE as

1 X
P(x, t) = a0 + [an cos(kn x) + bn sin(kn x)] exp(−kn2 Dt)
2
n=1

the period can be anything. a0 is the constant term. The


wavevector of the nth term, kn , is: kn = 2πn/L, for L the period of
P(x, t). The boundary conditions will determine the values of the
constants a0 , an and bn , and of the kn and then once these values
are determined we have the particular solution.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Fourier series solution

So to find a particular solution of the diffusion PDE with initial


BCs (i.e., function at t = 0), the procedure is as follows
1 Write down both the general expression for the Fourier series
solution of the diffusion PDE, and the expressions for a0 , an
and bn .
2 Use the expressions for a0 , an and bn in terms of integrals
over the function at t = 0, to calculate a0 , an and bn .
3 Put the now known values of a0 , an and bn in the Fourier
series general solution of the diffusion PDE, to get the
particular solution we want.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Fourier series solution

We can consider a simple example: the square wave, defined by



−1 −π < x < 0
P(x, t = 0) =
+1 0 < x < π

As we saw in the Fourier series revision part of this course, this can
be written as the sum of sine waves
X 4
P(x, t = 0) = sin (nx)

n=1,3,5,7,...

Note that for this square wave, a0 = an = 0 and only the bn for
odd values of n are non-zero (and equal to 4/nπ). Also, here
kn = n as the period is 2π.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Fourier series solution

To convert this to a solution of 1D diffusion we just multiply by


= exp(−kn2 Dt) = exp(−n2 Dt) - because here kn = n
X 4
sin (nx) exp −n2 Dt

P(x, t) =

n=1,3,5,7,...

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Fourier series solution


A plot of a sine wave approximation (up to n = 17) square-wave
travelling wave P(x, t = constant) of wavelength L = 2π, at three times,
t = 0 (thick green), t = 0.2 (medium red), and t = 1 (thin blue). The
diffusion constant D = 1.

1.5
P (x, t = constant)

1.0
0.5
0.0
−0.5
−1.0
−1.5
0 5 10 15
Richard Sear 1D Diffusion PDE
The diffusion PDE

Diffusion equation in one dimension: Gaussian solution

As we saw in question sheet 2, the 1D diffusion equation can be


solved by a Gaussian function of x, with a t −1/2 dependence of the
prefactor, and the x 2 in the exponential divided by 4Dt

x2
 
A
P(x, t) = 1/2 exp −
t 4Dt

for A a constant.

The Gaussian function is appropriate to the BC where at t = 0, P


is a delta function, i.e., is zero everywhere except at the origin. So
if there is localised hot spot at t = 0, then a Gaussian P describes
how the heat spreads out from this initial hot spot.
Also, if we know a molecule is at the origin at t = 0, and after that
it diffuses, then a Gaussian P is also the correct solution.

Richard Sear 1D Diffusion PDE


The diffusion PDE

Diffusion equation in one dimension: Gaussian solution


A plot of a profile P(x, t = constant) at three different times, that is
spreading via diffusion. The profile started localised at x = 0 at t = 0.
The thick green, medium red and think blue curves are at times t = 0.01,
1.0 and 3.0, respectively.

3.0
P (x, t = constant)

2.5
2.0
1.5
1.0
0.5
0.0
−4 −2 0 2 4
x
Richard Sear 1D Diffusion PDE
The diffusion PDE

Diffusion equation in one dimension

This lecture
Diffusion PDE in 1D
Method of Separation of Variables to solve diffusion PDE
Particular solution with just one wavevector k
Particular solutions using Fourier series
Particular solution that is a Gaussian function

Richard Sear 1D Diffusion PDE

You might also like