% vim: tw=50
% 28/10/2022 10AM

\section{The Diffusion Equation}

\subsection{Physical origin of heat equation}

Applies to processes that ``diffuse'' due to
spatial gradients. An early example was Fick's law
with flux $\bf{J} = -D \nabla c$ with
concentration $c$ and diffusion coefficient $D$.
For \emph{heat flow} we have Fourier's law
\[ \bf{q} = -k \nabla \theta \tag{4.1} \]
($\bf{q}$ is heat flux, $k$ is thermal
conductivity, $\theta$ is temperature)
In a volume $V$, the overall heat energy $Q$ is
\[ Q = \int c_V \rho \theta \dd V \tag{4.2} \]
so rate of change due to heat flow
\[ \dfrac{Q}{t} = \int c_v \rho \pfrac{\theta}{t}
\dd V \tag{$*$} \]
\begin{center}
    \includegraphics[width=0.6\linewidth]
    {images/2fdb61f656a211ed.png}
\end{center}
Now integrate (4.1) over surface $S$ enclosing $V$
\begin{align*}
    -\dfrac{Q}{t}
    &= \int_S \bf{q} \cdot \hat{\bf{n}} \dd S \\
    &= \int_S (-k \nabla \theta) \cdot
    \hat{\bf{n}} \dd S \\
    &= \int (-k \nabla^2 \theta) \dd V \tag{\dag}
\end{align*}
Equating ($*$) and (\dag) we find
\[ \int \left( c_v \rho \pfrac{\theta}{t} - k
\nabla^2 \theta \right) \dd V = 0 \]
True for all $V$, so integrand must vanish, so
\[ \pfrac{\theta}{t} - \frac{k}{c_v \rho} \nabla^2
\theta = 0 \]
so if we set $D = \frac{k}{c_v \rho}$ we have
\begin{flashcard}[diffusion-equation]
\prompt{Diffusion equation?}
\[ \boxed{\cloze{\pfrac{\theta}{t}} =
\cloze{D \nabla^2 \theta \tag{4.3}}} \]
\prompt{where $D = \cloze{\sqrt{\frac{k}{c_v
\rho}}}$.}
\end{flashcard}

\subsubsection*{Brownian motion (random walk)}

Gas particles are diffusing by scattering every
$\Delta t$ with probability PDF $p(\xi)$ of moving
distance $\xi$ with
\[ \langle \xi \rangle = \int p(\xi) \xi \dd \xi =
0 \]
Suppose the PDF after $N\Delta t$ steps is
$P_{N\Delta t}(x)$, then for the $(N + 1)\Delta t$
step:
\begin{align*}
    P_{(N + 1)\Delta t}(x)
    &= \int_{-\infty}^\infty p(\xi) P_{N\Delta
    t}(x - \xi) \dd \xi \\
    &\approx \int_{-\infty}^\infty p(\xi)
    \left[P_{N\Delta t}(x) + P_{N\Delta t}'(x)(-\xi) +
    P_{N\Delta t}''(x) \frac{\xi^2}{2} + \cdots
    \right] \dd \xi \\
    &= P_{N\Delta t}(x) - P_{N\Delta t}'(x)
    \langle \xi \rangle + P_{N\Delta t}''(x)
    \frac{\langle \xi^2 \rangle}{2} + \cdots
\end{align*}
Note that $\langle \xi \rangle$ is the mean of
$\xi$ which is 0. Denote $P_{N\Delta t}(x) = P(x,
N\Delta t)$, then we have
\[ P(x, (N + 1)\Delta t) - P(x, N\Delta t) =
\pfrac[2]{}{x} P(x, N\Delta t) \frac{\langle \xi
\rangle^2}{2} \]
Assuming $\frac{\langle \xi \rangle^2}{2} =
D\Delta t$ then $\Delta t \to 0$. We find
\[ \pfrac{P}{t} = D \pfrac[2]{P}{x} \tag{4.4} \]

\subsection{Similarity solution}

The characteristic relation between variance and
time, suggest seeking solutions with dimensionless
parameter
\begin{flashcard}[similarity-parameter]
\prompt{Dimensionless parameter of similarity
solution for heat equation?}
\[ \eta \equiv \cloze{\frac{x}{2\sqrt{Dt}}
\tag{4.5}} \]
\end{flashcard}
Can we find solutions $\theta(x, t) =
\theta(\eta)$?
Change variables in (4.3):
\[ LHS: \pfrac{\theta}{t} = \pfrac{\eta}{t}
\pfrac{\theta}{\eta} = -\half \frac{x}{\sqrt{D}
t^{3/2}}\theta' = -\half \frac{\eta}{t} \theta' \]
\[ RHS: D \pfrac[2]{\theta}{x} = D \pfrac{}{x}
\left( \pfrac{\eta}{x} \pfrac{\theta}{\eta}
\right) = D \pfrac{}{x} \left( \frac{1}{2\sqrt{D}t
}\theta' \right) = \frac{D}{4D t}\theta'' =
\frac{1}{4t} \theta'' \]
Equating
\[ \theta'' = -2\eta \theta' \tag{4.6} \]
Take $\psi = \theta'$, $\frac{\psi'}{\psi} =
-2\eta \implies \ln \psi = -\eta^2 + \text{const}$
\[ \implies \psi = \theta' = (\text{const})
e^{-\eta^2} \]
Integrate to find
\[ \theta = c \frac{2}{\sqrt{\pi}} \int_0^\eta
e^{-u^2} \dd u = c \erf \left( \frac{x}{2\sqrt{D
t}} \right) \tag{4.7} \]
where the error function is
\[ \erf (Z) = \frac{2}{\sqrt{\pi}} \int_0^z
e^{-u^2} \dd u \]
This describes discontinuous initial conditions
that spread over time ($D = 1$):
\begin{center}
    \includegraphics[width=0.6\linewidth]
    {images/82bab2ac56a511ed.png}
\end{center}

\subsection{Heat conduction in a finite bar}

Suppose we have a bar of length $wL$ with $-L \le
x \le L$ and initial temperature:
\[ \theta(x, 0) = H(x) = \begin{cases}
    1 & 0 \le x \le L \\
    0 & -L \le x < 0
\end{cases} \tag{4.8} \]
with boundary conditions
\[ \theta(h, t) = 1, \quad \theta(-h, t) = 0
\tag{4.9} \]
Transforming boundary conditions:
The boundary conditions (4.9) are not homogeneous.
Can we identify steady state solution (time
independent) that reflects late-time behaviour?
Try
\[ \theta_s(x) = Ax + B \]
satisfies $\pfrac[2]{\theta}{x} = 0$. To satisfy
(4.9), $A = \frac{1}{2L}$, $B = \half$.
\[ \theta_S = \frac{x + L}{2L} \tag{4.10} \]
Transform and solve for
\[ \hat{\theta}(x, t) = \theta(x, t) - \theta_S(x) \]
with homogeneous boundary conditions
\[ \hat{\theta}(-L, t) = \hat{\theta}(L, t) = 0 \]
and initial conditions
\[ \hat{\theta}(x, 0) = H(x) - \frac{x + L}{2L} \]
Separation of variables: try
\[ \hat{\theta}(x, t) = X(x) T(t) \]
\[ \implies X'' = -\lambda X, \dot{T} = -D \lambda
T \tag{4.12} \]
Boundary conditions imply $\lambda > 0$ with
\[ X(x) = A \cos \sqrt{\lambda} x + B \sin
\sqrt{\lambda} x \]
For $\cos(\sqrt{\lambda} L) = 0$
\[ \implies \sqrt{\lambda_m} = \frac{m\pi}{2L}
\qquad m = 1, 3, 5, \dots \]
$\sin(\sqrt{\lambda} L) = 0$
\[ \implies \sqrt{\lambda_n} = \frac{n\pi}{L}
\qquad n = 1, 2, 3, \dots \]
but initial conditions are \emph{odd} ($A_m = 0$)
so take
\[ X_n = B_n \sin \frac{n\pi x}{L} \quad \lambda_n
= \frac{n^2 \pi^2}{L^2} \]
Put $\lambda_n$ into (4.12) $\dot{T} = -D \lambda
T$ to find
\[ T_n(t) = C_n \exp \left( -\frac{Dn^2
\pi^2}{L^2}t \right) \]
