/*If more than one reaction is defined, it is necessary to distinguish*/
/* between these using the names of the reactions. */
if (!strcmp(r->name, \ {
/* Reaction 1 */ }
else if (!strcmp(r->name, \ {
/* Reaction 2 */ } else {
/* CX_Message(\ }
/* CX_Message(\ }
Activating a Volumetric Reaction Rate UDF in FLUENT
Once you have compiled and linked the source code for a custom volumetric reaction rate UDF, you can activate it in the User-Defined Function Hooks panel in FLUENT. See Section 8.2.6 for more details. 4.4 Multiphase DEFINE Macros
The following DEFINE macros are used only for multiphase applications. Table 4.4.1 provides a quick reference guide to the DEFINE macros, the functions they are used to define, and the panels where they are activated in FLUENT. Definitions of each DEFINE macro are listed in the udf.h header file. For your convenience, the definitions are also provided in Appendix A.
DEFINE_CAVITATION_RATE (Section 4.4.1) ? DEFINE_EXCHANGE_PROPERTY (Section 4.4.2)
? DEFINE_VECTOR_EXCHANGE_PROPERTY (Section 4.4.3)
?
Table 4.4.1: Quick Reference Guide for Multiphase DEFINE Macros Function DEFINE Macro Panel Activated In cavitation rate DEFINE_CAVITATION_RATE drag coefficient DEFINE_EXCHANGE_PROPERTY lift coefficient DEFINE_EXCHANGE_PROPERTY slip velocity
User-Defined Function Hooks Phase Interaction Phase Interaction DEFINE_VECTOR_EXCHANGE_PROPERTY Phase Interaction 4.4.1 DEFINE_CAVITATION_RATE ? 4.4.2 DEFINE_EXCHANGE_PROPERTY
? 4.4.3 DEFINE_VECTOR_EXCHANGE_PROPERTY
?
4.4.1 DEFINE_CAVITATION_RATE 功能和使用方法的介绍
你可以使用DEFINE_CAVITATION_RATE macro to model the creation of vapor due to pressure tension in a multiphase flow.
Macro: DEFINE_CAVITATION_RATE ( name, c, t, p, rhoV, rhoL, vofV, p_v, n_b, m_dot) Argument types: cell_t c Thread *t real *p real *rhoV real *rhoL real *vofV real *p_v real *n_b real *m_dot Function returns: void
There are ten arguments to DEFINE_CAVITATION_RATE: name, c, t, p, rhoV, rhoL, vofV, p_v, n_b, and m_dot. name is the name of the UDF, specified by you. 当你的UDF编译和连接时,你为函数所选择的名字会在FLUENT图形用户界面中变得可见,且可被选择。 c, t, p, rhoV, rhoL, vofV, p_v, n_b, and m_dot are variables that are passed by the FLUENT solver to your UDF.
t is a pointer to the mixture-level thread. c is the index of a cell on the thread pointed to by t. The remaining arguments are real pointers to the following data: shared pressure ( p), vapor density ( rhoV), liquid density ( rhoL), vapor volume fraction ( vofV), vaporization pressure ( p_v), number of bubbles per unit volume ( n_b), and rate of vapor formation ( m_dot) Your UDF will need to set the value referenced by the real pointer m_dot, to the cavitation rate. 例子:
下面的UDF名字为cavitation_rate, is an 例子: of how to calculate the mass transfer between the liquid and vapor phases (cavitation rate) in a multiphase mixture. The function can be executed as an interpreted or compiled UDF.
/***********************************************************************/ /* UDF that computes the cavitation rate */
/***********************************************************************/
#include \
#define MIN_VOF 1.e-5
#define MAX_VOF 0.999999
DEFINE_CAVITATION_RATE(cavitation_rate, c, t, p,
rhoV, rhoL, vofV, p_v, n_b, m_dot) {
real p_vapor = *p_v; real n_bubbles = *n_b; real dp, vofM, radV;
dp = p_vapor - ABS_P( p[c], op_pres );
vofM = MIN(MAX(MIN_VOF, vofV[c]),MAX_VOF);
radV = pow(vofM/((1.-vofM)*4./3.*M_PI*n_bubbles), 1./3.);
if (dp>0.)
*m_dot = (1.-vofV[c]) * n_bubbles * 4. * M_PI *
radV * radV/(1.+n_bubbles*4./3.*M_PI*radV*radV*radV) * sqrt(2.*ABS(dp)/(3.*rhoL[c])); else {
*m_dot = - (1.-vofV[c]) * n_bubbles * 4. *M_PI *
radV*radV/(1.+n_bubbles*4./3.*M_PI*radV*radV*radV) * sqrt(2.*ABS(dp)/(3.*rhoL[c])); if (vofV[c] <= MIN_VOF) *m_dot=0.; } }
Activating a Cavitation Rate UDF in FLUENT
Once you have compiled and linked the source code for a custom cavitation rate UDF, you can activate it in the User-Defined Function Hooks panel in FLUENT. See Section 8.3.1 for more details. 4.4.2 DEFINE_EXCHANGE_PROPERTY 功能和使用方法的介绍
你可以使用DEFINE_EXCHANGE_PROPERTY macro to specify custom lift and drag coefficients for the multiphase Eulerian model.
Macro: DEFINE_EXCHANGE_PROPERTY ( name, c, mixture_thread, second_column_phase_index, first_column_phase_index) Argument types: cell_t c Thread *mixture_thread int second_column_phase_index int first_column_phase_index Function returns: real
There are five arguments to DEFINE_EXCHANGE_PROPERTY: name, c, mixture_thread, second_column_phase_index, and first_column_phase_index. name is the name of the UDF, specified by you. 当你的UDF编译和连接时,你为函数所选择的名字会在FLUENT图形用户界面中变得可见,且可被选择。 c, mixture_thread, second_column_phase_index, and first_column_phase_index are variables that are passed by the FLUENT solver to your UDF.
mixture_thread is a pointer to the mixture-level thread. c is the index of a cell on the thread pointed to by mixture_thread. first_column_phase_index and second_column_ phase_index are integer identifiers corresponding to the pair of phases in your multiphase flow that you are specifying a slip velocity for. The identifiers correspond to the phases that are selected in the Phase Interaction panel in the graphical user interface. An index of 0 corresponds to the primary phase, and is incremented by one for each secondary phase. Your UDF will need to return the real value of the lift or drag coefficient to the FLUENT solver. 例子:
下面的UDF名字为custom_drag, can be used to customize the default Syamlal drag law in FLUENT. The default drag law uses 0.8 (for void <=0.85) and 2.65 (void >0.85) for bfac. This results in a minimum fluid velocity of 25 cm/s. The UDF modifies the drag law to result in a minimum fluid velocity of 8 cm/s, using 0.28 and 9.07 for the bfac parameters.
/***************************************************************/ /* UDF for customizing the default Syamlal drag law in Fluent */
/***************************************************************/
#include \
#define pi 4.*atan(1.) #define diam2 3.e-4
DEFINE_EXCHANGE_PROPERTY(custom_drag, cell, mix_thread, s_col, f_col) {
Thread *thread_g, *thread_s;
real x_vel_g, x_vel_s, y_vel_g, y_vel_s, abs_v, slip_x, slip_y, rho_g, rho_s, mu_g, reyp, afac,
bfac, void_g, vfac, fdrgs, taup, k_g_s;
/* find the threads for the gas (primary) */ /* and solids (secondary phases) */
thread_g = THREAD_SUB_THREAD(mix_thread, s_col);/* gas phase */ thread_s = THREAD_SUB_THREAD(mix_thread, f_col);/* solid phase*/
/* find phase velocities and properties*/
x_vel_g = C_U(cell, thread_g); y_vel_g = C_V(cell, thread_g);
x_vel_s = C_U(cell, thread_s); y_vel_s = C_V(cell, thread_s);
slip_x = x_vel_g - x_vel_s; slip_y = y_vel_g - y_vel_s;
rho_g = C_R(cell, thread_g); rho_s = C_R(cell, thread_s);
mu_g = C_MU_L(cell, thread_g);
/*compute slip*/
abs_v = sqrt(slip_x*slip_x + slip_y*slip_y);
/*compute reynolds number*/
reyp = rho_g*abs_v*diam2/mu_g;
/* compute particle relaxation time */
taup = rho_s*diam2*diam2/18./mu_g;
void_g = C_VOF(cell, thread_g);/* gas vol frac*/
/*compute drag and return drag coeff, k_g_s*/
afac = pow(void_g,4.14);
if(void_g<=0.85)
bfac = 0.281632*pow(void_g, 1.28); else
bfac = pow(void_g, 9.076960);
vfac = 0.5*(afac-0.06*reyp+sqrt(0.0036*reyp*reyp+0.12*reyp*(2.*bfac- afac)+afac*afac)); fdrgs = void_g*(pow((0.63*sqrt(reyp)/
vfac+4.8*sqrt(vfac)/vfac),2))/24.0;