set 限制解除
CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

define_het_rxn_rate

Welcome, bestucan.
You last visited: Yesterday at 19:19
Private Messages: Unread 0, Total 2.
User Panel Blogs FAQ Community New Posts Updated Threads Search Quick Links Log Out

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old   March 1, 2010, 11:02
Default define_het_rxn_rate
  #1
Member
 
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 15
coalgas is on a distinguished road
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
coalgas is offline Add to coalgas's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   March 2, 2010, 16:33
Default
  #2
Member
 
Michele Vascellari
Join Date: Mar 2009
Posts: 70
Rep Power: 15
mighelone is on a distinguished road
Quote:
Originally Posted by coalgas View Post
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
I have a little experience on writing multiphase udf, what kind of problem do you have?
mighelone is offline Add to mighelone's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   March 2, 2010, 20:59
Default
  #3
Member
 
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 15
coalgas is on a distinguished road
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?
coalgas is offline Add to coalgas's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   March 2, 2010, 21:22
Default
  #4
Member
 
Michele Vascellari
Join Date: Mar 2009
Posts: 70
Rep Power: 15
mighelone is on a distinguished road
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.
mighelone is offline Add to mighelone's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   March 2, 2010, 21:38
Default
  #5
Member
 
chétan
Join Date: May 2009
Location: Australia
Posts: 55
Rep Power: 15
coalgas is on a distinguished road
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
coalgas is offline Add to coalgas's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   March 2, 2010, 21:59
Default
  #6
Member
 
Michele Vascellari
Join Date: Mar 2009
Posts: 70
Rep Power: 15
mighelone is on a distinguished road
You can define at the beginning of tour udf file the following pre-processor command:

Code:
#define DEBUG TRUE
and inside the DEFINE_HET_RATE macro:

Code:
#if DEBUG
Message("x=%f\n",x);
#endif
in this way, when you enable the DEBUG with the key TRUE, every time the value of the varibale x is printed in fluent and you can verify if everything is ok.
mighelone is offline Add to mighelone's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   March 5, 2013, 00:08
Default access violation
  #7
New Member
 
prishor p k
Join Date: Jul 2012
Posts: 29
Rep Power: 12
prishor is on a distinguished road
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
prishor is offline Add to prishor's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   September 13, 2013, 13:26
Default
  #8
New Member
 
Thanh
Join Date: Feb 2010
Posts: 11
Rep Power: 14
thanhndb is on a distinguished road
Quote:
Originally Posted by mighelone View Post
I have a little experience on writing multiphase udf, what kind of problem do you have?
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
thanhndb is offline Add to thanhndb's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   September 13, 2013, 13:30
Default
  #9
New Member
 
Thanh
Join Date: Feb 2010
Posts: 11
Rep Power: 14
thanhndb is on a distinguished road
Quote:
Originally Posted by coalgas View Post
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?

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
thanhndb is offline Add to thanhndb's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Old   July 15, 2014, 16:31
Default
  #10
New Member
 
Joen.Combos
Join Date: Jul 2014
Posts: 1
Rep Power: 0
mrfive90 is on a distinguished road
Quote:
Originally Posted by thanhndb View Post
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
Your unit of "rr" is not consistent with kmol/(m3s),and i wonder about the molar concentration should replace ur mole fraction!gud9t!!!
mrfive90 is offline Add to mrfive90's Reputation Report Post   Reply With Quote Multi-Quote This Message Quick reply to this message

Reply

Tags
None

Quick Reply
Message:
Remove Text Formatting
Bold
Italic
Underline

Insert Image
Wrap [QUOTE] tags around selected text
 
Decrease Size
Increase Size
Switch Editor Mode
Please click one of the Quick Reply icons in the posts above to activate Quick Reply.
Options


Posting Rules
You may post new threads
You may post replies
You may post attachments
You may 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

Forum Jump


All times are GMT +8. The time now is 12:57.