timjm |
February 22, 2013 10:53 |
SR_Rate UDF For a MEMs model
We are trying to model a MEMs device with biological "cells" on one surface of the device.
1. Is it possible to define a full series of reactions at a surface using SR_RATE.
2. I am trying to follow an example I saw in the user manual for SR_RATE. Do I need to define the reaction three times as in the example, or could I just remove all of the extraneous calcs outside of the SR_RATE command?
Thanks.
-Tim
Our Routine:
Code:
#include "udf.h"
/*define the Constants */
#define sa 1875 /* surface area of bottom face of bioreactor mm^2 */
#define l 1e6 /* number of cells */
#define our 0.25 /* OUR for 1e6 hepatocytes */
real OUR_rate(real conc)
{
return -our*l/sa*conc;
}
/*define the scalars */
#define Air 0
#define O2 1
#define H2O 2
/* Reaction Rate Routine */
real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[])
{
real concO2 = C_R(c, cthread)*yi[O2]/mw[O2];
return OUR_rate(concO2);
}
DEFINE_SR_RATE(OUR,f,fthread,r,mw,yi,rr)
{
*rr =
reaction_rate(F_C0(f,fthread),THREAD_T0(f,fthread),mw,yi);
}
The Example Routine:
Code:
#include "udf.h"
/* ARRHENIUS CONSTANTS */
#define PRE_EXP 1e+15
#define ACTIVE 1e+08
#define BETA 0.0
real arrhenius_rate(real temp)
{
return
PRE_EXP*pow(temp,BETA)*exp(-ACTIVE/(UNIVERSAL_GAS_CONSTANT*temp));
}
/* Species numbers. Must match order in Fluent panel */
#define HF 0
#define WF6 1
#define H2O 2
#define NUM_SPECS 3
/* Reaction Exponents */
#define HF_EXP 2.0
#define WF6_EXP 0.0
#define H2O_EXP 0.0
#define MW_H2 2.0
#define STOIC_H2 3.0
/* Reaction Rate Routine that is used in both UDFs */
real reaction_rate(cell_t c, Thread *cthread,real mw[],real yi[])
*/ Note that all arguments in the reaction_rate function
call in your .c source file MUST be on the same line or a
compilation error will occur */
{
real concenHF = C_R(c,cthread)*yi[HF]/mw[HF];
return arrhenius_rate(C_T(c,cthread))*pow(concenHF,HF_EXP);
}
DEFINE_SR_RATE(arrhenius,f,fthread,r,mw,yi,rr)
{
*rr =
reaction_rate(F_C0(f,fthread),THREAD_T0(fthread),mw,yi);
}
real contact_area(cell_t c,Thread *t,int s_id,int *n)
{
int i = 0;
real area = 0.0, A[ND_ND];
*n = 0;
c_face_loop(c,t,i)
{
if(THREAD_ID(C_FACE_THREAD(c,t,i)) == s_id)
{
(*n)++;
F_AREA(A,C_FACE(c,t,i), C_FACE_THREAD(c,t,i));
area += NV_MAG(A);
}
}
return area;
}
|