# Diffusion equation with walls (if possible with gravity), analytical solution

The solution of diffusion equation $$\partial_t\rho=D\nabla^2\rho$$ with a point source $$\rho(0,z)=\delta(z)$$

is in 1 dimension $$\rho(t,z)=\frac{1}{\sqrt{4\pi Dt}}e^{-\frac{z^2}{4Dt}}$$

My question is : is there any analytical solution of the same problem with a boundary solution $$v(z_0)=0=-D\partial_z\rho(z_0)$$

meaning if you put a wall somewhere ?

My feeling is that the problem would be overconstrained. Is it right ?

If it's possible, what would be the way to achieve it ?

Edit 1 :

And if it's possible is it also possible to add a force towards the wall ? I mean for example if you have diffusion + gravity : $$v=-v_g-\frac{D\nabla\rho}{\rho}$$ which associate with : $$\partial_t \rho +\nabla.(\rho v)=0$$ to

$$\partial_t \rho=D\nabla^2\rho + v_g \nabla\rho$$

and in 1d : $$\partial_t \rho= D\frac{d^2\rho}{dz^2} + v_g \frac{d\rho}{dz}$$

This can be simplified thanks to a change of variable : $$z\rightarrow\tilde{z}=z+v_g t$$ into : $$\partial_t \rho= D\frac{d^2\rho}{d\tilde{z}^2}$$

and the solution is $$\rho(t,z)=\frac{1}{\sqrt{4\pi Dt}}e^{-\frac{(z-vt)^2}{4Dt}}$$

So I was wondering how this solution was changed if there is a wall.

Edit 2

I found this link in wikipedia about the Mason-Weaver equation where a solution for my second equation in the edit seems to be derived.

An analytical solution exists. The idea is to but an instantaneous "image source" behind the wall, so that assuming $$z_0 > 0$$, the problem is replaced with one where there is no wall, but the initial condition is $$\rho(0, z) = \delta(z) + \delta(z - 2z_0).$$ Because of the symmetry about $$z=z_0$$, $$\partial_z\rho$$ will be zero here at all times. This technique can be applied to a wide range of problems. The solution is $$\rho(t, z) = \frac{1}{\sqrt{4\pi D t}}\left[e^{-\frac{z^2}{4Dt}} + e^{-\frac{(z - 2z_0)^2}{4Dt}} \right].$$
• @Pulk Thanks that's a very nice answer. I tried your solution on a modified diffusion equation that I described in the new Edit but I don't get satisfying result, by changing the exponentials $z^2\rightarrow (z-t)^2$ and $(z-2z_0)^2\rightarrow (z-2z_0+t)^2$ but the waves go away... Would you have a way to solve that complication plz ? – J.A Jul 23 '19 at 20:10