2.3.46.  DEFINE_TURBULENT_VISCOSITY

2.3.46.1. Description

You can use DEFINE_TURBULENT_VISCOSITY to specify a custom turbulent viscosity function for the Spalart-Allmaras, - , and - 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.7: Eulerian Multiphase Model and DEFINE_TURBULENT_VISCOSITY UDF Usage for details.

Table 2.7:  Eulerian Multiphase Model and DEFINE_TURBULENT_VISCOSITY UDF Usage

Turbulence Model

Phase that Turbulent Viscosity UDF Is Specified On

- Mixture

mixture, primary and secondary phases

- Dispersed

primary and secondary phases

- Per-Phase

primary and secondary phases


2.3.46.2. 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.

2.3.46.3. Example 1 - Single Phase Turbulent Viscosity UDF

The following UDF, named user_mu_t, defines a custom turbulent viscosity for the standard - 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;
 } 

2.3.46.4. 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];
 } 

2.3.46.5. Hooking a Turbulent Viscosity UDF to ANSYS Fluent

After the UDF that you have defined using DEFINE_TURBULENT_VISCOSITY is interpreted (Interpreting UDFs) or compiled (Compiling UDFs), 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 Hooking DEFINE_TURBULENT_VISCOSITY UDFs for details.


Release 18.2 - © ANSYS, Inc. All rights reserved.