CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   UDFs error (https://www.cfd-online.com/Forums/fluent/38525-udfs-error.html)

Shuailin November 7, 2005 22:09

UDFs error
 
Hello. I'am studying UDFs. And now I need to set a surface reaction. The reactants flow through a hollow pipe with diameter of 1mm, and the reaction takes place on the wall. First I'd like to understand the program about surface reaction(SR)in the fluent UDFs help document. I copied the program code into the VC++, and saved it as exampleSR.cpp file. When I compiled in the fluent, an error appeared: "line 9: function returning float returns double" The code is "real arrhenius_rate(real temp) { return PRE_EXP*pow(temp,BETA)*exp(-ACTIVE/(UNIVERSAL_GAS_CONSTANT*temp)); }" I tried to change "real" into double, then another error "THREAD_STORE: undeclared variable" appeared. The corresponding code is "DEFINE_SR_RATE(arrhenius,f,fthread,r,mw,yi,rr ) { *rr = reaction_rate(F_C0(f,fthread),F_C0_THREAD(f,fthrea d),mw,yi); }" There is not the variable of THREAD_STORE. How to solve the problem?

The whole program code is the follow: /************************************************** *****************/ /* UDF for specifying a custom surface reaction rate * /************************************************** *****************/ #include "udf.h" /* ARRHENIUS CONSTANTS */ #define PRE_EXP 1e+15 #define ACTIVE 1e+08 #define BETA 0.0 real arrhenius_rate(real temp) { return PRE_EXP*pow(temp,BETA)*exp(-ACTIVE/(UNIVERSAL_GAS_CONSTANT*temp)); } /* Species numbers. Must match order in Fluent panel */ #define HF 0 #define WF6 1 #define H2O 2 #define NUM_SPECS 3 /* Reaction Exponents */ #define HF_EXP 2.0 #define WF6_EXP 0.0 #define H2O_EXP 0.0 #define MW_H2 2.0 #define STOIC_H2 3.0 /* Reaction Rate Routine that is used in both UDFs */ real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[]) { real concenHF = C_R(c, cthread)*yi[HF]/mw[HF]; return arrhenius_rate(C_T(c, cthread))*pow(concenHF,HF_EXP); }

DEFINE_SR_RATE(arrhenius,f,fthread,r,mw,yi,rr) { *rr = reaction_rate(F_C0(f,fthread),F_C0_THREAD(f,fthrea d),mw,yi); } real contact_area(cell_t c, Thread *t, int s_id, int *n) { int i = 0; real area = 0.0, A[ND_ND]; *n = 0; c_face_loop(c,t,i) { if(THREAD_ID(C_FACE_THREAD(c,t,i)) == s_id) { (*n)++; F_AREA(A, C_FACE(c,t,i), C_FACE_THREAD(c,t,i)); area += NV_MAG(A); } } return area; }



All times are GMT -4. The time now is 15:33.