CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   enum (http://www.cfd-online.com/Forums/fluent-udf/76808-enum.html)

MASOUD June 5, 2010 00:49

enum
 
Hi;
I need to define two scalars (UDS) and below you can find the UFDs for the aforementioned scalars.
I'm just wondering what does the "enum" do??? And shall I change anything?


********************
UDS-01
********************


#include "udf.h"
#include "sg.h"

/* Define which user-defined scalars to use. */
enum
{
E_CHARGE_UDS,
C_CHARGE_UDS,
N_REQUIRED_UDS
};
static real ACT_AREA_A=270000;
static real REF_EXCH_CURR_A=2.25;
static real MW_H2=0.002;
static real MW_CO2=0.044;
static real MW_H2O=0.018;
static real MW_MIX;
static real X_H2;
/*static real X_CO2;*/
/*static real X_H2O;*/
static real ALPHA_A=0.5;
static real ALPHA_C=1.5;
static real NO_ELEC=2;
static real FARADAY=96485;
static real UNI_GAS_CONS=8.314;
static real RXN_RATE_A;
static real Z;
static real ZZ;
static real ZZZ;
static real source;


DEFINE_SOURCE(ELECT_SOURCE_ANODE,c,t,dS,eqn)

{

MW_MIX=MW_H2*C_YI(c,t,0)+MW_CO2*C_YI(c,t,2)+MW_H2O *C_YI(c,t,3);
X_H2=C_YI(c,t,0)*MW_H2/MW_MIX;
/*X_CO2=C_YI(c,t,2)*MW_CO2/MW_MIX;*/
/*X_H2O=C_YI(c,t,3)*MW_H2O/MW_MIX;*/

Z=ACT_AREA_A*REF_EXCH_CURR_A*(pow((X_H2),0.25));

ZZ=exp((ALPHA_A*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

ZZZ=exp(-(ALPHA_C*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

RXN_RATE_A=Z*(ZZ-ZZZ);

source=-RXN_RATE_A;

dS[eqn]=0;

return source;
}



**************************
UDS-02
**************************


#include "udf.h"
#include "sg.h"

/* Define which user-defined scalars to use. */
enum
{
E_CHARGE_UDS,
C_CHARGE_UDS,
N_REQUIRED_UDS
};

static real ACT_AREA_C=300000;
static real REF_EXCH_CURR_C=0.4;
static real MW_O2=0.032;
static real MW_CO2=0.044;
static real MW_MIX;
static real X_O2;
static real X_CO2;
static real ALPHA_A=1.5;
static real ALPHA_C=0.5;
static real NO_ELEC=2;
static real FARADAY=96485;
static real UNI_GAS_CONS=8.314;
static real RXN_RATE_C;
static real Z;
static real ZZ;
static real ZZZ;
static real source;

DEFINE_SOURCE(ELECT_SOURCE_CATHODE,c,t,dS,eqn)

{

MW_MIX=MW_O2*C_YI(c,t,1)+MW_CO2*C_YI(c,t,2);
X_O2=C_YI(c,t,1)*MW_O2/MW_MIX;
X_CO2=C_YI(c,t,2)*MW_CO2/MW_MIX;

Z=ACT_AREA_C*REF_EXCH_CURR_C*pow(X_O2,0.375)*pow(X _CO2,(-1.25));

ZZ=exp((ALPHA_A*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

ZZZ=exp(-(ALPHA_C*FARADAY*(C_UDSI(c,t,0)-C_UDSI(c,t,1)))/(UNI_GAS_CONS*C_T(c,t)));

RXN_RATE_C=Z*(ZZ-ZZZ);

source=RXN_RATE_C;

dS[eqn]=0;

return source;
}


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