# Diffusion¶

## Model¶

The example model single-compartment-diffusion is a single compartment that contains two species: ‘fast’ and ‘slow’, each with the same analytic initial distribution

The two species have different diffusion coefficients: \(D=1cm^2/s\) for species ‘slow’, and \(D=3cm^2/s\) for species ‘fast’, and the model contains no reactions.

## Analytic solution¶

For this system without reactions, we are simulating the two-dimensional diffusion equation,

where

\(c_s\) is the concentration of species \(s\) at position \((x, y)\) and time \(t\)

\(D_s\) is the diffusion constant for species \(s\)

For the initial condition \(c_s(t=0) = \delta(x)\delta(y)\), the analytic solution at time t of this equation is the heat kernel:

and a solution for our model can then be found by convolving this expression with our initial condition, to give

where \(t_0 = 9/D_s\). Note that this solution ignores boundary effects, so will not be valid at late times or close to the compartment boundary.

The total amount of species in the compartment is a conserved quantity,

and this is also valid at late times, since our zero flux Neumann boundary conditions also conserve the amount of species in the compartment.