1.1.7 Pure diffusion. Left end nonhomogeneous and time dependent Dirichlet, right end at zero temperature

Solve the heat PDE \(u_{t}=u_{xx}\) with boundary conditions \(u\left ( 0,t\right ) =t,u\left ( \pi ,t\right ) =0\) and initial conditions \(u\left ( x,0\right ) =0\)

solution

Since boundary conditions are nonhomogeneous, the PDE is converted to one with homogenous BC using a reference function. The reference function needs to only satisfy the nonhomogeneous B.C.

Let \[ r\left ( x,t\right ) =t\left ( 1-\frac{x}{\pi }\right ) \] Hence \[ u\left ( x,t\right ) =w\left ( x,t\right ) +r\left ( x,t\right ) \] Substituting this back into \(u_{t}=u_{xx}\) gives\[ w_{t}+r_{t}=w_{xx}+r_{xx}\] but \(r_{t}=1-\frac{x}{\pi }\) and \(r_{xx}=0\), therefore the above becomes\begin{align} w_{t} & =w_{xx}+\frac{x}{\pi }-1\nonumber \\ w_{t} & =w_{xx}+Q\left ( x\right ) \tag{1} \end{align}

Where \(Q\left ( x\right ) =\frac{x}{\pi }-1\,.\) This PDE now has now homogenous B.C\begin{align*} w\left ( 0,t\right ) & =0\\ w\left ( \pi ,t\right ) & =0 \end{align*}

(1) is solved using eigenfunction expansion. Let \(w\left ( x,t\right ) =\sum a_{n}\left ( t\right ) \Phi _{n}\left ( x\right ) \). Where \(\Phi _{n}\left ( x\right ) =\sin \left ( \sqrt{\lambda _{n}}x\right ) =\sin nx\) and \(\lambda _{n}=\left ( \frac{n\pi }{\pi }\right ) ^{2}=n^{2}\) where \(n=1,2,3,\cdots \). Therefore\begin{equation} w\left ( x,t\right ) =\sum a_{n}\left ( t\right ) \sin \left ( nx\right ) \tag{1A} \end{equation} Substituting this back into (1) gives\[ \sum a_{n}^{\prime }\left ( t\right ) \Phi _{n}\left ( x\right ) =\sum a_{n}\left ( t\right ) \Phi _{n}^{\prime \prime }\left ( x\right ) +\sum q_{n}\Phi _{n}\left ( x\right ) \] Where \(Q\left ( x\right ) =\sum q_{n}\Phi _{n}\left ( x\right ) \) is the eigenfunction expansion of the source term. The above reduces, after replacing \(\Phi _{n}^{\prime \prime }\left ( x\right ) \) by \(-\lambda _{n}\Phi _{n}\left ( x\right ) \) to the following\begin{align} a_{n}^{\prime }\left ( t\right ) & =-a_{n}\left ( t\right ) \lambda _{n}+q_{n}\nonumber \\ a_{n}^{\prime }\left ( t\right ) +a_{n}\left ( t\right ) \lambda _{n} & =q_{n} \tag{2} \end{align}

Now \(q_{n}\) is found as follows. Since \begin{align*} Q\left ( x\right ) & =\sum _{n=1}^{\infty }q_{n}\Phi _{n}\left ( x\right ) \\ \int _{0}^{\pi }Q\left ( x\right ) \Phi _{n}\left ( x\right ) dx & =\frac{\pi }{2}q_{n}\\ q_{n} & =\frac{2}{\pi }\int _{0}^{\pi }\left ( \frac{x}{\pi }-1\right ) \sin \left ( nx\right ) dx\\ & =\frac{2}{\pi }\left ( \frac{-n\pi +\sin \left ( n\pi \right ) }{n^{2}\pi }\right ) \\ & =\frac{2}{\pi }\left ( \frac{-n\pi }{n^{2}\pi }\right ) \\ & =\frac{-2}{n\pi } \end{align*}

Hence (2) becomes\[ a_{n}^{\prime }\left ( t\right ) +a_{n}\left ( t\right ) n^{2}=\frac{-2}{n\pi }\] The solution is\begin{equation} a_{n}\left ( t\right ) =-\frac{2}{n^{3}\pi }+a_{n}\left ( 0\right ) e^{-n^{2}t} \tag{3} \end{equation} Therefore  (1A) becomes\begin{equation} w\left ( x,t\right ) =\sum _{n=1}^{\infty }\left ( -\frac{2}{n^{3}\pi }+a_{n}\left ( 0\right ) e^{-n^{2}t}\right ) \sin \left ( nx\right ) \tag{4} \end{equation} At time \(t=0\) the above becomes\begin{equation} w\left ( x,0\right ) =\sum _{n=1}^{\infty }\left ( -\frac{2}{n^{3}\pi }+a_{n}\left ( 0\right ) \right ) \sin \left ( nx\right ) \tag{5} \end{equation} But \begin{align*} w\left ( x,0\right ) & =u\left ( x,0\right ) -r\left ( x,0\right ) \\ & =0-0\\ & =0 \end{align*}

Therefore (5) becomes\[ 0=\sum _{n=1}^{\infty }\left ( -\frac{2}{n^{3}\pi }+a_{n}\left ( 0\right ) \right ) \sin \left ( nx\right ) \] Which implies\[ a_{n}\left ( 0\right ) =\frac{2}{n^{3}\pi }\] Hence from (4)\begin{equation} w\left ( x,t\right ) =\sum _{n=1}^{\infty }\frac{2}{n^{3}\pi }\left ( e^{-n^{2}t}-1\right ) \sin \left ( nx\right ) \tag{6} \end{equation} Hence the complete solution is\begin{align*} u\left ( x,t\right ) & =w\left ( x,t\right ) +r\left ( x,t\right ) \\ & =t\left ( 1-\frac{x}{\pi }\right ) +\sum _{n=1}^{\infty }\frac{2}{n^{3}\pi }\left ( e^{-n^{2}t}-1\right ) \sin \left ( nx\right ) \end{align*}

Example

Here is animation using Mathematica, for \(L=1,k=1\) for 3 seconds.

Source code is