Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
February 2013
Cascavel
2013
1 Introduction
This tutorial aims to assist the user in installing and goal setting for the Fortran compiler works
in conjunction with the ANSYS CFX, allowing the implementation of "User defined routine" in specific
cases where the routines implemented by CFX are not suitable for modeling and simulation.
The steps described below were run on a machine whose settings are displayed in Figure 1.
At the end of the tutorial results of a simulation that addresses the erosive effects in a tube
with butterfly valve, whose problem and specification are detailed in ANSYS CFX Tutorials (Flow
Through a Butterfly Valve, p. 193) will be presented.
For the correct operation of the applications listed here, look in order to perform the tasks
presented as carefully choose the software according to the settings of your system (32 or 64 bit).
With the ANSYS 14 installed and working properly should perform the installation and
configuration of SDK development tools. An .iso file with these applications can be found on the link
http://www.microsoft.com/en-us/download/details.aspx?id=8442. See Figure 2.
Figure 2: Progress of the download from the Microsoft Windows SDK 7.1.
After downloading the file one should mount the image with an appropriate application
(Alcohol, Nero or DeamonTools). See Figure 3.
iii
When mounting the image must run setup.exe to start the installation.
After the SDK 7.1 is installed one should perform the installation and configuration of Microsoft
Visual Studio 2008. A file with this application can be found at the Microsoft site
http://msdn.microsoft.com/pt-br/evalcenter/bb633753.aspx.
After downloading the file one should mount the image with an appropriate application (Alcohol,
Nero or DeamonTools). After mounting the image one must run setup.exe to start the installation.
After VS 2008 is installed one should perform the installation and configuration of the Intel
Fortran Composer XE 2013. A file with this application can be found on the Intel site
http://software.intel.com/en-us/fortran-compilers.
After downloading the file run the .exe to start the installation. Click Extract to unzip the files needed
for installation.
Integrate your Fortran with Visual Studio that is already installed. See Figure 29.
xvi
For the integration between CFX and FORTRAN compiler, you must set the environment
variables. To do this, open the properties of your computer by clicking with the mouse in the My
Computer Properties or using the shortcut keys Win + Pause button.
A new window appears. In this window click on the Advanced System Settings link, as shown
in Figure 34.
xviii
By clicking the link, a new window appears. In this window click the Environment Variables
button. See Figure 35.
To create the new environment variables, click the New button.... Figure 36.
xix
A box with the title Variable name: Variable and Value: displays and should be populated with
the values of the new environment variable:
Again, repeat this procedure by creating a new PATH variable with values:
C:\Program Files\ANSYS Inc\v140\CFX\bin;C:\Program Files ( x86)\Intel\ Composer XE
2013\bin;C:\Program Files (x86)\Intel\Composer XE 2013 \ bin\intel64;C:\Program Files
(x86)\Intel\Composer XE 2013 \redist;
C:\Program Files (x86)\Intel\Composer XE 2013 \redist\intel64;
C:\Program Files (x86)\Intel\Composer XE 2013 \redist\intel64\compiler;
C:\Program Files (x86)\Intel\Composer XE 2013 \redist\intel64\mkl;
xx
If your system is 32bits rename all the folders called EM64T for ia32. For example, the variable
lib in a 32bit system would be of the form:
For the use of sub routines implemented in Fortran, you must compile the source files through
the CFX module. Open CFX 14.0, through the start menu. See Figure 38:
On this prompt window, navigate to the directory where the FORTRAN compiler is
(C:\Program Files (x86)\Intel\Composer XE 2013\bin) and enter the following command:
ifortvars.bat Intel64. If your system is 32bits use the command ifortvars.bat ia32.
To generate the required operation of the CFX files, navigate to the directory at the location
where your Fortran source file prompt. Within the directory, enter the command: cfx5mkext -64bit
<file_name.F>. If your system is 32bits use the command cfx5mkext <file_name.F>. See Figure 42.
Figure 43 shows the window that should appear if the build is successful.
Note that the directory containing the source code is generated a new folder that contains
the files used by the CFX solver. See Figure 44.
Before proceeding make CFX configuration presented in section 2.5 and create a directory for
your project. Find the directory
C:\Program Files\ANSYS Inc\v140\CFX\examples\UserFortran and copy the files and pt_erosion.F
pt_erosion.cll to the directory that was created for your project.
The example shown here is a tutorial presented in the CFX manual "Flow Through a Butterfly
Valve ", with the difference that the model for Finnie erosion implemented in Fortran rather than
the Finnie model implemented in CFX will be used. Obviously using the same parameters, the results
should be the same.
After setting up the problem "Flow Through a Butterfly Valve" with the help of ANSYS CFX
Tutorial for use of Fortran subroutines should create a "User Routines". To do this, click with the
mouse to "User Routines " and enter a new routine, as in Figure 45 button.
In the window that appears, select the user routine particle and fill the campus according to
Figure 47
Library where Path is the location where you saved your Fortran source code pt_erosion.F.
Specific Fluid Models tab Erosion model choice as the User defined option, as shown in Figures
49 and 50.
In Fluid Values tab, select the options as shown in Figures 52 and 53.
xxviii
Where the value of the arguments is: Sand Fully Coupled.Particle Impact Angle, Sand Fully
Coupled.Velocity and return value is: Particle Erosion.
In Fluid Values tab, select the options as shown in Figures 55 and 56.
Where the value of the arguments is: Sand Fully Coupled.Particle Impact Angle, Sand Fully
Coupled.Velocity and return value is: Particle Erosion.
Then run the CFX Solver and wait for the end of the simulation. See Figure 57.
Figure 58 shows the results obtained using the Finnie CFX model and implemented in Fortran
(pt_erosion.F) to compare the results.
xxxi
Figure 58: Results of the simulation using the Finnie erosion model.
#include "cfd_constants.h"
C
C ------------------------------
C Argument list
C ------------------------------
C
INTEGER NARG, NRET, NLOC
C
REAL ARG(NLOC,NARG), RET(NLOC,NRET)
C
CHARACTER*(4) CRESLT
C
INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)
C
C ------------------------------
C External routines
C ------------------------------
C
C
C ------------------------------
C Local Parameters
C ------------------------------
C
C
C ------------------------------
C Local Variables
C ------------------------------
C
C ------------------------------
C Stack pointers
C ------------------------------
C
C=======================================================================
C
C ---------------------------
C Executable Statements
C ---------------------------
C
C=======================================================================
C
C Return variables: C
-----------------
C
C Particle erosion : RET(1,1)
C
C Argument variables
C -------------------
C
C Particle impact angle : ARG(1,1)
C Particle velocity : ARG(1,2)
C
xxxiii
C======================================================================= C
C-----------------------------------------------------------------------
C Calculate the return variables
C-----------------------------------------------------------------------
C
CALL FINNIE ( RET(1,1),
& ARG(1,1),ARG(1,2))
C
END
For simple conference, the definitions of the commands in the following CFX were:
The example shown here is a tutorial presented in the CFX manual "Flow Through a Butterfly
Valve ", with the difference that the model for Tabakoff erosion implemented in Fortran instead of
Tabakoff model implemented in CFX will be used. Obviously using the same parameters, the results
should be the same.
Figure 59 shows the results obtained using the CFX model of Tabakoff and implemented in
Fortran ( pt_erosion.F ) for comparison purposes.
xxxvi
#include "cfd_constants.h"
C
C ------------------------------
C Argument list
C ------------------------------
C
INTEGER NARG, NRET, NLOC
C
REAL ARG(NLOC,NARG), RET(NLOC,NRET)
C
CHARACTER*(4) CRESLT
C
INTEGER IZ(*)
CHARACTER CZ(*)*(1)
DOUBLE PRECISION DZ(*)
LOGICAL LZ(*)
REAL RZ(*)
C
C ------------------------------
C External routines
C ------------------------------
C
C
C ------------------------------
C Local Parameters
C ------------------------------
C
C
C ------------------------------
C Local Variables
C ------------------------------
C
C ------------------------------
C Stack pointers
C ------------------------------
C
C=======================================================================
C
C ---------------------------
C Executable Statements
C ---------------------------
C
C=======================================================================
C
C Return variables: C
-----------------
C
C Particle erosion : RET(1,1)
C
C Argument variables
C -------------------
C
C Particle impact angle : ARG(1,1)
C Particle velocity : ARG(1,2)
C
xxxviii
C======================================================================= C
C-----------------------------------------------------------------------
C Calculate the return variables
C-----------------------------------------------------------------------
C
CALL TABAKOFF ( RET(1,1),
& ARG(1,1),ARG(1,2))
C
END
For simple conference, the definitions of the commands in CFX were as follows:
EROSION MODEL:
Option = User Defined
END
PARTICLE USER WALL INTERACTION:
Argument Variables List = Sand Fully Coupled.Particle Impact \
Angle,Sand Fully Coupled.Velocity
Particle User Routine = myerosion
Particle Wall Interaction Return Variables List = Particle Erosion
END
PARTICLE WALL INTERACTION:
Option = Equation Dependent
END VELOCITY:
Option = Restitution Coefficient
Parallel Coefficient of Restitution = 1.0
Perpendicular Coefficient of Restitution = 0.9 END
END
END
FLUID: Sand One Way Coupled BOUNDARY
CONDITIONS:
EROSION MODEL:
Option = User Defined
END
PARTICLE USER WALL INTERACTION:
Argument Variables List = Sand One Way Coupled.Particle Impact \
Angle,Sand One Way Coupled.Velocity
Particle User Routine = myerosion
Particle Wall Interaction Return Variables List = Particle Erosion
END
PARTICLE WALL INTERACTION:
Option = Equation Dependent
END VELOCITY:
Option = Restitution Coefficient
Parallel Coefficient of Restitution = 1.0
Perpendicular Coefficient of Restitution = 0.9 END
END
END
END