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/)
-   -   defining a term for a domain using DEFINE_ADJUST (https://www.cfd-online.com/Forums/fluent-udf/80293-defining-term-domain-using-define_adjust.html)

MASOUD September 21, 2010 23:23

defining a term for a domain using DEFINE_ADJUST
 
Hi,
My geometry is including 5 subdomains (it's a fuel cell).
I'd like to define different reaction rate in different zones.
I guess DEFINE_ADJUST could be a good idea.
How can I do this?

Here is the code:

*****************

#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=270;
static real ACT_AREA_C=300;
static real REF_EXCH_CURR_A=2.1;
static real REF_EXCH_CURR_C=0.40;
static real REV_POT=1.02;
static real MW_H2=0.032;
static real MW_H2O=0.032;
static real MW_O2=0.032;
static real MW_CO2=0.044;
static real MW_N2=0.032;
static real MW_MIX;
static real X_H2;
static real X_H2O;
static real X_O2;
static real X_CO2;
static real X_N2;
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 STOCH_H2=-1;
static real STOCH_H2O=1;
static real STOCH_O2=-0.5;
static real STOCH_CO2_A=1;
static real STOCH_CO2_C=-1;
static real RXN_RATE_A;
static real RXN_RATE_C;
static real Z_A;
static real ZZ_A;
static real ZZZ_A;
static real Z_C;
static real ZZ_C;
static real ZZZ_C;
static real source;
static real u=0.0;
static real domain_ID=30;



DEFINE_ADJUST(SUR,d)
{
u+=0.001;
}


DEFINE_ADJUST(UDM,d)
{
Thread *t;
cell_t c;



MW_MIX=MW_H2*C_YI(c,t,0)+MW_O2*C_YI(c,t,1)+MW_CO2* C_YI(c,t,2)+MW_H2O*C_YI(c,t,3)+MW_N2*C_YI(c,t,4);
X_H2=C_YI(c,t,0)*MW_H2/MW_MIX;
X_O2=C_YI(c,t,1)*MW_O2/MW_MIX;
X_CO2=C_YI(c,t,2)*MW_CO2/MW_MIX;
X_H2O=C_YI(c,t,3)*MW_H2O/MW_MIX;
X_N2=C_YI(c,t,4)*MW_N2/MW_MIX;


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

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

ZZZ_A=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_A*(ZZ_A-ZZZ_A);

C_UDMI(c,t,0)=RXN_RATE_A;



Z_C=ACT_AREA_C*REF_EXCH_CURR_C*pow(X_O2,0.375)*pow (X_CO2,(-1.25));

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

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

RXN_RATE_C=Z_C*(ZZ_C-ZZZ_C);

C_UDMI(c,t,1)=RXN_RATE_C;

}

byronsmith September 24, 2010 05:08

use the macro get domain() where the domain numbe can be had from the boundary conditions and for each domain write the rate equation


All times are GMT -4. The time now is 21:36.