8/29/2011

CFX-Scripting and Batch Processing

Introduction

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.

Overview

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.

Define The First Simulation

  1. Start CFX-Pre from the CFX Launcher (do not use Workbench for this example) and create a new simulation

-The first simulation will use the k-epsilon turbulence model

  1. Import the mesh file backstep.gtm
  2. Select File > Import > CCL
  3. Import the file ke.ccl

The physics definition is imported. The CCL file you just imported was generated by setting up the simulation in CFX-Pre and then exporting the CCL through File > Export CCL.

Examining the Setup

Now take a minute to look at the simulation setup:

1D Interpolation Functions have been used to define Inlet velocity and turbulence profiles based on experimental data

The mesh is 1 element thick with symmetry boundaries on the X-Y planes

-This simplifies the simulation to 2D

There is a boundary named HeatedWall through which a constant Heat Flux is applied

The k-epsilon turbulence model is used

-The second and third simulations will use the SST and the k-omega turbulence models

Write the Solver File

You can now write the Definition file for the k-epsilon simulation.

  1. Click the Write Solver File icon
  2. Enter the filename as ke.def and click Save

Preparing CCL Files

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.

  1. Open a new text file in Notepad
  2. In CFX-Pre, right-click on Default Domain in the Outline tree, and select Edit in Command Editor
  3. Copy and paste all the text from the Command Editor to your text file

-Delete the lines Create Other Side = Off and Interface Boundary = Off under BOUNDARY: Default Domain Default and BOUNDARY: HeatedWall

-Save the text file in your working directory and name it SST.ccl

Now you can edit the text file in Notepad

  1. Edit the TURBULENCE MODEL Option and the TURBULENT WALL FUNCTIONS Option located at the bottom of the file as shown:

  1. Save the changes to SST.ccl

Now change to the k-omega turbulence model for the third simulation:

  1. Edit the TURBULENCE MODEL Option as shown:

  1. Save the file as komega.ccl

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.

Create a Solver Script

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:

-Perl scripts can be run on Windows and UNIX/Linux platforms

-Perl comes built-in with your CFX installation and is integrated into CCL

-Perl is used elsewhere in CFX, so learning some basic Perl will allow you to add advanced features to CCL. You will see an example of this when post-processing this workshop.

  1. Open a new text file in Notepad and save it in your working directory as runsolver.pl
  2. Enter the following text (the file is also provided in the scripts directory with the workshop)

  1. Save the changes to runsolver.pl

Notes on the Perl Script

The following provides a brief explanation of the syntax used in the Perl script:

-The first two lines provide information on how Perl should interpret the script. The details are not necessary here, but you can start all your Perl scripts with these two lines

-# is the comment character

-system executes the command in quotes

-Each statement should finish with the ; character

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.

http://www.cadfamily.com/html/Article/CFX-Scripting%20and%20Batch%20Processing_784_1.htm

http://www.cadfamily.com/html/Article/CFX-Scripting%20and%20Batch%20Processing_784_2.htm

No comments: