## The Diffusion Equation (Part 1)

### Introduction

Diffusion is the complicated process by which particles in two or more different substances mix together as a result of random motion. The particles move around, bump into each other, and redistribute themselves in a random way over time. Amazingly, after enough time has passed, the substances will be completely mixed together with no help from anybody stirring the mixture. We see diffusion in many areas of physics and chemistry - mixing solutions, Brownian motion, osmosis, etc.

A particle undergoing diffusion will experience huge numbers of collisions every second from all of the other particles randomly moving about and bumping into each other. Classical mechanics is not equipped to handle this problem because of the huge number of particles and collisions. Instead, we will turn to statistical physics to tell us something about the system.

### Deriving the Diffusion Equation

We can’t possibly keep track of every single particle that diffuses through a mixture. Instead, we will keep track of the number density of particles in every unit of space at every unit of time. We will call this number density $\phi(x,t)$. Notice that we are only looking at particle density along a single direction (x). We are only going to derive the diffusion equation in one dimension for now, just to get a good feel for what it entails. I might derive the three-dimensional diffusion equation at a later date (although it is pretty straightforward to do).

Let’s start our analysis with the continuity equation. The continuity equation states that the amount of “stuff” that goes into some volume of space minus the amount of “stuff” that leaves that volume of space, must equal the change in the amount of “stuff” in that volume of space. We can write that as:

In the equation above, $\phi$ is the number density of particles at some point in space and time while $\vec{j}$ is the flux of particles entering or leaving that point in space at that time. The continuity equation is a broad expression for any conserved quantity. We can combine the continuity equation with Fick’s first law in order to derive the diffusion equation.

Let’s assume that the diffusivity is a constant. In other words, $D$ does not depend on position ($x$), time ($t$), or number density ($\phi$). Then:

We are only going to analyze the diffusion equation in one dimension (along the $x$-axis), so the expression becomes:

### Solving the Diffusion Equation

Oftentimes when you solve the diffusion equation, you focus on the technique of separation of variables. Paul’s Online Notes is a great resource if you are not sure how to go through this procedure. I personally am not a huge fan of separation of variables for this formula because your final answer is an infinite series of sines and exponentials. It is a technically correct answer, but it is also difficult to draw real and useful conclusions from it.

I want to tackle this problem in a different way using the Laplace Transform. Yes, this is slightly more advanced math, but it will yield a pretty cool answer that actually makes intuitive sense.

Let’s begin by taking the Laplace transform of each side of the diffusion equation. I have included the arguments $(x,t)$ for the number density, just to keep everything clear. I write the Laplace transform of the number density as $\mathscr{L} \phi(x,t) = \Phi(x,s)$. Otherwise, I simply used a table of Laplace transforms and some math:

We have converted a differential equation for $\phi$ in terms of $x$ and $t$ to a new differential equation for $\Phi$ in terms of $x$ only. The one for $\Phi$ is much easier to solve than the one for $\phi$. In fact, if you have taken a course in differential equations, you might be able to solve it by inspection alone. Let’s work it out in detail. The total solution to the differential equation is the sum of the homogeneous and particular solutions:

First, we need to solve for the homogeneous solution. Let $\Phi_h = e^{\lambda x}$. Remember, this differential equation is only in terms of $x$, so variable $s$ is treated as a constant. Then:

The homogeneous solution is:

Now we can solve for the particular solution. We do not know what $\phi(x,0)$ is, but we can still use the method of variation of parameters to get a genral solution. We start off with the Wronskian:

And then write out the integral for the particular solution:

The general solution then becomes:

We can simplify the expression further by adding the condition that $\phi(x,t)$ be bounded (and then, by extension, $\Phi(x,s)$ also be bounded). In other words, the limit of $\Phi$ as variable $x$ approaches infinity must equal zero.

Then the first part of the expression yields:

And the second part of the expression yields:

Alright. Take $C_1$ and $C_2$. Plug them back into the expression for $\Phi$. Do some cancelling. I swear we are in the home stretch..

Ok, assuming that I did not make any stupid math mistakes, we have gotten to a nice, simple(?), expression for $\Phi$. To finish this problem, I am going to take the inverse Laplace transform (once again using a table of Laplace transforms):

The exponent inside the integral sign is called the heat kernel. We will definitely revisit it at a later date - there is lots of interesting structure in that expression. For now, let’s finish up the problem. Suppose that at time $t=0$, all of the particles are at the origin. In other words, we can represent the total initial number density as a Dirac delta function -> $\phi(\alpha,0) = \delta(\alpha)$. The final expression becomes:

### Conclusion

Whew, that was a lot of math today. But we did get an answer for the diffusion equation that does not involve a bunch of sines and exponentials! Instead, it is a strange Gaussian-looking equation that evolves with time.

Next week, we will visualize this answer and take a look at it on a deeper level.  