This fun tool allows us to explore the flow of heat through a one-dimensional conductive medium by specifying its initial distribution and parameters of the heat equation with a source:
$$ \begin{aligned} & u_t = D\,u_{xx}+f(x) & \: \: u(x,0)=u_0(x) \\ & \:\:\:\:\:\:u(0,t) = a & u(1,t) = b. \:\:\:\: \end{aligned} $$Mathematical comments
The temperature throughout a bar as described above is governed by a well-posed heat problem, that is the heat equation together with intial and boundary conditions:
$$ \begin{aligned} & u_t = D\,u_{xx}+f(x) & \: \: u(x,0)=u_0(x) \\ & \:\:\:\:\:\:u(0,t) = a & u(1,t) = b. \:\:\:\: \end{aligned} $$In this set of equations, \(u_t = D\,u_{xx}+f(x)\) is a partial differential equation called the heat equation with rate of diffusion $D$ and positional heat source $f(x)$. The function $u_0$ describes the initial distribution of heat while the constants $a$ and $b$ indicate the fixed temperatures on the ends of the bar. Alternatively, we could indicate how heat flows through the ends of the bar by specifying $u_x(0,t)$ and $u_x(1,t)$. Using the checkboxes above, for example, you can specify that either derivative is zero indicating that the end is perfectly insulated.
At this level of generality, the equations can be solved using separation of variables and Fourier series. When the temperature is fixed at both endpoints, for example, the solution is
$$ \begin{aligned} u(x,t) &= a+(b-a)x + 2\sum_{k=1}^{\infty} \left( \frac{1-e^{-D k^2 \pi^2 t}}{D k^2 \pi^2} \int_0^1 f(\chi) \sin(k\pi \chi) d\chi \cdots \right. \\ &+ \left. e^{-D k^2 \pi^2 t} \left(\frac{(-1)^k b - a}{k\pi} + \int_0^1 u_0(\chi)\sin(k\pi \chi) d\chi \right) \right)\sin(k\pi x). \end{aligned} $$