# Analytical solution of the thermal conductivity equation [closed]

What is the exact analytical solution of a 1D thermal conductivity PDE:

$$\dfrac{\partial T}{\partial t} = \alpha\cdot \dfrac{\partial^2 T}{\partial x^2}$$,

where $$T$$ = temperature, $$\alpha$$ = thermal conductivity coefficient, $$x\in\left(0,\ldots,L\right)$$ = distance coordinate, $$t$$ = time.

with mixed B.C.

• Dirichlet type B.C.: $$\:\:T\left(x=0, t\right)\:=\: 30$$
• Neumann type B.C.: $$\:\:\dfrac{\partial T}{\partial x} \left(x=L, t\right)\:=\: 0$$

I would like to implement the analytical solution into my code to compare an error of numerical schemes I used to numerically solve this eq. I have found that this equation has a numerical solution, but only as an information, not the solution itself.

• You can find this discussed here, for example, as well as in nearly any heat transfer textbook or handbook. Apr 3 at 18:43
• There is no one single analytic solution. The solutions to this equation vary with the imposed boundary conditions and initial conditions. Apr 3 at 18:50
• @ChetMiller Thanks, I think that I came by some source saying that. I also read that the geometry may play certain role (however, not in case of a 1D heat transfer without radial gradients, I assumed). I have updated my post with the I.C. and B.C.. Apr 3 at 19:33
• @Chemomechanics, I will look into the paper, thanks. Apr 3 at 19:36
• The term initial condition refers to the specified temperature profile at time zero. Apr 3 at 19:45

Our partial differential equation (PDE) and boundary conditions (BCs) are: $$T_t=\alpha T_{xx};$$ $$T(0,t)=30\text{ and }T_x(L,t)=0.$$ Let's use a generic initial condition (IC): $$T(x,0)=f(x).$$ First, we transform the dependent variable $$T(x,t)$$: $$u(x,t)=T(x,t)-30.$$ This means that: $$\Rightarrow u(0,t)=30-30=0.$$ The derivative $$T_x(L,t)$$ isn't affected, so: $$u_x(L,t)=T_x(L,t)=0.$$ Calculate the derivatives: $$u_t=T_t\text{ and }T_{xx}=u_{xx}.$$ So we've transformed our PDE to: $$u_t=\alpha u_{xx};$$ $$u(0,t)=0\text{ and }u_x(L,t)=0;$$ $$u(x,0)=f(x)-30.$$

Now the solving process starts. We use separation of variables.

Assume (make an Ansatz) that: $$u(x,t)=X(x)\Theta(t),$$ where $$X(x)$$ and $$\Theta(t)$$ are functions in $$x$$ and $$t$$ only, respectively. Insert into the PDE: $$X\Theta'=\alpha\Theta X''.$$ Divide both sides by $$XT$$ to get: $$\frac{\Theta'}{\alpha \Theta}=\frac{X''}{X}=-k^2,$$ where $$k^2\in\mathbb{R}$$ and $$k^2>0$$, called the separation constant. The PDE is now 'broken up' into two ordinary differential equations (ODEs): $$\frac{\Theta'}{\alpha \Theta}=-k^2\tag{1};$$ $$\frac{X''}{X}=-k^2\tag{2}.$$ Let's start with the second one. Its solution process is: $$X(x)=A\sin kx+B\cos kx;$$ $$u(0,t)=0\Rightarrow X(x)=0;$$ $$0=A\sin 0+B\cos 0\Rightarrow B=0;$$ $$X(x)=A\sin kx;$$ $$u_x(L,t)=0\Rightarrow X'(L)=0;$$ $$0=kA\cos kL\Rightarrow \cos kL=0;$$ $$\Rightarrow k=\frac{(n+1/2)\pi}{L};$$ $$k=\frac{(1+2n)\pi}{2L}.$$ The $$k$$ terms are the eigenvalues of the PDE. So we have:

$$X_n(x)=A_n\sin\left(\frac{(1+2n)\pi x}{2L}\right).$$ for $$n=0,1,2,3,...$$

From $$(1)$$, we glean easily that:

$$\Theta_n(t)=\exp{(-\alpha k^2t)}=\exp{\left[-\alpha\left(\frac{(1+2n)\pi}{2L}\right)^2t\right]};$$ Thus: $$u_n(x,t)=A_n\exp{\left[-\alpha\left(\frac{(1+2n)\pi}{2L}\right)^2t\right]}\sin\left(\frac{(1+2n)\pi x}{2L}\right).$$ With the superposition principle, we get:

$$\boxed{u(x,t)=\displaystyle\sum_{n=0}^{\infty}A_n\exp{\left[-\alpha\left(\frac{(1+2n)\pi}{2L}\right)^2t\right]}\sin\left(\frac{(1+2n)\pi x}{2L}\right)}$$ for $$n=0,1,2,3,...$$

At $$t=0$$, we have: $$f(x)-30=\displaystyle\sum_{n=1}^{\infty}A_n\sin\left(\frac{(1+2n)\pi x}{2L}\right).$$ We can then use the Fourier series to determine the coefficients $$A_n$$:

$$\boxed{A_n=\frac{2}{L}\int_0^L\mathrm{d}x\left[\big(f(x)-30\big)\sin\left(\frac{(1+2n)\pi x}{2L}\right)\right].}$$ Finally, don't forget that $$T(x,t)=u(x,t)+30$$.

• Awesome, it works, the code nicely plots the curve. Finally, I have a nice comparison, thanks. Thanks for writing it in words of one syllable, I highly appreciate it. Apr 4 at 16:18
• Great! I'm now going to make a small simplification.
– Gert
Apr 4 at 16:21
• I've simplified the use of $n$ a little.
– Gert
Apr 4 at 16:46
• I edited what seemed to be some typos involving $n$. Please check, and I apologize if I've introduced any errors into this fine answer. Apr 4 at 20:49
• @Chemomechanics Thank you!
– Gert
Apr 4 at 22:01

The general solution for $$\partial_t T(x,t)=\alpha\Delta T(x,t) \,\,\,\text{with}\,\,\, T(0,t)=T(L,t)=0$$ is $$u(x,t)=\sum_{k\in\mathbb{N}}a_k e^{-\alpha\lambda_kt}f_k(x),$$ where the functions $$f_k$$ are eigenfunctions of the La-Place-Operator to the eigenvalue $$\lambda_k$$ $$\Delta f_k=\lambda_k f_k,\,\,\,\,\,\,\,(1)$$ with boundary conditions $$f_k(0,t)=f_k(L,t)=0$$. Because this implies $$\partial_t u(x,t)=\sum_{k\in\mathbb{N}}a_k (-\alpha\lambda_k)e^{-\alpha\lambda_kt}f_k(x)\stackrel{(1)}{=}-\alpha\sum_{k\in\mathbb{N}}a_k e^{-\lambda_kt}\Delta f_k(x)=-\alpha\Delta u(x,t)$$ and $$u(0,t)=u(L,t)=0.$$

The eigenvalue problem (1) is easy to solve with the exponential function: $$f_k(x)=C\sin(k\pi x/L)\,\,\,\,\text{and}\,\,\,\,\lambda_k=-\left(\frac{k\pi}{L}\right)^2.$$ The constant $$C$$ is defined by the inicial condition $$T(x,0)$$, after plugged in in $$u(x,t)$$.

For other boundary conditions add linear terms in $$x$$ to $$u(x,t)$$, as it will still solve the PDE. For example $$v(x,t)=u(x,t)+30$$ solves your Dirichlet B.C.. For more difficult B.C., solve the eigenvalue problem with according boundary conditions.

• What does $u'(x,t)=u(x,t)+30$ mean? Looks like abuse of notation to me.
– Gert
Apr 4 at 16:53
• @Gert as it says explicitly in my answer: I used $u(x,t)$ for the solution with boundary conditions $u(0,t)=u(L,t)=0$ and $u'(x,t)$ for the solution with boundary conditions $u'(0,t)=u'(L,t)=30$. Apr 4 at 17:03
• So $u'(x,t)$ is u prime? If so, it's clearer to use $v(x,t)=u(x,t)+30$, IMHO...
– Gert
Apr 4 at 17:05
• @Gert depends on the notation you use. I don't think the prime notation is misleading, as this is the physics stack exchange and the prime notation for derivatives is more of a mathematical one. Nevertheless I will change my notation then. Apr 4 at 17:08
• I use (e.g.) $y'$ here all the time (also $\dot{y}$ and others). There's no convention that tells us what notation to use here or there.
– Gert
Apr 4 at 17:13