CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   FLUENT (https://www.cfd-online.com/Forums/fluent/)
-   -   Ansys fluent CFD (https://www.cfd-online.com/Forums/fluent/140524-ansys-fluent-cfd.html)

walied123 August 17, 2014 08:35

Ansys fluent CFD
 
hello every body...........need for help
i try to make an UDF for changing density as a function of coordinates(say z coordinate) but it didnot work in fluent.
this is my UDF.
#include "udf.h"
DEFINE_PROPERTY(ANODE_DENSITY, thread, position)
{
float x[ND_ND]; /* this will hold the position vector */
float t,air,anode,electrolyte,po,va,ve,n,z,a,r,l,p,d,w,y ,u,POROSITY;
cell_t c;
t= 0.00008; /* ANODE THICKNESS */
air=1.28;
anode=4500.;
electrolyte=6010.;
n=2;
z=5;
w=(n+z)/n;
y=n/(n+z);
r=pow(w,n);
l=pow(y,z);
a=r/(1-l);
begin_c_loop(c,thread)
{
C_CENTROID(x, c, thread);
va=x[3]/t;
ve=1-va;
u=x[3]/t;
p= pow(u,n);
d= pow(u,z);
POROSITY = (a*p*(1-d));
po= ((va*anode)+(ve*electrolyte));
C_R(c, thread, position) =po*(1-POROSITY)+air*POROSITY;
}
end_c_loop(c, thread)
}


All times are GMT -4. The time now is 20:30.