Ansys Learning Forum Forums Discuss Simulation Fluids Mass Source Term UDF of Chemical Reaction Reply To: Mass Source Term UDF of Chemical Reaction

jcooper
Ansys Employee

 

 

Hi:

In Multiphase, phase species are stored under the phase thread, so they must be called as

C_YI(c,tp,species_index), where tp is the phase thread and species_index is the number of the specie (from 0-N-1) in the given phase. (The secondary phase thread could be defined as ts.)

The declaration of the phase threads would be as for DEFINE_HET_RXN_RATE below, which is written for multiphase phase change:

 

 


DEFINE_HET_RXN_RATE(user_evap_condens_react, c, t, hr, mw, yi, rr, rr_t) {
#define index_evap_primary 0 /*evaporating species index in primary phase*/ #define prim_index 0 /*index of primary phase*/     Thread **pt = THREAD_SUB_THREADS(t); Thread *tp = pt[0]; Thread *ts = pt[1]; int i; real concentration_evap_primary, accum = 0., mole_frac_evap_prim, concentration_sat ; real T_prim = C_T(c,tp); /*primary phase (gas) temperature*/ real T_sec = C_T(c,ts); /*secondary phase (droplet) temperature*/ real diam = C_PHASE_DIAMETER(c,ts); /*secondary phase diameter*/ real D_evap_prim = C_DIFF_EFF(c,tp,index_evap_primary) - 0.7*C_MU_T(c,tp)/C_R(c,tp); /*primary phase species turbulent diffusivity*/ real Re, Sc, Nu, urel, urelx,urely,urelz=0., mass_coeff, area_density, flux_evap ; if(Data_Valid_P()) { urelx = C_U(c,tp) - C_U(c,ts); urely = C_V(c,tp) - C_V(c,ts); #if RP_3D urelz = C_W(c,tp) - C_W(c,ts); #endif urel = sqrt(urelx*urelx + urely*urely + urelz*urelz); /*relative velocity*/ Re = urel * diam * C_R(c,tp) / C_MU_L(c,tp); Sc = C_MU_L(c,tp) / C_R(c,tp) / D_evap_prim ; Nu = 2. + 0.6 * pow(Re, 0.5)* pow(Sc, 0.333); mass_coeff = Nu * D_evap_prim / diam ; for (i=0; i < MAX_SPE_EQNS_PRIM ; i++) { accum = accum + C_YI(c,tp,i)/mw[i][prim_index]; } mole_frac_evap_prim = C_YI(c,tp,index_evap_primary) / mw[index_evap_primary][prim_index] / accum; concentration_evap_primary = mole_frac_evap_prim * P_OPER / UNIVERSAL_GAS_CONSTANT / T_prim ; concentration_sat = psat_h2o(T_sec)/UNIVERSAL_GAS_CONSTANT/T_sec ; area_density = 6. * C_VOF(c,ts) / diam ; flux_evap = mass_coeff * (concentration_sat - concentration_evap_primary) ; *rr = area_density * flux_evap ; } }


 

The above UDF example was taken from the Fluent Customization Manual here:

https://ansyshelp.ansys.com/Views/Secured/corp/v242/en/flu_udf/flu_udf_MultiphaseDEFINE.html#flu_udf_sec_define_het_rxn_rate

Regards,

Judy