CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Fluent UDF and Scheme Programming (http://www.cfd-online.com/Forums/fluent-udf/)
-   -   UDF for Turbulent Viscosity (http://www.cfd-online.com/Forums/fluent-udf/46102-udf-turbulent-viscosity.html)

Lourival September 21, 2007 10:23

UDF for Turbulent Viscosity
 
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


rajneesh June 5, 2010 16:16

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

shmhava August 27, 2012 11:41

urgent
 
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

s.a.moshizi October 13, 2012 03:09

Error in running UDF
 
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?


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