Académique Documents
Professionnel Documents
Culture Documents
Introduction to CFX
Pardad Petrodanesh.Co
Lecturer: Ehsan Saadati
ehsan.saadati@gmail.com
www.petrodanesh.ir
ANSYS, Inc. Proprietary April 28, 2009
2009 ANSYS, Inc. All rights reserved. WS9-1 Inventory #002599
WS9: Scripting and Batch Processing
Introduction Workshop Supplement
This workshop models flow over a backwards facing step with heat
transfer through the lower wall. The quantities of interest are the Skin
Friction Coefficient and the Stanton Number on the lower wall. The
choice of turbulence model can influence these results, so you will
use session files and scripts to run three simulations, each with a
different turbulence model, and then compare the results.
3.8 x H 40 x H
Inlet Outlet
4xH
Flow Separation
q
H
In this workshop both the mesh and the physics definition are
provided. The physics definition is contained in a CCL file that you
will import into CFX-Pre to define the first simulation; you will then
write a Definition file. The same Definition file will be used to run all
three simulations, but additional CCL will be passed to the solver at
run-time to alter the turbulence model.
You will write a short script to run all three simulations, providing the
necessary solver arguments for each run.
Lastly you will create and edit a CFX-Post session file so that post-
processing output can be created for all three simulations.
You can now write the Definition file for the k-epsilon simulation.
The next step is to prepare CCL files that change the turbulence
model and can be passed to the solver at run-time. You can use the
existing CCL as a template. One way to extract the existing CCL is
through the Command Editor in CFX-Pre.
If you do not know the correct CCL syntax, you can make
changes in the CFX-Pre GUI and then edit the object in
the Command Editor to view the syntax.
Now change to the k-omega turbulence model for the third simulation:
8. Edit the TURBULENCE MODEL Option as shown:
TURBULENCE MODEL: TURBULENCE MODEL:
Option = SST Option = k omega
END END
TURBULENT WALL FUNCTIONS: TURBULENT WALL FUNCTIONS:
Option = Automatic Option = Automatic
END END
The files provided with this workshop contain a scripts directory which
has copies of komega.ccl and SST.ccl. You can use these files if
necessary. It is not recommended to copy and paste from Powerpoint
because the formatting on some characters does not translate well to
Notepad.
The next step is to create a script that will run all the simulations in the
solver. You could write the script in any scripting language that can be
executed on your computer. Some options are Perl, a Windows batch
script (.bat) or a UNIX shell script (.sh). In this workshop you will write
a Perl script. This is a good choice because:
The Perl script runs the solver three times using different arguments
each time. The first time the k-epsilon simulation is run by providing
the Definition file to the solver. The second and third time the following
additional arguments are provided:
ccl <file>.ccl: this passes the CCL file to the
solver that contains the new turbulence model settings.
This CCL is processed after the CCL contained in the
Definition file. In CCL, when the same parameter is
defined more than once, the last CCL to be processed
takes precedence
-ini <file>: uses the k-epsilon results to initialize
the run
-name <name>: this sets the name of the .out and .res
files output by the solver.
ANSYS, Inc. Proprietary April 28, 2009
2009 ANSYS, Inc. All rights reserved. WS9-14 Inventory #002599
WS9: Scripting and Batch Processing
Running the Script Workshop Supplement
The Perl script will now run the simulations and generate results files. You can
track the progress of the runs by opening the Solver Manager, selecting File >
Monitor Run in Progress, and selecting the appropriate _001.dir directory.
Next you will create new variables for the Skin Friction Coefficient (Cf)
and the Stanton Number (St). Both variables will be multiplied by
1000 to give a more sensible scale. You can then create Charts
showing these variables along the Polyline you just created.
1. Select Insert > Variable
2. Set the Name to Cf x 1000
3. Enter the definition in the Expression box as:
1000 * Wall Shear X / (0.5 * Density *
(massFlowAve(Velocity)@In^2))
then click Apply
4. Select Insert > Variable
5. Set the Name to St x 1000
6. Enter the definition in the Expression box as shown, then click OK:
1000 * Wall Heat Transfer Coefficient / (massFlowAve(Velocity)@In *
Density * Specific Heat Capacity at Constant Pressure)
ANSYS, Inc. Proprietary April 28, 2009
2009 ANSYS, Inc. All rights reserved. WS9-18 Inventory #002599
WS9: Scripting and Batch Processing
Create a Chart Workshop Supplement
The next step is to edit the Session file to make it useful for running in
batch mode. A discussion of all the commands you will enter is
provided at the end of the workshop.
If you encounter any problems you can look at the post.cse file
provided with this workshop in the scripts directory
COMMAND FILE:
CFX Post Version = 11.0
END
!foreach $res ('ke_001.res','SST_001.res','komega_001.res')
!{
! print Processing $res\n;
! @temp = split('_001.res',$res);
! $type = $temp[0];
DATA READER:
DATA READER:
Clear All Objects = false
Append Results = false
Apply X Offset = false
Apply Y Offset = false
Apply Z Offset = false
Keep Camera Position = true
Load Particle Tracks = true
END
DATA READER:
Domains to Load=
END
> load filename=$res
EXPORT:
Export File = $exfile
Export Chart Name = Chart 1
Overwrite = On
END
>export chart
> close
!}
3.0
2.5
2.0
1.5
1.0 ke
Cf (x1000)
SST
0.5
k-omega
0.0 Experiment
0 0.2 0.4 0.6 0.8 1 1.2
-0.5
-1.0
-1.5
-2.0
X [m]
3.5
2.5 ke
St (x 1000)
SST
2
k-omega
1.5 Experiment
0.5
0
0 0.2 0.4 0.6 0.8 1 1.2
X [m]
The results show reasonable agreement with the Skin Friction and
Stanton Number data. Note that the SST and k-omega model give a
more accurate downstream reattachment location (where the Skin
Friction Coefficient is zero). It has been found that a finer mesh will
produce results closer to the experimental data.
You can download the validation paper that was used as the basis for
this workshop from the ANSYS Customer Portal.
foreach $res(...)
This evaluates each object inside the brackets, assigns the current
value inside the bracket to $res, and then processes all the commands
inside the curly brackets {..}. Hence, $res changes for each loop
@temp = split(....);
This creates an array called temp by splitting the filename into parts,
separated by the pattern _001.res.
$type = $temp[0];
We now use the first element in the temp array as our type name. We
have now extracted the first part of the results file name (e.g. ke, SST
or komega)
ANSYS, Inc. Proprietary April 28, 2009
2009 ANSYS, Inc. All rights reserved. WS9-32 Inventory #002599
WS9: Scripting and Batch Processing
Discussion of Commands Workshop Supplement