Numerical Solution To Diffusion Problems & Atomic Models for Diffusion
2026-01-28
Key ideas from last lecture:
After today’s lecture, you will be able to:
In many cases the analytical solutions to a diffusion equation is hard / impossible to obtain, due to:
We need numerical methods for these situations!
For 1D problem 👉 use the finite difference (FD) method first proposed by Euler.
To solve the diffusion equation, we need to discretize spatial and temporal domains into “grids”.
In Fick’s second law, the required derivatives and their finite-difference approximations are summarized below. The concentration on grid is \(c(i,j)\), where \(i\) indexes space and \(j\) indexes time.
| derivative | finite-difference approximation | scheme |
|---|---|---|
| \(\displaystyle \frac{\partial c}{\partial t}\) | \(\displaystyle \frac{c(i,\,j+1) - c(i,\,j)}{\Delta t}\) | forward (time) |
| \(\displaystyle \frac{\partial c}{\partial x}\) | \(\displaystyle \frac{c(i+1,\,j) - c(i-1,\,j)}{2\Delta x}\) | central (space) |
| \(\displaystyle \frac{\partial^2 c}{\partial x^2}\) | \(\displaystyle \frac{c(i+1,\,j) - 2c(i,\,j) + c(i-1,\,j)}{(\Delta x)^2}\) | central (space) |
Fick’s second law is PDE which is hard to integrate directly. Method of lines use the following strategies:
After spatial discretization 👉 ODE in temporal domain
\[\begin{align} \frac{d c(i,t)}{d t} = D \frac{c(i+1,t) - 2c(i,t) + c(i-1,t)}{(\Delta x)^2} \end{align}\]Each spatial node \(i\) (line) corresponds to one ODE, hence the name.
Grid stability condition
\[\Delta t \le \frac{(\Delta x)^2}{2D}\]
Convergence: are \(\Delta t\) and \(\Delta x\) small enough?
Numerical precision: stiff diffusion problems (e.g. Nernst-Planck) may require higher numerical precision
Boundary condition implementation
Conservation
Solving steady state problem (Laplace problem) can be non-trivial
scipy.integrate.solve_ivp for time integrationMOL can usually be implemented using pure Python in less than 20 lines (really not that difficult!)
How do FD compare with analytical solution?
The first diffusivity in metal was presented in 1894 by Roberts-Austen using diffusion of Au in liquid Pb. (See review by Mehrer and Stolwijk, Diffusion Fundamentals, 2008, 1, 1-32).
The experiment is basically a solid Au-Pd alloy cylinder diffusing into semi-infinite molten Pd at \(T\)=492 ℃, as the geometry below. Experiment weight fraction of Au was determined by precision scales on sections of cylinder after \(t=6.96\) days. Can we verify his results of diffusivity (\(\tilde{D}=3.00\) cm\(^2\)d\(^{-1}\))?
See Bakerian Lecture: On the Diffusion of Metals. Roberts-Austen


Example 1: Ir–Re diffusion couple annealed at 2400°C (adapted from MIT KOM course)
Example 2: Os-W diffusion couple annealed at 2200°C (adapted from MIT KOM course)
pyDiffusionTwo major achievements in 20th century
A particle undergoes a sequence of thermally activated jumps
\[ \vec{R}(N_s) = \sum_{k=1}^{N_s} \vec{r}_k \]
Mean squared displacement (MSD):
\[ \langle R^2(N_s) \rangle = \left\langle \vec{R}(N_s)\cdot \vec{R}(N_s) \right\rangle \]
Expand the dot product:
\[ R^2(N_s) = \sum_{k=1}^{N_s} |\vec{r}_k|^2 + 2\sum_{k=1}^{N_s-1}\sum_{m=k+1}^{N_s} \vec{r}_k \cdot \vec{r}_m \]
If successive jumps are uncorrelated (random directions):
\[ \langle \vec{r}_k \cdot \vec{r}_m \rangle = 0 \quad (k\neq m) \]
Then
\[ \langle R^2(N_s) \rangle = N_s \langle r^2 \rangle \]
where \(\langle r^2 \rangle\) is the mean squared jump distance.
Consider diffusion from a point source in 3D into infinite space. The concentration at each \(r\) at any time \(t\) is \(c(r, t)\)
Define MSD as the normalized second moment of \(c(r, t)\)
\[ \langle R^2(t)\rangle = \frac{\int_0^\infty r^2\,c(r,t)\,4\pi r^2\,dr}{\int_0^\infty c(r,t)\,4\pi r^2\,dr} \]
Luckily, the solution to \(c(r, t)\) was already known in 1905 as Gaussian (also from last lecture):
\[ c(r, t) = \frac{N}{{\sqrt{4 \pi Dt}}^3} \exp\!(-\frac{r^2}{4Dt}),\qquad r^2 = x^2 + y^2 + z^2 \]
Use the Gaussian form, Einstein showed for 3D random jump, we have
\[ \langle R^2(t)\rangle = 6Dt \]
More generally in \(d\) dimensions:
\[ \langle R^2(t)\rangle = 2d\,Dt \]
1D random walk with step \(\pm 1\) (site index \(n\))
Constraints after \(N_\tau\) steps:
\[ N_R - N_L = n,\quad N_R + N_L = N_\tau \]
Number of ways (binomial):
\[ U(n,N_\tau)=\frac{N_\tau!}{N_R!N_L!} \]
For an unbiased walk \(p_L=p_R=1/2\):
\[ p(n,N_\tau) = \frac{N_\tau!}{N_R!N_L!}\left(\frac12\right)^{N_\tau} \]
Large-step limit gives Gaussian form:
\[ p(n,N_\tau)\propto \exp\!\left(-\frac{n^2}{2N_\tau}\right) \]
Identify:
From MSD (1D):
\[ \langle x^2(t)\rangle = \langle n^2\rangle (\Delta x)^2 \sim N_\tau (\Delta x)^2 \sim \Gamma t (\Delta x)^2 \]
Compare with Einstein (1D): \(\langle x^2(t)\rangle = 2Dt\)
\[ D = \frac{\Gamma (\Delta x)^2}{2} \qquad \text{(in 1D)} \]
General \(d\)-D form:
\[ D = \frac{\Gamma \langle r^2\rangle}{2d} \]