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

2.3.13 DEFINE_PR_RATE



Description


You can use DEFINE_PR_RATE to specify a custom particle surface reaction for the multiple surface reactions particle model. During ANSYS FLUENT execution, the same UDF is called sequentially for all particle surface reactions, so DEFINE_PR_RATE can be used to define custom reaction rates for a single reaction, or for multiple reactions. The volumetric and wall surface reactions are not affected by the definition of this macro and will follow the designated rates. Note that a DEFINE_PR_RATE UDF is not called with the coupled solution option, so you will need to disable the Coupled Heat Mass Solution option in the Discrete Phase Model dialog box when using it. The auxiliary function, zbrent_pr_rate, which is provided below, can be used when there is no analytical solution for the overall particle reaction rate.



Usage



DEFINE_PR_RATE( name, c, t, r, mw, ci, p, sf, dif_index, cat_index, rr)


Argument Type Description
symbol name UDF name.
cell_t c Cell index of current particle.
Thread *t Pointer to cell thread for particle.
Reaction *r Pointer to data structure that represents the current
  reaction.
real *mw Pointer to array containing gaseous and surface species
  molecular weights
real *ci Pointer to array containing gas partial pressures.
Tracked_Particle *p Pointer to Tracked_Particle data structure that contains
  data related to the particle being tracked.
real *sf Pointer to array containing mass fractions of the solid
  species in the particle char mass at the current time step.
int dif_index Diffusion controlled species as defined in the Reactions dialog box
  for the current reaction.
int cat_index Catalyst species as defined in the Reactions dialog box
  for the current reaction.
   
real *rr Pointer to array containing particle reaction rate (kg/s).
   
Function returns  
void  
   

There are eleven arguments to DEFINE_PR_RATE: name, c, t, r, mw, ci, p, sf, dif_index, cat_index, and rr. You supply name, the name of the UDF. c, t, r, mw, ci, p, sf, dif_index, cat_index, and rr are variables that are passed by the ANSYS FLUENT solver to your UDF. Your UDF will need to set the value referenced by the real pointer rr to the particle reaction rate in kg/s.

Note that p is an argument to many particle-specific macros defined in Section  3.2.7 and can be used to obtain information about particle properties. Also note that the order in which the solid species mass fractions are stored in array sf is the same as the order in which the species are defined in the Selected Solid Species list in the Create/Edit Materials dialog box, which is opened from the Edit Species names option for the Mixture Material.

DEFINE_PR_RATE is called by ANSYS FLUENT every time step during the particle tracking calculation. The auxiliary function zbrent_pr_rate is used when there is no analytical solution for the overall particle reaction rate. It uses Brent's method to find the root of a function known to lie between $x1$ and $x2$. The root will be refined until its accuracy has reached tolerance tol. This is demonstrated in Example 2.



Auxiliary function


zbrent_pr_rate ( real (*func),(real,real [],int [],cxboolean [],char *,) real ruser[],int iuser[],cxboolean buser[],char *cuser,real x1 real x2,real tol,cxboolean *ifail)

Auxiliary function returns: real



Example 1


The following UDF, named user_pr_rate, specifies a particle reaction rate given by this equation in the separate Theory Guide , where the effectiveness factor $\eta_r$ is defined as


\eta_r = 1 - x

where $x$ is the fractional conversion of the particle char mass. In this case, the UDF will be applied to all surface particle reactions defined in the ANSYS FLUENT model.

/* UDF of specifying the surface reaction rate of a particle */ 

#include "udf.h"

#define A1  0.002
#define E1  7.9e7

DEFINE_PR_RATE(user_pr_rate,c,t,r,mw,pp,p,sf,dif_i,cat_i,rr)
{
/* Argument types
    cell_t c
    Thread *t
    Reaction *r (reaction structure)
    real *mw  (species molecular weight)
    real *pp  (gas partial pressures)
    Tracked_Particle *p (particle structure)
    real *sf   (current mass fractions of solid species in 
                particle char mass)
    int dif_i  (index of diffusion controlled species)
    int cat_i  (index of catalyst species)
    real *rr   (rate of reaction kg/s)
*/

real ash_mass = 
P_INIT_MASS(p)*(1.-DPM_CHAR_FRACTION(p)-DPM_VOLATILE_FRACTION(p));

real one_minus_conv = 
MAX(0.,(P_MASS(p) -ash_mass) / P_INIT_MASS(p)/ DPM_CHAR_FRACTION(p));

real rate = A1*exp(-E1/UNIVERSAL_GAS_CONSTANT/P_T(p));

*rr=-rate*P_DIAM(p)*P_DIAM(p)*M_PI*sf[0]*one_minus_conv; 
}



Example 2


The following compiled UDF, named user_rate, specifies a particle reaction rate given by this equation to this equation in the separate Theory Guide . The reaction order on the kinetic rate is $0.9$ and the effectiveness factor $\eta_r$ is defined as


\eta_r = 1 - x

where $x$ is the fractional conversion of the particle char mass. In this case it is necessary to obtain a numerical solution for the overall surface reaction rate.

This UDF is called only for reaction 2, which means that the default ANSYS FLUENT solution will be used for the rest of the particle surface reactions defined.

/* UDF of specifying the surface reaction rate of a particle,
 using a numerical solution */ 

#include "udf.h"

#define c1  5e-12
#define A1  0.002
#define E1  7.9e7
#define tolerance 1e-4
#define order 0.9

real reaction_rate(real rate, real ruser[], int iuser[], cxboolean buser[],
 char *cuser)

/* 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 */

{
    return (ruser[2]*pow(MAX(0.,(ruser[0]-rate/ruser[1])),order) -rate);
}

DEFINE_PR_RATE(user_rate,c,t,r,mw,pp,p,sf,dif_i,cat_i,rr)
{
if (!strcmp(r->name, "reaction-2"))
  { 
  cxboolean ifail=FALSE;

  real ash_mass = 
  P_INIT_MASS(p)*(1.-DPM_CHAR_FRACTION(p)-DPM_VOLATILE_FRACTION(p));

  real one_minus_conv =
  MAX(0.,(P_MASS(p) -ash_mass) / P_INIT_MASS(p)/ DPM_CHAR_FRACTION(p));

  real ruser[3];
  int iuser[1];
  cxboolean buser[1];
  char cuser[30];

  real ratemin, ratemax, root;

  ruser[0] = pp[dif_i];
  ruser[1] = MAX(1.E-15, (c1*pow(0.5*(P_T(p)+C_T(c,t)),0.75)/P_DIAM(p)));
  ruser[2] = A1*exp(-E1/UNIVERSAL_GAS_CONSTANT/P_T(p));
  strcpy(cuser, "reaction-2");

  ratemin=0;
  ratemax=ruser[1]*pp[dif_i];

  /* arguments for auxiliary function zbrent_pr_rate */

  root = zbrent_pr_rate(reaction_rate, ruser, iuser, buser, cuser, 
                        ratemin, ratemax, tolerance, &ifail);

  if (ifail) root=MAX(1.E-15,ruser[1]);

  *rr=-root*P_DIAM(p)*P_DIAM(p)*M_PI*sf[0]*one_minus_conv; 

  Message("Fail status %d\n", ifail);
  Message("Reaction rate for reaction %s : %g\n", cuser, *rr);

 }
}

In this example, a real function named reaction_rate is defined at the top of the UDF. The arguments of reaction_rate are real rate, and the pointer arrays real ruser[], integer iuser[], cxboolean buser[], and char *cuser, which must be declared and defined in the main body of the DEFINE_PR_RATE function.

Typically, if the particle surface reaction rate is described by

        rate = f(ruser[],iuser[],rate)

then the real function (in this example reaction_rate) should return

        f(ruser[],iuser[],rate) - rate

The variables cxboolean buser[] and char *cuser can be used to control the flow of the program in cases of complicated rate definitions.

ratemin and ratemax, hold the minimum and maximum possible values of the variable rate, respectively. They define the search interval where the numerical algorithm will search for the root of the equation, as defined in the function reaction_rate. The value of reaction rate rr will be refined until an accuracy specified by the value of tolerance tol is reached.

The variable ifail will take the value TRUE if the root of the function has not been found.



Hooking a Particle Reaction Rate UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_PR_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., user_pr_rate) will become visible and selectable in the User-Defined Function Hooks dialog box in ANSYS FLUENT. See Section  6.2.13 for details.


next up previous contents index Previous: 2.3.12 DEFINE_NOX_RATE
Up: 2.3 Model-Specific DEFINE Macros
Next: 2.3.14 DEFINE_PRANDTL UDFs
Release 12.0 © ANSYS, Inc. 2009-01-14