 ## Fluids

• atul.srivastava216
Subscriber

Hello,

I am currently trying to write UDF for a surface reaction rate. The equation is like this: R=Aa*exp(-Ea/RT)*[GAF3]*[NH3]-Ab*exp(-Eb/RT)*[HF]^3.The reaction parameters Aa,Ea,Ab,Eb are my input parameters. I wrote the code as below, but when I try to interpret it, it gives an error for line 12 as 'no function prototype'. More specifically,

line 12: mphost_to_node_double_2: no function prototype

Can anyone point out what am I missing ? Is the code alright for my purpose? Also, can this be used with stiff chemistry solver?

#include "udf.h"
#include "mem.h"
#include "sg.h"
#include "prop.h"
#define BETA 0.0

/*routine for forward reaction rate*/
real arrhenius_ratef(real temp)
{
real A_a;
real E_a;
host_to_node_real_2(A_a,E_a);
A_a = RP_Get_Input_Parameter("real-8") ;
E_a = RP_Get_Input_Parameter("real-9") ;
return
(100000)*A_a*pow(temp,BETA)*exp(-E_a/(UNIVERSAL_GAS_CONSTANT*temp));
}

/*routine for backward reaction rate*/
real arrhenius_rateb(real temp)
{
real A_b;
real E_b;
host_to_node_real_2(A_b,E_b);
A_b = RP_Get_Input_Parameter("real-10") ;
E_b = RP_Get_Input_Parameter("real-11") ;
return
A_b*pow(temp,BETA)*exp(-E_b/(UNIVERSAL_GAS_CONSTANT*temp));
}

/*deining reaction exponents*/

#define GAF3 0
#define HF 1
#define NH3 2
#define GAN 3

#define GAF3_EXP_F 1.0
#define HF_EXP_F 0.0
#define NH3_EXP_F 1.0
#define GAN_EXP_F 0.0

#define GAF3_EXP_B 0.0
#define HF_EXP_B 3.0
#define NH3_EXP_B 0.0
#define GAN_EXP_B 0.0

real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[])

{
real concenGAF3 = C_R(c,cthread)*yi[GAF3]/mw[GAF3];
real concenHF = C_R(c,cthread)*yi[HF]/mw[HF];
real concenNH3 = C_R(c,cthread)*yi[NH3]/mw[NH3];
real concenGAN = C_R(c,cthread)*yi[GAN]/mw[GAN];

return XF-XB;
}

{
*rr =
}
• Nikhil Narale
Ansys Employee

Can you try compiling your code instead of interpreting it?

Thanks,

Nikhil

• atul.srivastava216
Subscriber

Hi Nikhil, Thank you for your reply. Yes, I did try the built-in compiler. The code compiled without any problem. However, when I hook the UDF surface reaction rate, the solution is not being calculated. It gets stuck at first iteration forever (imagine, being stuck in an infinite loop or so it feels). Do you see any glaring mistakes in my code that might cause this problem ? 