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

turbulent viscosity UDF!please your help

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

Like Tree3Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   September 29, 2009, 14:35
Default turbulent viscosity UDF!please your help
  #1
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
Hello everybody. I would be really grateful if any of you could address me on how to create an UDF to change the turbulent viscosity (hence k+ formula), only on a portion of my domain. I have been trying the following:

-----------------------------------------

/************************************************** ********************

UDF pour la vitesse et la viscosité turbulente
************************************************** ********************/

#include "udf.h"


//udf de viscosité turbulente//

DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{

real x[ND_ND];

real y;

real mu_t,yp,utau,nu,…..;

utau=;

nu=;
…..
y=x[1];

yp=(y*utau)/nu;
if (yp <= 20) {

mu_t =……….



return mu_t;


}

-----------------------------------------------------------

which I have interpreted and my program converged, by my result of k+=f(y+) is not correct.

I do not know if fluent takes into consideration that k also changes with the change of mu_turbulent or not?
gina is offline   Reply With Quote

Old   October 20, 2009, 03:52
Default Random value mu_t
  #2
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
Hello Gina,
Your code must specify a value for mu_t all the time, not only when yp <= 20! Otherwise the value will be undefined (random).
Code:
...
if(yp <= 20)
   mu_t = ...
else
   mu_t = ...
...
Dragos
dmoroian is offline   Reply With Quote

Old   October 23, 2009, 15:29
Default how to write in udf: take the default value?
  #3
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
Thank you very much for your reply

ok, if I mean: for the other values of mu_t fluent must take the default one that exists already in fluent

how to write that in my udf
gina is offline   Reply With Quote

Old   October 23, 2009, 15:34
Talking how to write in udf: take the default value?
  #4
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
thank you very much to have reply for my request

ok, if I mean:

if(yp <= 20)
mu_t = ...
else
mu_t = takes the default value in fluent


how to write this in my udf?
gina is offline   Reply With Quote

Old   October 23, 2009, 16:37
Default
  #5
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
I'm afraid that if you use a udf for the turbulent viscosity, you have to provide it for all the cells.
But I think you may check the manuals for the default implementation and add it to your own.
For example:
Code:
  real mu_t;
  real rho = C_R(c,t);
  real k   = C_K(c,t);
  real d   = C_D(c,t);

  mu_t = M_keCmu*rho*SQR(k)/d;

  return mu_t;
or try the default macro and see if it works:
Code:
mu_t  = C_MU_T(c,t);
Dragos
dmoroian is offline   Reply With Quote

Old   October 23, 2009, 17:35
Default it run but!!!
  #6
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
the calcul run but the results is not good! can i send you my udf to see it?
gina is offline   Reply With Quote

Old   October 23, 2009, 18:14
Default
  #7
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
Send me your code, but I will not be able to look at it until Tuesday.
dmoroian is offline   Reply With Quote

Old   October 23, 2009, 18:32
Default my udf
  #8
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
thank you very very much, i will wait your answer;
if you need the values of constant and for mu_t expression i will
send them for you
-------------------------------------------------------------------------
#include "udf.h"

DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{
real mu_t;
real rho = C_R(c,t);
real k = C_K(c,t);
real d = C_D(c,t);

real x[ND_ND];
real y,yplus,utau,vkr,Cv,Alplus,Akplus,B,nu;

Cv=..;
vkr=..;
B=..;
Akplus=..;
Alplus=..;
nu=..;
utau=..;

y=x[1];
yplus= (rho*utau*y)/nu;

if (yplus <= 20)
{
mu_t =(...)*nu;
}
else
{
mu_t = M_keCmu*rho*SQR(k)/d;
}

return mu_t;
}
gina is offline   Reply With Quote

Old   October 25, 2009, 14:35
Default
  #9
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
Hi Gina,
If this is your complete udf, then I don't see where you initialize the vector x. If you don't put an explicit value inside it, then
Code:
y = x[1];
will set a random value to variable "y", and consequently it will produce an erroneous value for "yplus"?

Dragos
dmoroian is offline   Reply With Quote

Old   October 26, 2009, 18:26
Default
  #10
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
i am new in udf and it is my first udf wich i write:

can you tell me please if it is correct to write
---------------------------------------------------------------------
#include "udf.h"

DEFINE_TURBULENT_VISCOSITY(user_mu_t,c,t)
{
real mu_t;
real rho = C_R(c,t);
real k = C_K(c,t);
real d = C_D(c,t);

real y,yplus,utau,vkr,Cv,Alplus,Akplus,B,nu;

Cv=..;
vkr=..;
B=..;
Akplus=..;
Alplus=..;
nu=..;
utau=..;

y=C_WALL_DIST(c,t);
yplus= (rho*utau*y)/nu;

if (yplus <= 20)
{
mu_t =(...)*nu;
}
else
{
mu_t = M_keCmu*rho*SQR(k)/d;
}

return mu_t;
}
gina is offline   Reply With Quote

Old   October 26, 2009, 22:22
Default
  #11
Member
 
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 7
t.krishnamohan is on a distinguished road
Hi,
I really cannot understand why you want to calculate eddy viscosity in the near wall regions. In near wall regions, properties are calculated using wall functions. If you want to define your own wall fuction, it is possible by using DEFINE_WALL_FUNCTIONS UDF. Numerical simulation is carried out only in the core turbulent flow region(Defect region). Please also be advised that the mean componet of minor velocities are zero in the near wall region and only the fluctuating component of velocty will exist and is equal in all the directions(isotropic). The mean component of major velocity is determined using wall function. Then why do you need eddy viscosity in the near wall region.

Hope I can be of any use to you if you can explain what exactly you need?
Regards,
Krishna Mohan
t.krishnamohan is offline   Reply With Quote

Old   October 27, 2009, 16:15
Default
  #12
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
yes i want to define my own wall function,
I want to implement a new eddy viscosity formulation for turbulent boundary layers near smooth walls.
For this reason that I thought to change the eddy viscosity which already exists in fluent but just near the wall,
i have write my new eddy viscosity formulation! , i have interpreted it and then i add it in the panal:
define_model_ viscous model_user define function_turbulent viscosity

it is not correct what i do!?

thanks to guide me
gina is offline   Reply With Quote

Old   October 27, 2009, 21:50
Default
  #13
Member
 
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 7
t.krishnamohan is on a distinguished road
Hi,
You are getting confused with wall functions and eddy viscosity. If you need to define your own wall functions, then why you need eddy viscosity in the near wall region? You can find the properties with wall functions near the wall region so, where is the question of eddy viscosity coming into picture. Please read "Near Wall Treatment for Wall Bounded Flows" chapter in fluent documentation. I am sure your approach to define eddy viscosity in the near wall region is wrong.
Regards,
Krishna Mohan
t.krishnamohan is offline   Reply With Quote

Old   October 27, 2009, 21:53
Default
  #14
Member
 
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 7
t.krishnamohan is on a distinguished road
If you want to run the UDF, change the term SQR(k) to pow(k,2.0), SQR() is not a valid function.
Rgds,
t.krishnamohan is offline   Reply With Quote

Old   October 28, 2009, 11:00
Default
  #15
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
There is a macro defined by Fluent in global.h:
Code:
#define SQR(a) ((a)*(a))
which makes the call valid and much faster than pow(x,2).

Dragos
dmoroian is offline   Reply With Quote

Old   October 28, 2009, 17:16
Default
  #16
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 7
gina is on a distinguished road
hello Krishna Mohan, Perhaps I am not well express
I am trying to add a new eddy viscosity formulation (nu_t_plus) for turbulent boundary layers near smooth walls in near wall region and specially in the region when y+<=20

nu_t_plus= n_t/nu
in fluent we cant modiffy directly nu_t_plus for that i can write also:
nu_t=nu_t_plus*nu
and since I have airflow ro=1 --> mu_t=nu_t
than i can write
mu_t=nu_t_plus*nu
because in fluent we have acces for the value of mu_t and not nu_t

I have write my udf for mu_t and interpreted it than i have add it in viscosity turbulent udf panal to modify the nu_t_plus for y+<=20

have you understand what i want to do I

am new in udfs,and please I need your orientation if you want.
I thank you
gina is offline   Reply With Quote

Old   October 28, 2009, 18:27
Default
  #17
New Member
 
Vivek Sampath
Join Date: Oct 2009
Location: Houston
Posts: 6
Rep Power: 7
vsampath is on a distinguished road
Gina i have a similar problem i am interested in getting the y co-ordinate

this is my udf

#include "udf.h"
DEFINE_PROPERTY(cell_viscosity,cell,thread)
{
cell_t c;
real x[ND_ND];
real mu_lam;
real y;
Domain *domain = Get_Domain(1);
Thread *t;
y=C_WALL_DIST(c,t);
printf("y= %f \n",y);
mu_lam= 0.001002*(2-(y/0.01));
printf("MU= %f \n",mu_lam);
return mu_lam;

}


y=C_WALL_DIST(c,t); does not seem to work for me...... is their an alternative way???

thanks
joy2000 likes this.
vsampath is offline   Reply With Quote

Old   October 29, 2009, 04:24
Default
  #18
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
Quote:
Originally Posted by t.krishnamohan View Post
Hi,
... You can find the properties with wall functions near the wall region so, where is the question of eddy viscosity coming into picture. ...
What about low Re turbulence models? Do they use wall functions, too?
I suspect that Gina tries to compute the flow using a low Re turbulence model. The only issue that I see is the macro C_WALL_DIST(c,t) which is not documented and I don't know when is available.
Gina, is your udf still not working? Maybe you can write your own function for the value of wall distance.

Dragos
dmoroian is offline   Reply With Quote

Old   October 29, 2009, 04:33
Default
  #19
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 646
Rep Power: 10
dmoroian is on a distinguished road
Quote:
Originally Posted by vsampath View Post
...
real y;
...
printf("y= %f \n",y);
...
Hi Vivek,
Besides the fact that you are using an undocumented macro, your udf should work only for single precision. To get it to work for double precision too, use "%g" or "%e" instead of "%f" (in both places). Then you will be sure that what you see on the screen is the actual value of the variable.

Dragos
dmoroian is offline   Reply With Quote

Old   October 29, 2009, 13:58
Default
  #20
New Member
 
Vivek Sampath
Join Date: Oct 2009
Location: Houston
Posts: 6
Rep Power: 7
vsampath is on a distinguished road
thank you dmorian,


Is there a way i can get y coordinate. My geometry is a circular pipe where my viscosity varies with radius of the pipe.... for that purpose i need the y cordinate in each cell to be able to specify the visocity.... can you help me find a way....


thank you
vsampath is offline   Reply With Quote

Reply

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
setting value of turbulent intensity and turbulent viscosity ratio in wind tunnel nuimlabib Main CFD Forum 0 August 4, 2009 01:05
Turbulent viscosity in a riser ap FLUENT 8 April 19, 2003 09:00
effective? turbulent? laminar? viscosity MIssNancy FLUENT 3 December 3, 2002 00:53
Problem of Turbulent Viscosity Ratio Limited David Yang FLUENT 3 June 3, 2002 07:13
Turbulent viscosity Christian Holm Main CFD Forum 4 June 23, 2001 23:04


All times are GMT -4. The time now is 21:48.