CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

udf for adsorption coefficient

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

Reply
 
LinkBack Thread Tools Display Modes
Old   August 19, 2009, 15:10
Question udf for adsorption coefficient
  #1
New Member
 
beibei
Join Date: Aug 2009
Posts: 6
Rep Power: 8
bzhu is on a distinguished road
I need to define my own adsorption coefficient of solid quartz as a function of x due to some chemical change. Shall I define it as a thread or cell or something else? This is my first time to use udf ever and C program since 15 years ago. Could you gurus check my code for me? thanks! Here's my C code:

/************************************************** *******************
UDF for specifying a x-axis-dependent absorption property
************************************************** ********************/
#include "udf.h"
DEFINE_PROPERTY(absorption_coefficient, thread, index)
{
real abs_lam;
real x;
if (0 < x < 0.2)
abs_lam = 0.1111;
else if (0.2 < x < 0.4)
abs_lam = 0.2222;
else if (0.4 < x < 0.6)
abs_lam = 0.3333;
else if (0.6 < x < 0.8)
abs_lam = 0.4444;
else
abs_lam = 0.5555;
return abs_lam;
}
bzhu is offline   Reply With Quote

Old   August 20, 2009, 02:48
Default
  #2
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 8
coglione is on a distinguished road
Hello Beibei,

1) if x should hold the position in x-direction of a given cell you must retrieve the coordinates of its centroid by using the macro C_CENTROID(pos,c,t) where pos is a vector with components (x,y,z). To get x use pos[0].
2) the correct syntax for DEFINE_PROPERTY is DEFINE_PROPERTY(name,c,t), no index in it!

Have a look at the udf-manuel, surely there is an example which is close to your specific application.

cheers
coglione is offline   Reply With Quote

Old   August 24, 2009, 15:09
Default
  #3
New Member
 
beibei
Join Date: Aug 2009
Posts: 6
Rep Power: 8
bzhu is on a distinguished road
Thank you for help! I revised my code as:
/************************************************** *******************
UDF for specifying a x-axis-dependent absorption property
************************************************** ********************/
#include"udf.h"
DEFINE_PROPERTY(absorption_coefficient, c, t)
{
real abs_coeff;
real pos;
C_CENTROID(pos[0],c,t);
if (0 <= pos[0] < 0.2)
abs_coeff = 0.1111;
elseif (0.2 <= pos[0] < 0.4)
abs_coeff = 0.2222;
elseif (0.4 <= pos[0] < 0.6)
abs_coeff = 0.3333;
elseif (0.6 <= pos[0] < 0.8)
abs_coeff = 0.4444;
else
abs_coeff = 0.5555;
return abs_coeff;
}

But it still didn't work. FLUENT gave me the error message of "line9: subscription expression is not an array or pointer: float". This pointer stuff is killing me. I never really understand the concept.
Could someone help me? Thanks a lot!

Last edited by bzhu; August 24, 2009 at 23:13.
bzhu is offline   Reply With Quote

Old   August 25, 2009, 03:53
Default
  #4
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 8
coglione is on a distinguished road
beibei, that's really basic C-stuff which you should try to understand as soon as possible if you need to use udf's.
However, as already stated pos is a vector, so you need to deslare it as one:

real pos[ND_ND]; (ND_ND is a fluent macro returning the right dimension automatically for 2d/3D)

then get the Cell-Center_coordinates into it:

C_CENTROID(pos,c,t);

The rest should be o.k.

cheers
coglione is offline   Reply With Quote

Old   August 26, 2009, 13:14
Default
  #5
New Member
 
beibei
Join Date: Aug 2009
Posts: 6
Rep Power: 8
bzhu is on a distinguished road
Thanks! I revised my code as:

/************************************************** *******************
UDF for specifying a x-axis-dependent absorption property
************************************************** ********************/
#include"udf.h"
DEFINE_PROPERTY(absorption_coefficient, c, t)
{
real abs_coeff;
real x[ND_ND];
C_CENTROID(x,c,t);
if (0 <= x[0] < 0.2)
abs_coeff = 0.1111;
elseif (0.2 <= x[1] < 0.4)
abs_coeff = 0.2222;
elseif (0.4 <= x[2] < 0.6)
abs_coeff = 0.3333;
elseif (0.6 <= x[4] < 0.8)
abs_coeff = 0.4444;
else
abs_coeff = 0.5555;
return abs_coeff;
}

It could interprete to FLUENT. The problem is that after iteration, I checked the adsorption coefficient. It didn't look like a function of x position. Could you see the cause in my code? Thanks!
bzhu is offline   Reply With Quote

Old   August 27, 2009, 04:41
Default
  #6
Senior Member
 
Max
Join Date: Mar 2009
Posts: 133
Rep Power: 8
coglione is on a distinguished road
yes i see the reason and you should be able to find the error too. I guess you do not really intend to solve a 5-D problem which would at least give some physical meaning to x[4] !

cheers
coglione is offline   Reply With Quote

Old   September 17, 2009, 10:36
Default
  #7
New Member
 
beibei
Join Date: Aug 2009
Posts: 6
Rep Power: 8
bzhu is on a distinguished road
I revised my code as below and FLUENT didn't seem to render it even though it could interprete. I changed the x-position dependent to a constant jsut by replacing the if-command to a constant to see if fluent can exert, and it didn't. What could it be wrong? Couldn't fluent render udf on a surface? Please help! Thanks!

Here's my code:

#include"udf.h"
DEFINE_PROPERTY(absorption_coefficient, c, t)
{
real abs_coeff;
real x[ND_ND];
C_CENTROID(x,c,t);
if (x[0] > 0 && x[0] < 0.2)
abs_coeff = 593.9187;
elseif (x[0] > 0 && x[0] < 0.2)
abs_coeff = 197.6521;
elseif (x[0] > 0 && x[0] < 0.2)
abs_coeff = 177.0521;
elseif (x[0] > 0 && x[0] < 0.2)
abs_coeff = 140.5854;
else
abs_coeff = 140.5854;
Message(
"Abs coefficient for this cell %e = %e", x[0],abs_coeff);
return abs_coeff;
}
bzhu is offline   Reply With Quote

Reply

Tags
adsorption coefficient, code, fluent, 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
Automotive test case vinz OpenFOAM Running, Solving & CFD 98 October 27, 2008 09:43
how to define restituition coefficient using UDF? haijj FLUENT 6 July 9, 2008 23:26
UDF for Heat transfer coefficient Dong Wenchao FLUENT 2 August 23, 2006 06:35
heat transfer coefficient udf nam su FLUENT 0 March 25, 2005 03:28
UDF - Heat transfer coefficient kulasekharan FLUENT 3 August 12, 2004 07:09


All times are GMT -4. The time now is 02:04.