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

2.3.27 DEFINE_VR_RATE



Description


You can use DEFINE_VR_RATE to specify a custom volumetric reaction rate for a single reaction or for multiple reactions. During ANSYS FLUENT execution, DEFINE_VR_RATE is called for every reaction in every single cell. 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.



Usage



DEFINE_VR_RATE( name,c,t,r,mw,yi,rr,rr_t)


Argument Type Description
symbol name UDF name.
cell_t c Cell index.
Thread *t Pointer to cell thread on which the volumetric reaction
  rate is to be applied.
Reaction *r Pointer to data structure that represents the
  current reaction.
real *mw Pointer to array of species molecular weights.
real *yi Pointer to array of the species mass fractions.
real *rr Pointer to laminar reaction rate.
real *rr_t Pointer to turbulent reaction rate.
   
Function returns  
void  
   

There are eight arguments to DEFINE_VR_RATE: name, c, t, r, mw, yi, rr, and rr_t. You supply name, the name of the UDF. c, t, r, mw, yi, rr, and rr_t are variables that are passed by the ANSYS FLUENT solver to your UDF. Your UDF will need to set the values referenced by the real pointers rr and rr_t to the laminar and turbulent reaction rates, respectively.

rr and rr_t (defined by the UDF) are computed and the lower of the two values is used when the finite-rate/eddy-dissipation chemical reaction mechanism used. Note that rr and rr_t are conversion rates in kmol/m $^3$-s. These rates, when multiplied by the respective stoichiometric coefficients, yield the production/consumption rates of the individual chemical components.



Example 1


The following UDF, named vol_reac_rate, specifies a volume reaction rate. The function must be executed as a compiled UDF in ANSYS FLUENT.

/*********************************************************************
   UDF for specifying a volume reaction rate                         
   The basics of ANSYS FLUENT's calculation of reaction rates:  only an    
   Arrhenius ("finite rate") reaction rate is calculated              
   from the inputs given by the user in the graphical user interface 
**********************************************************************/

#include "udf.h"

DEFINE_VR_RATE(vol_reac_rate,c,t,r,wk,yk,rate,rr_t)
{
  real ci, prod;
  int i;

/* Calculate Arrhenius reaction rate  */

  prod = 1.;

  for(i = 0; i < r->n_reactants; i++)
    {
       ci     = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
       prod  *= pow(ci, r->exp_reactant[i]);
    }
  *rate = r->A * exp( - r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) * 
                                        pow(C_T(c,t), r->b) * prod;

  *rr_t = *rate;

  /* No "return..;" value. */
}



Example 2


When multiple reactions are specified, a volume reaction rate UDF is called several times in each cell. Different values are assigned to the pointer r, depending on which reaction the UDF is being called for. Therefore, you will need to determine which reaction is being called, and return the correct rates for that reaction. Reactions can be identified by their name through the r->name statement. To test whether a given reaction has the name reaction-1, for example, you can use the following C construct:

if (!strcmp(r->name, "reaction-1"))
    {
      ....  /* r->name is identical to "reaction-1" ... */
    }

figure   

Note that strcmp(r->name, "reaction-1") returns $0$ which is equal to FALSE when the two strings are identical.

It should be noted that DEFINE_VR_RATE defines only the reaction rate for a predefined stoichiometric equation (set in the Reactions dialog box) thus providing an alternative to the Arrhenius rate model. DEFINE_VR_RATE does not directly address the particular rate of species creation or depletion; this is done by the ANSYS FLUENT solver using the reaction rate supplied by your UDF.

The following is a source code template that shows how to use DEFINE_VR_RATE in connection with more than one user-specified reaction. Note that ANSYS FLUENT always calculates the rr and rr_t reaction rates before the UDF is called. Consequently, the values that are calculated are available only in the given variables when the UDF is called.

/*********************************************************************
   Multiple reaction UDF that specifies different reaction rates
   for different volumetric chemical reactions                       
**********************************************************************/
#include "udf.h"

DEFINE_VR_RATE(myrate,c,t,r,mw,yi,rr,rr_t)
{
 /*If more than one reaction is defined, it is necessary to distinguish
   between these using the names of the reactions.                    */

      if (!strcmp(r->name, "reaction-1"))
        {
          /* Reaction 1 */
        }
      else if (!strcmp(r->name, "reaction-2"))
        {
          /* Reaction 2 */
        }
      else
        { 
/*        Message("Unknown Reaction\n"); */
        } 
/*    Message("Actual Reaction: %s\n",r->name); */
                 
}



Hooking a Volumetric Reaction Rate UDF to ANSYS FLUENT


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


next up previous contents index Previous: 2.3.26 DEFINE_TURBULENT_VISCOSITY
Up: 2.3 Model-Specific DEFINE Macros
Next: 2.3.28 DEFINE_WALL_FUNCTIONS
Release 12.0 © ANSYS, Inc. 2009-01-14