
[Sponsors] 
September 29, 2009, 13:35 
How to change the turbulent viscosity via UDF!?

#1 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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? 

October 20, 2009, 02:52 
Random value mu_t

#2 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
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 = ... ... 

October 23, 2009, 14:29 
how to write in udf: take the default value?

#3 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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 

October 23, 2009, 14:34 
how to write in udf: take the default value?

#4 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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? 

October 23, 2009, 15:37 

#5 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
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; Code:
mu_t = C_MU_T(c,t); 

October 23, 2009, 16:35 
it run but!!!

#6 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
the calcul run but the results is not good! can i send you my udf to see it?


October 23, 2009, 17:14 

#7 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
Send me your code, but I will not be able to look at it until Tuesday.


October 23, 2009, 17:32 
my udf

#8 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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; } 

October 25, 2009, 13:35 

#9 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
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]; Dragos 

October 26, 2009, 17:26 

#10 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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; } 

October 26, 2009, 21:22 

#11 
Member
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 9 
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 

October 27, 2009, 15:15 

#12 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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 

October 27, 2009, 20:50 

#13 
Member
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 9 
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 

October 27, 2009, 20:53 

#14 
Member
Krishna
Join Date: Oct 2009
Posts: 34
Rep Power: 9 
If you want to run the UDF, change the term SQR(k) to pow(k,2.0), SQR() is not a valid function.
Rgds, 

October 28, 2009, 10:00 

#15 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
There is a macro defined by Fluent in global.h:
Code:
#define SQR(a) ((a)*(a)) Dragos 

October 28, 2009, 16:16 

#16 
Member
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 10 
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 

October 28, 2009, 17:27 

#17 
New Member
Vivek Sampath
Join Date: Oct 2009
Location: Houston
Posts: 6
Rep Power: 9 
Gina i have a similar problem i am interested in getting the y coordinate
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 

October 29, 2009, 03:24 

#18  
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
Quote:
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 

October 29, 2009, 03:33 

#19 
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 13 
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 

October 29, 2009, 12:58 

#20 
New Member
Vivek Sampath
Join Date: Oct 2009
Location: Houston
Posts: 6
Rep Power: 9 
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 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
wrong results after use UDF turbulent viscosity  lehoanganh07  Fluent UDF and Scheme Programming  0  July 21, 2014 11:12 
hel (turbulent viscosity ratio limited) for supersonic combustion problem  omar.2002bh  FLUENT  2  September 5, 2012 11:04 
Turbulent viscosity and shear rate  shib  FLUENT  0  June 22, 2010 12:44 
turbulent viscosity in ke model  orlik  Fluent UDF and Scheme Programming  0  March 31, 2010 11:48 
effective? turbulent? laminar? viscosity  MIssNancy  FLUENT  3  December 3, 2002 00:53 