Sei sulla pagina 1di 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 recorded 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
Release 16.0 - SAS IP, Inc. All rights reserved. - Contains proprietary and confidential information
of ANSYS, Inc. and its subsidiaries and affiliates.

Automation with Templates, Scripting and Journals


8.3.4. Mesh
8.3.5. Physics
8.3.6. Results
8.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 start
a new ANSYS AIM session.

This displays the ANSYS AIM application window. The various Simulation Process Templates are
displayed in the Study panel at the left. The right is the help window where you can go through
the various videos to learn ANSYS AIM and also has links to the Help menu. The Workflow tab is
displayed 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 information
of ANSYS, Inc. and its subsidiaries and affiliates.

Setup And Solution

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 dialog
box, ensure that the unit system you are interested in is de-selected in column D or the
Suppressed 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 Simulation Process Templates.

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

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.

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

Automation with Templates, Scripting and Journals

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 information
of ANSYS, Inc. and its subsidiaries and affiliates.

Setup And Solution

3.

Click on Add next to Mesh Controls and select Inflation.


a.

The Inflation 1 panel is now displayed.

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

Automation with Templates, Scripting and Journals

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 default
values are not captured in the recorded journal. So it is recommended to change the
values 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 information
of ANSYS, Inc. and its subsidiaries and affiliates.

Setup And Solution

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 context
menu. This selects all the bodies in the geometry.

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

Automation with Templates, Scripting and Journals

c.
2.

3.

Click Apply.

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-down
list.

Return to the Physics panel and click Add next to Boundary Conditions and select Inlet from the dropdown list.

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

Setup And Solution

4.

a.

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

b.

Enter 3 m s^-1 for Magnitude.

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

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

Automation with Templates, Scripting and Journals

5.

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

Return to the Physics panel and click Add next to Boundary Conditions and select Wall from the dropdown list.
The program automatically updates the Location You will see that the panel is already marked
Up-to-date.

6.

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

10

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

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

Setup And Solution

7.

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.

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

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

11

Automation with Templates, Scripting and Journals

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 next
to the Out-of-date message near the top of the Physics panel, the blue lightning bolt next to the Output
tab near the bottom of the Physics panel, by selecting Update under the Workflow tab, or by RMB
within 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.

12

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 information
of ANSYS, Inc. and its subsidiaries and affiliates.

Setup And Solution


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.

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

13

Automation with Templates, Scripting and Journals

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

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

14

Enter Z0 for the title name.

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

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

Enter Y0 for the title name.

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

15

Automation with Templates, Scripting and Journals

ii.
c.

16

Under Transformation enter 90 [degree] for Rotation angle.

Click Next Step > Add > Results > Contour

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

Setup And Solution

d.

e.

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.

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.

Click Next Step > Add > Results > Streamline

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

17

Automation with Templates, Scripting and Journals

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.

18

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

Setup And Solution


5.

In your working folder you will find a journal file CFD_auto_script. Open it in any text editor. You will
see in the scripts the steps that were followed in the tutorial. You can change the settings in the journal
file 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 similar
to the one you have created. It has added comments to show the process of the simulation. 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.

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

19

20

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

Potrebbero piacerti anche