CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   UDF combining (http://www.cfd-online.com/Forums/fluent/89252-udf-combining.html)

michalku June 8, 2011 07:02

UDF combining
 
I try to resolve a problem with UDFs.
Want to combine to reaction in one DEFINE_VR_RATE UDF. See below. However, I have a problem to compile it in Fluent.
Can anybody check the UDF and say me where the problem could be?
Thanks!

Michal

#include "udf.h"
static const real Arrhenius = 1.e15;
static const real E_Activation = 1.e6;

DEFINE_VR_RATE(myrate,c,t,r,mw,yi,rr,rr_t)
{
/*If more than one reaction is defined, it is necessary to distinguish
between these using the names of the reactions. */
if (!strcmp(r->name, "reaction-1"))


{
real ci, prod;
int i;
/* Calculate Arrhenius reaction rate */
prod = 1.;
for(i = 0; i < r->n_reactants; i++)
{
ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
prod *= pow(ci, r->exp_reactant[i]);
}
*rate = r->A * exp( - r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) *
pow(C_T(c,t), r->b) * prod;
*rr_t = *rate;
/* No "return..;" value. */
}
}
else if (!strcmp(r->name, "reaction-2"))
static const real Arrhenius = 1.e15;
static const real E_Activation = 1.e6;

{
DEFINE_VR_RATE(myrate,c,t,r,mw,yi,rr,rr_t)
{
/*If more than one reaction is defined, it is necessary to distinguish
between these using the names of the reactions. */
if (!strcmp(r->name, "reaction-1"))
{



real ci, prod;
int i;
/* Calculate Arrhenius reaction rate */
prod = 1.;
for(i = 0; i < r->n_reactants; i++)
{
ci = C_R(c,t) * yk[r->reactant[i]] / wk[r->reactant[i]];
prod *= pow(ci, r->exp_reactant[i]);
}
*rate = r->A * exp( - r->E / (UNIVERSAL_GAS_CONSTANT * C_T(c,t))) *
pow(C_T(c,t), r->b) * prod;
*rr_t = *rate;
/* No "return..;" value. */
}
else
{
/* Message("Unknown Reaction\n"); */
}
/* Message("Actual Reaction: %s\n",r->name); */
}


All times are GMT -4. The time now is 17:42.