[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.3.26 DEFINE_TURBULENT_VISCOSITY



Description


You can use DEFINE_TURBULENT_VISCOSITY to specify a custom turbulent viscosity function for the Spalart-Allmaras, $k$- $\epsilon$, and $k$- $\omega$ turbulence models for single-phase applications. In addition, for 3d versions of ANSYS FLUENT you can specify a subgrid-scale turbulent viscosity UDF for the large eddy simulation model. For Eulerian multiphase flows, turbulent viscosity UDFs can be assigned on a per-phase basis, and/or to the mixture, depending on the turbulence model. See Table  2.3.6 for details.


Table 2.3.6: Eulerian Multiphase Model and DEFINE_TURBULENT_VISCOSITY UDF Usage
Turbulence Model Phase that Turbulent Viscosity UDF Is Specified On
$k$- $\epsilon$ Mixture
mixture,
primary and secondary phases
$k$- $\epsilon$ Dispersed
primary and
secondary phases
$k$- $\epsilon$ Per-Phase
primary and
secondary phases



Usage



DEFINE_TURBULENT_VISCOSITY( name, c, t)


Argument Type Description
symbol name UDF name.
cell_t c Cell index.
Thread *t Pointer to cell thread on which the turbulent viscosity
  is to be applied.
   
Function returns  
real  
   

There are three arguments to DEFINE_TURBULENT_VISCOSITY: name, c, and t. You supply name, the name of the UDF. c and t are variables that are passed by the ANSYS FLUENT solver to your UDF. Your UDF will need to return the real value of the turbulent viscosity to the solver.



Example 1 - Single Phase Turbulent Viscosity UDF


The following UDF, named user_mu_t, defines a custom turbulent viscosity for the standard $k$- $\epsilon$ turbulence model. Note that the value of M_keCmu in the example is defined through the graphical user interface, but made accessible to all UDFs. The source code can be interpreted or compiled in ANSYS FLUENT.

/********************************************************************
    UDF that specifies a custom turbulent viscosity for standard
    k-epsilon formulation
*********************************************************************/

#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);

  mu_t = M_keCmu*rho*SQR(k)/d;

  return mu_t;
}



Example 2 - Multiphase Turbulent Viscosity UDF


/********************************************************************
    Custom turbulent viscosity functions for each phase and the
    mixture in a two-phase multiphase flow
*********************************************************************/
#include "udf.h"

DEFINE_TURBULENT_VISCOSITY(mu_t_ke_mixture, c, t)
{
  real mu_t;
  real rho = C_R(c,t);
  real k   = C_K(c,t);
  real d   = C_D(c,t);
  real cmu = M_keCmu;

  mu_t = rho*cmu*k*k/d;

  return mu_t;
}

DEFINE_TURBULENT_VISCOSITY(mu_t_ke_1, c, t)
{
  Thread *tm = lookup_thread_by_id(DOMAIN_SUPER_DOMAIN(THREAD_DOMAIN(t)),
                                        t->id);
  CACHE_T_SV_R (density,   t,   SV_DENSITY);
  CACHE_T_SV_R (mu_t,      t,   SV_MU_T);
  CACHE_T_SV_R (density_m, tm,  SV_DENSITY);
  CACHE_T_SV_R (mu_t_m,    tm,  SV_MU_T);

  return density[c]/density_m[c]*mu_t_m[c];
}

DEFINE_TURBULENT_VISCOSITY(mu_t_ke_2, c, t)
{
  Thread *tm = lookup_thread_by_id(DOMAIN_SUPER_DOMAIN(THREAD_DOMAIN(t)),
                                        t->id);
  CACHE_T_SV_R (density,   t,   SV_DENSITY);
  CACHE_T_SV_R (mu_t,      t,   SV_MU_T);
  CACHE_T_SV_R (density_m, tm,  SV_DENSITY);
  CACHE_T_SV_R (mu_t_m,    tm,  SV_MU_T);

  return density[c]/density_m[c]*mu_t_m[c];
}



Hooking a Turbulent Viscosity UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_TURBULENT_VISCOSITY is interpreted (Chapter  4) or compiled (Chapter  5), the function name(s) that you specified in the DEFINE macro argument(s) (for example user_mu_t for single phase, or mu_t_ke_mixture, mu_t_ke_1, and mu_t_ke_2 for multiphase) will become visible and selectable in the Viscous Model dialog box in ANSYS FLUENT. See Section  6.2.26 for details.


next up previous contents index Previous: 2.3.25 DEFINE_TURB_SCHMIDT UDF
Up: 2.3 Model-Specific DEFINE Macros
Next: 2.3.27 DEFINE_VR_RATE
Release 12.0 © ANSYS, Inc. 2009-01-14