![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Description
You can use the
DEFINE_NOX_RATE to specify a custom NOx rate for thermal NOx, prompt NOx, fuel NOx, and N
O intermediate pathways that can
either replace the internally-calculated NOx rate in the source term equation, or be added to the
ANSYS FLUENT rate. Example 1 demonstrates this use of
DEFINE_NOX_RATE. By default, the
Add to FLUENT Rate option is enabled
UDF Rate group box in each of the tabs under
Formation Model Parameters, so that user-defined rates are added to the
ANSYS FLUENT-calculated rates. You can change this default by selecting
Replace FLUENT Rate, so that the
ANSYS FLUENT-calculated rate for that NOx pathway will not be used and it will instead be replaced by the NOx rate you have defined in your UDF.
|
Note that a single UDF is used to define the different rates for the four NOx pathways: thermal NOx, prompt NOx, fuel NOx, and N
![]()
|
DEFINE_NOX_RATE may also be used to calculate the upper limit for the integration of the temperature PDF (when temperature is accounted for in the turbulence interaction modeling). You can calculate a custom maximum limit (
) for each cell and then assign it to the
POLLUT_CTMAX(Pollut_Par) macro (see Section
3.2.7 for further details about data access macros). Example 2 demonstrates this use of
DEFINE_NOX_RATE.
|
If you want to use
DEFINE_NOX_RATE only for the purpose of specifying
![]()
|
Usage
DEFINE_NOX_RATE( name, c, t, Pollut, Pollut_Par, NOx) |
Argument Type | Description |
symbol name | UDF name. |
cell_t c | Cell index. |
Thread *t | Pointer to cell thread on which the NOx rate |
is to be applied. | |
Pollut_Cell *Pollut | Pointer to the data structure that contains |
the common data at each cell | |
Pollut_Parameter *Pollut_Par | Pointer to the data structure |
that contains auxiliary data. | |
NOx_Parameter *NOx | Pointer to the data structure that contains |
data specific to the NOx model. | |
Function returns | |
void | |
There are six arguments to DEFINE_NOX_RATE: name, c, t, Pollut, Pollut_Par, and NOx. You will supply name, the name of the UDF. c, t, Pollut, Pollut_Par, and NOx are variables that are passed by the ANSYS FLUENT solver to your function. A DEFINE_NOX_RATE function does not output a value. The calculated NOx rates (or other pollutant species rates) are returned through the Pollut structure as the forward rate POLLUT_FRATE(Pollut) and reverse rate POLLUT_RRATE(Pollut), respectively.
|
The data contained within the NOx structure is specific
only to the NOx model. Alternatively, the
Pollut structure contains data at each cell that are useful for all pollutant species (e.g., forward and reverse rates, gas phase temperature, density). The
Pollut_Par structure contains auxiliary data common to all pollutant species (e.g., equation solved, universal gas constant, species molecular weights). Note that molecular weights extracted from the
Pollut_Par structure (i.e.,
Pollut_Par->sp[IDX(i)].mw for pollutant species--NO, HCN, etc.--and
Pollut_Par->sp[i].mw for other species, such as O
![]()
|
Example 1
The following compiled UDF, named user_nox, exactly reproduces the default ANSYS FLUENT NOx rates for the prompt NOx pathway. Note that this UDF will replace the ANSYS FLUENT rate only if you select Replace FLUENT Rate in the UDF Rate group box in the Prompt tab. Otherwise, the rate computed in the UDF will be added to ANSYS FLUENT's default rate. See Section 6.2.12 for details.
See Section 3.2.7 for details about the NOx macros (e.g., POLLUT_EQN, MOLECON, ARRH) that are used in pollutant rate calculations in this UDF.
/***************************************************************** UDF example of User-Defined NOx Rate for ANSYS FLUENT 12 or later If used with the "Replace with UDF" radio buttons activated, this UDF will exactly reproduce the default ANSYS FLUENT NOx rates for prompt NOx pathway. The flag "Pollut_Par->pollut_io_pdf == IN_PDF" should always be used for rates other than that from char N, so that if requested, the contributions will be PDF integrated. Any contribution from char must be included within a switch statement of the form "Pollut_Par->pollut_io_pdf == OUT_PDF". * * Arguments: * char nox_func_name - UDF name * cell_t c - Cell index * Thread *t - Pointer to cell thread on * which the NOx rate is to be * applied * Pollut_Cell *Pollut - Pointer to Pollut structure * Pollut_Parameter *Pollut_Par - Pointer to Pollut_Par * structure * NOx_Parameter *NOx - Pointer to NOx structure *****************************************************************/ #include "udf.h" DEFINE_NOX_RATE(user_nox, c, t, Pollut, Pollut_Par, NOx) { /* NOx->prompt_nox = Flag to indicate Prompt NOx is enabled * NOx->prompt_udf_replace = Flag to indicate UDF replace * Pollut_Par->nfstreams = Number of fuel streams * Pollut_Par->nfspe[i] = Number of fuel species in stream "i" * NOx->equiv_ratio[i] = Equivalence ratio for stream "i" * NOx->c_number[i] = Carbon number for stream "i" * Pollut_Par->fuel_idx[j][i] = Index of jth species in stream "i" * Pollut_Par->fuel_dup[j][i] = Fuel species duplication check * Pollut_Par->uni_R = Universal gas constant in SI units * Pollut->temp_m = Mean gas temperature (K) * Pollut->press = Pressure in SI units * Pollut->oxy_order = Oxygen order (please refer to user manual) */ POLLUT_FRATE(Pollut) = 0.0; POLLUT_RRATE(Pollut) = 0.0; switch (Pollut_Par->pollut_io_pdf) { case IN_PDF: /* Included source terms other than those from char */ if (POLLUT_EQN(Pollut_Par) == EQ_NO) { /* Prompt NOx */ if (NOx->prompt_nox && NOx->prompt_udf_replace) { int ifstream; real f=0., rf; Rate_Const K_PM = {6.4e6, 0.0, 36483.49436}; for(ifstream=0; ifstream<Pollut_Par->nfstreams; ifstream++) { int i; real xc_fuel=0., eqr=NOx->equiv_ratio[ifstream]; for (i=0; i<Pollut_Par->nfspe[ifstream]; i++) { if(!Pollut_Par->fuel_dup[i][ifstream]) xc_fuel += MOLECON(Pollut, Pollut_Par->fuel_idx[i][ifstream]); } f += (4.75 + 0.0819*NOx->c_number[ifstream] - 23.2*eqr + 32.0*pow(eqr, 2.) - 12.2*pow(eqr, 3.))*xc_fuel; } rf = ARRH(Pollut, K_PM); rf *= pow((Pollut_Par->uni_R*Pollut->temp_m/Pollut->press), (1.+Pollut->oxy_order)); rf *= pow(MOLECON(Pollut, O2), Pollut->oxy_order); rf *= MOLECON(Pollut, N2); POLLUT_FRATE(Pollut) += f*rf; } } break; case OUT_PDF: /* Char Contributions, must be included here */ break; default: /* Not used */ break; } } |
Example 2
The following compiled UDF, named
nox_func_name, specifies a custom maximum limit (
) for the integration of the temperature PDF for each cell. Note that this UDF does not alter the internally-calculated NOx rate.
See Section 3.2.7 for details about the NOx macro ( POLLUT_CTMAX) used in this UDF.
/************************************************************ UDF example of User-Defined Tmax value * * Arguments: * char nox_func_name - UDF name * cell_t c - Cell index * Thread *t - Pointer to cell thread * on which the NOx rate * is to be applied * Pollut_Cell *Pollut - Pointer to Pollut_Cell * structure * Pollut_Parameter *Pollut_Par - Pointer to Pollut_Parameter * structure * NOx_Parameter *NOx - Pointer to NOx_Parameter * structure ANSYS FLUENT Version: 12.0 or later *************************************************************/ #include "udf.h" int ud_nox_do_once=1; enum { CELL_TMAX=0, N_REQUIRED_UDM }; /*Compute/assign Tmax at each cell*/ real ud_eval_cell_tmax(cell_t c,Thread *t) { real tmax = 0.; /* Compute cell-based Tmax value */ tmax = 1.1*C_T(c,t); /* This is only an example */ return tmax; } DEFINE_NOX_RATE(user_nox, c, t, Pollut, Pollut_Par, NOx) { /* Assign cell-based Tmax value */ POLLUT_CTMAX(Pollut_Par) = ud_eval_cell_tmax(c,t); /*POLLUT_CTMAX(Pollut_Par) = C_UDMI(c,t,CELL_TMAX);*/ } DEFINE_ON_DEMAND(init_tmax) { Domain *domain; register Thread *t; register cell_t c; Message("Computing/Storing cell Tmax values\n"); domain = Get_Domain(1); /* Store User-Defined Tmax at each cell */ if(ud_nox_do_once == 1) { if(n_udm < N_REQUIRED_UDM) Error("Not enough udm allocated\n"); thread_loop_c (t,domain) begin_c_loop (c,t) C_UDMI(c,t,CELL_TMAX) = ud_eval_cell_tmax(c,t); end_c_loop (c,t) ud_nox_do_once = 0; } Message("Computing cell Tmax values completed..\n"); } |
Hooking a NOx Rate UDF to
ANSYS FLUENT
After the UDF that you have defined using DEFINE_NOX_RATE is compiled (Chapter 5), the name of the argument that you supplied as the first DEFINE macro argument (e.g., user_nox) will become visible and selectable in the NOx Model dialog box in ANSYS FLUENT. See Section 6.2.12 for details.