CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Fluent UDF and Scheme Programming (
-   -   UDF carbon conversion (

papteo August 15, 2011 08:36

UDF carbon conversion
Hi, I wrote a UDF to calculate more accurately the carbon conversion. When I apply the UDF for each reaction separately it works perfect, but when I enable all the 4 simultaneously then it works wrong. Can someone explain me why this happen?
Thank you very much in advance for your help

#include "udf.h"

#define A1 113.12 /*pre-exponential factor for reaction-1*/
#define A2 1.92e5 /*pre-exponential factor for reaction-2*/
#define A3 4.18e4 /*pre-exponential factor for reaction-3*/
#define A4 0.004 /*pre-exponential factor for reaction-4*/
#define E1 1.3e8 /*activation energy for reaction-1*/
#define E2 2.71e8 /*activation energy for reaction-2*/
#define E3 2.52e8 /*activation energy for reaction-3*/
#define E4 1.69e9 /*activation energy for reaction-4*/
#define n1 0.68 /*reaction order for reaction-1*/
#define n2 0.54 /*reaction order for reaction-2*/
#define n3 0.64 /*reaction order for reaction-3*/
#define n4 1 /*reaction order for reaction-4*/
#define D1 9.69e-10 /*bulk diffusion coefficient for reaction-1*/
#define D2 7.67e-10 /*bulk diffusion coefficient for reaction-2*/
#define D3 1.23e-09 /*bulk diffusion coefficient for reaction-3*/
#define D4 3.56e-09 /*bulk diffusion coefficient for reaction-4*/
#define Mc 12 /*Molecular weight of carbon, kg/kmol*/
#define M1 32 /*Molecular weight of o2, kg/kmol*/
#define M2 44 /*Molecular weight of co2, kg/kmol*/
#define M3 18 /*Molecular weight of h2o, kg/kmol*/
#define M4 2 /*Molecular weight of h2, kg/kmol*/
#define v1 0.5 /*stoichiometric coefficient for reaction-1*/
#define v2 1 /*stoichiometric coefficient for reaction-2*/
#define v3 1 /*stoichiometric coefficient for reaction-3*/
#define v4 2 /*stoichiometric coefficient for reaction-4*/
#define At0 2.5e5 /*initial specific surface area of char particle, m^2/kg*/
#define strucpara 0.12 /*particle structure parameter*/
#define density 1100 /*particle true density, kg/m^3*/
#define f 0.7 /*surface roughness factor*/
#define tolerance 1e-4

real r1_pressure(real r1_psi, real r1_ruser[], int r1_iuser[], cxboolean r1_buser[], char *r1_cuser)
return (r1_psi-r1_ruser[0]+3/(r1_ruser[19]*pow(r1_psi,(n1-1)/2))*(1/(tanh(r1_ruser[19]*pow(r1_psi,(n1-1)/2)))-1/(r1_ruser[19]*pow(r1_psi,(n1-1)/2)))*r1_ruser[1]*pow(r1_psi,n1)*r1_ruser[2]/r1_ruser[8]/r1_ruser[20]);

real r2_pressure(real r2_psi, real r2_ruser[], int r2_iuser[], cxboolean r2_buser[], char *r2_cuser)
return (r2_psi-r2_ruser[0]+3/(r2_ruser[19]*pow(r2_psi,(n2-1)/2))*(1/(tanh(r2_ruser[19]*pow(r2_psi,(n2-1)/2)))-1/(r2_ruser[19]*pow(r2_psi,(n2-1)/2)))*r2_ruser[1]*pow(r2_psi,n2)*r2_ruser[2]/r2_ruser[8]/r2_ruser[20]);

real r3_pressure(real r3_psi, real r3_ruser[], int r3_iuser[], cxboolean r3_buser[], char *r3_cuser)
return (r3_psi-r3_ruser[0]+3/(r3_ruser[19]*pow(r3_psi,(n3-1)/2))*(1/(tanh(r3_ruser[19]*pow(r3_psi,(n3-1)/2)))-1/(r3_ruser[19]*pow(r3_psi,(n3-1)/2)))*r3_ruser[1]*pow(r3_psi,n3)*r3_ruser[2]/r3_ruser[8]/r3_ruser[20]);

real r4_pressure(real r4_psi, real r4_ruser[], int r4_iuser[], cxboolean r4_buser[], char *r4_cuser)
return (r4_psi-r4_ruser[0]+3/(r4_ruser[19]*pow(r4_psi,(n4-1)/2))*(1/(tanh(r4_ruser[19]*pow(r4_psi,(n4-1)/2)))-1/(r4_ruser[19]*pow(r4_psi,(n4-1)/2)))*r4_ruser[1]*pow(r4_psi,n4)*r4_ruser[2]/r4_ruser[8]/r4_ruser[20]);

and then using the define_pr_rate 4 times for the 4 reactions

papteo August 18, 2011 07:32

can someone help me pls

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