CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   FLUENT (http://www.cfd-online.com/Forums/fluent/)
-   -   Guide me (http://www.cfd-online.com/Forums/fluent/99460-guide-me.html)

Negar GH April 4, 2012 00:37

Guide me
 
Hello dear friends,I simulated a membrane process by FLUENT.I have a mixture consist of two species and process is gas separation.I wrote a UDF for source terms but I have a problem with line (Domain* domain; cell_t c; face_t f; Thread *t; Domain *d; int i;).Please guide me.Thanks a lot.

#include "udf.h"
#include "mem.h"


#define ro 0.13
#define M1 2
#define M2 44
#define epsilon1 0.9
#define epsilon2 1
#define k 1
#define sigma11 1
#define sigma12 0.9
#define sigma22 1.1
#define sigma21 0.95
#define Co1 2.72e-6
#define Co2 23.29e-8
#define Ea1 8.71
#define Ea2 -1.72
#define R 8.314
#define A 0.002512
#define deltaP 100000


Domain* domain; cell_t c; face_t f; Thread *t; Domain *d; int i;

DEFINE_SOURCE(species_source1,c,t,dS,eqn)
{
real y1;
real y2;
real dy1;
real x1;
real x2;
real p;
real T;
real D11;
real D12;
real j1;
real permeance1;
real per1;
real source1;

thread_loop_c (t,domain) { if (THREAD_ID(thread)==2) { begin_c_loop_all(c,t)
{
y1=C_YI(c,t,0);
y2=C_YI(c,t,1);
dy1=C_YI_G(c,t,0)[1];
p=C_P(c,t);
T=C_T(c,t);
x1=(y1/M1)/(y1/M1+y2/M2);
x2=1-x1;
D11=0.018583*pow(T,1.5)*(pow(((1/M1)+(1/M1)),0.5))/(p*pow(sigma11,2)*k/(pow(epsilon1*epsilon1,0.5)));
D12=0.018583*pow(T,1.5)*(pow(((1/M1)+(1/M2)),0.5))/(p*pow(sigma12,2)*k/(pow(epsilon1*epsilon2,0.5)));
j1=-(ro*(1-x1)*dy1)/((x1/D11)+(x2/D12));
permeance1=Co1*exp(Ea1/(R*T));
per1=permeance1*A*deltaP/M1;
source1=-(j1+per1);
end_c_loop(c,t)
}
}}
return source1;
}

DEFINE_SOURCE(species_source2,c,t,dS,eqn)
{

real y1;
real y2;
real dy2;
real x1;
real x2;
real p;
real T;
real D21;
real D22;
real j2;
real permeance2;
real per2;
real source2;

thread_loop_c (t,domain) { if (THREAD_ID(thread)==2) { begin_c_loop_all(c,t)
{
y1=C_YI(c,t,0);
y2=C_YI(c,t,1);
dy2=C_YI_G(c,t,1)[1];
p=C_P(c,t);
T=C_T(c,t);
x1=(y1/M1)/(y1/M1+y2/M2);
x2=1-x1;
D21=0.018583*pow(T,1.5)*(pow(((1/M2)+(1/M1)),0.5))/(p*pow(sigma21,2)*k/(pow(epsilon1*epsilon1,0.5)));
D22=0.018583*pow(T,1.5)*(pow(((1/M2)+(1/M2)),0.5))/(p*pow(sigma22,2)*k/(pow(epsilon2*epsilon2,0.5)));
j2=-(ro*(1-x2)*dy2)/((x1/D21)+(x2/D22));
permeance2=Co2*exp(Ea2/(R*T));
per2=permeance2*A*deltaP/M2;
source2=-(j2+per2);
end_c_loop(c,t)
}
}}
return source2;
}


All times are GMT -4. The time now is 22:08.