Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Surface Reaction

A 1D diffusion model. On the left boundary a surface reaction is modelled. To handle general surface reactions, we make the concentration at the boundary a variable to be solved.

The governing equation inside the domain is

∂c∂t+div(−D grad(c))=0\frac{\partial c}{\partial t} + \mathrm{div} (-D \, \mathrm{grad}(c)) = 0

On the boundary at x=0x = 0 we have, using the outward normal nn (which points in the −x-x direction there):

D∂c∂n=r(c),i.e.−D∂c∂x=r(c)at x=0,D \frac{\partial c}{\partial n} = r(c), \qquad \text{i.e.} \qquad -D \frac{\partial c}{\partial x} = r(c) \quad \text{at } x = 0,

where r(c)r(c) can be a non-linear multicomponent surface reaction. At x=Lx = L the domain is closed: ∂c/∂x=0\partial c/\partial x = 0.

Solution Methodology

The method we use here is to extend the variables to be solved in the system with the concentration on the boundary: cbc_b, and then solve the non-linear equation for the surface reaction simultaneously with the other transport equations.

Imports

Parameters

Grid and Kinetics

Boundary Conditions and Operators

Residual Function

Initial Conditions and Plot Setup

<Figure size 640x480 with 1 Axes>

Time-Stepping Loop

<Figure size 640x480 with 1 Axes>

Checking the result

construct_g returns the residual and its Jacobian for the full extended state, including the boundary unknown cbc_b. At the final converged state we can use pymrm.checks.residual_check to verify, in a scale-free (backward-error) sense, that the residual is close to zero. This is a stronger statement than Newton’s success=True, which only says that the last step was small. It does not test the Jacobian itself; pymrm.checks.check_jacobian does that.

{'ok': True, 'backward_error': 1.331178923542547e-16, 'max_abs_residual': 4.774847184307873e-12}
residual_check ok=True, backward_error=1.331e-16