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.

Counter-current convection and reaction

Reaction: A+B→∗A+B\rightarrow *

∂cA∂t+div(vA cA)=−k cAcB\frac{\partial c_A}{\partial t} + \mathrm{div}(v_A \, c_A) = -k \, c_A c_B

∂cB∂t+div(vB cB)=−k cAcB\frac{\partial c_B}{\partial t} + \mathrm{div}(v_B \, c_B) = -k \, c_A c_B

with boundary conditions: cA(0)=1c_A(0)=1, ∂cA(L)∂n=0\frac{\partial c_A(L)}{\partial n} = 0, ∂cB(0)∂n=0\frac{\partial c_B(0)}{\partial n} = 0, cB(L)=1c_B(L)=1

Notes:

  • Counter-current flow is implemented by taking vBv_B negative and setting the proper boundary conditions.

  • With ∣vA∣>∣vB∣|v_A| > |v_B| and same inlet concentrations not all AA will react away.

  • For high reaction rate coefficient kk, there is only a thin boundary layer where BB is present. If this boundary layer is not resolved the result is incorrect. Uncomment the non-uniform mesh for high kk.

  • This is a numerically tough problem for high reaction rates. Note that TVD deferred correction is currently off, i.e. the upwind scheme is used. TVD seems to decrease robustness.

Imports

Parameters and boundary conditions

Physical and numerical parameters, and the boundary dictionaries in the a*dc/dn + b*c = d convention (outward normal): a Danckwerts-style inlet for AA at x=0x=0 with a zero-gradient outlet at x=Lx=L, and the mirror image for BB.

Reaction term

A+B→∗A + B \rightarrow * with rate k cAcBk \, c_A c_B, consuming AA and BB in equal amounts.

Grid and operators

A grid refined near both ends (needed to resolve the thin reaction layer at high kk) and the constant convection and divergence operators. The first-order upwind part of the convection is kept in the constant Jacobian; a TVD deferred correction is added explicitly in the solve loop.

Solve (pseudo-transient Newton)

Implicit Euler time stepping toward steady state; each step takes num_inner_iter Newton iterations with the reaction Jacobian rebuilt from NumJac and the TVD deferred correction added to the residual. TVD is currently off (plain upwind is used); switch interp_cntr_to_stagg_tvd’s limiter argument to minmod to turn it back on, at the cost of robustness for this stiff reaction.

'progress: 100 out of 100'

Plot the concentration profiles

<Figure size 640x480 with 1 Axes>

Checking the result

AA enters at x=0x=0 with velocity vA=1v_A=1 and BB enters at x=Lx=L with velocity ∣vB∣=0.5|v_B|=0.5 (counter-current); at steady state the net convective inflow of AA must equal the amount consumed by the reaction, vA [cA(0)−cA(L)]=∫0Lk cAcB dxv_A\,[c_A(0)-c_A(L)] = \int_0^L k\,c_Ac_B\,dx, read from the FACE values with compute_boundary_values (not the last cell centre). This catches a wrong boundary-condition sign, a reaction term left out of the residual, or a run that has not actually reached steady state.

A: inflow 1.000000, outflow 0.500000, consumed 0.500000, balance residual 0.000e+00
A closed balance to machine precision confirms the steady state and the reaction term are consistent.