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

Udf Porus

This tutorial demonstrates the modeling of a position-dependent porous plug in a two-dimensional channel flow using a User Defined Function (UDF) in FLUENT. It provides a step-by-step guide on compiling the UDF, setting up the grid, defining models and materials, linking UDFs, and setting boundary conditions for the simulation. The results indicate that the fluid flows preferentially near the bottom of the channel due to the influence of the source term on the axial momentum.

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)
14 views7 pages

Udf Porus

This tutorial demonstrates the modeling of a position-dependent porous plug in a two-dimensional channel flow using a User Defined Function (UDF) in FLUENT. It provides a step-by-step guide on compiling the UDF, setting up the grid, defining models and materials, linking UDFs, and setting boundary conditions for the simulation. The results indicate that the fluid flows preferentially near the bottom of the channel due to the influence of the source term on the axial momentum.

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

Position Dependent Porous Media

Purpose
The purpose of this tutorial is to illustrate the modelling of a position dependent porous
plug in a two dimensional channel flow with the help of 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 1.1. The domain is divided
into two fluid zones. In zone fluid-2 a x-momentum source is patched with the help of a
user defined function (UDF) which effectively behaves like a porous plug.

porous plug

inlet outlet

Figure 1.1: Problem specification

c Fluent Inc. May 22, 2002 1-1


Position Dependent Porous Media

Setup and Solution


Step 1: Compile the UDF’s
This UDF can be compiled as well as interpreted.In this tutorial we are using the compiled
option, so it is neccessary to compile the UDF before setting up the case.
In a separate editor, view the UDF porous plug.c, and familiarize yourself with it’s contents.
When you understand the structure and function of the UDF to your satisfaction, interpret
the UDF.
The contents of the UDF file if viewed will be as follows:

/*******************************************************************/
/* */
/* Position-Dependent Porous Media */

/* */
/*******************************************************************/

#include "udf.h"

DEFINE_SOURCE(xmom_source, cell, thread, dS, eqn)

#define c2 100.0

real x[ND_ND];
float con, source;

C_CENTROID(x, cell, thread);


con = c2*0.5*C_R(cell, thread)*x[1];

source = - con*fabs(C_U(cell, thread))*C_U(cell, thread);


dS[eqn] = - 2.*con*fabs(C_U(cell, thread));

return source;

1. Copy porous plug.msh and porous plug.c to your working directory.


The user defined function porous plug.c is used to patch a x-momentum source term
dependent on y position in part of the fluid domain (i.e. in fluid-2
2. Make a directory to put your library in:
mkdir lib porous
cd lib porous

3. Under lib porous directory, create two subdirectories named src and ntx86.
4. Copy the source file (porous plug.c) to the src directory.
5. Under ntx86 directory, create a subdirectory called 2d and copy the files makefile nt.udf
and user nt.udf to it. Use the following path to obtain both the files:
\Fluent.inc\fluent6.0\src

1-2 c Fluent Inc. May 22, 2002


Position Dependent Porous Media

6. Rename the makefile nt.udf file as makefile.

7. Modify the user nt.udf file.


(a) Change the last three lines of the code as shown below:
SOURCES = $(SRC)porous plug.c
VERSION = 2d
PARALLEL NODE = none

8. Finally, in the command prompt, go to the working directory (2d) and type the
command nmake to compile the udf.
Note: If there is some problem, type nmake clean and then again type nmake. You
will see the appropriate message in the console.

Step 2: Grid

1. Start the 2D version of FLUENT.


Do not use the Start menu for the purpose. Start FLUENT from the working directory
in the command prompt.

2. Read the grid file (porous plug.msh).

3. Check and display the grid.

Grid Mar 27, 2002


FLUENT 6.0 (2d, segregated, lam)

Figure 1.2: Grid Display

c Fluent Inc. May 22, 2002 1-3


Position Dependent Porous Media

Step 3: Models

1. Keep the default solver settings.

2. Turn on the standard k-epsilon (2 eqn) turbulence model with standard wall functions.

Step 4: Materials
We will use the default fluid properties of air for this problem. Therefore, we need not make
any changes to the material properties.
Step 5: Link the UDF’s

1. Access the UDF interface.


Define −→ User-Defined −→ Functions −→Compiled...

2. Under Library Name, enter lib porous and click Compile.

For more information on linking the compiled UDF’s, refer to Section 7.3.4 Linking Your
Shared Library to the FLUENT Executable, in the UDF Manual.
Step 6: Boundary Conditions

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


(a) Enable Source Terms and select udf xmom source for X Momentum.
(b) Retain the default values for the other parameters.

2. Set the boundary conditions for the velocity-inlet-1 zone.


(a) Select Intensity and Length Scale as the Turbulence Specification Method and set
the to Turbulence Intensity to 5.
(b) Set Velocity Magnitude to 1 and retain the default values for the other parameters.

3. Set the boundary conditions for the pressure-outlet-1 zone.


(a) Select Intensity and Length Scale as the Turbulence Specification Method and set
the Turbulence Intensity to 5.
(b) Retain the default values for the other parameters.

4. Retain the default settings for the other zones.

1-4 c Fluent Inc. May 22, 2002


Position Dependent Porous Media

Step 7: Solution

1. Initialize the flow field using the boundary conditions set at velocity-inlet-1.
2. Enable the plotting of residuals during calculation.

3. Start by requesting 100 iterations.


Residuals
continuity
x-velocity
1e+01
y-velocity
k
epsilon
1e+00

1e-01

1e-02

1e-03

1e-04

1e-05

1e-06
0 5 10 15 20 25 30 35 40 45

Iterations

Scaled Residuals Mar 27, 2002


FLUENT 6.0 (2d, segregated, ske)

Figure 1.3: Scaled Residuals

Step 8: Postprocessing

1. Display velocity vectors.

2.09e+00

1.92e+00

1.75e+00

1.58e+00

1.41e+00

1.24e+00

1.07e+00

8.96e-01

7.25e-01

5.54e-01

3.83e-01

Velocity Vectors Colored By Velocity Magnitude (m/s) Mar 27, 2002


FLUENT 6.0 (2d, segregated, ske)

Figure 1.4: Contours of Static Temperature

c Fluent Inc. May 22, 2002 1-5


Position Dependent Porous Media

Results
The above vector plot shows that the fluid flows preferentially near the bottom of the
channel due to the effect of the source term on the axial momentum of the fluid.

Summary
This tutorial has demonstrated the use of UDFs for specifying source terms. User-defined
source terms can be a useful way of introducing additional physics into the simulation, and
can usually be modeled as sources or sinks of mass, momentum, energy, species, etc.
Once you are comfortable with the present exercise, try modifying the UDF to specify
momentum sources for both the x and y momentum equations. The present UDF could
be copied and suitably modified for the y momentum equation. Both functions would then
reside in the UDF file, and be accessible to the solver upon compilation.

1-6 c Fluent Inc. May 22, 2002


Position Dependent Porous Media

Appendix
If you prefer to compile the UDFs on a UNIX machine, follow the procedure below:

1. Copy porous plug.msh and porous plug.c to your working directory.

2. Make a directory to put your library in:


mkdir lib porous
cd lib porous

3. Move makefile.udf2 to this directory. Rename it as Makefile.

4. Make a source directory (mkdir src) and put your source code (porous plug.c) in the
src directory.

5. Move makefile.udf to this directory and rename it as makefile.

6. Edit the SOURCES and FLUENT INC macros in makefile for your own use.

7. Make the directory for the 2d version you want to built:


mkdir ultra
mkdir ultra/2d

8. Build the shared libraries by typing make in your lib porous directory (the one with
Makefile in it):

make FLUENT ARCH=ultra

For compiling UDF’s on any other platform, refer to Section 7.3, Compiled UDFs,
in the UDF Manual.

c Fluent Inc. May 22, 2002 1-7

You might also like