Udf Temp
Udf Temp
Purpose
This tutorial examines the modeling of a liquid metal flow through a two dimensional
channel. The viscosity of the liquid metal is modeled as a function of the temperature
utilizing a User Defined Function (UDF).
Prerequisites
This tutorial assumes that you are familiar with FLUENT interface and that you have
a good understanding of the basic setup and solution procedures. If not, the FLUENT
Tutorial Guide will provide you with the necessary experience. If you have not used UDF’s,
it would be helpful to review the FLUENT UDF Manual.
Problem Description
The problem to be considered is shown schematically in Figure 3.1. Only half the channel is
modeled, as the symmetry condition is imposed at the centerline. The wall of the channel is
split into two parts: wall-2, which has a temperature of 280 K specified for it, 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.
The molecular viscosity of the liquid metal will be defined as a function of temperature.
The relationship is given as follows:
( )
5.5e − 3 T > 288K
µ=
143.2135 − 0.49725T 286K ≥ T ≤ 288K
where,
T = temperature of the fluid (K)
µ = molecular viscosity of the fluid (kg/m-s).
inlet outlet
symmetry
Step 2: Models
/**************************************************************/
/* */
/* User-Defined Functions for temperature-dependent viscosity */
/* */
/**************************************************************/
#include "udf.h"
else
mu_lam = 1.0;
return mu_lam;
/* The above equations are applied to each and every cell which
is associated to the thread ( in this case a fluid zone).
This user defined function will be called from the material panel where
under viscosity, user defined function is specified. */
Note: Additional comments have been inserted to describe how the code works.
For more information on interpreted UDF’s, refer to Section 7.2, Interpreted UDFs, in the
UDF Manual.
1. Compile the UDF viscosity.c using the Interpreted UDFs panel. Enter (viscosity.c) under
Source File Name.
Make sure that the C source code for your UDF and your file reside in your working
directory. If the source code is not in your working directory, then when you compile
the UDF, you must enter the complete path of the file in the Interpreted UDFs panel,
instead of just the file name.
3. Keep the default Stack Size setting of 10000, unless the number of local variables in
your function will cause the stack to overflow.
Set the Stack Size to a number that is greater than the number of local variables used.
4. Select the Use Contributed CPP option if you want to use the C preprocessor that
Fluent Inc. has supplied, instead of using your own.
5. Click Compile.
Step 4: Materials
Step 6: Solution
1. Initialize the flow field using the boundary conditions set at velocity-inlet-6.
1e-01
1e-02
1e-03
1e-04
1e-05
1e-06
1e-07
1e-08
0 25 50 75 100 125 150 175 200 225
Iterations
Step 7: Postprocessing
1.00e+00
9.01e-01
8.01e-01
7.02e-01
6.02e-01
5.03e-01
4.03e-01
3.04e-01
2.04e-01
1.05e-01
5.50e-03
Results
The above contour plot shows that, 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.
Summary
This tutorial has demonstrated the use of UDFs for specifying a user-defined property.
Note that this capability is available for viscosity and thermal conductivity only (density
and specific heat cannot be specified through UDFs).
When you are comfortable with the present exercise, try modifying the UDF to specify a
temperature-dependent thermal conductivity. You can copy the source code for the viscosity
UDF and change the appropriate lines to calculate thermal conductivity. The thermal
conductivity UDF is then accessed in the materials panel in the same way as viscosity.