# Solution to the 1-D heat equation

In solutions to the heat equation $u_t(x,t)=cu_{xx}(x,t)$ I've seen they've used the set of boundary conditions

$$u(0,t)=u(L,t)=0$$ $$u(x,0)=u_0(x)$$

These set of boundary conditions is set to model a situation in which a rod with some initial heat distribution is submerged in 0 degrees Celsius. I'm interested in using the heat equation to model the diffusion of particles in a closed system, and therefore my system must conserve mass.

In other words, I need to solve

$$u_t(x,t)=cu_{xx}(x,t)$$ $$u(x,0)=u_0(x)$$ $$\int_0^L u(x,t) \, dx = \text{Constant}$$

I know there are many posts on this site that deal with solving the heat equations, but I haven't found any that deal with this specific set of boundary conditions. Can someone point me in the directions of solving this equation?

• If you solve it with the boundary conditions you mentioned, you will absolutely not conserve mass because all the mass will slowly dribble out the ends of your domain. There is no way to fix this without changing the boundary conditions. Changing conditions so that the derivatives of $u$ are zero on the boundaries, or so that the boundary is periodic, would do it. – bob.sacamento May 27 '15 at 22:07
• How does requiring $\int_0^L u(x,t) \, dt = \text{Constant}$ not imply mass conservation? – eepperly16 May 27 '15 at 22:09
• Your integral does imply mass conservation. Your boundary conditions $u(0,t)=u(L,t)=0$ guarantee that there will not be mass conservation. There is a contradiction. – bob.sacamento May 27 '15 at 22:11
• Is requiring $\int_0^L u(x,t) \, dt = \text{Constant}$ equivalent to saying the derivatives of $u$ are zero on the boundaries? – eepperly16 May 27 '15 at 22:14
• No, but setting the derivatives to zero on the boundaries does imply your integral. There might be several other artificial ways to satisfy your integral, like putting a "source" term on one boundary. Setting derivatives to zero is simplest. – bob.sacamento May 27 '15 at 22:19

If an end is isolated, the $x$ derivative there must be set to zero: $$u_x(0,t)=u_x(L,t)=0\tag{1}$$ This will imply the conservation of mass: $$\frac{d}{dt}\int_0^L u(x,t) \, dx =\int_0^L cu_{xx}(x,t) \, dx =c (u_x(L,t)-u_x(0,t))=0$$
The physical meaning of $(1)$ becomes transparent if we recall that the flow of heat is proportional to the gradient: it's $-cu_x$. So, zero flow of heat through an endpoint means $u_x$ being zero.