Example: Char combustion with UDF ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. math:: \text{C}(s) + 0.5\text{O}_2 (g) → \text{CO}(g) Notes: * The fluid cell index (``IJK``) is passed as a dummy argument. * Algebraic expressions for the rate limiting steps are omitted for brevity. .. code-block:: none ###mfix.dat: see step 3. ###usr_rates.f: SUBROUTINE USR_RATES(IJK, RATES) DOUBLE PRECISION, INTENT(IN) :: IJK ! Fluid Cell Index DOUBLE PRECISION, INTENT(OUT) :: RATES(:) ! Reaction Rates ⋮ ! Rate limiting steps: DOUBLE PRECISION k_f ! film diffusion (cm/sec) DOUBLE PRECISION k_a ! ash layer diffusions (cm/sec) DOUBLE PRECISION k_s ! chemical kinetics (cm/sec) DOUBLE PRECISION k_eff ! effective rate (cm/sec) ! Total surface area of solids phase 1 in IJK DOUBLE PRECISION Sa ! (cm^2/cm^3) ! C + 0.5O2 --> CO (reacted moles/sec.cm^3) !-------------------------------------------------------// ! Verify that solids are present IF(.NOT.COMPARE(EP_g(IJK),ONE)) THEN ! Calculate film diffusion rate k_f = < film diffusion rate expression > ! (cm/sec) ! Calculate ash diffusion rate k_a = < ash diffusion rate expression > ! (cm/sec) ! Calculate kinetic rate k_s = < kinetic rate expression > ! (cm/sec) ! Effective rate (cm/sec) k_eff = ONE/(ONE/k_a + ONE/k_f + ONE/k_s) ! Calculate total surface area of solids phase 1 Sa = 6.0 * EP_s(IJK,1) / D_p0(1) ! Calculate the reaction rate. RATES(Char_Combustion) = 2.0 *(Sa * k_eff * Conc(O2)) ELSE ! No solids --> No reaction RATES(Char_Combustion) = ZERO ENDIF END SUBROUTINE USR_RATES See legacy_tutorials/SpoutedBedCombustor for details on a similar simulation setup.