How to change the turbulent viscosity via UDF!?
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? |
Random value mu_t
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:
... |
how to write in udf: take the default value?
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 |
how to write in udf: take the default value?
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? |
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; Code:
mu_t = C_MU_T(c,t); |
it run but!!!
the calcul run but the results is not good! can i send you my udf to see it?
|
Send me your code, but I will not be able to look at it until Tuesday.
|
my udf
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; } |
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 |
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; } |
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 |
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 |
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 |
If you want to run the UDF, change the term SQR(k) to pow(k,2.0), SQR() is not a valid function.
Rgds, |
There is a macro defined by Fluent in global.h:
Code:
#define SQR(a) ((a)*(a)) Dragos |
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 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 |
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 |
Quote:
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 |
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 |
All times are GMT -4. The time now is 20:34. |