
[Sponsors] 
UDF for writing porosity as a function of distance from the wall 

LinkBack  Thread Tools  Display Modes 
August 1, 2012, 12:10 
UDF for writing porosity as a function of distance from the wall

#1 
New Member
Rohini Bala Chandran
Join Date: Apr 2012
Posts: 8
Rep Power: 7 
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? 

August 6, 2012, 02:05 

#2  
Senior Member
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 111
Rep Power: 10 
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:


August 7, 2012, 17:06 
@gearboy

#3 
New Member
Rohini Bala Chandran
Join Date: Apr 2012
Posts: 8
Rep Power: 7 
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, 

August 7, 2012, 22:05 

#4  
Senior Member
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 111
Rep Power: 10 
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) } 

August 8, 2012, 05:04 

#5 
New Member
zainab
Join Date: Mar 2012
Posts: 17
Rep Power: 7 
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) } 

August 8, 2012, 08:16 
checked printing cells

#6 
New Member
Rohini Bala Chandran
Join Date: Apr 2012
Posts: 8
Rep Power: 7 
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. 

Tags 
define_profile, porosity, udf 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Fluent3DMeshToFoam  simvun  OpenFOAM Other Meshers: ICEM, Star, Ansys, Pointwise, GridPro, Ansa, ...  48  May 14, 2012 05:20 
latest OpenFOAM1.6.x from git failed to compile  phsieh2005  OpenFOAM Bugs  25  February 9, 2010 05:37 
Version 15 on Mac OS X  gschaider  OpenFOAM Installation  113  December 2, 2009 11:23 
Compilation errors in ThirdPartymallochoard  feng_w  OpenFOAM Installation  1  January 25, 2009 07:59 
Wall function in adverse pressure gradients  stephane baralon  Main CFD Forum  11  September 2, 1999 04:05 