CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > FLUENT > Fluent UDF and Scheme Programming

UDF carbon conversion

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2011, 08:36
Exclamation UDF carbon conversion
  #1
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 15
papteo is on a distinguished road
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

Last edited by papteo; August 15, 2011 at 08:56. Reason: more details now
papteo is offline   Reply With Quote

Old   August 18, 2011, 07:32
Default
  #2
Member
 
Theodoros Papadopoulos
Join Date: Mar 2011
Posts: 36
Rep Power: 15
papteo is on a distinguished road
can someone help me pls
papteo is offline   Reply With Quote

Reply

Tags
carbon conversion problem


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF parallel error: chip-exec: function not found????? shankara.2 Fluent UDF and Scheme Programming 1 January 16, 2012 22:14
How to add a UDF to a compiled UDF library kim FLUENT 3 October 26, 2011 21:38
plotting carbon conversion Ekiguy FLUENT 0 May 28, 2011 00:57
UDF...UDF...UDF...UDF Luc SEMINEL FLUENT 0 November 25, 2002 04:03
UDF, UDF, UDF, UDF Luc SEMINEL Main CFD Forum 0 November 25, 2002 04:01


All times are GMT -4. The time now is 05:47.