UDF for writing porosity as a function of distance from the wall
Hi,
I am unable to get my UDF for setting porosity variation to work out. Here is what my fn.c code looks like. /***************************** UDF to specifiy porosity as a function of distance from the wall of the packed bed reactor ************************************/ #include "udf.h" #define H 0.1 #define dp 0.008 DEFINE_PROFILE(porosity_function,t,i) { cell_t c; real x[ND_ND]; /*This will hold the position vectors*/ real y; real a1; real a2=6; /*to specifiy the porosity variation function*/ real eps_inf=0.37; real eps; a1 = (1./eps_inf)1; begin_c_loop(c,t) { C_CENTROID(x,c,t); y = (H  x[1])/ dp ; eps = eps_inf*(1. + a1*exp(1*a2*y)); F_PROFILE(c,t,i) = eps; } end_c_loop(c,t) } I tried using both F_PROFILE and C_PROFILE inside the code. The code builds and loads alright during compilation. But when I try to use in in the porous zone as function for porosity, it doesn't work. It gives me an error which is : Error = invalid argument; not a number[1] Could anybody help me with this? 
use the following code to specify cell profile. It seems your error is led by other problems.
begin_c_loop(c,t) { F_PROFILE(c,t,i)=......; } end_c_loop(c,t) Quote:

@gearboy
hey,
Thanks for responding. But then, I am still unable to figure out what you are actually saying. I did put in F_PROFILE(c,t,i) in my code. and, its still giving me the same error. Am I not catching something you are saying correctly? thanks, 
Quote:
#include "udf.h" #define H 0.1 #define dp 0.008 DEFINE_PROFILE(porosity_function,t,i) { cell_t c; real x[ND_ND]; /*This will hold the position vectors*/ real y; real a1; real a2=6; /*to specifiy the porosity variation function*/ real eps_inf=0.37; real eps; a1 = (1./eps_inf)1; begin_c_loop(c,t) { C_CENTROID(x,c,t); y = (H  x[1])/ dp ; eps = eps_inf*(1. + a1*exp(1*a2*y)); Message("%g\n",eps); // monitor each cell's eps F_PROFILE(c,t,i) = eps; } end_c_loop(c,t) } 
Hi gearboy
i working on modeling 3D gasliquid slug flow in horizontal pipe with fluent, but I can not get the true phase distribution for the fluids, I think that I need to use a volume fraction UDF can you help me the following UDF for profile of velocity, how can I change it to get one for VF where I wont to set lower half of the cylindrical pipe to 1 means filled with secondary phase while the upper half being take its values from the normal iterations from the mixture velocity and other initial and boundary conditions. I need UDF constant with time not like the below which is time dependent. Thank you. DEFINE_PROFILE(VOLUMEFRACTION_profile, t, nv ) { face_t f; real x[ND_ND]; real f_time = RP_Get_Real("flowtime") begin_f_loop (f,t) { F_CENTROID(x,f,t); if (f_time<=10e1) {F_PROFILE(f,t,nv) = 1*cos(PI*f_time/3); } else F_PROFILE(f,t,nv) = 0; } end_f_loop (f,t) } 
checked printing cells
Hi gearboy,
I checked printing out my porosity values outside of this udf function as a regular c function and it seems to be fine. There is no case where NaN comes up when I evaluate this function. 
All times are GMT 4. The time now is 07:39. 