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

defining a term for a domain using DEFINE_ADJUST

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   September 21, 2010, 23:23
Default defining a term for a domain using DEFINE_ADJUST
  #1
Senior Member
 
MASOUD
Join Date: Mar 2009
Posts: 102
Rep Power: 7
MASOUD is on a distinguished road
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;

}
MASOUD is offline   Reply With Quote

Old   September 24, 2010, 05:08
Default
  #2
Member
 
Byron Smith R J
Join Date: Mar 2009
Location: India
Posts: 46
Rep Power: 7
byronsmith is on a distinguished road
use the macro get domain() where the domain numbe can be had from the boundary conditions and for each domain write the rate equation
byronsmith is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45
Defining two bubbles inside a domain daraujo FLUENT 0 October 16, 2009 09:39
Defining a circle within a rectangle domain amscosta OpenFOAM Meshing & Mesh Conversion 1 August 14, 2009 15:03
defining the domain umesh CFX 0 March 14, 2009 01:18
PDE in udf for defining momentum source term shekhar FLUENT 0 April 12, 2004 01:43


All times are GMT -4. The time now is 02:56.