You are on page 1of 10

DEFINE HET RXN RATE

Description
You need to use DEFINE HET RXN RATE to specify reaction rates for heterogeneous reactions. A
heterogeneous reaction is one that involves reactants and products from more than one phase. Unlike
DEFINE VR RATE, a DEFINE HET RXN RATE UDF can be specified differently for different
heterogeneous reactions. During ANSYS FLUENT execution, the DEFINE HET RXN RATE UDF for
each heterogeneous reaction that is defined is called in every fluid cell. ANSYS FLUENT will use the
reaction rate specified by the UDF to compute production/destruction of the species participating in the
reaction, as well as heat and momentum transfer across phases due to the reaction.
A heterogeneous reaction is typically used to define reactions involving species of different phases. The
bulk phase can participate in the reaction if the phase does not have any species (i.e. phase has fluid
material instead of mixture material). Heterogeneous reactions are defined in the Phase Interaction dialog
box.

There are eight arguments to DEFINE HET RXN 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 pointer rr. The values must be specified in kmol m3 s (where
the volume is the cell volume).

Example
The following compiled UDF named user evap condens react defines the reaction rate
required to simulate evaporation or condensation on the surface of droplets. Such a
reaction can be formally described by the following:
Here, gas is a primary phase mixture of two species: H2O(gas) and air. Droplets constitute
the secondary phase and represent a mixture of one species - H2O(liq). Single-species mixtures are allowed
in multiphase models. The formulation for the reaction rate follows the model for particle evaporation that
is defined in Section 15.4.2: Droplet Vaporization (Law 2) in the separate Theory Guide.

#include "udf.h"
/*Constants used in psat_h2o to calculate saturation pressure*/
#define PSAT_A 0.01
#define PSAT_TP 338.15
#define C_LOOP 8
#define H2O_PC 22.089E6
#define H2O_TC 647.286
/*user inputs*/
#define MAX_SPE_EQNS_PRIM 2 /*total number of species in primary phase*/
#define index_evap_primary 0 /*evaporating species index in primary phase*/
#define prim_index 0 /*index of primary phase*/
#define P_OPER 101325 /*operating pressure equal to GUI value*/
/*end of user inputs*/
/*************************************************************/
/* UDF for specifying an interfacial area density */
/*************************************************************/
double psat_h2o(double tsat)
/* */
/* Computes saturation pressure of water vapor */
/* as function of temperature */
/* Equation is taken from THERMODYNAMIC PROPERTIES IN SI, */
/* by Reynolds, 1979 */
/* Returns pressure in PASCALS, given temperature in KELVIN */
{
int i;
double var1,sum1,ans1,psat;
double constants[8]={-7.4192420, 2.97221E-1, -1.155286E-1,
8.68563E-3, 1.094098E-3, -4.39993E-3, 2.520658E-3, -5.218684E-4};

/* var1 is an expression that is used in the summation loop */


var1 = PSAT_A*(tsat-PSAT_TP);
/* Compute summation loop */
i = 0;
sum1 = 0.0;
while (i < C_LOOP){
sum1+=constants[i]*pow(var1,i);
++i;
}
ans1 = sum1*(H2O_TC/tsat-1.0);
/* compute exponential to determine result */
/* psat has units of Pascals */
psat = H2O_PC*exp(ans1);
return psat;
}
DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t)
{
Thread **pt = THREAD_SUB_THREADS(t);
Thread *tp = pt[0];
Thread *ts = pt[1];
int i;
real concentration_evap_primary, accum = 0., mole_frac_evap_prim,
concentration_sat ;
real T_prim = C_T(c,tp); /*primary phase (gas) temperature*/
real T_sec = C_T(c,ts); /*secondary phase (droplet) temperature*/
real diam = C_PHASE_DIAMETER(c,ts); /*secondary phase diameter*/
real D_evap_prim = C_DIFF_EFF(c,tp,index_evap_primary)
- 0.7*C_MU_T(c,tp)/C_R(c,tp);
/*primary phase species turbulent diffusivity*/
real Re, Sc, Nu, urel, urelx,urely,urelz=0., mass_coeff, area_density,
flux_evap ;
if(Data_Valid_P())
{
urelx = C_U(c,tp) - C_U(c,ts);
urely = C_V(c,tp) - C_V(c,ts);
#if RP_3D
urelz = C_W(c,tp) - C_W(c,ts);
#endif
urel = sqrt(urelx*urelx + urely*urely + urelz*urelz);
/*relative velocity*/
Re = urel * diam * C_R(c,tp) / C_MU_L(c,tp);
Sc = C_MU_L(c,tp) / C_R(c,tp) / D_evap_prim ;
Nu = 2. + 0.6 * pow(Re, 0.5)* pow(Sc, 0.333);
mass_coeff = Nu * D_evap_prim / diam ;
for (i=0; i < MAX_SPE_EQNS_PRIM ; i++)
{

accum = accum + C_YI(c,tp,i)/mw[i][prim_index];


}
mole_frac_evap_prim = C_YI(c,tp,index_evap_primary )
/ mw[index_evap_primary][prim_index] / accum;
concentration_evap_primary = mole_frac_evap_prim * P_OPER
/ UNIVERSAL_GAS_CONSTANT / T_prim ;
concentration_sat = psat_h2o(T_sec)/UNIVERSAL_GAS_CONSTANT/T_sec ;
area_density = 6. * C_VOF(c,ts) / diam ;
flux_evap = mass_coeff *
(concentration_sat - concentration_evap_primary ) ;
*rr = area_density * flux_evap ;
}
}

Hooking a Heterogeneous Reaction Rate UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE HET RXN RATE is interpreted (Chap
ter 4: Interpreting UDFs) or compiled (Chapter 5: Compiling UDFs), the name of the ar
gument that you supplied as the first DEFINE macro argument (e.g., user evap condens react)
will become visible and selectable under Reaction Rate Function in the Reactions tab of
the Phase Interaction dialog box. (Note you will first need to specify the Total Number
of Reactions greater than 0.) See Section 6.3.3: Hooking DEFINE HET RXN RATE UDFs for
details.

Example 2 - Degassing Boundary Condition


The following UDFs are used to define the bottom surface as a standard velocity
inlet for
the gas (primary) phase. The inlet VOF of the droplet phase is 0 and a negative
source
term for secondary phase mass conservation is set for the layer of cells next to the
outlet.
The source removes all secondary phase mass in the cell during one time step. The
recoil
force due to the mass source is also calculated.
/*******************************************************************/
/*This UDF is an implementation of the degassing boundary condition*/
/*******************************************************************/
#include "udf.h"
#include "sg.h"
#include "sg_mphase.h"
#include "flow.h"
#include "mem.h"
#include "metric.h"
DEFINE_SOURCE(degassing_source, cell, thread, dS, eqn)
{
real source;
Thread *tm = THREAD_SUPER_THREAD(thread);
source = -C_R(cell,thread)*C_VOF(cell,thread)/CURRENT_TIMESTEP ;
C_UDMI(cell,tm,0) = source;
dS[eqn] = -C_R(cell,thread)/CURRENT_TIMESTEP;
return source;
}
DEFINE_SOURCE(x_prim_recoil, cell, tp, dS, eqn)
{
real source;
Thread *tm = THREAD_SUPER_THREAD(tp);
Thread *ts;
ts = THREAD_SUB_THREAD(tm,1);
source = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP*C_U(cell,tp);
dS[eqn] =-C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP;
return source;
}
DEFINE_SOURCE(x_sec_recoil, cell, ts, dS, eqn)
{
real source;
Thread *tm = THREAD_SUPER_THREAD(ts);
source = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP*C_U(cell,ts);
dS[eqn] = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP;
return source;
}

DEFINE_SOURCE(y_prim_recoil, cell, tp, dS, eqn)


{
real source;
Thread *tm = THREAD_SUPER_THREAD(tp);
Thread *ts;
ts = THREAD_SUB_THREAD(tm,1);
source = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP*C_V(cell,tp);
dS[eqn] =-C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP;
return source;
}
DEFINE_SOURCE(y_sec_recoil, cell, ts, dS, eqn)
{
real source;
Thread *tm = THREAD_SUPER_THREAD(ts);
source = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP*C_V(cell,ts);
dS[eqn] = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP;
return source;
}
DEFINE_SOURCE(z_prim_recoil, cell, tp, dS, eqn)
{
real source;
Thread *tm = THREAD_SUPER_THREAD(tp);
Thread *ts;
ts = THREAD_SUB_THREAD(tm,1);
source = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP*C_W(cell,tp);
dS[eqn] =-C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP;
return source;
}
DEFINE_SOURCE(z_sec_recoil, cell, ts, dS, eqn)
{
real source;
Thread *tm = THREAD_SUPER_THREAD(ts);
source = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP*C_W(cell,ts);
dS[eqn] = -C_R(cell,ts)*C_VOF(cell,ts)/CURRENT_TIMESTEP;
return source;
}

6.2.19 Hooking DEFINE SOURCE UDFs


After you have interpreted (Chapter 4: Interpreting UDFs) or compiled (Chapter 5:
Compiling UDFs) your DEFINE SOURCE UDF, the name of the function you supplied
as a
DEFINE macro argument will become visible and selectable in a source term dialog
box
(e.g., the Mass sources dialog box) in ANSYS FLUENT.
To hook the UDF to ANSYS FLUENT, you will first need to open the Cell Zone
Conditions

task page.
Cell Zone Conditions
Select the appropriate zone in the Zone selection list of the Cell Zone Conditions
task page
and click the Edit... button to open the cell zone condition dialog box (e.g., the Fluid
dialog box, as shown in Figure 6.2.26).

You might also like