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.

Unsteady convection + reaction 1D

Reaction: A→B→CA \rightarrow B\rightarrow C

∂cA∂t+div(v cA)=−k1 cA\frac{\partial c_A}{\partial t} + \mathrm{div}(v \, c_A) = -k_1 \, c_A

∂cB∂t+div(v cB)=k1 cA−k2 cB\frac{\partial c_B}{\partial t} + \mathrm{div}(v \, c_B) = k_1 \, c_A - k_2 \, c_B

∂cC∂t+div(v cC)=k2 cB\frac{\partial c_C}{\partial t} + \mathrm{div}(v \, c_C) = k_2 \, c_B

with boundary conditions: cA(0)=0.5,cB(0)=cC(0)=0c_A(0)=0.5, c_B(0)=c_C(0)=0, ∂ci(L)∂x=0\frac{\partial c_i(L)}{\partial x} = 0

Imports

Reaction term

The first-order series reaction A→B→CA \rightarrow B \rightarrow C; the sum of the three rates is zero, so the total concentration is unaffected by the reaction.

Parameters and boundary conditions

Physical and numerical parameters, and the boundary dictionary in the a*dc/dn + b*c = d convention (outward normal): cA=0.5c_A=0.5, cB=cC=0c_B=c_C=0 fixed at x=0x=0, and a zero-gradient outlet at x=Lx=L for every component.

Grid and operators

Uniform grid and the constant convection, divergence, and reaction Jacobian (evaluated once at c=0c=0, since the reaction is linear). The first-order upwind part of the convection is kept in the constant Jacobian; a TVD deferred correction (minmod limiter) is added explicitly in the solve loop.

Solve (implicit Euler time stepping)

One Newton iteration per time step is enough because the reaction is linear and only the convective deferred correction is nonlinear in c. The plot is updated live every output_interval steps.

<Figure size 640x480 with 1 Axes>

Checking the result

Because the reaction rates sum to zero, the total concentration ctot=cA+cB+cCc_{tot}=c_A+c_B+c_C obeys plain convection with inlet value 0.5 and no reaction sink. With the front x=vtx=vt still short of the outlet, the total amount of ctotc_{tot} in the domain must equal the accumulated inflow v tend ctot(0)v\,t_{end}\,c_{tot}(0). This would catch a stoichiometry error in reaction, a wrong inlet value, or a convection scheme that fails to conserve the total.

accumulated total 0.250000, expected v*t_end*c_in 0.250000, relative difference 5.174e-14
Matching to machine precision confirms the series reaction conserves the total concentration and the front has not yet left the domain.