discretization of mixed boundary conditions in the advection diffusion reaction equation, the Crank Nicolson method Sorry, I have some doubts regarding the discretization of mixed boundary conditions in a PDE.
I have discretized my equation, but I doubt about the boundary conditions. I dont know if you have to discretize them using Crank-Nicolson or using the usual methods such as Progressive or Regressive Finite differences?
Here is my equation
$$\begin{multline}
-(α+β)\phi_{i-1}^{j+1}+(1-γ+2α) ϕ_i^{j+1}-(α+β) ϕ_{i+1}^{j+1}
\\
=(α+β) ϕ_{i-1}^j+(1+γ-2α) ϕ_i^j+(α-β) ϕ_{i+1}^j+Q(t^j)δ(x_i-x_0)
\end{multline}$$
but what about the boundary conditions?
$$
ϕ(x,0)=0 ,~~~       μ \frac{∂ϕ(l,t)}{∂x}=0 ,~~~    μ \frac{∂ϕ(0,t)}{∂x}-uϕ(0,t)=0     
$$
If someone can help me, many thanks!

 A: Anyway, here go some thoughts.
Since you are using a Crank-Nicolson scheme, which is $\mathcal{O}(\Delta x^2, \Delta t^2)$ precise, your boundary conditions should also be discretize using a second order approximation, i.e.:
$$ \begin{align}
\mu \varphi_x(0,t) - u  \, \varphi(0,t) = 0 \implies &  \mu \frac{\varphi_{1}- \varphi_{-1}}{2 \Delta x} - u \, \varphi_0 = 0 \tag{1} \\
\mu \varphi_x(l,t)  = 0 \implies & \mu \frac{\varphi_{N+1} - \varphi_{N-1}}{2 \Delta x}  = 0\tag{2}
\end{align} $$
where I have assumed you are using a grid $\{(x_i,t_n) = (x_0+i\Delta x, t_0 + n\Delta t)\}$ and $\varphi_{i}^n \approx \varphi(x_i,t_n)$. From eqs. (1) and (2) you can see that the terms $\varphi_{-1}$ and $\varphi_{N+1}$ lie outsied the boundary and they must therefore be substituted in the Crank Nicolson scheme for $i=0$ and $i=N+1$ (this nodes are often called ficticious). Note that in the aforementioned equations, I have not specified what time the discretization is made at, i.e., the boundary conditions should be independent from $n$ (check it).
In the other hand, and assuming $\delta(t-t_0)$ is the Dirac's delta function (distribution), the heat source should be conveniently softened since the singular character of $\delta$ will not be suitable for a discretized scheme. You could try the following aproach:
$$Q(x,t) \approx Q_0(t) \exp{(-\kappa x^2)}, \quad \kappa > 0. $$
Hope this helps.
Cheers!
