[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.3.22 DEFINE_SR_RATE



Description


You can use DEFINE_SR_RATE to specify a custom surface reaction rate. A custom surface reaction rate function defined using this macro will overwrite the default reaction rate (e.g., finite-rate) that is specified in the Create/Edit Materials dialog box. A DEFINE_VR_RATE UDF is compatible with the laminar finite-rate model, but you must make sure that the stiff chemistry option is disabled.

An example of a reaction rate that depends upon gas species mass fractions is provided below. Also provided is a reaction rate UDF that takes into account site species.

figure   

Note that the three types of surface reaction species are internally numbered with an (integer) index i in order



Usage



DEFINE_SR_RATE( name,f,t,r,my,yi,rr)


Argument Type Description
symbol name UDF name.
face_t f Index that identifies a face within the given thread (or cell in
  the case of surface reaction in a porous zone).
Thread *t Pointer to face thread on which the surface rate reaction is to
  be applied.
Reaction *r Pointer to data structure for the reaction.
real *mw Pointer to array of species molecular weights.
real *yi Pointer to array of mass fractions of gas species
  at the surface and the coverage of site species (or site fractions).
real *rr Pointer to reaction rate.
   
Function returns  
void  
   

There are seven arguments to DEFINE_SR_RATE: name, f, t, r, my, yi, and rr. You supply name, the name of the UDF. After your UDF is compiled and linked, the name that you have chosen for your function will become visible and selectable in the graphical user interface in ANSYS FLUENT. f, t, r, my, and yi are variables that are passed by the ANSYS FLUENT solver to your UDF. Your UDF will need to set the reaction rate to the value referenced by the real pointer rr as shown in the examples below.



Example 1 - Surface Reaction Rate Using Species Mass Fractions


The following compiled UDF, named arrhenius, defines a custom surface reaction rate using species mass fractions in ANSYS FLUENT.

/*******************************************************************
   Custom surface reaction rate UDF
********************************************************************/
#include "udf.h"
/* ARRHENIUS CONSTANTS */
#define PRE_EXP 1e+15
#define ACTIVE 1e+08
#define BETA 0.0

real arrhenius_rate(real temp)
{
  return
  PRE_EXP*pow(temp,BETA)*exp(-ACTIVE/(UNIVERSAL_GAS_CONSTANT*temp));
}

/* Species numbers. Must match order in ANSYS FLUENT dialog box */
#define HF  0
#define WF6 1
#define H2O 2
#define NUM_SPECS 3

/* Reaction Exponents */
#define HF_EXP  2.0
#define WF6_EXP 0.0
#define H2O_EXP 0.0

#define MW_H2 2.0
#define STOIC_H2 3.0

/* Reaction Rate Routine */

real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[])

/* Note that all arguments in the reaction_rate function
call in your .c source file MUST be on the same line or a
compilation error will occur */

{
  real concenHF = C_R(c,cthread)*yi[HF]/mw[HF];
  return arrhenius_rate(C_T(c,cthread))*pow(concenHF,HF_EXP);
}

DEFINE_SR_RATE(arrhenius,f,fthread,r,mw,yi,rr)
{
 *rr =
reaction_rate(F_C0(f,fthread),THREAD_T0(fthread),mw,yi);
}



Example 2 - Surface Reaction Rate Using Site Species


The following compiled UDF, named my_rate, defines a custom surface reaction rate that takes into account site species.

/*******************************************************************
   Custom surface reaction rate UDF
********************************************************************/
#include "udf.h"
DEFINE_SR_RATE(my_rate,f,t,r,mw,yi,rr)
{
 Thread *t0=t->t0;
 cell_t c0=F_C0(f,t);
 real sih4  = yi[0];   /* mass fraction of sih4 at the wall */
 real si2h6 = yi[1];
 real sih2  = yi[2];
 real h2    = yi[3];
 real ar    = yi[4];   /* mass fraction of ar at the wall */

 real rho_w = 1.0, site_rho = 1.0e-6, T_w = 300.0; 

 real si_s  = yi[6];   /* site fraction of si_s*/
 real sih_s = yi[7];   /* site fraction of sih_s*/

 T_w = F_T(f,t);
 rho_w = C_R(c0,t0)*C_T(c0,t0)/T_w;

 sih4  *= rho_w/mw[0];  /* converting of mass fractions 
to molar concentrations */
 si2h6 *= rho_w/mw[1];
 sih2  *= rho_w/mw[2];
 h2    *= rho_w/mw[3];
 ar    *= rho_w/mw[4];

 si_s   *= site_rho;   /* converting of site fractions to
 site concentrations */
 sih_s  *= site_rho;

 if (STREQ(r->name, "reaction-1"))
   *rr = 100.0*sih4;
 else if (STREQ(r->name, "reaction-2"))
   *rr = 0.1*sih_s;
 else if (STREQ(r->name, "reaction-3"))
   *rr = 100*si2h6*si_s;
 else if (STREQ(r->name, "reaction-4"))
   *rr = 1.0e10*sih2;  

}



Hooking a Surface Reaction Rate UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_SR_RATE is interpreted (Chapter  4) or compiled (Chapter  5), the name of the argument that you supplied as the first DEFINE macro argument (e.g., my_rate) will become visible and selectable in the User-Defined Function Hooks dialog box in ANSYS FLUENT. See Section  6.2.22 for details.


next up previous contents index Previous: 2.3.21 DEFINE_SPECIFIC_HEAT
Up: 2.3 Model-Specific DEFINE Macros
Next: 2.3.23 DEFINE_TRANS UDFs
Release 12.0 © ANSYS, Inc. 2009-01-14