Beruflich Dokumente
Kultur Dokumente
: www.learncax.com
: info@learncax.com
Note: Videos used in this blog (if any) are not included in this document. Please visit the
original blog to view the videos.
Writing a UDF i.e. a user defined function, has always been a challenging stuff for CFD
engineers those have never tried out one, nevertheless has been a matter of interest for
all. Hereby we present a short article to demonstrate the significance of writing a UDF in
CFD modeling with a simple test case that would help us all to develop an understanding
at the introductory level.
Prerequisite : The reader is already familiar with ANSYS FLUENT software and C
programming language.
The blog shall give us an overview of user defined function (UDF) with a short demo
session explaining how UDF are written using C programming and how they
are interpreted or compiled in a commercial CFD software like ANSYS FLUENT, and will
finally explain how they are called in the software.
What is a UDF ?
A UDF is basically a C program or a C function that can be dynamically loaded with ANSYS
FLUENT to enhance its standard features. The features of a typical UDF are as follows :
Copyrights : www.LearnCAx.com
Web
Email
: www.learncax.com
: info@learncax.com
Defining a UDF :
UDFs are implemented in FLUENT code as macros. The general format for a defined
macros is the macro name that is define followed by a underscore with the udf name
in parenthesis followed by a coma and then mentioning the variables that are to be
passed, as shown in examples below.
The definitions for DEFINE macros are contained in the udf.h header file; hence it is not
possible to have something else defined in the UDF that is outside the udf.h header file.
Let us say for example, if we want to define a customized velocity profile to a inlet we
have to define something like as shown below.
Example :
A UDF should begin with #include followed with "udf.h" followed by whichever macro to be
used can be defined, shown below.
Copyrights : www.LearnCAx.com
Web
Email
: www.learncax.com
: info@learncax.com
Copyrights : www.LearnCAx.com
Web
Email
: www.learncax.com
: info@learncax.com
First we will study a constant inlet velocity profile without the use of UDF, so the graph
shown below is of a constant velocity profile i.e. 0.01 m/s in the negative Y axis.
After simulation the velocity contours display that the flow is taking some distance to
develop the parabolic velocity profile (as seen below). This can be seen more clearly using
the velocity vectors wherein we see straight profile at the inlet and after some time we
see different color vectors in the same zone till the parabolic profile has been achieved.
Copyrights : www.LearnCAx.com
Web
Email
: www.learncax.com
: info@learncax.com
Figure 3: Comparative velocity profiles in the 2 cases (without & with UDF)
Figure 4: Comparative contour plots in the 2 cases (without & with UDF)
Copyrights : www.LearnCAx.com
Web
Email
: www.learncax.com
: info@learncax.com
Figure 5: Comparative velocity vector plots in the 2 cases (without & with UDF)
Thus comparing both cases in detail, what we see is, without the use of UDF the velocity
profile at the inlet was a straight line and along the length of the pipe it started
developing the actual velocity profile. In order to achieve the actual velocity profile right
at the inlet, we have to extend the inlet at least till a length equal to or greater than the
length the flow took to develop the profile. In this approach is where as with the use of
UDF we could have the real velocity profile that is supposed to be at the inlet.
Software Demo :
Below video shows a demo in ANSYS FLUENT software:
References :
1. A step-by-step UDF Example, ANSYS FLUENT UDF tutorial, An airfoil in a free shear
layer.
1 Akshay Residency, 50 Anand Park, Aundh, Pune 411007, India
Copyrights : www.LearnCAx.com
Web
Email
: www.learncax.com
: info@learncax.com
Copyrights : www.LearnCAx.com