FLUENT V6  How to calcuate angular momentum flux for steady state engine port flow by using a UserDefined Function (UDF)
Engine swirl is an important parameter. However, transient swirl is not easy to measure. Steady state testing, on the other hand, is quite easy, and steady state data can be used to evaluate engine swirl. In a steady state test, the valves are not moving and the piston is removed. And a honeycomb structure is connected at the end of the cylinder to straighten the flow. Air flows steadily through the inlet port, the valve, the cylinder, and the honeycomb structure. There is angular momentum flux going into the honeycomb but zero coming out of it due to straightened flow by the honeycomb structure. There needs to be some torque to hold the honey comb. The torque needed to hold the honey comb is measured. The torque thus should be equal to the angular momentum flux into the honeycomb according to the angular momentum balance. Even though it is hard to measure angular momentum flux, it is easy to measure torque. And it is believed that if the torque is large for certain engine, then the angular momentum (or swirl) for such engine should be high as well. Unlike experiments, FLUENT can calculate both angular momentum flux and torque easily. However, in order to calculate the torque, a mesh is needed to resolve the honeycomb structure, which could be expensive. So, a porous media is used to model the honeycomb inside FLUENT. If porous media is used, FLUENT cannot calculate the torque. However, FLUENT can still be used easily to calculate the angular momentum flux. And the angular momentum flux from FLUENT should be equal to the torque from experiments. This is how FLUENT data can be used to compare with experimental data. In order to calcuate the angular momentum flux, a UserDefined Function (UDF) is needed. An example of such a UDF is included in this Solution. /********************************************************************************************* UDF for angular momentum flux calculation How to use it:  Converge your cas/dat  Modify the user input part of the udf.  Build the lib  The ON_DEMAND udf will give the angular momentum flux Note:  UDF works in 2d axisymmetry and 3d. And it works in both serial and parallel. Written by : Xiao HU (Fluent Inc) Last updated : 10/29/2004 ***********************************************************************************************/ # include "udf.h" /********************************* User input starts *****************************************/ /* Face zone ID list for angular momentum flux calculation. 1 is a flag so please keep it. */ static int Zone_ID[]={6, 1}; /* Center and axis for angular momentum flux */ static real swirl_axis[ND_ND]={0, 0, 1}; static real swirl_center[ND_ND]={0, 0, 0}; /********************************** User input ends ******************************************/ static void f_angular_mom_flux(real * angular_mom_flux, real * flowrate) { int i; real x[ND_ND], r[ND_ND], rv[ND_ND], v[ND_ND], mag; cell_t c; face_t f; Thread * tf, *tc; Domain *domain; domain=Get_Domain(1); /* Normalize the axis */ mag=NV_MAG(swirl_axis); NV_S(swirl_axis, /=, mag); /* Calculate angular momentum flux */ (* angular_mom_flux)=0; (* flowrate)=0; i=0; while(Zone_ID[i]>=0) { tf=Lookup_Thread(domain, Zone_ID[i]); begin_f_loop(f, tf) if (PRINCIPAL_FACE_P(f,tf)) { c = F_C0(f,tf); tc = THREAD_T0(tf); F_CENTROID(x, f, tf); NV_VV(r, =, x, , swirl_center); #if RP_2D if (rp_axi) { (* angular_mom_flux) += x[1]*C_W(c, tc)*F_FLUX(f, tf); /* adjacent cell velocity is used */ (* flowrate) += F_FLUX(f, tf); } #else ND_SET(v[0], v[1], v[2], C_U(c, tc), C_V(c, tc), C_W(c, tc)); /* adjacent cell velocity is used */ NV_CROSS(rv, r, v); (* angular_mom_flux) += NV_DOT(rv, swirl_axis)*F_FLUX(f, tf); (* flowrate) += F_FLUX(f, tf); #endif } end_f_loop(f, tf) i++; } PRF_GRSUM2((* angular_mom_flux),(* flowrate)); } static void f_print_info(void) { real angular_mom_flux, flowrate; f_angular_mom_flux(&angular_mom_flux, &flowrate); Message0("nnn************* Angular Momentum Flux Results in SI Units ****************n"); Message0("n Flow rate = %10.4e (kg/s)n", flowrate); Message0("n Angular momentum flux center = (%11.4e %11.4e %11.4e)n", swirl_center[0], swirl_center[1], swirl_center[2]); Message0("n Angular momentum flux axis = (%11.4e %11.4e %11.4e)n", swirl_axis[0], swirl_axis[1], swirl_axis[2]); Message0("n Angular momentum flux = %10.4e (nm)n", angular_mom_flux); Message0("n************************************************************************nn"); } DEFINE_ON_DEMAND(Angular_mom_flux) { #if !RP_HOST #if RP_2D if (rp_axi) { f_print_info(); } else { Message0("nnn************* Angular Momentum Flux Results in SI Units ****************n"); Message0("nIt makes no sense to calcualte swirl for 2d cases!!n"); Message0("n************************************************************************nn"); } #else f_print_info(); #endif #endif } 

