I want to write the numerical scheme of \begin{equation*} \frac{\partial u}{\partial t} = \alpha \Delta u - u H(u - u_c)+f(x,y,t) \end{equation*} Where $H$ is a Heaviside function and $u_c$ is a constant. I want to write its numerical scheme by Implicit method.
I wrote the scheme for \begin{equation*} \frac{\partial u}{\partial t} = \alpha \Delta u +f(x,y,t) \end{equation*}
I don't know how to approximate Heaviside function by finite difference. Can any one suggest some notes or idea how to solve this with Heaviside function.
Thanks in advance.
Finite differences are used to approximate derivatives, not functions. A fully implicit scheme for your problem would be just $$ \frac{u^{n+1} - u^n}{\Delta t} = \alpha \Lambda u^{n+1} - u^{n+1} H(u^{n+1} - u_c) + f^{n+1}. $$
The problem is that now you have a nonlinear system of equations for $u^{n+1}$: $$ u^{n+1} - \alpha \Delta t \Lambda u^{n+1} + \Delta t u^{n+1} H(u^{n+1} - u_c) = u^n + \Delta t f^{n+1}. \tag{*} $$ This might be a tough problem for nonlinear solver you're using for the problem.
To overcome the discontinuous nature of the Heaviside function you might replace it with a smooth analogous: $$ H(u - u_c) \approx \frac{1}{2}\left(1 + \tanh \frac{u - u_c}{\delta}\right). $$ Parameter $\delta$ controls the approximation quality: for smaller values of $\delta$ approximation is better, but the nonlinear problem $(*)$ becomes much harder.
Maybe you don't need a fully implicit scheme and $$ \frac{u^{n+1} - u^n}{\Delta t} = \alpha \Lambda u^{n+1} - u^{n+1} H(u^n - u_c) + f^{n+1}. $$ might work. This scheme leads to a linear problem for $u^{n+1}$ $$ u^{n+1} - \alpha \Delta t \Lambda u^{n+1} + \Delta t u^{n+1} H(u^{n} - u_c) = u^n + \Delta t f^{n+1}, \tag{**} $$ but it might be oscillating or unstable when the numerical solution approaches $u_c$.