You can use DEFINE_CHEM_STEP to specify
the change in mass fraction due to homogeneous reaction over a time
step:
(2–2) |
where is the initial mass
fraction of species
,
is time,
is the given time step, and
is the
net rate of change of the
th species mass fraction.
is
th species
mass fraction at the end of the integration.
DEFINE_CHEM_STEP UDFs are used for
the Laminar finite-rate (with Stiff Chemistry enabled), EDC and PDF
Transport models.
DEFINE_CHEM_STEP (name, c, t, p, num_p, n_spe, dt, pres, temp, yk)
|
Argument Type |
Description |
|
|
UDF name. |
|
|
Cell index of current particle. |
|
|
Pointer to cell thread for particle. |
|
|
Pointer to |
|
|
Not Used. |
|
|
Number of volumetric species. |
|
|
Time step. |
|
|
Pointer to pressure. |
|
|
Pointer to temperature. |
|
|
Pointer to array of initial species mass fractions. |
Function returns
void
There are nine arguments to DEFINE_CHEM_STEP: name, c, p, num_p, n_spe, dt, pres, temp, and yk. You supply name, the name of the UDF. c, p, n_spe, dt, pres, temp, and yk are variables that are passed by
the ANSYS Fluent solver to your UDF. num_p is
not used by the function and can be ignored. The output of the function
is the array of mass fractions yk after the integration step. The initial mass fractions
in array yk are overwritten.
The following UDF, named user_chem_step, assumes that the net volumetric reaction rate is the expression,
(2–3) |
where is
the number of species.
An analytic solution exists for the integral of this ODE as,
(2–4) |
/***************************************************
Example UDF that demonstrates DEFINE_CHEM_STEP
***************************************************/
#include "udf.h"
DEFINE_CHEM_STEP(user_chem_step,cell,thread,particle,nump,nspe,dt,pres,temp,yk)
{
int i;
double c = 1./(double)nspe;
double decay = exp(-(*dt));
for(i=0;i<n_spe;i++)
yk[i] = (yk[i]-c)*decay + c;
}
After the UDF that you have defined using DEFINE_CHEM_STEP is interpreted (Interpreting UDFs)
or compiled (Compiling UDFs), the name
of the argument that you supplied as the first DEFINE macro argument (for example, user_chem_step) will become visible and selectable in the User-Defined
Function Hooks dialog box in ANSYS Fluent. See Hooking DEFINE_CHEM_STEP UDFs for details.