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

UDF for Turbulent Viscosity

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 21, 2007, 11:23
Default UDF for Turbulent Viscosity
  #1
Lourival
Guest
 
Posts: n/a
Hy every one, I'm trying to make an UDF to calculate the Turbulent Vicosity using the LES model in FLUENT.

Actually I would like to change the damping function near the wall, once the standard and the Werner and Wengle model can not give accurate results on the transition Re.

I want to make a damping function using the van Driest formulae, changing the Turbulent Viscosity of the LES model. For the Smagorinsky approach is done and here is the implementation:

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

DEFINE_TURBULENT_VISCOSITY(van_driest,c,t) {

const real Cs = 0.1 ; /* Smagorinsky */

/* Threads Near the Cylinder */

const int th_ds_zn_xn = 19 ;

const int th_ds_zn_xp = 21 ;

const int th_ds_zp_xn = 18 ;

const int th_ds_zp_xp = 20 ;

const int th_us_z_neg = 22 ;

const int th_us_z_pos = 23 ;

const int th_w_zn_xn = 15 ;

const int th_w_zn_xp = 17 ;

const int th_w_zp_xn = 14 ;

const int th_w_zp_xp = 16 ;

Thread *thread_check ;

face_t face_celula ;

int n ;

real y_plus ; /* Y+ */

real volume ; /* Cell Volume */

real viscosidade ; /* Turb Viscosidade */

real strain_rate_mag ; /* Strain Rate = S^2 */

real van_driest_amortecimento ; /* van Driest Damping */

/*Message("\n ***** UDF VISCOSITY ***** \n");*/

/* Y+ */

y_plus = 0 ;

c_face_loop(c,t,n)

{

face_celula= C_FACE(c,t,n);

thread_check= C_FACE_THREAD(c,t,n);

if (( THREAD_ID(t)== th_ds_zn_xn ) || ( THREAD_ID(t)== th_ds_zn_xp ) || ( THREAD_ID(t)== th_ds_zp_xn ) ||

( THREAD_ID(t)== th_ds_zp_xp ) || ( THREAD_ID(t)== th_us_z_neg ) || ( THREAD_ID(t)== th_us_z_pos ) ||

( THREAD_ID(t)== th_w_zn_xn ) || ( THREAD_ID(t)== th_w_zn_xp ) || ( THREAD_ID(t)== th_w_zp_xn ) ||

( THREAD_ID(t)== th_w_zp_xp ) )

{

y_plus = F_STORAGE_R(face_celula, thread_check , SV_WALL_YPLUS);

}

}

volume=0;

volume= pow(C_VOLUME(c,t), 0.33333333333333) ;

strain_rate_mag= 0;

strain_rate_mag=C_STRAIN_RATE_MAG(c,t) ;

/* Check if it is far from the wall, if yes, y+= 0, then there is NO van Driest damping, only the Smagorinsky model, otherwise use the van Driest model that is zero near the wall, this is the reason that must be a function of Y+ NEAGTIVE */

if (y_plus != 0)

{

van_driest_amortecimento = pow( (1 - exp( pow((-y_plus/25), 3) ) ), 0.5) ;

}

else

{

van_driest_amortecimento = 1;

}

viscosidade = pow( (Cs*volume*van_driest_amortecimento), 2)*strain_rate_mag*C_R(c,t); ;

return viscosidade ;

}

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

My question concern the Dynamic model, how can I calculate the Leonard and the Resolved stress once I can not use

C_STORAGE_R(c,t,SV_LES_LSTRESS)

C_STORAGE_R(c,t,SV_LES_MSTRESS)

Does someone can help me???

Hugs

Lourival

  Reply With Quote

Old   June 5, 2010, 17:16
Default
  #2
New Member
 
Rajneesh
Join Date: Jun 2010
Posts: 1
Rep Power: 0
rajneesh is on a distinguished road
Hi Lourival,

I am trying your Van Driest damping function in smagorinsky. Have you thoroughly tested it, does it work fine?
And I hope these numbers (i.e. const int th_ds_zn_xn = 19 ) are the wall IDs?

Thanks
Rajneesh
rajneesh is offline   Reply With Quote

Old   August 27, 2012, 12:41
Default urgent
  #3
New Member
 
hava
Join Date: Aug 2012
Posts: 11
Rep Power: 14
shmhava is on a distinguished road
Hello Lourival,

I hope you or someone else would answer my post.
I'm trying for a very long time to simulate a simple fully developed flow in a square duct (4 walls). The flow is periodic in the streamwise direction. The Re number is 10504. I'm using the LES approach with smagorinsky constant equal to 0.1. I don't know why, but the u_rms, or more precisely, the location of the peak of u_rms is in a very wrong place. According to the literature, it should be somewhere between y+=15-17, but to me it's in y+=27.
I thought that the reason could be that fluent doesn't use the van-driest damping function. So, I created udf file with the code you wrote, but now I get even a more strange thing. The turbulent viscosity on my walls becomes large instead of being zero.
What am I doing wrong?
Please help me,
Hava
shmhava is offline   Reply With Quote

Old   October 13, 2012, 04:09
Default Error in running UDF
  #4
New Member
 
sajad
Join Date: Oct 2012
Posts: 1
Rep Power: 0
s.a.moshizi is on a distinguished road
Hy every one, I'm trying to make an UDF to calculate the Turbulent Vicosity using the k-omega SST model in FLUENT.

I wrote the following UDF:

/************************************************** ******************/
/* UDF that specifies a custom turbulent viscosity for SST */
/* k-omega formulation using DEFINE_TURBULENT_VISCOSITY */
/************************************************** ******************/

#include "udf.h"
#include "math.h"
#include "stdio.h"


/* *********************************************** */
DEFINE_TURBULENT_VISCOSITY(user_mu_t, c, t)
{
int wall_ID = 14;
Domain*d = Get_Domain(1);
Thread*t_wall = Lookup_Thread(d,wall_ID);
/* real x[ND_ND]; */
real tauwall3;
real wallfricv1;
real mu_t;
real a1;
real Rt;
real Rw = 2.61;
real Rk = 6.0;
real Rb = 8.0;
real a1_hiRe = 0.553;
real a0 = 1.0/9.0;
real b0 = 0.071;
real aS;
real bS;
real f2;
real Fsst ;
real yplus;
thread_loop_c(t,d)
{

begin_c_loop(c,t)
{
real rho = C_R(c,t_wall);
real rho1 = C_R(c,t);
real k = C_K(c,t);
real omg = C_O(c,t);
real mu_L = C_MU_L(c,t_wall);
real mu_L1 = C_MU_L(c,t);
real s = C_STRAIN_RATE_MAG(c,t_wall);
real Cmu = M_keCmu ;
real y = C_WALL_DIST(c,t);
/* real y = x[1]; */
real DUDX2 = C_DUDX(c,t_wall)+C_DUDX(c,t_wall);
real DUDY_DVDX = C_DUDY(c,t_wall)+C_DVDX(c,t_wall);
real DVDX_DUDY = C_DVDX(c,t_wall)+C_DUDY(c,t_wall);
real DVDY2 = C_DVDY(c,t_wall)+C_DVDY(c,t_wall);

tauwall3 = mu_L*sqrt( C_DUDX(c,t_wall)*DUDX2 + C_DUDY(c,t_wall)*DUDY_DVDX + C_DVDX(c,t_wall)*DVDX_DUDY + C_DVDY(c,t_wall)*DVDY2 );

wallfricv1=sqrt(tauwall3/rho);
yplus = y*rho*wallfricv1/mu_L;
Fsst = 0.1 + (1.0-0.1*tanh(pow(0.03*yplus,4))) * (0.9+0.1*tanh(pow(0.03*yplus,8)));

Rt = k*rho1/(omg*mu_L1);
aS = ( b0/3 + Rt/Rk )/( 1 + Rt/Rk );
a1 = (a1_hiRe/aS)*((a0+Rt/Rw)/(1+Rt/Rw));

f2 = tanh( ( MAX( (2.0*sqrt(k)/(b0*omg*y)),(500*mu_L1/(omg*y*y*rho1)) ) )*( MAX( (2.0*sqrt(k)/(b0*omg*y)),(500*mu_L1/(omg*y*y*rho1)) ) ) );

mu_t = Fsst*MIN((rho1*k/omg),(a1*rho1*k/(s*f2)));


}
end_c_loop(c,t)
}
return mu_t;

}

But as I am running it it gives me the following error:

Error:
FLUENT received fatal signal (ACCESS_VIOLATION)
1. Note exact events leading to error.
2. Save case/data under new name.
3. Exit program and restart to continue.
4. Report error to your distributor.
Error Object: #f

Can anybody help me please?
s.a.moshizi 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
viscosity in UDF! denhan FLUENT 0 April 6, 2007 02:12
subgrid turbulent viscosity for UDF in LES David TAIEB FLUENT 0 April 2, 2007 09:27
Help !! UDF for second phase viscosity. yong FLUENT 2 January 24, 2007 12:11
VISCOSITY UDF AdN FLUENT 0 May 23, 2006 06:33
Help - UDF for solid shear viscosity nbh2801 FLUENT 0 April 21, 2006 08:49


All times are GMT -4. The time now is 23:44.