CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT

Looping in UDF!!!

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 11, 2007, 09:07
Default Looping in UDF!!!
  #1
safa
Guest
 
Posts: n/a
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
  Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping inside UDF and use of C_UDMs in DEFINE_DPM_BC shankara.2 Fluent UDF and Scheme Programming 0 November 10, 2009 18:11
looping UDF in given direction ak6g08 Fluent UDF and Scheme Programming 0 September 10, 2009 11:13
Looping over nodes of a cell (UDF) error Manoj FLUENT 2 December 1, 2005 01:30
UDF, Looping through threads or faces Zhang FLUENT 1 June 21, 2005 02:24
UDF for looping over nodes in cells. Malcolm Wallace FLUENT 3 July 3, 2000 10:22


All times are GMT -4. The time now is 20:21.