Sei sulla pagina 1di 41

Itaipu Technological Park - PTI

Center for Advanced Studies in Dam Safety

State University of West Paraná

Laboratory for High Performance Computing - LCAD

Tutorial for installation and configuration for integration with


Fortran Ansys CFX 14.0
Prof. Dr. Ricardo Lessa Azevedo
Prof. Dr. Rogério Luís Rizzi
Pétterson Vinícius Pramiu
Jeverson da Costa Pinto
Igor Castoldi

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.

Figure 1: the machine and operating system settings.

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.

2 Installation and Configuration

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

Applications needed to carry out this tutorial are:


• ANSYS CFX 14;
• Microsoft Windows SDK 7.1 for Windows 7 and .NET Framework 4;
• Microsoft Visual Studio 2008 (or later);
• Intel Fortran Compiler Composer XE 2013.
2.1 Microsoft Windows SDK 7.1 for Windows 7 and .NET
Framework 4

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

Figure 3. Mounting iso file of Microsoft Windows SDK 7.1.

When mounting the image must run setup.exe to start the installation.

Figure 4: Installing SDK.

The following windows will be displayed when you click Next.


iv

Figure 5: Installing SDK.

Figure 6: Installing SDK.


v

Figure 7: Installing SDK.

Check all according to Figure 8.

Figure 8: Installing SDK.


vi

Figure 9: Installing SDK.

Figure 10: Installing SDK.


vii

Figure 11: Completion of the SDK installation.

2.2 Installation of Microsoft Visual Studio 2008

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.

The following windows will be displayed when you click Next.

Figure 12: Installing VS 2008.


viii

Figure 13: Installing VS 2008.

Figure 14: Installing VS 2008.


ix

Figure 15: Installing VS 2008.

Select the Custom option for a custom installation.

Figura 16: Instalação do VS 2008.

Be sure to check all the options as shown in Figure 17.


x

Figure 17: Installing VS 2008.

Figure 18: Installing VS 2008.


xi

Figure 19: Installing VS 2008.

2.3 Installation of Intel Fortran Composer XE 2013

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.

Figure 20: Installing the Intel Fortran Composer XE 2013.


xii

Figure 21: Installing the Intel Fortran Composer XE 2013.

The following windows will be displayed when you click Next.

Figure 22: Installing the Intel Fortran Composer XE 2013.


xiii

Figure 23: Installing the Intel Fortran Composer XE 2013.

Select the option Evaluate this product.

Figure 24: Installing the Intel Fortran Composer XE 2013.


xiv

Figure 25: Installing the Intel Fortran Composer XE 2013.

Select Custom Installation. See Figure 26.

Figure 26: Installing the Intel Fortran Composer XE 2013.


xv

Figure 27: Installing the Intel Fortran Composer XE 2013.

Check all as in Figure 28.

Figure 28: Installing the Intel Fortran Composer XE 2013.

Integrate your Fortran with Visual Studio that is already installed. See Figure 29.
xvi

Figure 29: Installing the Intel Fortran Composer XE 2013.

Figure 30: Installing the Intel Fortran Composer XE 2013.

Figure 31: Installing the Intel Fortran Composer XE 2013.


xvii

Figure 32: Installing the Intel Fortran Composer XE 2013.

2.4 Setting Environment Variables

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.

Figure 33: Opening the computer properties.

A new window appears. In this window click on the Advanced System Settings link, as shown
in Figure 34.
xviii

Figure 34: Computer properties.

By clicking the link, a new window appears. In this window click the Environment Variables
button. See Figure 35.

Figure 35: System properties.

To create the new environment variables, click the New button.... Figure 36.
xix

Figure 36: Environment Variables.

A box with the title Variable name: Variable and Value: displays and should be populated with
the values of the new environment variable:

Figure 37: New environment variable.

Variable Name: lib

Variable value: C:\Program Files (x86)\Intel\Composer XE 2013 \compiler\lib;


C:\Program Files (x86)\Intel\Composer XE 2013 \compiler\lib\intel 64
Click OK to the variable to be created. Note that the address used here may change according
to the currently selected installation options.

Repeat this procedure by creating a new variable with values:

C:\Program Files (x86)\Intel\Composer XE 2013 \compiler\include;


C:\Program Files (x86)\Intel\Composer XE 2013 \compiler\include\intel 64

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

C:\Program Files (x86)\Intel\Composer XE 2013 \redist\intel64\mpirt

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:

Variable Name: lib


Variable value: C:\Program Files (x86)\Intel\Composer XE 2013\compiler\lib; C:\Program Files
(x86)\Intel\Composer XE 2013 \compiler\lib\ia32
After it is done, click OK to exit the System Properties window.

2.5 Setup CFX 14 to use Fortran routines

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:

Figure 38: Setup CFX 14.

Then click on Tools - > Command Line. See Figure 39:


xxi

Figure 39: Setup CFX 14.

A new prompt window will open. See Figure 40.

Figure 40: Setup CFX 14.

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.

If the configuration is successful a message as in Figure 41 appears.


xxii

Figure 41: Setup CFX 14.

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 42: Setup CFX 14.

Figure 43 shows the window that should appear if the build is successful.

Figure 43: Setup CFX 14.


xxiii

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.

Figure 44: Setup CFX 14.


3 Example of Fortran routines in CFX: Flow Through a Butterfly
Valve

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.

3.1 Finnie erosion model

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.

Figure 45: Creating routines in CFX.

Name your routine as myerosion. See Figure 46


xxv

Figure 46: Creating routines in CFX.

In the window that appears, select the user routine particle and fill the campus according to
Figure 47

Figure 47: Creating routines in CFX.

Library where Path is the location where you saved your Fortran source code pt_erosion.F.

Then you must edit the Default Domain options:


xxvi

Figure 48: Creating routines in CFX.

Specific Fluid Models tab Erosion model choice as the User defined option, as shown in Figures
49 and 50.

Figure 49: Creating routines in CFX.


xxvii

Figure 50: Creating routines in CFX.

Change the Default Domain default options:

Figure 51: Creating routines in CFX.

In Fluid Values tab, select the options as shown in Figures 52 and 53.
xxviii

Figure 52: Creating routines in CFX.

Figure 53: Creating routines in CFX.

Where the value of the arguments is: Sand Fully Coupled.Particle Impact Angle, Sand Fully
Coupled.Velocity and return value is: Particle Erosion.

Change the options for Wall:


xxix

Figure 54: Creating routines in CFX.

In Fluid Values tab, select the options as shown in Figures 55 and 56.

Figure 55: Creating routines in CFX.


xxx

Figure 56: Creating routines in CFX.

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 57: Creating routines in CFX.

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.

The pt_erosion.F source code file is described below:

#include "cfx5ext.h" dllexport(pt_erosion)


SUBROUTINE PT_EROSION(NLOC,NRET,NARG,RET,ARG,CRESLT,
& CZ,DZ,IZ,LZ,RZ)
CC
CD User routine: Finnie erosion model
CC
CC --------------------
CC Input
CC --------------------
CC
CC NLOC - number of entities
CC NRET - length of return stack
CC NARG - length of argument stack
CC ARG - argument values
CC
CC --------------------
CC Modified
CC --------------------
CC
CC --------------------
CC Output
CC --------------------
CC
CC RET - return values
CC
CC --------------------
CC Details
CC --------------------
CC
CC======================================================================
C
C ------------------------------
C Preprocessor includes
C ------------------------------
C
#include "cfd_sysdep.h"
xxxii

#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

SUBROUTINE FINNIE ( EROSION,ANGLE,VEL_PT )


C
C=======================================================================
C Calculate Finnie erosion rate
C=======================================================================
C
C ---------------------------
C Preprocessor includes
C ---------------------------
C
#include "cfd_sysdep.h"
#include "cfd_constants.h"
C
C ------------------------------
C Argument list
C ------------------------------
C
REAL EROSION, ANGLE, VEL_PT(3)
C
C ------------------------------
C Local variables
C ------------------------------
C
REAL ANGLE_DEG, F, V0, N, VEL
C
C ------------------------------
C Executable statements
C ------------------------------
C
V0 = 1.0
N = 2.0
C
ANGLE_DEG = ANGLE*180./PI
C
IF(ANGLE_DEG .GE. 18.5) THEN F =
COS(ANGLE)**2 / THREE
ELSE
F = SIN(TWO*ANGLE) - THREE*SIN(ANGLE)**2 ENDIF
C
VEL = SQRT(VEL_PT(1)**2 + VEL_PT(2)**2 + VEL_PT(3)**2)
C
EROSION = (VEL/(V0+SN))**N * F
C
END
xxxiv

For simple conference, the definitions of the commands in the following CFX were:

USER ROUTINE DEFINITIONS:


USER ROUTINE: myerosion
Calling Name = pt_erosion
Library Name = pt_erosion
Library Path = C:/PIPE VALVE EROSION 2
Option = Particle User Routine END
END
END
FLOW: Flow Analysis 1 SOLUTION
UNITS:
Angle Units = [ rad ]
Length Units = [ m ]
Mass Units = [ kg ]
Solid Angle Units = [ sr ]
Temperature Units = [ K ]
Time Units = [ s ]
END
ANALYSIS TYPE:
Option = Steady State
EXTERNAL SOLVER COUPLING: Option =
None
END
END
DOMAIN: Default Domain
Coord Frame = Coord 0
Domain Type = Fluid
Location = B1.P3
BOUNDARY: Default Domain Default
Boundary Type = WALL
Location = \
F1.B1.P3,F10.B1.P3,F11.B1.P3,F12.B1.P3,F2.B1.P3,F6.B1.P3,F7.B1.P3,F8.\
B1.P3,F9.B1.P3
BOUNDARY CONDITIONS:
MASS AND MOMENTUM:
Option = No Slip Wall
END
WALL ROUGHNESS:
Option = Smooth Wall
END
END
FLUID: Sand Fully Coupled BOUNDARY
CONDITIONS:
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:
xxxv

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

3.2 Tabakoff Model

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

Figure 59: Results of the simulation using Tabakoff erosion model.

The erosion_tabakoff.F source code file is described below:

#include "cfx5ext.h" dllexport(erosion_tabakoff)


SUBROUTINE EROSION_TABAKOFF(NLOC,NRET,NARG,RET,ARG,CRESLT,
& CZ,DZ,IZ,LZ,RZ)
CC
CD User routine: Tabakoff erosion model
CC
CC --------------------
CC Input
CC --------------------
CC
CC NLOC - number of entities
CC NRET - length of return stack
CC NARG - length of argument stack
CC ARG - argument values
CC
CC --------------------
CC Modified
CC --------------------
CC
CC --------------------
CC Output
CC --------------------
CC
CC RET - return values
CC
CC --------------------
CC Details
CC --------------------
CC
CC======================================================================
C
C ------------------------------
C Preprocessor includes
C ------------------------------
C
#include "cfd_sysdep.h"
xxxvii

#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

SUBROUTINE TABAKOFF ( EROSION,ANGLE,VEL_PT )


C
C=======================================================================
C Calculate Tabakoff erosion rate
C=======================================================================
C
C ---------------------------
C Preprocessor includes
C ---------------------------
C
#include "cfd_sysdep.h"
#include "cfd_constants.h"
C
C ------------------------------
C Argument list
C ------------------------------
C
REAL EROSION, ANGLE, VEL_PT(3)
C
C ------------------------------
C Local variables
C ------------------------------
C
REAL RT, VP, K2, K12, V1, V2, V3, ANGLE_MAX_RAD, ANGLE_MAX, ANGLE_DEG, F, VEL
C
C ------------------------------
C Executable statements
C ------------------------------
C
ANGLE_MAX = 25.0
ANGLE_MAX_RAD = ANGLE_MAX*PI/180. K12
= 0.585
V1 = 159.11
V2 = 194.75
V3 = 190.5
C
ANGLE_DEG = ANGLE*180./PI
C
VEL = SQRT(VEL_PT(1)**2 + VEL_PT(2)**2 + VEL_PT(3)**2)
C
VP = (( VEL/V2)*SIN(ANGLE ))**4
C
RT = 1-( VEL/V3)*SIN(ANGLE )
C
xxxix

IF(ANGLE_DEG .LE. ANGLE_MAX) THEN K2 =


1.0
ELSE
K2 = 0.0
ENDIF
C
F = (1+K2 *K12*SIN(ANGLE*(PI/2)/ANGLE_MAX_RAD ))**2
C
EROSION = ( F*((VEL/V1)**2)*(COS(ANGLE)**2)*(1-RT**2)+VP )/1000.
C
END

For simple conference, the definitions of the commands in CFX were as follows:

USER ROUTINE DEFINITIONS:


USER ROUTINE: myerosion
Calling Name = erosion_tabakoff
Library Name = erosion_tabakoff
Library Path = C:\PIPE VALVE EROSION_tabakoff
Option = Particle User Routine END
END
END
FLOW: Flow Analysis 1 SOLUTION
UNITS:
Angle Units = [ rad ]
Length Units = [ m ]
Mass Units = [ kg ]
Solid Angle Units = [ sr ]
Temperature Units = [ K ]
Time Units = [ s ]
END
ANALYSIS TYPE:
Option = Steady State
EXTERNAL SOLVER COUPLING: Option =
None
END
END
DOMAIN: Default Domain
Coord Frame = Coord 0
Domain Type = Fluid
Location = B1.P3
BOUNDARY: Default Domain Default
Boundary Type = WALL
Location = \
F1.B1.P3,F10.B1.P3,F11.B1.P3,F12.B1.P3,F2.B1.P3,F6.B1.P3,F7.B1.P3,F8.\ B1.P3,F9.B1.P3
BOUNDARY CONDITIONS:
MASS AND MOMENTUM:
Option = No Slip Wall
END
WALL ROUGHNESS:
Option = Smooth Wall
END
END
FLUID: Sand Fully Coupled BOUNDARY
CONDITIONS:
xl

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

Potrebbero piacerti anche