Looping in UDF!!!
Hello,
First, thanks for all who answred me before:) This time I have a UDF problem : I wrote a UDF for heterogeneous reaction rate in which I put a while loop that works out concentrations'species as a function of the radius growth of a particle, then reaction rate that itself is used to calculate the heat source. What is strange is that when starting iterations, i found that nothing inside the while loop is calculated!! I am still have a constant value of all variables, then reaction rate and heat source!! Besides, I wrote a UDF for temperature profile which changes with reaction rate! Actually, all variables depend on the radius growth of a particle which depends on time!!! Below, is the UDF text: *--------------------------------------------------------*/ /* HETEROGENEOUS REACTION RATE */ /*-------------------------------------------------------*/ DEFINE_HET_RXN_RATE(PP_REACTION,c,t,r,mw,yi,rr,rr_ t) { float up; float flow_time=RP_Get_Real("flow-time"); while (R<=Rmax) { C_cat=pow((2*R0)/(2*R),3)*density_cat;/*Kgcat/m3*/ printf("catalyst Concentration=%fKg/m3\n",C_cat); C_pr_micro=(C_pr_bulk*M_WEIGHT_Pr)/(1+(((kp*C_cat)/(3*D_micro))*pow(R0,2)*(1-(R0/R))));/*Kg/m3*/ printf("monomer Concentration=%fKgcat/m3\n",C_pr_micro); up=(kp*C_cat*C_pr_micro*R)/(2*DENSITY_PROPYLENE);/*m/s*/ printf("velocity growth=%fm/s\n",up); R=up*flow_time+R0; printf("particle radius=%fm\n",R);/*m*/ REACTION_RATE=(kp*C_cat*C_pr_micro)/M_WEIGHT_Pr;/*Kmol/m3s*/ printf("reaction rate =%f/Kmol/m3s\n",REACTION_RATE); } *rr=REACTION_RATE; } /*--------------------------------------------------------*/ /*HEAT SOURCE ON THE CATALYST SURFACE*/ /*--------------------------------------------------------*/ DEFINE_SOURCE(Heat_polym,c,t,dS,eqn) { heat_source=REACTION_RATE*M_WEIGHT_Pr*(-DELTA_H); /*W/m3*/ printf("heat =%f/W/m3\n",heat_source); return heat_source; } /*--------------------------------------------------------*/ /* TEMPERATURE PROFILE/* /*--------------------------------------------------------*/ DEFINE_PROFILE(temperature,t,i) { face_t f; begin_f_loop(f,t) { F_PROFILE(f,t,i)=EP/(log((kp0*C_cat*C_pr_micro)/(REACTION_RATE*M_WEIGHT_Pr))*GAS_CONSTANT);/*K*/ } end_f_loop(f,t) } Thank you |
All times are GMT -4. The time now is 18:57. |