2

I've built a finite element solver to solve the transient diffusion-reaction equation $$\frac{\partial c}{\partial t} = D\frac{\partial^{2} c}{\partial x^{2}} - \lambda c + f$$ where $\lambda$ and $f$ are the reaction and source terms respectively. I've built the solver to be able to take any initial condition and Dirichlet/Neumann boundary conditions. However, I'm struggling to find analytical solutions that can help me benchmark my solver. Could someone point me in the right direction with finding some analytical solutions?

S0yboi
  • 23

1 Answers1

1

Assume $D=1$. Assume a source term of the form $F(t,x)=-\mathrm e^{-\lambda t}x(1-x)$. Consider Dirichlet BCs on the interval $x\in[0,1]$. Now try $c(t,x)=\mathrm e^{-\lambda t}\phi(x)$ to get $$-\lambda \mathrm e^{-\lambda t}\phi(x)=\mathrm e^{-\lambda t}\phi''(x)-\lambda \mathrm e^{-\lambda t}\phi(x)-\mathrm e^{-\lambda t}x(1-x) \\ \implies \phi''(x)=x(1-x)$$ Which is solved by $$\phi(x)=\frac{-1}{12}(x^4-2x^3+x)$$ You can choose any $\lambda$ you want, $1$ is convenient. So, formally, the problem $$\begin{cases}\partial_t c=\partial_x^2c-c+F & (t,x)\in[0,\infty)\times [0,1] \\ c(0,x)=\frac{-1}{12}(x^4-2x^3+x)\\c(t,0)=c(t,1)=0\end{cases}$$ With $F(t,x)=-\mathrm e^{- t}x(1-x)$, is solved by $$c(t,x)=\mathrm e^{-t}c(0,x)$$

Hopefully this is good enough for testing purposes?

K.defaoite
  • 12,536
  • Is it weird that the analytical solution matches my finite element solution exactly at different timescales? The finite element solution diffuses much quicker and reaches the same steady state at $$t=1$$ that the analytical solution would at $$t= 10$$. – S0yboi Dec 09 '22 at 22:19
  • 1
    There is no steady state. Observe $\partial_t c\neq 0$. – K.defaoite Dec 09 '22 at 22:20