|
[Sponsors] |
February 28, 2010, 23:02 |
define_het_rxn_rate
|
#1 |
Member
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 17 |
Hello Everyone,
Anybody has any experience with macro "define_het_rxn_rate"? for writing heterogeneous reaction rate for multiphase model. I have some problems to understand few things. any help will be appreciated . Thanks chetan |
|
March 2, 2010, 04:33 |
|
#2 |
Member
Michele Vascellari
Join Date: Mar 2009
Posts: 70
Rep Power: 17 |
I have a little experience on writing multiphase udf, what kind of problem do you have?
|
|
March 2, 2010, 08:59 |
|
#3 |
Member
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 17 |
Thanks Michele,
I am trying to model, char gasification in 'packed bed' with Eulerian Granular model. While defining phase interaction reaction between phases, i need to write a UDF with macro "DEFINE_HET_RXN_RATE" to return heterogeneous reaction rate. I have a simple reaction with C+0.5O2->CO. And i wish to use random pore model which is rr=kp*(1-x)*sqrt[(1-x)*const] where x is carbon conversion. And Kp is reaction rate constant which is given as kp= A*exp(-E/RT)*Po2^n where is reaction order Po2 is partial pressure of Oxygen. If we know A, E, T, Po2, n and const we can calculate kp. Now only problem is about x. To calculate x, rr UDF is required, i did that but whenever i run my model, solver diverges. I want to confirm whether my UDF has problem or i need to refine my model by changing boundary conditions and parameters? |
|
March 2, 2010, 09:22 |
|
#4 |
Member
Michele Vascellari
Join Date: Mar 2009
Posts: 70
Rep Power: 17 |
coalgas,
I have the same problem of divergence, using eulerian-eulerian multiphase model with reaction defined by udf. Have you tried to debug your udf printing the value of the variables inside the fuction, using the command Message. However, multiphase problems give a lot of convergence problem. Are you considering time-dependant simulations? It could help your convergence. At the moment I leave Fluent and I'm using another CFD code to perform coal gasification fixed bed simulation, MFIX. |
|
March 2, 2010, 09:38 |
|
#5 |
Member
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 17 |
Thanks Michele,
Yes, its time dependent flow simulation. well, can you please elaborate on debugging udf by printing the value of the variables inside the fuction, using the command Message. How can i perform debugging? Thanks again and regards Chetan |
|
March 2, 2010, 09:59 |
|
#6 |
Member
Michele Vascellari
Join Date: Mar 2009
Posts: 70
Rep Power: 17 |
You can define at the beginning of tour udf file the following pre-processor command:
Code:
#define DEBUG TRUE Code:
#if DEBUG Message("x=%f\n",x); #endif |
|
March 4, 2013, 12:08 |
access violation
|
#7 |
New Member
prishor p k
Join Date: Jul 2012
Posts: 29
Rep Power: 14 |
hi everyone,
i am using a udf using macro define_het_rxn_rate for the phase interaction in heterogeneous reaction for multiphase grannular flow in fluidized bed gasifier. i have compiled and loaded udfs in fluent 12. but after initializing it shows some error given below Error: FLUENT received fatal signal (ACCESS_VIOLATION) 1. Note exact events leading to error. 2. Save case/data under new name. 3. Exit program and restart to continue. 4. Report error to your distributor. Error Object: #f can anyone tell me what is the problem one of my udf code is given below /*for the reaction C+H2O --> CO+H2*/ #include "udf.h" static const real Arrhenius = 200; static const real E_Activation = 6000; #define SMALL_S 1.e-29 DEFINE_HET_RXN_RATE(heterogeneous2,c,t,hr,mw,yi,rr ,rr_t) { Domain **domain_reactant = hr->domain_reactant; real *stoich_reactant = hr->stoich_reactant; int *reactant = hr->reactant; int i; int sp_id; int dindex; Thread *t_reactant; real ci; real T = C_T(c,t); /* should obtain from cell */ /* instead of compute rr directly, compute log(rr) and then take exp */ *rr = 0; for (i=0; i < hr->n_reactants; i++) { sp_id = reactant[i]; /* species ID to access mw and yi */ if (sp_id == -1) sp_id = 0; /* if phase does not have species, mw, etc. will be stored at index 0 */ dindex = DOMAIN_INDEX(domain_reactant[i]); /* domain index to access mw & yi */ t_reactant = THREAD_SUB_THREAD(t,dindex); /* get conc. */ ci = yi[dindex][sp_id]*C_R(c,t_reactant)/mw[dindex][sp_id]; ci = MAX(ci,SMALL_S); *rr += stoich_reactant[i]*log(ci); } *rr += log(Arrhenius + SMALL_S) - (E_Activation/T); /* 1.e-40 < rr < 1.e40 */ *rr = MAX(*rr,-40); *rr = MIN(*rr,40); *rr = exp(*rr); } please help me in this regards, eagerly waiting for your valuable reply. thanks and regards, prishor p k |
|
September 13, 2013, 01:26 |
|
#8 | |
New Member
Thanh
Join Date: Feb 2010
Posts: 11
Rep Power: 16 |
Quote:
I am also trying a simulation with a heterogeneous reaction using Eulerian-granular model in Fluent. The reaction is CaSO4(s) + 4H2(g) -> CaS(s) + 4H2O(g). I used a shrinking-core mode where the reaction rate is rr=const*k*pH2 where k =A*exp(-E/RT) and pH2 is partial pressure of H2. To create the materials for the simulation for the gas phase I use species transport mode where this gas phase consists of H2, H2O and N2. The solid phase is only CaSO4 (of course it is defined from a fluid material). To account for the heterogeneous reaction between the two phase I used a UDF. I wrote a UDF for DEFINE_HET_RXN_RATE with the content: /*Heterogeneous net reaction*/ # include "udf.h" //# include "mem.h" //# include "sg_mphase.h" # define FLUID_ZONE_ID 2 /*Zone ID of Reaction*/ # define R 8.31434 /*Gas Constant J/mol-K*/ # define Pre 4.3e3 /*Pre-exponential factor, 1/s-kPa*/ # define E1 151e5 /*Activation Energy, J/mol*/ # define rho_caso4 21.74 /*Molar density of CaSO4, kgmol/m3*/ DEFINE_HET_RXN_RATE(het_rxn_rate,c,t,r,mw,yi,rr,rr _t) { //int zone_id; Thread **pt = THREAD_SUB_THREADS(t); Thread *prim_t = pt[0]; /*Thread for primary Phase*/ Thread *sec_t = pt[1]; /*Thread for secondary Phase*/ real T_SEC = C_T(c,sec_t); /*Phase secondary temperature, K*/ real P = C_P(c,prim_t)/1000; /*Static pressure of the primary phase, kPa*/ real y_h2 = C_YI(c,prim_t,0); /*Mass fraction of gas species in primary phase*/ real y_h2o = C_YI(c,prim_t,1); real y_n2 = C_YI(c,prim_t,2); real Nsum; y_h2 *= 1/mw[0][0]; y_h2o *= 1/mw[0][1]; y_n2 *= 1/mw[0][2]; Nsum = y_h2 + y_h2o + y_n2; y_h2 *= 1/Nsum; y_h2o *= 1/Nsum; y_n2 *= 1/Nsum; *rr = rho_caso4*P*y_h2*Pre*exp(-E1/(R*T_SEC)); } The UDF was compiled successfully however it seems not work even I did setup the reaction in Phases>Interactions...>Reaction tab. I know you have experience on CFD simulation of mutiphase reaction. Could you tell me what is wrong with my simulation and how can I solve it. Thank you very much in advance and I am looking forward to hearing from you. Thanh |
||
September 13, 2013, 01:30 |
|
#9 | |
New Member
Thanh
Join Date: Feb 2010
Posts: 11
Rep Power: 16 |
Quote:
Dear Chetan, I am also trying a simulation with a heterogeneous reaction using Eulerian-granular model in Fluent. The reaction is CaSO4(s) + 4H2(g) -> CaS(s) + 4H2O(g). I used a shrinking-core mode where the reaction rate is rr=const*k*pH2 where k =A*exp(-E/RT) and pH2 is partial pressure of H2. To create the materials for the simulation for the gas phase I use species transport mode where this gas phase consists of H2, H2O and N2. The solid phase is only CaSO4 (of course it is defined from a fluid material). To account for the heterogeneous reaction between the two phase I used a UDF. I wrote a UDF for DEFINE_HET_RXN_RATE with the content: /*Heterogeneous net reaction*/ # include "udf.h" //# include "mem.h" //# include "sg_mphase.h" # define FLUID_ZONE_ID 2 /*Zone ID of Reaction*/ # define R 8.31434 /*Gas Constant J/mol-K*/ # define Pre 4.3e3 /*Pre-exponential factor, 1/s-kPa*/ # define E1 151e5 /*Activation Energy, J/mol*/ # define rho_caso4 21.74 /*Molar density of CaSO4, kgmol/m3*/ DEFINE_HET_RXN_RATE(het_rxn_rate,c,t,r,mw,yi,rr,rr _t) { //int zone_id; Thread **pt = THREAD_SUB_THREADS(t); Thread *prim_t = pt[0]; /*Thread for primary Phase*/ Thread *sec_t = pt[1]; /*Thread for secondary Phase*/ real T_SEC = C_T(c,sec_t); /*Phase secondary temperature, K*/ real P = C_P(c,prim_t)/1000; /*Static pressure of the primary phase, kPa*/ real y_h2 = C_YI(c,prim_t,0); /*Mass fraction of gas species in primary phase*/ real y_h2o = C_YI(c,prim_t,1); real y_n2 = C_YI(c,prim_t,2); real Nsum; y_h2 *= 1/mw[0][0]; y_h2o *= 1/mw[0][1]; y_n2 *= 1/mw[0][2]; Nsum = y_h2 + y_h2o + y_n2; y_h2 *= 1/Nsum; y_h2o *= 1/Nsum; y_n2 *= 1/Nsum; *rr = rho_caso4*P*y_h2*Pre*exp(-E1/(R*T_SEC)); } The UDF was compiled successfully however it seems not work even I did setup the reaction in Phases>Interactions...>Reaction tab. I know you have experience on CFD simulation of mutiphase reaction. Could you tell me what is wrong with my simulation and how can I solve it. Thank you very much in advance and I am looking forward to hearing from you. Thanh |
||
July 15, 2014, 04:31 |
|
#10 | |
New Member
Joen.Combos
Join Date: Jul 2014
Posts: 1
Rep Power: 0 |
Quote:
|
||
|
|