0
$\begingroup$

I'm trying to solve the following one dimensional diffusion equation in the range $L=2.5-6$ $\begin{equation} \frac{\partial f}{\partial t} = L^2\frac{\partial}{\partial L}\bigg(D(L,t)\frac{\partial f}{\partial L}\bigg) \end{equation} $

Subject to the following boundary conditions:

$\begin{align} f(L=2.5,t) &= f(L=2.5,0), \forall t \\ \frac{\partial f}{\partial L} &= 0\text{ at } L=6, \forall t \end{align}$

For this I'm using the semi implicit Crank Nicolson scheme given by: $\begin{equation} \frac{f_{j}^{n+1} - f_{j}^{n}}{\Delta t} = \frac{L_j^2}{2}\bigg[\frac{D_{j+\frac{1}{2}}^{n+\frac{1}{2}}(f_{j+1}^{n}-f_j^n) - D_{j-\frac{1}{2}}^{n+\frac{1}{2}}(f_{j}^{n}-f_{j-1}^n)}{(\Delta L)^2} + \frac{D_{j+\frac{1}{2}}^{n+\frac{1}{2}}(f_{j+1}^{n+1}-f_j^{n+1}) - D_{j-\frac{1}{2}}^{n+\frac{1}{2}}(f_{j}^{n+1}-f_{j-1}^{n+1})}{(\Delta L)^2}\bigg] \label{CN} \end{equation}$ where $L_j = 2.5 + j\Delta L, t_n = n\Delta t, f_j^n = f(L_j,t_n), D_j^{n+\frac{1}{2}} = D(L_j,t_{n+\frac{1}{2}})$.

I believe I know how to implement the boundary conditions correctly, but I seem to be having stability issues. My $D$ is not continuous, but instead changes every so many hours (where an hour is the timestep). even when $D$ changes every hour, it remains constant for the time inbetween. Could this be a reason why I am producing solutions which are unphysical? If so, what is the best way to solve my diffusion equation where the diffusion coefficient varies in space and time, but is not continuous?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.