0% found this document useful (0 votes)
272 views

03 Udf Temp PDF

The document describes a tutorial on modeling temperature dependent viscosity in ANSYS Fluent. It involves: 1) Defining a user-defined function (UDF) to specify viscosity as a function of temperature in each cell. 2) Setting up a 2D channel geometry where one wall is at 280K and the other at 290K. 3) Solving the energy and flow equations using the UDF to calculate variable viscosity based on local temperature.
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)
272 views

03 Udf Temp PDF

The document describes a tutorial on modeling temperature dependent viscosity in ANSYS Fluent. It involves: 1) Defining a user-defined function (UDF) to specify viscosity as a function of temperature in each cell. 2) Setting up a 2D channel geometry where one wall is at 280K and the other at 290K. 3) Solving the energy and flow equations using the UDF to calculate variable viscosity based on local temperature.
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/ 9

Tutorial: Temperature Dependent Viscosity

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:

• Interpret the UDF.

• Use the UDF for specifying the user-defined property.

• Postprocess the resulting data.

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

Figure 1: Schematic of the Problem

Strategy
The function cell viscosity is defined on a cell using DEFINE PROPERTY. Two real variables
are introduced:

• temp = the value of C T (cell, thread).

• mu = laminar viscosity (computed by the function).

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

Setup and Solution

Preparation

1. Copy the files (user-vis.msh and viscosity.c) to your working folder.

2. Use FLUENT Launcher to start the 2D version of ANSYS FLUENT.


For more information about FLUENT Launcher see Section 1.1.2, Starting
ANSYS FLUENT Using FLUENT Launcher in ANSYS FLUENT 12.0 User’s Guide.

3. Enable Double-Precision in the Options list.

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

1. Read the mesh file (user-vis.msh).


File −→ Read −→Mesh...
As the mesh file is read, ANSYS FLUENT will report the progress in the console.

Step 2: General Settings

1. Retain the default solver settings.


General

2. Check the mesh (see Figure 2).


General −→ Check
ANSYS FLUENT will perform various checks on the mesh and will report the progress
in the console. Make sure the minimum volume reported is a positive number.


c ANSYS, Inc. September 30, 2009 3
Temperature Dependent Viscosity

Figure 2: Mesh Display

Step 3: Models
Enable energy equation.

Models −→ Energy −→ Edit...


Step 4: User-Defined Functions
Interpret the UDF.
Define −→ User-Defined −→ Functions −→Interpreted...

1. Click the Browse... button to open the Select File dialog dialog box.

2. Select the file viscosity.c.

3. Specify the C preprocessor to be used for CPP Command Name.

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.

4. Retain the default value of 10000 for Stack Size.


The Stack Size should be 10000 unless the number of local variables in your function
causes the stack to overflow. Its value should be set to a number that is greater than
the number of local variables used.

5. Click Interpret and close the Interpreted UDFs dialog box.

Step 5: Materials
Modify the fluid material.

Materials −→ Fluid −→ Create/Edit...

1. Change Name to liquid metal.

2. Enter 8000 kg/m3 for Density.

3. Enter 680 j/kg-k for Cp (Specific Heat).

4. Enter 30 w/m-k for Thermal Conductivity.


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.

6. Click Change/Create and close Create/Edit Materials dialog box.

Step 6: Boundary Conditions

1. Set the boundary conditions for wall-2.


Boundary Conditions −→ wall-2 −→ Edit...
(a) Click Thermal tab and select Temperature from the Thermal Conditions list.
(b) Enter 280 K for Temperature.
(c) Click OK to close the Wall dialog box.

2. Set the boundary conditions for wall-3.


Boundary Conditions −→ wall-3 −→ Edit...
(a) Click Thermal tab and select Temperature from the Thermal Conditions list.
(b) Enter 290 K for Temperature.
(c) Click OK to close the Wall dialog box.

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


Boundary Conditions −→ velocity-inlet-6 −→ Edit...
(a) Select Components from the Velocity Specification Method drop-down list.
(b) Enter 0.001 m/s for X-Velocity.
(c) Click Thermal tab and enter 290 K for Temperature.
(d) Click OK to close the Velocity Inlet dialog box.

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


Boundary Conditions −→ pressure-outlet-7 −→ Edit...
(a) Click Thermal tab and enter 290 K for Backflow Total Temperature.
(b) Click OK to close the Pressure Outlet dialog box.

Step 7: Solution

1. Initialize the flow field from velocity-inlet-6.


Solution Initialization

2. Start the calculation for 300 iterations (see Figure 3).


Run Calculation
The solution converges in approximately 200 iterations.

6
c ANSYS, Inc. September 30, 2009
Temperature Dependent Viscosity

Figure 3: Scaled Residuals

Step 8: Postprocessing

1. Display filled contours of molecular viscosity.


Graphics and Animations −→ Contours −→ Set Up...
(a) Enable Filled in the Options list.
(b) Select Properties... and Molecular Viscosity from Contours of drop-down list.
(c) Click Display (Figure 4) and close the Contours dialog box.

Figure 4: Contours of Molecular Viscosity


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"

DEFINE_PROPERTY(user_vis, cell, thread)

float temp, mu;

temp = C_T(cell, thread);

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

if ( temp > 288. )


mu = 5.5e-3;

else if ( temp >= 286. )


mu = 143.2135 - 0.49725 * temp;

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

You might also like