2.3.2.  DEFINE_CHEM_STEP

2.3.2.1. Description

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.

2.3.2.2. Usage

DEFINE_CHEM_STEP (name, c, t, p, num_p, n_spe, dt, pres, temp, yk)

Argument Type

Description

symbol name

UDF name.

cell_t c

Cell index of current particle.

Thread *t

Pointer to cell thread for particle.

Particle *p

Pointer to Particle data structure that represents a particle used by the PDF transport model.

int num_p

Not Used.

int n_spec

Number of volumetric species.

double *dt

Time step.

double *pres

Pointer to pressure.

double *temp

Pointer to temperature.

double *yk

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.

2.3.2.3. Example

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;
 } 

2.3.2.4. Hooking a Chemistry Step UDF to ANSYS Fluent

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.


Release 18.2 - © ANSYS, Inc. All rights reserved.