Build a model of two reactive components counter-diffusing in a membrane. A chemical reaction is carried out in a membrane reactor. The reaction scheme and reaction kinetics are given as follows:
Reaction kinetics: . The reactants and are fed at different sides of a porous membrane. The concentrations on the boundaries are provided in the figure below. For the description of this problem you may assume that the diffusion obeys Fick’s law.

Concentration boundary conditions at both sides of the membrane.
| Parameter | Value |
|---|---|
| Membrane thickness | |
| Kinetic constant | |
| Kinetic constant | |
| Effective diffusion coefficients of A, B, C and D |
Questions:
Write down the governing steady-state equations. For the diffusive term use the notation with a divergence and gradient operator.
Write down the spatially discretized equations in terms of matrices corresponding to the discretization of the divergence and gradient operator. Discuss, how the boundary conditions contribute to the discretized equations.
The reaction term is non-linear. Formulate the equation to be solved as a root-seeking problem (i.e. a set of non-linear equations that all need equal zero).
Formulate the solution algorithm applying the Newton-Raphson method.
Provide a Python implementation for the set of equations and its Jacobian using the pymrm building blocks:
construct_grad,construct_divandnumjac.Implement the numerical solution using the
newtonfunction from thepymrmpackage.Obtain the steady state solution using Newton-Raphson iteration.
Make an unsteady implementation assuming initial zero concentrations.
Play with the reaction rates and boundary conditions.