0% found this document useful (0 votes)
13 views7 pages

Udf Temp

This tutorial focuses on modeling liquid metal flow through a channel, using temperature-dependent viscosity defined by a User Defined Function (UDF). It provides step-by-step instructions for setting up the simulation in FLUENT, including grid setup, model configuration, UDF compilation, material properties, boundary conditions, and solution procedures. The results demonstrate how viscosity changes with temperature as the fluid interacts with the channel walls at different temperatures.

Uploaded by

Rashaq Alheety
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

Udf Temp

This tutorial focuses on modeling liquid metal flow through a channel, using temperature-dependent viscosity defined by a User Defined Function (UDF). It provides step-by-step instructions for setting up the simulation in FLUENT, including grid setup, model configuration, UDF compilation, material properties, boundary conditions, and solution procedures. The results demonstrate how viscosity changes with temperature as the fluid interacts with the channel walls at different temperatures.

Uploaded by

Rashaq Alheety
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Tutorial 3.

Temperature Dependent Viscosity

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

c Fluent Inc. May 16, 2002 3-1


Temperature Dependent Viscosity

wall at 290 K wall at 280 K

inlet outlet

symmetry

Figure 3.1: Problem Specification

3-2 c Fluent Inc. May 16, 2002


Temperature Dependent Viscosity

Setup and Solution


Step 1: Grid

1. Copy the files user-vis.msh and viscosity.c to your working directory.

2. Read the grid file user-vis.msh.

3. Check and display the grid.

Grid Mar 27, 2002


FLUENT 6.0 (2d, segregated, lam)

Figure 3.2: Graphics Display of the Grid

Step 2: Models

1. Keep the default solver settings.

2. Enable energy equation.

Step 3: Compile the Interpreted UDF’s


The user defined function viscosity.c is used to specify the temperature-dependent molecular
viscosity in each cell. In a separate editor, view the UDF, viscosity.c, and familiarise your-
self with it’s contents. When you understand the structure and function of the UDF to your
satisfaction, interpret the UDF.

c Fluent Inc. May 16, 2002 3-3


Temperature Dependent Viscosity

/**************************************************************/
/* */
/* User-Defined Functions for temperature-dependent viscosity */
/* */
/**************************************************************/

#include "udf.h"

DEFINE_PROPERTY(user_vis, cell, thread)

float temp, mu_lam;

temp = C_T(cell, thread);

/* If the temperature is high, use a small, constant viscosity */

if (temp > 288.)


mu_lam = 5.5e-3;

/* Otherwise, use a profile to get higher viscosity values */

else if (temp >= 286. && temp <= 288.)


mu_lam = 143.2135 - 0.49725 * temp;

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.

2. Specify the C preprocessor to be used in the CPP Command Name field.

3. Keep the default Stack Size setting of 10000, unless the number of local variables in
your function will cause the stack to overflow.

3-4 c Fluent Inc. May 16, 2002


Temperature Dependent Viscosity

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.

6. When the compilation is over, click Close to close the panel.


If you keep the panel open, the Compile button can be used repeatedly while you are in
the process of debugging your function, since you can make changes with an editor in
a separate window, and continue to compile until no errors are reported.

Step 4: Materials

1. Modify the fluid material.


(a) Change Name to liquid metal.
(b) Set Density and Cp to 8000 and 680 respectively.
(c) Set Thermal Conductivity to 30 and select the user-defined function user-vis for
Viscosity.

Step 5: Boundary Condition

1. Set the boundary conditions for the wall-2 zone.


(a) Set Temperature to 280 and retain the default values for the other parameters.

2. Set the boundary conditions for the wall-3 zone.


(a) Set Temperature to 290 and retain the default values for the other parameters.

3. Set the boundary conditions for the velocity-inlet-6 zone.


(a) Select Components as the Velocity Specification Method and set the X-Velocity to
0.001.
(b) Set Temperature to 290 and retain the default values for the other parameters.

4. Set the boundary conditions for the pressure-outlet-7 zone.


(a) Set the Backflow Total Temperature to 290 and retain the default values for the
other parameters.

5. Retain the default settings for the other zones.

c Fluent Inc. May 16, 2002 3-5


Temperature Dependent Viscosity

Step 6: Solution

1. Initialize the flow field using the boundary conditions set at velocity-inlet-6.

2. Enable the plotting of residuals during calculation.

3. Start by requesting 300 iterations.


Residuals
continuity
x-velocity
1e+01
y-velocity
energy
1e+00

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

Scaled Residuals Mar 27, 2002


FLUENT 6.0 (2d, segregated, lam)

Figure 3.3: Scaled Residuals

3-6 c Fluent Inc. May 16, 2002


Temperature Dependent Viscosity

Step 7: Postprocessing

1. Display filled contours of molecular viscosity.

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

Contours of Molecular Viscosity (kg/m-s) Mar 27, 2002


FLUENT 6.0 (2d, segregated, lam)

Figure 3.4: Contours of Molecular Viscosity

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.

c Fluent Inc. May 16, 2002 3-7

You might also like