ws08 jounaling scripting

20
Chapter 8: Automation with Templates, Scripting and Journals This tutorial demonstrates the ability to record, modify and playback script files and show how a single, consistent, and well-documented journaling and scripting capability is useful for automating all phases of a simulation. It is designed to introduce you to the ANSYS AIM user interface using a simple geometry. In this tutorial you will learn how to Launch ANSYS AIM. Record a session in a script file. Import the geometry. Create computational mesh. Set up the CFD simulation which includes setting the material properties and boundary conditions. Calculating a solution. Playback the script file from the interactive session for end-to-end simulation. Examining the results. Modification of script file, including customization with advanced operations that are available in the scripting language (such as conditional logic) Ability to access and modify the fluids setup and results data via commands and scripts. 8.1. Prerequisites This tutorial assumes that you have little to no experience with ANSYS AIM and so each step will be explicitly described. 8.2. Problem Description The goal of the tutorial is to demonstrate the ability of ANSYS AIM to record, playback and modify a journal file. You will simulate a steady-state flow through a trumpet valve recording all of the simulation steps in a journal file. You will import a CAD model of the flow volume of a trumpet valve. You will then create a mesh, define materials, solve and post-process a fluid analysis.You will then use the re- corded journal file to playback the entire simulation. 8.3. Setup And Solution The following sections describe the setup and solution steps for this tutorial: 8.3.1. Preparation 8.3.2. Starting AIM 8.3.3. Geometry 1 Release 16.0 - © SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Upload: ian-as

Post on 17-Dec-2015

17 views

Category:

Documents


0 download

DESCRIPTION

cfd

TRANSCRIPT

  • Chapter 8: Automation with Templates, Scripting and Journals

    This tutorial demonstrates the ability to record, modify and playback script files and show how a single,consistent, and well-documented journaling and scripting capability is useful for automating all phasesof a simulation. It is designed to introduce you to the ANSYS AIM user interface using a simple geometry.

    In this tutorial you will learn how to

    Launch ANSYS AIM.

    Record a session in a script file.

    Import the geometry.

    Create computational mesh.

    Set up the CFD simulation which includes setting the material properties and boundary conditions.

    Calculating a solution.

    Playback the script file from the interactive session for end-to-end simulation.

    Examining the results.

    Modification of script file, including customization with advanced operations that are available in thescripting language (such as conditional logic)

    Ability to access and modify the fluids setup and results data via commands and scripts.

    8.1. Prerequisites

    This tutorial assumes that you have little to no experience with ANSYS AIM and so each step will beexplicitly described.

    8.2. Problem Description

    The goal of the tutorial is to demonstrate the ability of ANSYS AIM to record, playback and modify ajournal file. You will simulate a steady-state flow through a trumpet valve recording all of the simulationsteps in a journal file. You will import a CAD model of the flow volume of a trumpet valve. You willthen create a mesh, define materials, solve and post-process a fluid analysis. You will then use the re-corded journal file to playback the entire simulation.

    8.3. Setup And Solution

    The following sections describe the setup and solution steps for this tutorial:8.3.1. Preparation8.3.2. Starting AIM8.3.3. Geometry

    1Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

  • 8.3.4. Mesh8.3.5. Physics8.3.6. Results8.3.7. Summary

    8.3.1. Preparation

    1. Set up a working folder on the computer you will be using.

    2. Copy the files TrumpetValve.agdb and CFD_Automation_V3.wbjn to the working folder.

    8.3.2. Starting AIM

    In this step you will start ANSYS AIM and set up a simulation process.

    1. From the Windows Start menu, select Start > All Programs > > ANSYS 16.0 > ANSYS AIM 16.0 to starta new ANSYS AIM session.

    This displays the ANSYS AIM application window. The various Simulation Process Templates aredisplayed in the Study panel at the left. The right is the help window where you can go throughthe various videos to learn ANSYS AIM and also has links to the Help menu. The Workflow tab isdisplayed at the bottom.

    2. Ensure that the units system selected is Metric.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.2

    Automation with Templates, Scripting and Journals

  • Home( ) > Units > Metric (kg,m,s,C,A,N,V)

    Note

    If the unit system is not in the list, click on Unit Systems.... In the Unit Systems dialogbox, ensure that the unit system you are interested in is de-selected in column D or theSuppressed column.

    3. From the menu select File > Scripting > Record Journal

    a. In the Save As window browse to your working folder and enter an appropriate name,CFD_auto_script.

    b. Click Save.

    The journal file now records the session.

    8.3.3. Geometry

    In the Study panel click on Import Geometry in the group Additional Creation Methods under Simu-lation Process Templates.

    Click Choose File... and select the file TrumpetValve.agdb from your working folder and clickOpen.

    8.3.4. Mesh

    1. Now you need to mesh the geometry. You can do this by either:

    Clicking on Geometry cell > Add Next > Meshing in the Workflow tab.

    Clicking on Add > Meshing in the Geometry panel under Connected Tasks.

    3Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • RMB in the graphics window and clicking on Add Next Task > Meshing.

    2. In the Mesh panel select Fluid flow from the Engineering intent drop-down list.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.4

    Automation with Templates, Scripting and Journals

  • 3. Click on Add next to Mesh Controls and select Inflation.

    a. The Inflation 1 panel is now displayed.

    5Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • b. Select wall from the Location drop-down list.

    c. Enter 5 for Maximum Layers.

    d. Retain 1.2 for Growth rate.

    Note

    The recording journal captures the properties only when they are changed. The defaultvalues are not captured in the recorded journal. So it is recommended to change thevalues of the properties like changing inflation here for instance.

    4. In the Workflow tab right-click on Mesh and select Update from the menu.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.6

    Automation with Templates, Scripting and Journals

  • 8.3.5. Physics

    Add a Physics task. You can do this by either:

    Clicking on Mesh cell > Add Next > Physics Solution in the Workflow tab.

    Clicking on Add >Physics Solution in the Mesh panel under Connected Tasks.

    RMB in the graphics window and selecting Add Next Task > Physics Solution.

    1. In the Physics panel click on Physics Region.

    a. In the Physics Region panel enable Fluid flow.

    b. Enable Body selection ( ). Right click in the graphics area, and click on Select All from the contextmenu. This selects all the bodies in the geometry.

    7Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • c. Click Apply.

    2. Return to the Physics panel. Click Add next to Material Assignments.

    a. Click on New using from the drop-down list and select Water (Material Samples) from the list.

    b. In the Water Assignment panel select Fluid Flow Physics Region from the Location drop-downlist.

    3. Return to the Physics panel and click Add next to Boundary Conditions and select Inlet from the drop-down list.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.8

    Automation with Templates, Scripting and Journals

  • a. In the Inlet panel select inlet from the Location drop-down list.

    b. Enter 3 m s^-1 for Magnitude.

    4. Return to the Physics panel and click Add next to Boundary Conditions and select Outlet from thedrop-down list.

    9Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • Select outlet from the Location drop-down list and enter 0 Pa or Gauge static pressure.

    5. Return to the Physics panel and click Add next to Boundary Conditions and select Wall from the drop-down list.

    The program automatically updates the Location You will see that the panel is already markedUp-to-date.

    6. Return to the Physics panel. Under Solver Options click on Numerical Controls.

    a. In the Numerical Controls panel click on >to expand Solution Control. Under Coupling Controlselect SIMPLE from Pressure velocity coupling drop-down list.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.10

    Automation with Templates, Scripting and Journals

  • b. Under Explicit relaxation enter 0.4 as the Explicit relax factor for pressure.

    c. Enter 0.6 as the Explicit relax factor for velocity.

    7. Now go back to Physics panel and click on Solution Controls.

    11Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • Enter 250 for Maximum number of iterations.

    8. The Physics task is now ready to be updated. You can update it by either clicking blue lightning bolt nextto the Out-of-date message near the top of the Physics panel, the blue lightning bolt next to the Outputtab near the bottom of the Physics panel, by selecting Update under the Workflow tab, or by RMBwithin the graphics window and selecting Solve Physics from the context menu.

    9. You can click on the Transcript and the Solution Quality tabs to check the progress.

    Note

    You have changed the default numerical values so that they can be recorded in the journal.

    8.3.6. Results

    You can add Results by either:

    Clicking on Physics cell > Add Next > Results Evaluation In the Workflow tab.

    Clicking on Add > Results Evaluation in the Physics panel under Connected Tasks.

    Or, RMB in the graphics window and selecting Add Next Task > Results Evaluation

    1. In the Results panel click Add and select Contour from the drop-down menu.

    a. In the Contour panel select the wall from Location drop-down list.

    b. Select Pressure from Variable drop-down list.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.12

    Automation with Templates, Scripting and Journals

  • c. Change the name to Wall Pressure.

    d. Now click Next Step > Add > Results > Vector

    i. In the Vector panel select outlet from Location drop-down list.

    ii. Select Velocity from Variable drop-down list.

    iii. Change the title name to Outlet Velocity.

    13Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • Now you will create planes to display the velocity vectors and pressure contours.

    2. Click Next Step > Add > Construction Geometry > Plane

    a. Enter Z0 for the title name.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.14

    Automation with Templates, Scripting and Journals

  • b. Click Next Step > Add > Construction Geometry > Plane to add another plane.

    i. Enter Y0 for the title name.

    15Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • ii. Under Transformation enter 90 [degree] for Rotation angle.

    c. Click Next Step > Add > Results > Contour

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.16

    Automation with Templates, Scripting and Journals

  • i. Enter Y0 Pressure for the title name.

    ii. Retain selection of Y0 from the Location drop-down list.

    iii. Select Pressure from the Variable drop-down list.

    d. Click Next Step > Add > Results > Vector

    i. Enter Z0 Velocity for the title name.

    ii. Select ZO from the Location drop-down list.

    iii. Select Velocity from the Variable drop-down list.

    e. Click Next Step > Add > Results > Streamline

    17Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • i. Enter Streamlines_from_inlet for the title name.

    ii. Select inlet from the Seed location drop-down list.

    3. In the Workflow tab right-click on Results and select Update from the menu.

    4. To stop writing the journal from the menu click

    File > Scripting > Stop recording journal...

    You will get a dialog box to confirm that you want to stop recording. Click OK.

    Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.18

    Automation with Templates, Scripting and Journals

  • 5. In your working folder you will find a journal file CFD_auto_script. Open it in any text editor. You willsee in the scripts the steps that were followed in the tutorial. You can change the settings in the journalfile and then run the script with the modifications to see the results.

    Note

    A journal file (CFD_Automation) is given with the geometry file. This file looks similarto the one you have created. It has added comments to show the process of the simu-lation. You can change the settings in the file and run the script to check the results.

    8.3.7. Summary

    With ANSYS AIM you can record, playback and modify a journal file. You learned how to:

    1. Record a journal file,

    2. Set-up a fluid analysis in AIM by defining tasks directly,

    3. Import CAD geometry,

    4. Create a mesh,

    5. Assign materials from existing libraries,

    6. Apply boundary conditions,

    7. Solve the analysis,

    8. Post-process results, and

    9. Playback a simulation using a recorded journal file.

    19Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information

    of ANSYS, Inc. and its subsidiaries and affiliates.

    Setup And Solution

  • Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential informationof ANSYS, Inc. and its subsidiaries and affiliates.20

    Chapter 8: Automation with Templates, Scripting and Journals8.1. Prerequisites8.2. Problem Description8.3. Setup And Solution8.3.1. Preparation8.3.2. Starting AIM8.3.3. Geometry8.3.4. Mesh8.3.5. Physics8.3.6. Results8.3.7. Summary