03 Udf Temp PDF
03 Udf Temp PDF
Introduction
This tutorial examines the flow of liquid metal through a two dimensional channel. The
viscosity of the liquid metal is modeled as a function of the temperature using a user-defined
function (UDF).
This tutorial demonstrates how to do the following:
Prerequisites
This tutorial is written with the assumption that you have completed Tutorial 1 from
ANSYS FLUENT 12.0 Tutorial Guide, and that you are familiar with the ANSYS FLUENT
navigation pane and menu structure. Some steps in the setup and solution procedure will
not be shown explicitly.
For more details about UDFs, see ANSYS FLUENT 12.0 UDF Manual.
Problem Description
The problem considered in this tutorial is shown schematically in Figure 1. As the symmetry
condition is imposed at the centerline, only half the channel is modeled, The wall of the
channel is split into two parts: wall-2, which has a temperature of 280 K and wall-3,
which has a temperature of 290 K. The temperature-dependent viscosity of the liquid metal
will respond to this change in wall temperature.
c ANSYS, Inc. September 30, 2009 1
Temperature Dependent Viscosity
Strategy
The function cell viscosity is defined on a cell using DEFINE PROPERTY. Two real variables
are introduced:
The value of the tempertaure is checked and based upon its range, the appropriate value of
mu is computed. At the end of the function, the computed value for mu is returned to the
solver.
The molecular viscosity of the liquid metal will be defined as a function of temperature
which is given as follows:
5.5 × 10−3 kg/m-s T > 288 K
µ= 143.2135 − 0.49725 T kg/m-s 286 ≤ T ≤ 288 K (1)
T < 286 K 1 kg/m-s
where,
T = temperature of the fluid (K)
µ = molecular viscosity of the fluid (kg/m-s).
2
c ANSYS, Inc. September 30, 2009
Temperature Dependent Viscosity
Preparation
4. Click the UDF Compiler tab and ensure that the Setup Compilation Environment for
UDF is enabled.
The path to the .bat file which is required to compile the UDF will be displayed as soon
as you enable Setup Compilation Environment for UDF.
If the UDF Compiler tab does not appear in the FLUENT Launcher dialog box by default,
click the Show More >> button to view the additional settings.
The Display Options are enabled by default. Therefore, after you read in the mesh, it
will be displayed in the embedded graphics window.
Step 1: Mesh
c ANSYS, Inc. September 30, 2009 3
Temperature Dependent Viscosity
Step 3: Models
Enable energy equation.
1. Click the Browse... button to open the Select File dialog dialog box.
4
c ANSYS, Inc. September 30, 2009
Temperature Dependent Viscosity
If you want to use the C preprocessor that ANSYS, Inc. has supplied, you can enable
the Use Contributed CPP option.
Step 5: Materials
Modify the fluid material.
c ANSYS, Inc. September 30, 2009 5
Temperature Dependent Viscosity
5. Select user-defined from the Viscosity drop-down list and click OK to close User-Defined
Functions dialog box.
A Question dialog box opens, asking whether to overwrite air. Click Yes.
Step 7: Solution
6
c ANSYS, Inc. September 30, 2009
Temperature Dependent Viscosity
Step 8: Postprocessing
c ANSYS, Inc. September 30, 2009 7
Temperature Dependent Viscosity
Appendix
The UDF (viscosity.c) is used to specify the temperature-dependent molecular viscosity
in each cell. You can open the UDF in a separate editor and view its contents to understand
the structure and function.
The contents of the UDF file are as follows:
/**************************************************************/
/* */
/* User-Defined Function for temperature-dependent viscosity */
/* */
/* Author: Liz Marshall */
/* */
/**************************************************************/
#include "udf.h"
else
mu = 1.0;
}
return mu;
}
The above equations are applied to each and every cell which is associated to the thread
(in this case a fluid zone). This UDF will be called from the Create/Edit Materials dialog
box where the user-defined is specified for Viscosity.
Results
Figure 4 shows that when the warmer fluid enters the channel from the left and encounters
the cooler wall further on, its viscosity increases according to the user-defined viscosity
relation.
8
c ANSYS, Inc. September 30, 2009
Temperature Dependent Viscosity
Summary
This tutorial demonstrated the use of UDFs for specifying a user-defined property.
Note: This capability is available only for viscosity and thermal conductivity (density and
specific heat cannot be specified through UDFs).
Extra: When you are comfortable with this exercise, you can try modifying the UDF to
specify temperature-dependent thermal conductivity. You can copy the source code for
the viscosity UDF and change the appropriate lines to calculate thermal conductivity.
You need to access the thermal conductivity UDF in the Create/Edit Materials dialog
box in the same way as viscosity.
c ANSYS, Inc. September 30, 2009 9