CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (https://www.cfd-online.com/Forums/fluent-udf/)
-   -   DEFINE_SOURCE and DEFINE_VR_RATE (https://www.cfd-online.com/Forums/fluent-udf/149018-define_source-define_vr_rate.html)

Tleja February 24, 2015 04:04

DEFINE_SOURCE and DEFINE_VR_RATE
 
Hi everyone!

I'm studying in reaction field.

In my reaction,

A(s)+B(g) ---kp---> C(s) ;;SourceA= -Kp[A][B] ,SourceB= -Kp[A][B], SourceC= +Kp[A][B]

According to my reaction,I think UDF can solve my problem,I read fluent UDF tutorial many time and I still confused about what different between using DEFINE_SOURCE and DEFINE_VR_RATE.

I need someone help me which method i should go with.

At the moment, i try to write UDF source term code and hook to mass source in fluent. I could interpret my UDF to fluent and calculate but i have problem that product C didn't generate. I don't know how to solve my problem.
Should i use DEFINE_VR_RATE?

My UDF code is shown as below:

DEFINE_SOURCE(source_A,c,t,dS,eqn)
{
Thread *mt=THREAD_SUPER_THREAD(t);
Thread **pt = THREAD_SUB_THREADS(mt);
Thread *tp = pt[0]; /* Thread for gas phase */
Thread *ts = pt[1]; /* Thread for solid phase*/
real source,rho_B,mw_B;
real Kp,PreKp;
mw_B=104;
rho_B=850;
PreKp = 4.4e8; /*Pre-exponential m^3/kmols*/
real T_prim = C_T(c,tp); /* gas phase Temperature*/
real T_sec = C_T(c,ts); /* solid phase Tenperature*/
Kp=PreKp*exp(-Ea/(R*C_T(c,ts)));
source=-Kp*C_YI(c,tp,0)*rho_B/mw_B*C_YI(c,ts,0)*C_R(c,ts,0);
dS[eqn]=-Kp*C_YI(c,tp,0)*rho_B/mw_B;

return source;
}

If someone have any idea, Please let me know
I really need your help. I have solved this problem for many week.

Thank you
Tleja


All times are GMT -4. The time now is 18:34.