8.2.4. Reaction Rates

This section contains an example of a custom reaction rate UDF. It is executed as a compiled UDF in ANSYS Fluent.

8.2.4.1. Volume Reaction Rate

A custom volume reaction rate for a simple system of two gaseous species is considered. The species are named species-a and species-b. The reaction rate is one that converts species-a into species-b at a rate given by the following expression:

(8–4)

where is the mass fraction of species-a, and and are constants.

The 2D (planar) domain consists of a 90° bend. The duct has a porous region covering the bottom and right-hand wall, and the reaction takes place in the porous region only. The species in the duct have identical properties. The density is 1.0 kg/, and the viscosity is 1.7894 kg/m-s.

The outline of the domain is shown in Figure 8.32: The Outline of the 2D Duct. The porous medium is the region below and to the right of the line that extends from the inlet on the left to the pressure outlet at the top of the domain.

Figure 8.32:  The Outline of the 2D Duct

The Outline of the 2D Duct

Through the inlet on the left, gas that is purely species-a enters with an x velocity of 0.1 m/s. The gas enters both the open region on the top of the porous medium and the porous medium itself, where there is an inertial resistance of 5 m-1 in each of the two coordinate directions. The laminar flow field (Figure 8.33: Streamlines for the 2D Duct with a Porous Region) shows that most of the gas is diverted from the porous region into the open region.

The flow pattern is further substantiated by the vector plot shown in Figure 8.34: Velocity Vectors for the 2D Duct with a Porous Region. The flow in the porous region is considerably slower than that in the open region.

Figure 8.33:  Streamlines for the 2D Duct with a Porous Region

Streamlines for the 2D Duct with a Porous Region

Figure 8.34:  Velocity Vectors for the 2D Duct with a Porous Region

Velocity Vectors for the 2D Duct with a Porous Region

The source code (rate.c) that contains the UDF used to model the reaction taking place in the porous region is shown below. The function, named vol_reac_rate, is defined on a cell for a given species mass fraction using DEFINE_VR_RATE. The UDF performs a test to check for the porous region, and only applies the reaction rate equation to the porous region. The macro FLUID_THREAD_P(t) is used to determine if a cell thread is a fluid (rather than a solid) thread. The variable THREAD_VAR(t).fluid.porous is used to check if a fluid cell thread is a porous region.

/******************************************************************
   rate.c 
  Compiled UDF for specifying a reaction rate in a porous medium
 *******************************************************************/
 
 #include "udf.h"
 
 #define K1 2.0e-2
 #define K2 5.
 
 DEFINE_VR_RATE(vol_reac_rate,c,t,r,mole_weight,species_mf,rate,rr_t)
 {
    real s1 = species_mf[0];
    real mw1 = mole_weight[0];
    if (FLUID_THREAD_P(t) && THREAD_VAR(t).fluid.porous)
      *rate = K1*s1/pow((1.+K2*s1),2.0)/mw1;
    else
      *rate = 0.;
    *rr_t = *rate;
 } 

This UDF is executed as a compiled UDF in ANSYS Fluent. Follow the procedure for compiling source files using the Compiled UDFs dialog box that is described in Compiling a UDF Using the GUI.

After the function vol_reac_rate is compiled and loaded, you can hook the reaction rate UDF to ANSYS Fluent by selecting the function’s name in the Volume Reaction Rate Function drop-down list in the User-Defined Function Hooks dialog box (Figure 6.70: The User-Defined Function Hooks Dialog Box).

 Parameters & Customization → User Defined Functions  Function Hooks...

Figure 8.35:  The User-Defined Functions Hooks Dialog Box

The User-Defined Functions Hooks Dialog Box

Initialize and run the calculation. The converged solution for the mass fraction of species-a is shown in Figure 8.36: Mass Fraction for species-a Governed by a Reaction in a Porous Region. The gas that moves through the porous region is gradually converted to species-b in the horizontal section of the duct. No reaction takes place in the fluid region, although some diffusion of species-b out of the porous region is suggested by the wide transition layer between the regions of 100% and 0% species-a.

Figure 8.36:  Mass Fraction for species-a Governed by a Reaction in a Porous Region

Mass Fraction for species-a Governed by a Reaction in a Porous Region


Release 18.2 - © ANSYS, Inc. All rights reserved.