2.3.18.  DEFINE_NET_REACTION_RATE

2.3.18.1. Description

You can use DEFINE_NET_REACTION_RATE to compute the homogeneous net molar reaction rates of all species. The net reaction rate of a species is the sum over all reactions of the volumetric reaction rates:

(2–7)

where is the net reaction rate of species and is the Arrhenius molar rate of creation/destruction of species in reaction .

A DEFINE_NET_REACTION_RATE UDF may be used for the laminar finite-rate (with stiff chemistry enabled), EDC, and PDF Transport models, as well as for the surface chemistry model. In contrast, the volumetric UDF function DEFINE_VR_RATE and surface UDF function DEFINE_SR_RATE are used for the laminar finite-rate model when stiff chemistry is disabled.

2.3.18.2. Usage

DEFINE_NET_REACTION_RATE (name, c, t, particle, pressure, temp, yi, rr, jac)

Argument Type

Description

symbol name

UDF name.

cell_t c

Cell index of current particle.

Thread *t

Pointer to cell thread for particle.

Particle *particle

Pointer to Particle data structure that represents a particle used by the PDF transport model.

double *pressure

Pointer to pressure variable.

double *temp

Pointer to temperature variable.

double *yi

Pointer to array containing species mass fractions.

double *rr

Pointer to array containing net molar reaction rates.

double *jac

Pointer to array of Jacobians.

Function returns

void

There are nine arguments to DEFINE_NET_REACTION_RATE: name, c, t, particle, pressure, temp, yi, rr, and jac. You supply name, the name of the UDF. The variables c, t, particle, pressure, temp, yi, rr, and jac are passed by the ANSYS Fluent solver to your UDF and have SI units. The outputs of the function are the array of net molar reaction rates, rr (with units kmol/m3-s for volumetric reactions and kmol/m2-s for the surface reactions), and the Jacobian array jac. The Jacobian is only required for surface chemistry, and is the derivative of the surface net reaction rate with respect to the species concentration.

DEFINE_NET_REACTION_RATE is called for all fluid zones (volumetric reactions as well as surface reactions in porous media) and for all wall thread zones whenever the Reaction option is enabled in the boundary conditions dialog box and the UDF is hooked to ANSYS Fluent in the User-Defined Function Hooks dialog box.


Important:   DEFINE_NET_REACTION_RATE functions can be executed only as compiled UDFs.


2.3.18.3. Example

The following UDF, named net_rxn, assumes that the net volumetric reaction rate is the expression,

(2–8)

where is the number of species.

/***********************************************************
    Net Reaction Rate Example UDF
 ************************************************************/
 #include "udf.h"
 
 DEFINE_NET_REACTION_RATE(net_rxn,c,t,particle,pressure,temp,yi,rr,jac)
 {
   int i;
   for(i=0;i<n_spe;i++)
      rr[i] = 1./(real)n_spe - yi[i];
 } 

Note that during the course of the ODE solution, the species mass fractions can exceed realizable bounds. For optimal ODE performance, the species mass fractions should not be clipped, but derived quantities, such as concentrations which are raised to non-integer powers, must be bounded. Also, if density is required, for instance to calculate concentrations, it should be calculated from the temperature and species passed into the UDF. Finally, double precision should be used for all local variables.

2.3.18.4. Hooking a Net Reaction Rate UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_NET_REACTION_RATE is interpreted (Interpreting UDFs) or compiled (Compiling UDFs), the name of the argument that you supplied as the first DEFINE macro argument (for example, net_rxn) will become visible and selectable in the User-Defined Function Hooks dialog box in ANSYS Fluent. See Hooking DEFINE_NET_REACTION_RATE UDFs for details.


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