
[Sponsors] 
September 16, 2010, 15:40 
Including Two Reactions in single UDF..!!

#1 
New Member
paaresh
Join Date: Mar 2009
Posts: 18
Rep Power: 10 
I have two separate surface reactions. I have individual UDF's for each reaction. But we can hook only one UDF in fluent.
I have two square channels separated by a wall. In one channel one surface reaction and in another channel other surface reaction. How to include both reactions in single UDF. How can we assign the threads for each reaction independently. I was trying since 3 months but i could not solve this problem. Note: The surface reaction is only at the wall. I need to get thread only for a wall. Please suggests some macros/methods. Thanks in Advance 

September 17, 2010, 03:08 

#2 
Member
Byron Smith R J
Join Date: Mar 2009
Location: India
Posts: 46
Rep Power: 10 
write both the reaction udf in a single file one below the other with different names and compile it, hook into fluent and when you go to the boundary conditions on source terms you will find both the reaction names where you can select the corresponding reaction name.
hope this helps 

September 18, 2010, 02:05 

#3 
New Member
paaresh
Join Date: Mar 2009
Posts: 18
Rep Power: 10 
Hi
The problem is that I have two different reactions. I have to give the two reactions in two different places. Initially i tried your method but it produces two rates even in hook itself, but it allows only one rate to hook. Thanks for Reply....!! 

September 18, 2010, 03:39 

#4 
Member
Byron Smith R J
Join Date: Mar 2009
Location: India
Posts: 46
Rep Power: 10 
I am not getting why you have a problem. you need to create the fluid zone separately and apply the reactions individually or write the UDF in such a way that you call the cell domain for the corresponding reacion and include the reaction rates for th e domains


September 18, 2010, 06:46 

#5 
New Member
paaresh
Join Date: Mar 2009
Posts: 18
Rep Power: 10 
I have included both reactions in single UDF. One of the method i Tried is as follows......!! Here i got the id numbers from the fluent boundary conditions.
#include "udf.h" #define R 83140000 #define R1 8.314 #define p 1013250 #define pi 3.14159 DEFINE_SR_RATE(coupled,f,t,r,mw,yi,rr) { Domain *domain; int id; if(id == 4) { real c3h8 = yi[3]; real o2 = yi[4]; real co2 = yi[5]; real h2o = yi[6]; real n2 = yi[7]; real rho_w, sd = 2.49e8, T_w; real o_s,o_vac; real xc3h8=1, xo2=1; real tn,Ea3, Ea4, Ea5; real rA3, rA4, rA5,rk3, rk4, rk5; real ro,rate; Thread *t0=Lookup_Thread(domain, id)>t0; cell_t c0=F_C0(f,t0); T_w = F_T(f,t); rho_w = C_R(c0,t0)*C_T(c0,t0)/T_w; c3h8 *= rho_w/mw[3]; o2 *= rho_w/mw[4]; co2 *= rho_w/mw[5]; h2o *= rho_w/mw[6]; n2 *= rho_w/mw[7]; xc3h8 = c3h8/(c3h8+o2+co2 +h2o+n2); xo2 = o2/(c3h8+o2+co2 +h2o+n2); tn = T_w/300; Ea3 = 0.0; Ea4 = 0.126*tn*tn*tn*tn  1.849*tn*tn*tn + 9.124*tn*tn  13.253*tn + 23.903; Ea5 = 4.0; Ea3 *= 4184e7; Ea4 *= 4184e7; Ea5 *= 4184e7; rA3 = (0.0542)*pow(tn,0.766); rA4 = (8.41e12)*pow(tn,0.796); rA5 = (0.06)*pow(tn,0.154); rk3 = (rA3/(sd*sd))*sqrt(R*T_w/(2*pi*mw[1]))*(p/(R*T_w)); rk4 = (rA4/sd)*exp(Ea4/(R*T_w)); rk5 = (rA5/(sd*sd))*sqrt(R*T_w/(2*pi*mw[0]))*(p/(R*T_w))*exp(Ea5/(R*T_w)); ro = sqrt(rk3*xo2/rk4); o_s = ro/(1+ro); o_vac = 1o_s; rate = rk5*xc3h8*(sd*sd)*pow(o_vac,2); if (STREQ(r>name, "reaction1")) { *rr = rate*pow(10,1)*1.7; } } if(id == 3) { Thread *t0=Lookup_Thread(domain, id)>t0; cell_t c1=F_C0(f,t0); real nh3= yi[0]; real n2r = yi[1]; real h2=yi[2]; real rho_w1, sd1 = 1.66e7, T_w1; /* sd1kmol/m2 */ real xnh3, xn2r, xh2; real Eh2, En2, Enh3, Er, En2d; real ah,an,anh,ar,and; real Kha,Kna,Knh3,Kr,knd; real omega,rate1,denom; T_w1 = F_T(f,t); rho_w1 = C_R(c1,t0)*C_T(c1,t0)/T_w1; nh3 *= rho_w1/mw[0]; h2 *= rho_w1/mw[1]; n2r *= rho_w1/mw[2]; xnh3 = nh3/(nh3+n2r+h2); xn2r = n2r/(nh3+n2r+h2); xh2 = h2/(nh3+n2r+h2); Eh2 = 21.8*4187; /* kcal/mol > e7*ergs/mol (or jol/mole) */ En2 = 23.1*4187; Enh3 = 18.2*4187; Er=13.8*4187; En2d=37.2*4187; ah=5.44e3/(sqrt(R1*T_w1)); an=1.45e3/(sqrt(R1*T_w1)); anh=1.87e3/(sqrt(R1*T_w1)); ar=5e3; and=1e13; Kha=ah*exp(Eh2/(R1*T_w1)); Kna=an*exp(En2/(R1*T_w1)); Knh3=anh*exp(Enh3/(R1*T_w1)); Kr=ar*exp(Er/(R1*T_w1)); knd=and*exp(En2d/(R1*T_w1)); omega=sqrt(Kna*xn2r+Kr*Knh3*xnh3/(sqrt(Kha*xh2))); denom=(1+Knh3*xnh3+sqrt(Kha*xh2)+omega); rate1=sd1*knd*(pow(omega,2)Kna*xn2r)/(pow(denom,2)); if (STREQ(r>name, "reaction2")) *rr = rate1; } } 

September 18, 2010, 07:11 

#6 
Member
Byron Smith R J
Join Date: Mar 2009
Location: India
Posts: 46
Rep Power: 10 
Dear Paaresh
I could not sit down and decipher your UDF but by going through a glance i suggest you to use get domain () to identify the domain you want to use and the if loop may not be necesary. could you compile the udf u have written and what problems are you encountering 

September 18, 2010, 15:16 

#7 
New Member
paaresh
Join Date: Mar 2009
Posts: 18
Rep Power: 10 
The UDF is running without errors but reaction is not happening. I checked individual UDF's they worked well.
some problem assigning thread i guess...! because of that I could not able to solve..! 

September 19, 2010, 15:58 

#8 
New Member
Steven Qhin
Join Date: Jul 2010
Posts: 15
Rep Power: 8 
The wall should have a shadow wall.
The key is to discriminate the two threads. maybe: int zone_id; zone_id == THREAD_ID(t); if ( zone_id == wall index ) ....... if (zone_id == shadow wall index) ....... Hope it is useful to you. 

September 20, 2010, 02:05 

#9 
New Member
paaresh
Join Date: Mar 2009
Posts: 18
Rep Power: 10 
I have used exact wall ID from the Boundary conditions panel. So it should assign the proper thread. But still I tried your method but the problem continues again.....!!


September 24, 2010, 06:23 

#10 
Member
Byron Smith R J
Join Date: Mar 2009
Location: India
Posts: 46
Rep Power: 10 
I think you can also use the lookup_Thread(d,ZoneID) to identify the thread. see if that could work


June 14, 2013, 21:42 

#11 
New Member
Mahboobe Mahdavi
Join Date: Mar 2013
Posts: 22
Rep Power: 6 
Hi, I have the similar problem. can you help me??


Tags 
hook, two reactions, udf 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
UDF parallel error: chipexec: function not found?????  shankara.2  Fluent UDF and Scheme Programming  1  January 16, 2012 23:14 
10 reactions udf hooking  m&s  FLUENT  0  July 6, 2010 00:36 
convergency of reactions with udf  m&s  FLUENT  0  May 22, 2010 02:02 
single Variable storage UDF  bohis  FLUENT  2  November 17, 2008 10:34 
UDF problem on single computer with two procesor  Dmitry  FLUENT  3  May 18, 2005 12:44 