I'm trying to solve the PDE for $c(r,t)$ $$c_t=(1/r)(rJ)_r$$ using Crank-Nicolson, and I'm having difficulty with the boundary conditions. $J$ is the flux, the initial condition is $c(0,r)=c_{init}$, and the flux is 0 at both boundaries $r=r_0$ and $r=r_1$. The flux is $J=rDc_r-s\omega^2r^2c$; $D$ and $s$ may be functions of $c$, but are often constants, as they are treated in this example.
So for the Crank-Nicolson scheme I use these approximations: $$c_t=(c_{n+1,j}-c_{n,j})/\Delta t$$ $$c_{rr}=\left({1\over 2}\right)\left[{c_{n,j+1}-2c_{n,j}+c_{n,j-1}\over (\Delta r)^2}+{c_{n+1,j+1}-2c_{n+1,j}+c_{n+1,j-1}\over (\Delta r)^2}\right]$$ $$c_r=\left({1\over 2}\right)\left[{c_{n,j+1}-c_{n,j-1}\over \Delta r}+{c_{n+1,j+1}-c_{n+1,j-1}\over \Delta r}\right]$$ $$c=\left({1\over 2}\right)\left[c_{n,j}+c_{n+1,j}\right]$$ where $n=$ the time step ($t=t_0+n\Delta t$), and $j=$ the position ($r=r_0+j\Delta r$, $j=0,...,J$).
For the boundary conditions, I want $J(r_0,t)=0$ and $J(r_1,t)=0$ for all $t$.
My first attempt was to use "ghost points" at $j=-1$ and $j=J+1$. I used the centered difference at $j=0$ and $j=J$, respectively, for the derivative $c_r$, and the values $c_{n,0}$ and $c_{n,J}$: $$c_r={c_{n,1}-c_{n,-1}\over 2\Delta r}$$ $$c_r={c_{n,J+1}-c_{n,J-1}\over 2\Delta r}$$ Substituting these approximations into the expression for the flux $J$ yields $c_{n,-1}$ in terms of $c_{n,0}$ and $c_{n,1}$, and $c_{n,J+1}$ in terms of $c_{n,J-1}$ and $c_{n,J}$.
With the ghost points eliminated, the $J+1 \times J+1$ tridiagonal matrices ${\bf A}$ and ${\bf B}$ are used to solve for the vector ${\bf c}_{n+1}$ from ${\bf c}_n$ for each time step.
Yet, when the numerical solution is calculated, instead of the expected exponential curve, becoming large near $r=r_1$, $c$ becomes tiny everywhere, and the values over time make it apparent that there is flux out at both boundaries. That is the issue I am grappling with.
I thought about using a Crank-Nicolson average to approximate $c_r$ at the boundaries, but then I get four additional unknowns, and I don't know how to deal with this.
Any suggestions?