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/)
-   -   porosity udf (https://www.cfd-online.com/Forums/fluent-udf/148557-porosity-udf.html)

walied123 February 14, 2015 17:26

porosity udf
 
hello every body

i made a UDF for anode and cathode porosity in the SOFC module, but the energy residual get the following reading 1.#QNBe+00

PLEASE URGENT HELP.......
here is my UDF

#include "udf.h"

/**********************Anode Porosity **************/
DEFINE_PROFILE(anode_porosity, thread, np)
{
cell_t c;
real x[ND_ND];
real y;

begin_c_loop (c,thread)
{

C_CENTROID(x,c,thread);
y =x[1];

F_PROFILE(c,thread,np) =((y-1.53)/0.02)*(1-((y-1.53)/0.02));
}

end_c_loop (c,thread)

}

/*********************Cathode Porosity*****************/
DEFINE_PROFILE(cathode_porosity, thread, np)
{
cell_t c;
real x[ND_ND];
real y;

begin_c_loop (c,thread)
{

C_CENTROID(x,c,thread);
y=x[1];

F_PROFILE(c,thread,np) =((y-1.53)/0.02)*(1-((y-1.53)/0.02));
}

end_c_loop (c,thread)
}

upeksa February 16, 2015 12:04

Take into account the following:

- Remember the units given by UDF are meters

- The values of porosity must be 0-1.

- You must set an appropriate value for Ri and Rv

walied123 February 16, 2015 13:55

thank you upeksa for your kind reply.
but what do you mean by Rv and Ri

regards

upeksa February 17, 2015 04:11

Quote:

Originally Posted by walied123 (Post 532075)
thank you upeksa for your kind reply.
but what do you mean by Rv and Ri

regards

Viscous resistence and inertial resistence.

Check this post

http://www.cfd-online.com/Forums/flu...us-medium.html

Looking at your UDF, nothing seems wrong with your code.

The error you get must have something to with some number out of range, so I think that the values of porosity you retrieve are higher than 1 or lower than 0.

Cheers

walied123 February 17, 2015 14:34

hello upeksa;

thank you for your kind reply.

please can you check the following udf for any error.i compiled it without any problems but i need to know is it right as a writing........ .

#include "udf.h"
#include "math.h"
/************************************************** CONSTANT****************************************** *************/
#define m 1
#define rua 1.2
#define thermal 0.0242
#define anode_density 4760
#define electrolyte_density 1980
#define anode_ca 377
#define ca 1006.43
#define electrolyte_ca 2000
#define anode_THER 11
#define electrolyte_THER 2
#define cathode_density 4640
#define cathode_ca 377
#define cathode_THER 2.37
/************************************************** Anode Porosity****************************************** ********************/
DEFINE_PROFILE(Anode_porosity, t, i)
{
cell_t c;
real x[ND_ND],y;

begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
y=(x[1]*1000-1.56)/0.7;
C_PROFILE(c,t,i) = pow(y,m)*(1-pow(y,m));
}
end_c_loop (c,t)
}

/*************************************************C athode Porosity****************************************** ************************/
DEFINE_PROFILE(Cathode_porosity, t,i)
{

cell_t c;
real x[ND_ND],y;

begin_c_loop(c,t)
{
C_CENTROID(x,c,t);
y=(x[1]*1000-1.5)/0.05;
C_PROFILE(c,t,i) = pow(y,m)*(1-pow(y,m));
}

end_c_loop (c,t)
}

/*************************************************A node Density******************************************* *********************/
DEFINE_PROPERTY(A_Density, c,t)
{
real va, ve, p, d, u, y, x[ND_ND], dens, POR, po;
C_CENTROID(x,c,t);
y = x[1];
u = (y*1000 - 1.56) / 0.7;
va = pow(u, m); /* ve is the electrolyte material volume fraction*/
POR = C_POR(c,t);
ve = 1 - (va+POR); /* va is the anode material volume fraction*/
po = va*anode_density + ve*electrolyte_density;
dens = po*(1 - POR) + rua* POR;
return dens;
}
/*****************************************Anode thermal conductivity************************************** ***********/
DEFINE_PROPERTY(A_THER_cond,c,t)
{

real va, ve, p, d, u, x[ND_ND], POR, A, B, D, G, Lo,R,T,H, y, termal_cond_anode;
C_CENTROID(x,c,t);
y = x[1];
u = (y*1000 - 1.56) / 0.7;
va = pow(u, m);
POR = C_POR(c,t); /* va is the anode material volume fraction*/
ve = 1 - (va+POR); /* ve is the electrolyte material volume fraction*/
A = (3 * (anode_THER - electrolyte_THER)*va);
B = (3 * va*electrolyte_THER + (anode_THER +2* electrolyte_THER)*(1 - va));
Lo =electrolyte_THER*(1+( A / B));
D = Lo*(Lo*(1 - pow(POR, (2 / 3))) + thermal*pow(POR, (2 / 3)));
R = (pow(POR, (1 / 3))*thermal);
T = (1 - pow(POR, (1 / 3)))*((1 - pow(POR, 2 / 3))*Lo);
H = (1 - pow(POR, (1 / 3)))*(pow(POR, (2 / 3)))*thermal;
G = R + T + H;
termal_cond_anode = D / G;
return termal_cond_anode;
}
/********************************** CATHODE_DENSITY ************************************************** ******/
DEFINE_PROPERTY(C_Density, c,t)
{

real va, ve, p, d, u, y, x[ND_ND], dens, POR, po;

C_CENTROID(x,c,t);
y = x[1];
u = (y*1000 - 1.5) / 0.05;
POR = C_POR(c,t);
ve = pow(u, m); /* va is the anode material volume fraction*/
va = 1 - (ve+POR); /* ve is the electrolyte material volume fraction*/
po = va*anode_density + ve*electrolyte_density;
dens = po*(1 - POR) + rua* POR;
return dens;

}
/****************************************Cathode thermal conductivity************************************** ************/
DEFINE_PROPERTY(C_THER_cond, c,t)
{

real va, ve, p, d, u, x[ND_ND], POR, y,M,K,P,W, Lo,U1,J, termal_cond;
C_CENTROID(x,c,t);
y = x[1];
u = (y*1000 - 1.5) / 0.05;
POR = C_POR(c,t);
ve = pow(u, m); /* va is the anode material volume fraction*/
va = 1 - (ve+POR); /* ve is the electrolyte material volume fraction*/
M = (3 * (-cathode_THER + electrolyte_THER)*ve);
K = (3 * ve*cathode_THER + (2 * cathode_THER + electrolyte_THER)*(1 - ve));
Lo = cathode_THER*(1+(M / K));
P = Lo*(Lo*(1 - pow(POR, 2 / 3)) + thermal*pow(POR, 2 / 3));
J = pow(POR, 1 / 3)*thermal;
U1 = (1 - pow(POR, 1 / 3))*((1 - pow(POR, 2 / 3))*Lo);
W = (1 - pow(POR, 1 / 3))*(pow(POR, 2 / 3))*thermal;
termal_cond = P / (J + U1 + W);
return termal_cond;
}


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