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
(for example, finite-rate) that is specified
in the Create/Edit Materials dialog box. A DEFINE_SR_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.
Important: Note that the three types of surface reaction species are internally
numbered with an (integer) index i in order
DEFINE_SR_RATE (name,f,t,r,my,yi,rr)
|
Argument Type |
Description |
|---|---|
|
|
UDF name. |
|
|
Index that identifies a face within the given thread (or cell in the case of surface reaction in a porous zone). |
|
|
Pointer to face thread on which the surface rate reaction is to be applied. |
|
|
Pointer to data structure for the reaction. |
|
|
Pointer to array of species molecular weights. |
|
|
Pointer to array of mass fractions of gas species at the surface and the coverage of site species (or site fractions). |
|
|
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.
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);
}
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);
double sih4 = yi[0]; /* mass fraction of sih4 at the wall */
double si2h6 = yi[1];
double sih2 = yi[2];
double h2 = yi[3];
double ar = yi[4]; /* mass fraction of ar at the wall */
double rho_w = 1.0, site_rho = 1.0e-6, T_w = 300.0;
double si_s = yi[6]; /* site fraction of si_s*/
double 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;
}
After the UDF that you have defined using DEFINE_SR_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, my_rate) will
become visible and selectable in the User-Defined Function
Hooks dialog box in ANSYS Fluent. See Hooking DEFINE_SR_RATE UDFs for details.