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

How to change the turbulent viscosity via UDF!?

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 29, 2009, 13:17
Default
  #21
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
First see if you get the right values from C_WALL_DIST macro. If not, then it is rather simple to write your own udf that computes this distance using the BOUNDARY_FACE_GEOMETRY macro.

Dragos
joy2000 likes this.
dmoroian is offline   Reply With Quote

Old   October 29, 2009, 13:21
Default
  #22
New Member
 
Vivek Sampath
Join Date: Oct 2009
Location: Houston
Posts: 6
Rep Power: 17
vsampath is on a distinguished road
Thanks a lot.....

I tried the C_WALL_DIST.... the udf compiles but when initaliasing it shows error....... I will try with the Boundary_FACE_geometry..... where can i find an example on how to use that??
pratikddhoot likes this.
vsampath is offline   Reply With Quote

Old   October 29, 2009, 13:46
Default
  #23
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
I wouldn't give up using C_WALL_DIST macro. What error do you get? Could you post your udf? There is an error in your previous posted code.
Try first your code changing the line:
Code:
y=C_WALL_DIST(c,t);
with:
Code:
y=C_WALL_DIST(cell,thread);
...I hope you understand the error...


However, here is an untested example of how to compute it your self (should be valid for Gina, too):
Code:
real wallDist(cell_t c, Thread *t)
{
   real A[ND_ND], es[ND_ND], dr0[ND_ND];
   real ds, A_by_es;
   real y;
   int n;
   face_t f;
   Thread *tf;
   
   c_face_loop(c, t, n)         /* loops over all faces of a cell */
   {
      f = C_FACE(c,t,n);
      tf = C_FACE_THREAD(c,t,n);

      if(BOUNDARY_FACE_P(tf)) /* if the face is on boundary */
      {
         BOUNDARY_FACE_GEOMETRY(f,tf,A,ds,es,A_by_es,dr0);
         y = NV_DOT(es,dr0);

         return y;
      }
   }
   return 0;
}
Dragos
mm.abdollahzadeh likes this.
dmoroian is offline   Reply With Quote

Old   November 1, 2009, 16:04
Default
  #24
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 17
gina is on a distinguished road
Hi Vivek,
can you find any solution for your udf?
for me, I could not turn it to have good results
gina is offline   Reply With Quote

Old   November 1, 2009, 16:36
Default
  #25
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 17
gina is on a distinguished road
there is someone who can help me?

I would like to know whether a UDF turbulent viscosity permits me to provide a turbulent viscosity profile where the turbulent visosity is a function of wall normal distance y.
I know that, i must calculate the wall normal distance and define turbulent viscosity as a function of the distance.

but how to do this?? I AM NEW IN UDF ALSO IN C PROGRAMATION.....

please i need some help
gina is offline   Reply With Quote

Old   November 2, 2009, 01:46
Default
  #26
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Hi Gina,
I think your approach should work if you are using a low Re turbulence model (meaning without wall functions). Did you check if the C_WALL_DIST gives you the right values?

Dragos
dmoroian is offline   Reply With Quote

Old   November 2, 2009, 16:31
Default
  #27
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 17
gina is on a distinguished road
hi Dragos,
I use k-e model with enhanced wall treatment.
my Reynolds number= 5400.

Gina
gina is offline   Reply With Quote

Old   November 2, 2009, 18:28
Default
  #28
Senior Member
 
dmoroian's Avatar
 
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20
dmoroian is on a distinguished road
Do you have enough resolution near the wall? If you don't then enhanced wall treatment will apply a wall function and your back to what Krishna said before.
If the resolution is enough then what is the error you are complaining about?
Have you checked the C_WALL_DISTANCE macro if it provides the right value?
You can also attach a debugger to your udf and follow it step by step. There is an example on wiki describing how to do this (http://www.cfd-online.com/Wiki/Fluen..._udf_using_gdb).

Dragos
dmoroian is offline   Reply With Quote

Old   November 3, 2009, 14:05
Default
  #29
Member
 
gina
Join Date: Apr 2009
Posts: 56
Rep Power: 17
gina is on a distinguished road
dear dragos,
yes i have enough resolution near the wall.
no i have not checked the C_WALL_DISTANCE macro if it provides right value, how to do this?
the objective of my udf is to improved the nu_t formula in the near wall region when y_plus<=20.
can you send me your mail @ to explain better what i want to to
thank you

gina
gina is offline   Reply With Quote

Old   March 30, 2016, 15:29
Default
  #30
New Member
 
Pratik Dhoot
Join Date: Mar 2016
Location: Boston, MA
Posts: 20
Rep Power: 10
pratikddhoot is on a distinguished road
Quote:
Originally Posted by vsampath View Post
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
C_WALL_DIST is not a pre defined macro in udf. If you want the distance of a cell from a wall, you can use the centroid macro over a loop of all the cells and get distance from a particular side.

If you have used a centroid macro or any other method, please share. I am struggling with this too.
pratikddhoot is offline   Reply With Quote

Old   April 15, 2016, 18:57
Default
  #31
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,761
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
Quote:
Originally Posted by pratikddhoot View Post
C_WALL_DIST is not a pre defined macro in udf. If you want the distance of a cell from a wall, you can use the centroid macro over a loop of all the cells and get distance from a particular side.

If you have used a centroid macro or any other method, please share. I am struggling with this too.
Check out post #23 by Dragos. There's a UDF written that you can use.
LuckyTran is offline   Reply With Quote

Old   April 18, 2016, 11:33
Default
  #32
New Member
 
Pratik Dhoot
Join Date: Mar 2016
Location: Boston, MA
Posts: 20
Rep Power: 10
pratikddhoot is on a distinguished road
Quote:
Originally Posted by LuckyTran View Post
Check out post #23 by Dragos. There's a UDF written that you can use.
Thanks. But that still didn't help. I am still struggling to find the wall distance. If you have a better solution let me know.
pratikddhoot is offline   Reply With Quote

Old   January 17, 2017, 15:31
Default
  #33
New Member
 
Ekta J
Join Date: Jul 2014
Posts: 5
Rep Power: 12
Ekta J is on a distinguished road
Quote:
Originally Posted by dmoroian View Post
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
Hello, Does anyone know the correct udf for modifying turbulent viscosity in k-epsilon per phase model? (for Euler-Euler)

I am using the following udf (modified as per my knowledge, from the basic udf for k-epsilon mixture model) But it does not seem to be taking the correct value of k, epsilon etc from the fluent:

"
#include "udf.h"


DEFINE_TURBULENT_VISCOSITY(mu_t_ke_air,c,t)
{

real rho_g, KE_g, D_g, mu_t_g;

rho_g = C_R(c, t); /* gas phase density */
KE_g = C_K(c, t); /* gas phase Kinetic energy */
D_g = C_D(c, t); /* gas phase epsilon */

mu_t_g= 0.09*rho_g*KE_g*KE_g/D_g;

C_UDMI(c,t,2) = mu_t_g; // (Calculated above)

return mu_t_g;

}
"
Ekta J is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 16:27.