CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Fluent UDF and Scheme Programming

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

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 1, 2012, 12:10
Default 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: 5
rohinibc is on a distinguished road
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?
rohinibc is offline   Reply With Quote

Old   August 6, 2012, 02:05
Default
  #2
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 106
Rep Power: 7
gearboy is on a distinguished road
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:
Originally Posted by rohinibc View Post
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?
gearboy is offline   Reply With Quote

Old   August 7, 2012, 17:06
Default @gearboy
  #3
New Member
 
Rohini Bala Chandran
Join Date: Apr 2012
Posts: 8
Rep Power: 5
rohinibc is on a distinguished road
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,
rohinibc is offline   Reply With Quote

Old   August 7, 2012, 22:05
Default
  #4
Senior Member
 
Ji Junjie
Join Date: Feb 2010
Location: Shanghai, China
Posts: 106
Rep Power: 7
gearboy is on a distinguished road
Quote:
Originally Posted by rohinibc View Post
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,
I think there might be a math error in your computation. Try printing the "eps" for each cell.

#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)
}
gearboy is offline   Reply With Quote

Old   August 8, 2012, 05:04
Default
  #5
New Member
 
zainab
Join Date: Mar 2012
Posts: 17
Rep Power: 5
zainab is on a distinguished road
Hi gearboy
i working on modeling 3D gas-liquid 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("flow-time")
begin_f_loop (f,t)
{
F_CENTROID(x,f,t);
if (f_time<=10e-1)
{F_PROFILE(f,t,nv) = 1*cos(PI*f_time/3);
}
else
F_PROFILE(f,t,nv) = 0;
}
end_f_loop (f,t)
}
zainab is offline   Reply With Quote

Old   August 8, 2012, 08:16
Default checked printing cells
  #6
New Member
 
Rohini Bala Chandran
Join Date: Apr 2012
Posts: 8
Rep Power: 5
rohinibc is on a distinguished road
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.
rohinibc is offline   Reply With Quote

Reply

Tags
define_profile, porosity, udf

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 OpenFOAM-1.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 120 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


All times are GMT -4. The time now is 06:40.