Introduction to ANSYS DesignXplorer

17
1 Quick Workshop 10: Running Workbench in Batch 19.0 Release Introduction to ANSYS DesignXplorer

Transcript of Introduction to ANSYS DesignXplorer

Page 1: Introduction to ANSYS DesignXplorer

1

Quick Workshop 10: Running Workbench in Batch

19.0 Release

Introduction to ANSYS DesignXplorer

Page 2: Introduction to ANSYS DesignXplorer

2

• Goal

– To use python batch scripts to automate an optimization study

• Model Description

– The geometry is a 2D rectangle, fixed on one side and with an applied force on the opposite side

– The problem is solved in Mechanical APDL

Input parameters

- Force magnitude

- Width and Height

Output parameters

- Maximum deformation

Overview

Page 3: Introduction to ANSYS DesignXplorer

3

1. File > Open > Plate_pull.wbpj

2. Optionally, inspect the geometry, mesh, and analysis cells. If not familiar with Mechanical APDL, the following summary will provide the details necessary to understand the problem

Width

Height

Fixed support

Force (FX_MAG)

Max X displacement (MAX_U_SUM)

Height, Width, and FX_MAG are set as input parameters MAX_U_SUM is set as an output parameter

Project Startup

Page 4: Introduction to ANSYS DesignXplorer

4

• Now we will begin to create a script by recording a journal file in Workbench that opens a project, changes parameter values, updates the project, and saves the project. We will then modify the script so that it can be run in batch

1. Close Plate_pull.wbpj by clicking File > New

2. Click File > Scripting > Record Journal > save the journal file as ChangeParameters.wbjn. All of the actions will now be recorded

3. Open Plate_pull.wbpj

4. Double-click on the Parameter Set bar set FX_MAG to 100.5, width to 0.02, and height to 0.01

5. Return to Project and click Update Project

6. Save Project as Plate_pull_ParametersChanged.wbpj

7. Click File > Scripting > Stop Recording Journal > click OK

Workbench in Batch

Page 5: Introduction to ANSYS DesignXplorer

5

Open the journal file (ChangeParameters.wbjn) in a text editorThe journal file will look as follows:

We will now modify the journal file so that it uses variables to define the name of the project to be opened, the name of the project to be saved, and the parameter values

Workbench in Batch

Page 6: Introduction to ANSYS DesignXplorer

6

8. Change the journal file to the following:

Workbench in Batch

Page 7: Introduction to ANSYS DesignXplorer

7

9. Close Workbench

10. Open a command prompt. This can be done by clicking Windows > All Programs > Accessories > Command Prompt and type the following (with paths appropriate for your computer settings):

"C:\Program Files\ANSYS Inc\v190\Framework\bin\Win64\runWB2.exe" -B -R C:\Users\mboulos\Desktop\ChangeParameters.wbjn

The above will launch the script in batch. Look for C:/Plate_pull_ParameterChangeInBatch.wbpj to ensure that the batch script was run correctly

Workbench in Batch

Page 8: Introduction to ANSYS DesignXplorer

8

• Now we will begin to create another script that opens a project, adds new Design Points, updates the project, and saves the project. We will then modify the script so that it can be run in batch

1. Open Workbench

2. Click File > Scripting > Record Journal > save the journal file as AddDesignPoints.wbjn. All of the actions will now be recorded

3. Open Plate_pull.wbpj

4. Double-click on the Parameter Set bar. In the Table of Design Points, enter the following settings in the empty row at the bottom of the table

P7-FX_MAG = 50

P5-width=0.01

P6-height=0.02

5. Click Update All Design Points

6. Save Project as Plate_pull_NewDesignPoints.wbpj

7. Click File > Scripting > Stop Recording Journal > click OK

Workbench in Batch

Page 9: Introduction to ANSYS DesignXplorer

9

The journal file will look as follows:

We will now modify the journal file so that it creates many design points using a while loop and solves each DP in sequence using “try” and “except” to avoid stopping if certain DP updates fail

Workbench in Batch

Page 10: Introduction to ANSYS DesignXplorer

10

8. Change the journal file so that variables are used to define the project names:

Workbench in Batch

Page 11: Introduction to ANSYS DesignXplorer

11

9. Add a variable defining the number of new design points and arrays containing the various values for each parameter:

Workbench in Batch

Page 12: Introduction to ANSYS DesignXplorer

12

Notice that the design point creation is composed of three steps

1. A new design point is created

2. The internal parameter name is extracted

3. Parameter value is adjusted

Workbench in Batch

Page 13: Introduction to ANSYS DesignXplorer

13

11. Change the journal file so that all three parameter names are extracted, and the parameter values are adjusted in a loop

Workbench in Batch

Page 14: Introduction to ANSYS DesignXplorer

14

• Notice that the design points are updated with manual specification of each design point to update. Since we now have 4 design points we must adjust this. Putting all design points within this UpdateAllDesignPoints line will allow for the update of all design points

Workbench in Batch

Page 15: Introduction to ANSYS DesignXplorer

15

12. Change the journal file as follows:

Workbench in Batch

Page 16: Introduction to ANSYS DesignXplorer

16

13.Close Workbench

14. Open a command prompt. This can be done by clicking Windows > All Programs > Accessories > Command Prompt and type the following (with paths appropriate for your computer settings):

"C:\Program Files\ANSYS Inc\v190\Framework\bin\Win64\runWB2.exe" -B -R C:\Users\mboulos\Desktop\AddDesignPoints.wbjn

The above will launch the script in batch. Open C:\Plate_pull_NewDPs.wbpj to ensure that the batch script was run correctly

Workbench in Batch

Page 17: Introduction to ANSYS DesignXplorer

17

Try to use the same procedure to add goal driven optimization to this project. The project should do the following:

1. Open the project

2. Add a Goal Driven Optimization system to the project schematic

3. Set DOE parameter ranges for each parameter

4. Update the DOE

5. Update the Response Surface

6. Define Optimization Goals

7. Update the Optimization Cell

8. Save the project

After creating the script, compare your script file with addGDO.wbjn

Additional Work