I am trying to get analytical solution of heat equation with non-homogenous boundary conditions, which i can code in MATLAB and compare with my numerical results.
In short, i am unable to reach the correct analytical solution. Can someone help me with this. Here is the equation with BCs:
$\frac{\partial{u(x,t)}}{\partial{t}} = \alpha\frac{\partial^2{u(x,t)}}{\partial{x^2}}$ $\qquad$ (where $0<x<L$ and $t>0$)
where $\alpha$ is the thermal diffusivity.
IC: $u(x,0)= f(x)$
BC1: $u(0,t)= a(t)$
BC2: $u(L,t)= b(t)$
Thanks in advance.
$\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,} \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack} \newcommand{\dd}{\mathrm{d}} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,} \newcommand{\ic}{\mathrm{i}} \newcommand{\mc}[1]{\mathcal{#1}} \newcommand{\mrm}[1]{\mathrm{#1}} \newcommand{\pars}[1]{\left(\,{#1}\,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,} \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}} \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{equation} \mbox{Lets}\ \mrm{u}\pars{x,t} \equiv \mrm{a}\pars{t} + \bracks{\mrm{b}\pars{t} - \mrm{a}\pars{t}}{x \over L} + \mrm{U}\pars{x,t} \end{equation} such that \begin{align} &\partiald{\mrm{U}\pars{x,t}}{t} - \alpha\,\partiald[2]{\mrm{U}\pars{x,t}}{x} = -\dot{\mrm{a}}\pars{t} - \bracks{\dot{\mrm{b}}\pars{t} - \dot{\mrm{a}}\pars{t}}{x \over L} \\[5mm] &\ \mrm{U}\pars{x,0} \equiv \mrm{f}\pars{x} - \mrm{a}\pars{0} - \bracks{\mrm{b}\pars{0} - \mrm{a}\pars{0}}{x \over L} \equiv \,\mrm{F}\pars{x} \label{1}\tag{1} \\[5mm] &\ \ds{\left\{\begin{array}{rcl} \ds{\mrm{U}\pars{0,t}} & \ds{\equiv} & \ds{0} \\ \ds{\mrm{U}\pars{L,t}} & \ds{\equiv} & \ds{0} \end{array}\right.} \end{align}
Then, $\ds{\mrm{U}\pars{x,t} = \sum_{n =1}^{\infty}\mrm{A}_{n}\pars{t} \sin\pars{{n\pi \over L}x}}$ which leads to \begin{align} \sum_{m =1}^{\infty}\bracks{\dot{\mrm{A}}_{m}\pars{t} + {m^{2} \over L^{2}}\mrm{A}_{m}\pars{t}}\sin\pars{{m\pi \over L}x} = -\dot{\mrm{a}}\pars{t} - \bracks{\dot{\mrm{b}}\pars{t} - \dot{\mrm{a}}\pars{t}}{x \over L} \end{align}
\begin{align} &\dot{\mrm{A}}_{n}\pars{t} + {n^{2} \over L^{2}}\mrm{A}_{n}\pars{t} = 2\,{\pars{-1}^{n}\,\dot{\mrm{b}}\pars{t} - \dot{\mrm{a}}\pars{t} \over n\pi} \\[5mm] &\ \totald{\bracks{\mrm{A}_{n}\pars{t}\exp\pars{n^{2}t/L^{2}}}}{t} = 2\,{\pars{-1}^{n}\,\dot{\mrm{b}}\pars{t} - \dot{\mrm{a}}\pars{t} \over n\pi}\,\exp\pars{{n^{2} \over L^{2}}\,t} \\[1cm] &\ \mrm{A}_{n}\pars{t}\exp\pars{{n^{2} \over L^{2}}\,t} - \mrm{A}_{n}\pars{0} \\[2mm] = &\ {2 \over n\pi} \int_{0}^{t}\bracks{\pars{-1}^{n}\dot{\mrm{b}}\pars{\tau} - \dot{\mrm{a}}\pars{\tau} \exp\pars{{n^{2} \over L^{2}}\,\tau}}\dd\tau \label{2}\tag{2} \end{align}
I hope you work out some details !!!.