# Solve convection-diffusion equation with a non-linear source term

I would like to solve this equation (which is adapted in my case, a plug flow reactor when a reaction occurs):

$$\frac{df}{dt} = D \frac{d²f}{dz²} - u \frac{df}{dz} + r(z,t)$$

with $$r(z,t)= - k f^{n}$$ (f power to n) where $$k$$ and $$n$$ are positive kinetic constants.

$$r$$ is the local reaction rate. $$D$$ is the dispersion coefficient and $$u$$ the fluid velocity which is constant.

How can I do it? I have already tried an explicit scheme with the finite differences method but it doesn't converge because of the source term $$r$$. So I wanted to opt for an implicit scheme but I don't know how to deal with the power $$n$$.

My initial condition is: $$f(z>0,0)= f_{0}$$ where $$f_0$$ is the initial concentration in the reactor and also the inlet concentration).

My boundary conditions are: $$f(0,t)= f_{0}$$ and $$f(L,t)=f(L-dL,t)$$ (this latter expresses the continuity of the fluid at the oulet of the plug flow reactor at the $$L$$ coordinate along $$z$$-axis. $$z \in [0,L]$$).

• Hi, after you discretize in space you end up with a large system of ODEs in time. You boundary conditions seems to me like Dirichlet on the left and Neumann homogeneous on the right (i.e. the function is flat at the boundary). The only thing that change using an implicit scheme is that you need to use Newton method (if the source is nonlinear) – VoB Feb 20 at 19:28

In some sense, it does not matter what kind of problem you have -- after (implicit) time discretization, you are left with a nonlinear PDE for the current time step, and that's what you need to learn to solve.

Rather than repeat what has already been discussed elsewhere, let me simply refer you to a couple of video lectures on the topic -- take a look at lectures 31.5 and following here: https://www.math.colostate.edu/~bangerth/videos.html