# Fluent UDF urgent! Variable reaction rate

 Register Blogs Members List Search Today's Posts Mark Forums Read

 July 4, 2011, 16:48 Fluent UDF urgent! Variable reaction rate #1 Member   Nathan Join Date: Aug 2010 Posts: 62 Rep Power: 15 Hi I've written a UDF in Fluent for a volumetric reaction rate. I want to know how I can make the reaction rate variable along my reactor due to variation in catalyst activity. Any idea? Example: r= p* k C^2 ( p is a function of distance into the reactor) How do you implement this, I'm new to UDf Thanks

 July 6, 2011, 16:36 #3 Member   Nathan Join Date: Aug 2010 Posts: 62 Rep Power: 15 Thanks A lot for the comment The problem is my reaction is defined through a volumetric reaction rate DEFINE_VR_RATE , the reaction needs the temperature and mass fraction of each node (300000 nodes) at each iteration. Apparently inside the ADJUST udf we don't ahve access to node values. I get error. Below is my original UDf for VR_Rate, if you like take a look at it. #include"udf.h" DEFINE_VR_RATE(proprate,c,t,r,mw,yi,rr,rr_t) { /*mass fraction of species i */ real y_c3h8=yi[3]; real y_h2o=yi[4]; real y_h2=yi[0]; real y_co=yi[1]; real y_co2=yi[2]; real y_n2=yi[5]; real Nsum, R, Keq1, T_w, r1,r2; /*calculate species i in the unit of kgmol i/kg mix*/ y_c3h8 *= 1/mw[3]; y_h2o *= 1/mw[4]; y_h2 *= 1/mw[0]; y_co *= 1/mw[1]; y_co2 *= 1/mw[2]; y_n2 *= 1/mw[5]; Nsum = y_c3h8+ y_h2o + y_h2 + y_co + y_co2 + y_n2; y_c3h8 *= 1/Nsum; y_h2o *= 1/Nsum; y_h2 *= 1/Nsum; y_co *= 1/Nsum; y_co2 *= 1/Nsum; y_n2 *= 1/Nsum; R=8.314; T_w=C_T(c,t); Keq1=pow(10,(2073/T_w)-2.029); if(STREQ(r->name, "reaction-1")){ /*unit for rr, kg/m3s*/ r1= 44*3e8*exp(-105000/(R*T_w))*(y_c3h8*y_h2o)/(1+105*exp(3000/(R*T_w))*pow(y_c3h8,2)); *rr = r1; } elseif (STREQ(r->name, "reaction-2")){ r2= 28*3.4e9*exp(-130000/(R*T_w))*(y_co*y_h2o-(y_h2*y_co2)/Keq1) ; *rr = r2; } }

 July 7, 2011, 03:59 #4 New Member   Kristian Etienne Einarsrud Join Date: Oct 2010 Location: Trondheim Posts: 29 Rep Power: 15 Hello again, If I understand your original post correctly, your problem is that you want to include a position dependency in your DEFINE_VR_RATE? This can be done by the following modification (I have made my changes in bold text for clarity): #include"udf.h" DEFINE_VR_RATE(proprate,c,t,r,mw,yi,rr,rr_t) { /*mass fraction of species i */ real Nsum, R, Keq1, T_w, r1,r2,x[ND_ND],xpos,ypos,zpos; real y_c3h8=yi[3]; real y_h2o=yi[4]; real y_h2=yi[0]; real y_co=yi[1]; real y_co2=yi[2]; real y_n2=yi[5]; /* Find and store coordinates for each cell*/ C_CENTROID(x,c,t); /* store position in array x*/ xpos = x[0]; ypos = x[1]; zpos = 0.0; #if RP_3D zpos = x[2]; #endif /* The above #if statement ensures that you only can access the z-position (x[2]) if you are doing a 3D-simulation */ /* The coordinates of each cell are now stored in xpos,ypos and zpos (if 3D) for future use*/ /*calculate species i in the unit of kgmol i/kg mix*/ y_c3h8 *= 1/mw[3]; y_h2o *= 1/mw[4]; y_h2 *= 1/mw[0]; y_co *= 1/mw[1]; y_co2 *= 1/mw[2]; y_n2 *= 1/mw[5]; Nsum = y_c3h8+ y_h2o + y_h2 + y_co + y_co2 + y_n2; y_c3h8 *= 1/Nsum; y_h2o *= 1/Nsum; y_h2 *= 1/Nsum; y_co *= 1/Nsum; y_co2 *= 1/Nsum; y_n2 *= 1/Nsum; R=8.314; T_w=C_T(c,t); Keq1=pow(10,(2073/T_w)-2.029); if(STREQ(r->name, "reaction-1")){ /*unit for rr, kg/m3s*/ r1= 44*3e8*exp(-105000/(R*T_w))*(y_c3h8*y_h2o)/(1+105*exp(3000/(R*T_w))*pow(y_c3h8,2)); *rr = r1; } elseif (STREQ(r->name, "reaction-2")){ r2= 28*3.4e9*exp(-130000/(R*T_w))*(y_co*y_h2o-(y_h2*y_co2)/Keq1) ; *rr = r2; } } Another point; note that the values you are using are *not* node values but *cell* values, as it is the cell pointer "c" which is passed from the macro DEFINE_VR_RATE. Happy simulating! -KE soheil_r7 likes this.

 March 14, 2016, 15:53 Calcination Reaction #5 New Member   Diogo Join Date: Mar 2016 Posts: 1 Rep Power: 0 Hello all, first of all i would like to introduce myself as new on this field... I've read your posts and i have some doubts... How do you access the molecular weight of each component?? Have you defined it previously?? Because i coudn't realise where are these values on your program line... Another doubt is about making an User Defined Function for this reaction: caco3=cao+co2 I'm simulating a rotary kiln used for calcination... I need to compilate this reactions in the Fluent but i have no idea about how to do this... Can anyone help me?? Thank you in advance

 July 25, 2016, 08:17 #6 New Member   Omar Join Date: Jul 2016 Posts: 2 Rep Power: 0 Hello Can someone please help me write a FLUENT UDF the reaction below which is defined by reaction rate equation of (R) below CO+3H2=>CH4+H2O R=k exp (E/RT)*(Pco^m*Ph2^n) Where: R is the volumetric reaction rate k is Rate constant E is Activation energy for reaction R is Universal gas constant T is Temperature Pco is Partial pressure of carbon monoxide Ph2 is Partial pressure of hydrogen m is Power for CO partial pressure n is Power for H2 partial pressure UDF for volumetric reaction rate-unnamed.png Thank you. hesamna likes this.

 June 4, 2018, 01:26 Reactions between gas and liquid phase in porous media #7 New Member   Join Date: Feb 2015 Posts: 9 Rep Power: 11 Hello all, I am modeling a gas liquid reaction in a porous media: ArS+H2=Ar+H2S I have written the udf for porous media. It is working fine. Then I wrote the following VR-rate udf for reaction and loaded in the function hooks. I have defined the stoichiometric coefficients of all species in the phase interaction panel and disabled heterogeneous stiff chemistry and set the reaction rate to none (since I am defining it in the function hooks). However, there is no change in reactant or species concentration and the entire flow proceeds without any species transport. The udf is compiled and loaded witthout any error. This is the udf: #include "udf.h" #include "mem.h" #define KHDS 0.005083992078 DEFINE_VR_RATE(vol_reac_rate,c,t,r,mole_weight,spe cies_mf,rate,rr_t) { real kad=50000; begin_c_loop(c,t) { real X_ars=C_YI(c,t,3)*C_R(c,t); real X_h2=C_YI(c,t,1)*C_R(c,t); real X_h2s=C_YI(c,t,0)*C_R(c,t); if (FLUID_THREAD_P(t) && THREAD_VAR(t).fluid.porous) *rate = ((-KHDS)*(pow(X_ars,1.6))*(pow(X_h2,0.56)))/(1+(kad*X_h2s)); else *rate = 0; *rr_t = *rate; } end_c_loop(c,t) } I will be extremely grateful if someone could kindly help me with this. Thanks.

November 18, 2020, 23:43
#8
New Member

hesam
Join Date: Jul 2020
Posts: 6
Rep Power: 5
Quote:
 Originally Posted by Boniface Omar Hello Can someone please help me write a FLUENT UDF the reaction below which is defined by reaction rate equation of (R) below CO+3H2=>CH4+H2O R=k exp (E/RT)*(Pco^m*Ph2^n) Where: R is the volumetric reaction rate k is Rate constant E is Activation energy for reaction R is Universal gas constant T is Temperature Pco is Partial pressure of carbon monoxide Ph2 is Partial pressure of hydrogen m is Power for CO partial pressure n is Power for H2 partial pressure UDF for volumetric reaction rate-unnamed.png Thank you.
Hello dear
Did you find how we can write UDF for reactions like what you mentioned?

October 17, 2021, 03:35
#9
New Member

Join Date: Jul 2012
Posts: 10
Rep Power: 13
Quote:
 Originally Posted by tabirense Hello all, first of all i would like to introduce myself as new on this field... I've read your posts and i have some doubts... How do you access the molecular weight of each component?? Have you defined it previously?? Because i coudn't realise where are these values on your program line... Another doubt is about making an User Defined Function for this reaction: caco3=cao+co2 I'm simulating a rotary kiln used for calcination... I need to compilate this reactions in the Fluent but i have no idea about how to do this... Can anyone help me?? Thank you in advance
Hi tabirense,

I came across the same problem, wrote a udf for the heteregeneous reaction rate, but the code diverges quite soon, in any test I made.
I tested also the stiff chemistry solver to aid convergence and stability.
But with no success so far.

Have you figured out how to approach this?

Thanks