Once you have compiled and linked your diffusivity UDF, you can activate it by selecting it as the mass or UDS diffusivity in the Materials panel in FLUENT. See Section 8.2.4 for more details. 4.3.3 DEFINE_HEAT_FLUX 功能和使用方法的介绍
In spite of its name, the DEFINE_HEAT_FLUX macro is not to be used to explicitly set the heat flux along a wall. FLUENT computes the heat flux along a wall based on currently selected models to account for the diffusive and radiative energy fluxes (if any). You must only use a DEFINE_HEAT_FLUX UDF when you want to employ some other heat transfer mechanism that is not currently being modeled. The total heat flux at the wall will be the sum of the currently computed heat flux (based on the activated models) and the heat flux defined by the UDF.
Macro: DEFINE_HEAT_FLUX ( name, f, t, c0, t0, cid, cir) Argument types: face_t f Thread *t cell_t c0 Thread *t0 real cid[] real cir[] Function returns: void
There are seven arguments to DEFINE_HEAT_FLUX: name, f, t, c0, t0, cid, and cir. name is the name of the UDF, specified by you. 当你的UDF编译和连接时,你为函数所选择的名字会在FLUENT图形用户界面中变得可见,且可被选择。 f, t, c0, t0, cir[], and cid[] are variables that are passed by the FLUENT solver to your UDF. f is an index that identifies a wall face within the given thread. t is a pointer to the thread on which the heat flux function is to be applied. c0 is an index that identifies the cell next to the wall, and t0 is a pointer to the adjacent cell's thread.
cid[] and cir[] are real arrays that need to be computed by your UDF. Array cid[] stores the fluid-side diffusive heat transfer coefficients, while array cir[] stores radiative heat transfer coefficients. With these inputs provided to the function, the
diffusive heat flux ( qid) and radiative heat flux ( qir) are computed by FLUENT according to the following equations:
qid = cid[0] + cid[1]*C_T(c0,t0) - cid[2]*F_T(f,t) - cid[3]*pow(F_T(f,t),4) qir = cir[0] + cir[1]*C_T(c0,t0) - cir[2]*F_T(f,t) - cir[3]*pow(F_T(f,t),4)
The sum of qid and qir defines the total heat flux from the fluid to the wall (this direction being positive flux), and, from an energy balance at the wall, equals the heat flux of the surroundings (exterior to the domain). Note that heat flux UDFs (defined using DEFINE_HEAT_FLUX) are called by FLUENT from within a loop over wall faces.
!! In order for the solver to compute C_T and F_T, the values you supply to cid[1] and cid[2] should never be zero. 例子:
Section 10.5.2 provides an 例子: of the P-1 radiation model implementation through a user-defined scalar. An 例子: of the usage of the DEFINE_HEAT_FLUX macro is included in that implementation. Activating a Heat Flux UDF in FLUENT
Once you have compiled and linked your heat flux UDF, you can activate it by selecting it in the User-Defined Function Hooks panel in FLUENT. See Section 8.2.2 for more details. 4.3.4 DEFINE_NOX_RATE 功能和使用方法的介绍
你可以使用DEFINE_NOX_RATE macro to calculate NOx production and reduction rates in FLUENT. The UDF rate that you specify is independent of the standard NOx model options. You can deselect the standard NOx options in your simulation, and choose the UDF rate instead.
Macro: DEFINE_NOX_RATE ( name, c, t, NOx) Argument types: cell_t c Thread *t NOx_Parameter *NOx Function returns: void
There are four arguments to DEFINE_NOX_RATE: name, c, t, and NOx. name is the name of the UDF, specified by you. 当你的UDF编译和连接时,你为函数所选择的名字会在FLUENT图形用户界面中变得可见,且可被选择。 c, t, and NOx are variables that are passed by the FLUENT solver to your UDF.
c is an index that identifies a cell within the given thread. t is a pointer to the thread on which the NOx rate is to be applied. NOx is a pointer to the NOx structure. A DEFINE_NOX_RATE function does not return a value. The calculated NOx rates are returned through the NOx structure.
Note that, although the data structure is called NOx, the DEFINE_NOX_RATE macro can be used to calculate the rates of any of the pollutant species (i.e., NO, HCN, and NH 3), depending on which of the pollutant species equations is being solved. 例子:
下面编译的UDF名字为user_nox, computes NOx production and reduction rates based on the forward and reverse rates of NO defined as
(4.3.1)
and
(4.3.2)
where the rate coefficients, which have units of m 3/mol-s, are defined as k 1
=
k -1
=
k 2
=
(4.3.5) (4.3.4) (4.3.3)
k -2 =
O concentration is given by
=
All concentrations in the rate expressions have units of mol/mol 3. /************************************************************/ /* UDF 例子: of User-Defined NOx Rate */ /************************************************************/
#include \
#define SMALL_S 1.e-29
DEFINE_NOX_RATE(user_nox, c, t, NOx) {
real kf1, kr1, kf2, kr2; real o_eq;
real s1, s2, s3, rf, rr;
Rate_Const K_F[2] = {{1.80e8, 0.0, 38370.0}, {1.80e4, 1.0, 4680.0}};
Rate_Const K_R[2] = {{3.80e7, 0.0, 425.0}, {3.80e3, 1.0, 20820.0}};
Rate_Const K_O = {3.664e1, 0.5, 27123.0};
if (NOX_EQN(NOx) != EQ_NO) return;
kf1 = ARRH(NOx, K_F[0]); kr1 = ARRH(NOx, K_R[0]); kf2 = ARRH(NOx, K_F[1]); kr2 = ARRH(NOx, K_R[1]);
(4.3.6)
(4.3.7)
s1 = kf2*MOLECON(NOx, O2);
s3 = s1 + kr1*MOLECON(NOx, NO);
/* determine O concentration (partial equilibrium)*/
o_eq = ARRH(NOx, K_O)*sqrt(MOLECON(NOx, O2));
/* calculate NO rate */ s2 = 2.*o_eq;
/* forward rate... */
rf = s2*(kf1*MOLECON(NOx, N2))*s1/s3; /* reverse rate... */
rr = -s2*kr1*kr2*pow(MOLECON(NOx, NO), 2.0)/s3; /* rates have units mole/m^3/s */ NOX_FRATE(NOx) = rf; NOX_RRATE(NOx) = rr; }
A number of Fluent-provided macros can be used in the calculation of pollutant rate using user-defined functions. The macros listed below are defined in the header file sg_nox.h which is included in the udf.h file. The variable NOx indicates a pointer to the NOx_Parameter structure.
NOX_EQN(NOx) returns the index of the pollutant equation currently being solved. The indices are EQ_NO for NO, EQ_HCN for HCN, and EQ_NH3 for NH 3.
? MOLECON(NOx, SPE) returns the molar concentration of a species specified by SPE, which must be replaced by one of the following identifiers: FUEL, O 2, O, OH, H 2O, N 2, N, CH, CH 2, CH 3, NO, HCN, NH 3. Identifier FUEL represents the fuel species as specified in the Fuel Species drop-down list under Prompt NO Parameters in the NOx Model panel.
? NULLIDX(NOx, SPE) returns TRUE if the species specified by SPE does not exist in the FLUENT case (i.e., in the Species panel).
? ARRH(NOx, K) returns the Arrhenius rate calculated from the constants specified by K. K is defined using the Rate_Const data type and has three elements - A, B, and C. The Arrhenius rate is given in the form of
?
where T is the temperature.
?
NOX_FRATE(NOx) is used to return the production rate of the pollutant species being solved.