Professional Documents
Culture Documents
This worksheet is designed to introduce you to analytical solutions of the diffusion (or
heat) equation in 1D, on a finite domain. You should feel free to attempt the questions in
any order, although one approach to Questions 4–6 is to reuse results from Questions 1–3,
so you may want to attempt those first.
You will note that all of the questions are posed on the interval [0, 1], with diffusion
coefficient 1, and with simple boundary and initial conditions. Note that this is not what
you should expect from an industrial problem. Such problems will generally be posed on
physically-relevant intervals, with essentially arbitrary parameters, and possibly more com-
plicated boundary and initial conditions. You will see some of these problems in the first
Project. Later in the course we will also discuss non-dimensionalisation.
This will result in you having mastered (at least) two different approaches to solving these
real-world problems:
i) Repeat the sort of analysis used in the problems here, but in the more general case in-
cluding an arbitrary interval [a, b], diffusion coefficient D0 and boundary conditions. You can
then insert the relevant values from the industrially-motivated problem;
ii) Non-dimensionalise the industrially-motivated problem so that it lies on [0, 1], with diffu-
sion coefficient 1, and ‘simple’ boundary conditions. Use the solutions from this worksheet
to solve the problem, and then convert back to the physical dimensions.
Hopefully it’s obvious that the two approaches should give the same results. As such, you
should consider the problems here as model ones, which will allow you to appreciate the gen-
eral techniques necessary to find analytical solutions to (simplified versions of) the problems
in the Project. This is to mimic the idea that at University you are taught ‘sanitised’ version
of problems, generally with nice solutions that are tractable in a reasonable amount of time
(e.g., during an exam). Real-world problems tend to be (far) more complex, but often the
techniques you have learnt in your courses can be used to make a good attempt at a slightly
simplified version.
1
We will cover some examples of advection-diffusion equations later in the course. This
worksheet focusses on the separation of variables approach. There are many other ways to
solve these diffusion equations, for example through Fourier transform methods, although the
method presented here is probably the simplest. As well as solutions of ‘standard’ ODEs, you
will need to know the basics of Fourier series (here presented in sine and cosine expansions),
although really everything you need for this was covered in Video 1.6.
The problems focus on the following boundary conditions:
1. Zero Dirichlet;
2. Zero Neumann;
Solution:
We proceed by the method of separation of variables and write u(x, t) = X(t)T (t). This
results in ∂t u(x, t) = X(x)T 0 (t) and ∂xx u(x, t) = X 00 (x)T (t). Note that here, and throughout,
a prime (0 ) on a function of only one variable denotes differentiation with respect to that
variable.
Hence we have, from the PDE,
2
Now note that the function on the left depends only on x whereas the one on the right
depends only on t. Hence both functions must be independent of both x and t (otherwise
changing one of the variables changes only one side of the equality). We therefore have, for
some constant −λ,
X 00 (x) T 0 (t)
= = −λ.
X(x) T (t)
The reason for the choice to include a minus sign will become clear later.
We now have two ODEs to solve, one in x and one in t. Let’s start with the t equation:
X(0) = X(1) = 0.
X 00 (x) = k 2 X(x).
where the constants a and b are determined by the initial and boundary conditions.
Applying the boundary conditions gives
X(0) = 0 = a + b
X(1) = 0 = aek + be−k .
From the first equation we have b = −a and hence the second equation becomes a(ek −e−k ) =
0. Hence we have a = 0 or ek − e−k = 0. The case a = 0 gives only the trivial (constantly
zero) solution, which is unlikely to match any given initial condition (and we’ve assumed the
solution is non-zero). Hence we must have ek − e−k = 0, but this only holds when k = 0,
which contradicts the assumption λ < 0. Hence the only solution with λ < 0 is the trivial
solution.
ii) For λ = 0 we have
X 00 (x) = 0 ⇒ X(x) = ax + b.
Applying the boundary conditions gives
X(0) = 0 = b ⇒ b = 0
X(1) = 0 = a + b ⇒ a = 0.
3
Hence we once again only have the trivial solution.
iii) For λ > 0 we set λ = k 2 and wish to solve
X 00 (x) = −k 2 X(x).
where, once again, the constants a and b are determined by the initial and boundary condi-
tions.
Applying the boundary conditions gives
X(0) = a = 0
λn = (nπ)2 .
The challenge now is to find a solution u which satisfies the initial condition u(x, 0) = f (x).
Here we use the linearity of the problem. In particular, if u and v are both solutions to the
PDE (including the boundary conditions and a given initial condition), then u + v is also a
solution, but with a different initial condition. We may therefore write a general solution as
∞
X
u(x, t) = cn sin(nπx) exp(−n2 π 2 t).
n=1
The question remaining is how to find the cn to satisfy the initial condition.
To start with we have ∞
X
u(x, 0) = cn sin(nπx).
n=1
We will now use some properties of the functions sin(nπx), which are easily checked. In
particular we find that they are orthogonal on [0, 1]:
Z 1 (
0 n 6= m
sin(nπx) sin(mπx)dx =
0 1/2 n = m.
4
Taking our expansion of the initial condition, multiplying by sin(mπx) and integrating
over [0, 1] therefore gives
∞
X
u(x, 0) = f (x) = cn sin(nπx)
n=1
∞ Z
X 1 Z 1
⇒ cn sin(nπx) sin(mπx)dx = f (x) sin(mπx)dx
n=1 0 0
Z 1
⇒ cm /2 = f (x) sin(mπx)dx.
0
Solution:
We proceed through separation of variables as in Question 1 and find, once again, for some
constant −λ,
X 00 (x) T 0 (t)
= = −λ.
X(x) T (t)
The t equation again has solution
T (t) = C exp(−λt).
The key difference here lies in the boundary conditions. Once again, consider the three
cases λ > 0, λ = 0, and λ > 0. The x equation is given by
X 00 (x) = −λX(x).
i) λ < 0. Once again this results in only the trivial solution (check this yourself!).
ii) λ = 0. Here we find something other than the trivial solution. We have, as before,
X(x) = ax + b, with X 0 (x) = a. The boundary conditions give
X 0 (0) = X 0 (1) = a = 0
5
and hence there is a solution X(x) = b = c0 , for some constant to be determined.
iii) λ > 0. As before, we set λ = k 2 and wish to solve
X 00 (x) = −k 2 X(x).
X 0 (0) = bk = 0 ⇒ b = 0
X 0 (1) = −ak sin(k) = 0 ⇒ k = nπ,
Xn (x) = an cos(nπx), n ∈ N.
and so
∞
X
u(x, t) = c0 + cn cos(nπx) exp(−n2 π 2 t)
n=1
Z 1
c0 = f (x)dx
0
Z 1
cn = 2 f (x) cos(nπx)dx, n > 0.
0
3: Zero Mixed
Find an analytical solution for the equation
6
Solution:
We focus only on the x equation with λ > 0; the t equation is the same as before and the
other cases for λ give the trivial solution.
As before, we have
X(x) = a cos(kx) + b sin(kx)
X 0 (x) = −ak sin(kx) + bk cos(kx).
The boundary conditions require
X(0) = 0 = a
X 0 (1) = 0 = bk cos(kx) ⇒ cos(kx) = 0.
Where, as always, we exclude the trivial solution. This corresponds to
k = (n + 1/2)π, n = 0, 1, 2, . . . .
Using that (
1
n 6= m
Z
0
sin((n + 1/2)πx) sin((m + 1/2)πx)dx =
0 1/2 n = m.
gives
∞
X
u(x, t) = cn sin((n + 1/2)πx) exp(−(n + 1/2)2 π 2 t)
n=0
Z 1
cn = 2 f (x) sin((n + 1/2)πx)dx.
0
4: Inhomogeneous Dirichlet
Find an analytical solution for the equation
∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)
u(0, t) = 0;
u(1, t) = 1;
u(x, 0) = f (x).
Hint: use linearity of the solution.
Solution:
To tackle this problem, we are going to use a very general approach, hinted at in the solution
to Question 1. Namely, if u and v are two solutions to the PDE with
∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)
u(0, t) = u0 ;
u(1, t) = u1 ;
u(x, 0) = fu (x).
7
and
The idea is therefore to find any function v that satisfies the PDE and boundary conditions
v(0, t) = 0, v(1, t) = 1, with initial condition fv (x). We look at a function w = u − v which
must satisfy
So how do we find such a solution? Well, we’ve essentially already seen how to obtain it
when we looked at the case λ = 0, which corresponded to a solution X(x) = ax+b. Choosing
a = 1 and b = 0 gives the solution
v(x, t) = x, v(0, t) = x.
8
It remains to reconstruct u = w + v, and so
∞
X
u(x, t) = cn sin(nπx) exp(−n2 π 2 t) + x
n=1
Z 1
cn = 2 [f (x) − x] sin(nπx)dx.
0
9
In this case determine all coefficients explicitly.
Note that the initial condition is not compatible with the boundary conditions, but it
will turn out that this doesn’t matter (essentially because the solutions are different only on
a set of measure zero).
Solution:
This is the same as Question 2 with a specific choice of x. We therefore have a solution
∞
X
u(x, t) = c0 + cn cos(nπx) exp(−n2 π 2 t)
n=1
Z 1
c0 = f (x)dx
0
Z 1
cn = 2 f (x) cos(nπx)dx, n > 0.
0
10