








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!









In this lab, we consider the partial differential equation known as the diffusion equation. Let γ represent the concentration of a substance along a one- dimensional interval in the coordinate x. If the diffusion of the substance is governed by Fick’s Law, then γ satisfies the diffusion equation,
γt(t, x) = Dγxx(t, x) (1)
Note. • Subscripts denote partial differentiation, so that γt = ∂γ ∂t.
γ(t + ∆t, x) = γ(t, x) + γt(t, x)∆t + O((∆t)^2 )
⇒
γ(t + ∆t, x) − γ(t, x) ∆t
= γt(t, x) + O(∆t)
As a first order approximation, this defines the finite difference,
γtt(t, x) ≈
c(t + ∆t, x) − c(t, x) ∆t
I now approximate the spatial derivative, holding the time component fixed,
γ(t, x + ∆x) + γ(t, x − ∆x) = 2γ(t, x) + 2 ·
γxx(t, x) 2
(∆x)^2 + O((∆x)^4 )
γ(t, x + ∆x) − 2 γ(t, x) + γ(t, x − ∆x) (∆x)^2
= γxx(t, x) + O((∆x)^2 )
As a second order approximation, this defines the finite difference,
γxx(t, x) ≈
c(t, x + ∆x) − 2 c(t, x) + c(t, x − ∆x) (∆x)^2
Substituting (2) and (3) into the diffusion equation (1) gives a recursive relationship that defines the approximation c(x, t),
c(t + ∆t, x) − c(t, x) ∆t
c(t, x + ∆x) − 2 c(t, x) + c(t, x − ∆x) (∆x)^2
⇒ c(t + ∆t, x) = c(t, x) + D
∆t (∆x)^2
c(t, x + ∆x) − 2 c(t, x) + c(t, x − ∆x)
I now consider a particular mesh of points with fixed spacing to compute the approximation c(x, t). In particular, I consider c(m · ∆x, n · ∆t), where m and n are integers. Let m be chosen such that there are a total of M interior mesh points on the spatial interval [a, b] where the approximation is to be obtained. This determines the spacing of the mesh points,
∆x =
(b − a) M + 1
Note. The points c(0∆x, t) and c(M∆x, t) correspond to the endpoints of the spatial interval. The values of the exact solution at these points are given in the problem statement. I set the values of the approximation equal to the exact values at these endpoints, and hence my interpolation scheme deals only with the interior spatial mesh points.
Hence,
c(t + ∆t) = c(t) + D
∆t (∆x)^2
1 2 −^1
1 2
= c(t) ( 1 1 + A)
The resulting coefficient matrix A is conveniently tri-diagonal.
Sections 2 and 3: Solving the PDE
Exact solution
Before calculating any approximations, I solve the differential equation (1) analytically, so that I can determine the accuracy of my numerical approxi- mations. In lecture, we found that exact solutions to the diffusion equation are given by,
γ(t, x) =
πDt
−∞
γ(0, x′)e−^
(x−x′)^2 4 Dt (^) dx′^ (4)
where x′^ is an arbitrary dummy variable of integration. I am given the explicit form of γ(0, x′) as an initial condition, γ(0, x′) = sin(x′). To perform the integral in (4), I write the sinusoid as part of an imaginary exponential,
1 2
πDt
−∞
sin(x′)e−^
(x−x′)^2 4 Dt (^) dx′^ = 1 2
πDt
−∞
eıx
′ e−^
(x−x′)^2 4 Dt (^) dx′
To convert the integral into a familiar Gaussian, I complete the square in the
exponent,
−
4 Dt
(x − x′)^2 + ıx′^ = −
4 Dt
x^2 +
2 Dt
xx′^ −
4 Dt
x′^2 + ıx′
4 Dt
x′^2 + x′
2 Dt
x + ı
4 Dt
x^2
4 Dt
x′^2 − (2x + 4ıDt)
4 Dt
x^2
= −
4 Dt
[x′^2 − (2x + 4ıDt)
4 Dt
x^2
= −
4 Dt
(x′^ − (x + 2ıDt)) 2 (x + 2ıDt)^2
4 Dt
x^2
= −
4 Dt
[x′^ − (x + 2ıDt)] 2
4 Dt
x^2 +
4 Dt
(x + 2ıDt)^2
x′ 2
Dt
x 2
Dt
Dt
4 Dt
x^2 +
4 Dt