Tutorial
OPTIMIZATION
COUPLING ANSA/ETA to OPTIMUS
Table of Contents
1. Introduction ...................................................................................................................................2 1.1 Prerequisites........................................................................................................................2 1.2 Problem Description ............................................................................................................2 1.3 Data Files ............................................................................................................................3 2. Defining the Optimization Task .....................................................................................................4 2.1 Definition of Design Variables ................................................................................................6 2.2 User Script for Mass Output ...................................................................................................9 2.3 The Design Variables Input file ............................................................................................11 2.4 The FE output file.................................................................................................................13 3. Run the Optimization Task..........................................................................................................15 4. Set up the ANSA Settings...........................................................................................................16 5. DOE Study..................................................................................................................................18 6. Define Responses ......................................................................................................................20 6.1 Define the Mass of the model...............................................................................................20 6.2 Define the Maximum Displacement......................................................................................21 7. Set up OPTIMUS ........................................................................................................................27 8. Results........................................................................................................................................37
1.1 Prerequisites The user must be familiar with the basic keywords of NASTRAN for Solution 111 since the model has been prepared for a Modal Frequency Response analysis in NASTRAN. If another solver is to be used, the user has to update the model properly. 1.2 Problem Description A body in white model is tested in a Modal Frequency Response analysis. (Sol 111 in Nastran). The model is being subjected to a harmonic excitation in the front left shock housing, which represents a road induced load, while being constraint in all 6 degrees of freedom in the rest 3 shock housings. The purpose of the optimization is to minimize the weight while constraining the displacement under the drivers seat which is produced from the harmonic load. The design variables are the thicknesses of 4 sheet metal parts. In order not to have very long run times and since this study is performed only for training purposes, only 4 design variables have been used. The 4 design variables are the thicknesses of the parts that appear on the left, namely the firewall, the upper firewall, the toe pan and the toe pan reinforcements.
The total weight of the model is 382.5 kg while the harmonic force has a magnitude of one fourth the models weight which is approximately 95.6 kg or 940 Newton. The model is tested under this load in a range of up to 50 Hertz.
The maximum displacement under drivers seat, appears when the model is being excited with a load having a frequency of 18 Hertz and have the value of 4.95 mm. This value is going to be used as constraint in the optimization and the goal is to be lower than 4 mm.
The above can be summarized in the following table. It must be noted that the thicknesses can take specific values, so the design variables have been specified to take the discrete values between the minimum and the maximum allowed value, with a step of 0.1 mm. Design Variables Firewall Upper Firewall Toe Pan Toe Pan Reinforcement Constraints Maximum Displacement Objective Weight 1.3 Data Files The files of this tutorial are located at the directory where this document is located under the /tutorial_files/. The user should copy these files in the directory where ANSA, ETA and OPTIMUS will run. The files are:
biw_initial.ansa biw.ansa biw.nas biw.txt mass.bs Max_displacement.ses Max_displacement.ses.results biw.opt
Maximum Value 2 2 4 4 4
initial ANSA database the resulting ANSA database the initial NASTRAN output file design variables file script file the ETA session file the responses file OPTIMUS project file
Open file: biw_initial.ansa The optimization sequence will be defined through the Task Manager Tool. This sequence will be saved in the ANSA database when the user saves the database. Use the button of the main menu to open the Task Manager. To create a new Optimization Task pick on the Tasks button and select the Optimization Task from the pull-down menu that appears.
A default Optimization Task is defined which contains the following Task Items: DV file : the ASCII design variables input file Design Variable : a design variable FE_output : output command for the FE model. At this time the Optimization Task is at Definition mode. In this mode the user is able to define and modify the Task. This is the default mode when an Optimization Task is created. To run the Optimization Task the user should switch to the Execution mode. This action is described in a later section.
The Optimization Task list opens. The by default created design variable is listed under the task. Select it and press the Delete button in order to delete it. At the same time it will be deleted also from the Optimization Task. Note that if the Option Buttons in the end of the window are not visible, you have to press the little arrow on the left down corner of the window to make them visible. The same options are also appearing as a list if you select the Design Variable item and press the right mouse button.
2.1 Definition of Design Variables In order to create design variables which will be connected to the thickness of the desired Parts, select the Optimization Task item and press the right mouse button. Select the option New > DV from entity
The Database Browser opens. Here you can select whatever ANSA entity you want in order to connect a characteristic of this entity with a design variable. Select the PSHELL listed under the PROPERTY item. The corresponding list appears, containing all the Pshell Properties of the model. Select these with Id 2000085, 2000088, 2000095 and 2000096, which correspond to the before mentioned parts.
The red number in the list indicates the number of selected entities. When all the desired properties are selected press the OK button. Note that you can select entities of different type. For example after the Properties selection you can pick also the MATERIAL item in order to select Materials from the list.
4 ANSA Parameters are automatically created and connected with the Thickness of the selected properties. The value of each ANSA Parameter is controlled by a Design Variable.
At the same time the new Design Variables are listed also in the Optimization Task in the Task Manager. The next step is to define the possible values that the design variables can take. Have also in mind that the thickness of the sheet metal parts can take only discrete values Select the design variable connected to the Property with id 2000085, press the right mouse button and in the list that appears select the Edit option.
The design variables possible values can have a range of three types. The BOUNDS type, where the design variables can take all the values between the minimum and the maximum, the STEP type where you specify a step and the LIST type where you specify specific values in a list form. In the design variables card that appears switch the RANGE pull down menu to the STEP option and give the value 0.1 in the Step Value field. Specify also the minimum and maximum values 0.5 and 2 respectively. Press OK to confirm. Follow the same procedure for the rest three design variables. The corresponding values are presented in the following table: PSHELL 2000088 TYPE RANGE Min Value Current Value Max Value Step Value REAL STEP 0.5 1.7 2 0.1 PSHELL 2000095 TYPE RANGE Min Value Current Value Max Value Step Value REAL STEP 0.5 1.9 4 0.1 PSHELL 2000096 TYPE RANGE Min Value Current Value Max Value Step Value REAL STEP 0.5 2.5 4 0.1
2.2 User Script for Mass Output User scripts can be added to the optimization sequence to perform a specific operation. The user scripts can be added under a Design Variable Task Item or directly at the main root of the Optimization Task. In this example the objective of the optimization is to minimize the mass. So the models mass should be output from ANSA and should be read from the Optimus parser tool. The mass output can be performed either through a session command or using a user script. In this case a user script has been used. Note that the most important and commonly used functionalities of ANSA are available also as script functions, while the case is not the same for the session commands. For this reason the user scripts are strongly recommended. So, the mass output should be performed just before the FE output and after the change of the design variables value. Select the Optimization Task right click on it and pick the New > User Script option.
A new Task Item is defined at the end of the optimization task. Drag and Drop it one step above, just before the FE_output command.
The Select script function window appears. Through this window the user can select the script file that will be associated to the User Script task item in the Optimization Task. Pick the Load module button to open the file manager and select the script file to be used
This is the mass.bs that is located in the tutorial folder of the installation directory.. The file is considered as a module. This means that every function inside this file will be loaded and will be available for use. Note that the modules are stored in the ANSA database, so they can be used at any time without the need of loading them in every session and having them in a specific directory.
From the pull-down menu select the loaded module. All the scripts of the module are listed below in the Function list. In this example only one function is available, the main(). Select the function and press OK to confirm. The selected script function has been associated to the User Script item.
10
11
The specified path and the name are appearing in the DV file task item. You can specify also the current directory as the one where the DV file will be saved. To do so, rename the DV file to ./biw.txt by clicking on it twice. The ./ means the current directory which refers to the directory where ANSA runs from, as mentioned before. The DV File Task item is defined and the path is indicated to the Task Item name. However the file is not yet created and saved. The file will be saved as soon as the user switches the Optimization Task from Definition to Execution mode. The DV file is shown bellow:
# # ANSA_VERSION: 13.1.1 # # file created by A N S A Tue Nov 30 14:25:25 2010 # # Output from: # /home/demo/Desktop/Optimus_Tutorial/biw.ansa Min values # Current values Max values # DESIGN VARIABLES #-----------------------------------------------------------------------# ID | DESIGN VARIABLE NAME | TYPE | RANGE | CURRENT VALUE | MIN VALUE -> MAX VALUE | STEP #-----------------------------------------------------------------------2, PSHELL_2000088_T, REAL, STEP, 1.7, 0.5, 2., 0.1 3, PSHELL_2000095_T, REAL, STEP, 1.9, 0.5, 4., 0.1 4, PSHELL_2000096_T, REAL, STEP, 2.5, 0.5, 4., 0.1 5, PSHELL_2000085_T, REAL, STEP, 1.7, 0.5, 2., 0.1 #-----------------------------------------------------------------------Step values
12
2.4 The FE output file The last Task Item of the optimization sequence creates an FE output of the model in the format of the desired solver. Right click on the FE Output Task Item and select the Edit button.
The OUTPUT DECK window appears. Select the NASTRAN option from the pull-down menu to output the model in this format. Press OK to confirm.
The file manager window opens. Enter the path where the file will be output and a name and confirm. In this example the name of the file is biw.nas. In every iteration of the optimization process, the Fe output file will be output in the specified directory.
13
The FE Output Task item is defined and the path is indicated to the Task Item name. You can rename the file and specify the current directory as the output directory. Click on the task item twice and give the name ./biw.nas. Note that the file is not yet created and saved. The file will be created when the Optimization Task runs in the Execution mode.
14
The Optimization Task card appears. Switch the Run Mode pull-down menu to Execution and pick OK to confirm. As it is mentioned before the ANSA file should be saved with the Optimization Task in execution mode in order to perform the defined sequence during the optimization procedure.
15
NOTES: If the Cancel button is picked, the Optimization Task will remain in Definition mode. This ensures that the Optimization Task wont run using a non compatible DV File. The Optimization Task is able to be switched to Execution mode only if all Task Items are defined properly. To check this, select the Optimization task when in definition mode, right click on it and pick the Update button. All the correctly defined items will be ticked. The symbol indicates that Execution. of the Optimization Task the current mode is the
Now, save the ANSA file. The model is ready to be connected to the OPTIMUS workflow.
16
- The DECK REPORT window appears. - Switch the pull-down menu on the top to As Text in order to save the report as a text file. - Press ESC to exit.
Save settings Open the MENUBAR>Windows> Options and pick the Save Settings and Save GUI Settings buttons to save the changes to the ANSA.defaults and ANSA.xml files respectively.
17
5. DOE Study
A simple Design of Experiments algorithm can be performed through ANSA for the validation of the model for all combinations of the design variable values. The available DOE algorithm is the Full Factorial. The user can produce experiments either to validate the model before coupling with an optimizer or to run a simple optimization process where only the definition of experiments is needed. Run the DOE Activate the function by right clicking on the Optimization Task and selecting the DOE Study option. NOTE: To run a DOE Study the Optimization Task should be saved in Execution mode. For this reason a warning window pops up when a DOE Study is requested. Press OK to save the ANSA file.
The DOE Study window opens in which all the design variables of the Optimization Task are listed. Make active the design variables that will take place to the experiments calculation by picking on the relative flags. The discrete values of the Design Variables can be selected from the corresponding List option. Pick it with the left mouse button.
18
The file manager appears. Specify the directory where the DOE files will be output and press OK. The DOE starts.
For each experiment all the actions defined at the Optimization Task will run starting from the initial model. For each run, a directory will be created at the directory that will be specified in the File manager. The name of the directory will be the name of the ANSA file, plus the current values of the design variables. The DV file and the FE output that are created during the run will be saved in these directories. In the same mother directory, a .txt file will be saved, named combinations.txt that contains the values of the design variables for each experiment. More information about the DOE Study you can find in the Optimization_with_ANSA.pdf at <ANSA installation directory>/docs/
19
20
6.2 Define the Maximum Displacement The maximum displacement under the drivers seat, will be used as a design constraint. The value of this response will be extracted from eta Post Processor version 6.6.2, using the results of the initial solution.
1. 2. 3.
Open ETA at the directory where the optimization will be set up. Pick the Read of the Geometry tab to open the file manager. Read the biw.nas file.
4.
Switch to the Results tab to read solver results. The biw.op2 file which is located in the same directory is automatically selected. At the Scalar tab select Displacements> Transalational >Centroid >Magnitude. Pick the Read button to read the results.
21
5. 6. 7.
Activate the Wire flag button Select the iNode selection option. Pick a Node of the cross member under the drivers seat. This would be the node, the maximum displacement of which will be used as design constraint. Note that in this way ETA will store the coordinates of the click in the session file, and not the id of the node itself.
22
8.
Pick the Windows > Create 2d plot option. A new window opens
9 10
9. Switch to the Pick from model tab 10. Press the adv. filter option in order to select the identified node for a 2d plot creation. 11. In the Advanced Filter window specify the options add, Nodes and identified as shown in the picture and press OK to confirm. The id of the identified node appears in the respective window.
23
12
12. Select the identified node, pick the Total Node Data from the available results tab, switch the Select x axis pull down menu to Frequency and press the Create button. The plot which represents the displacement of the identified node in respect with frequency is created.
13
13. Pick the Tools>Annotations of the main menu to open the annotation tool.
24
14
15
16 17
18. An annotation is created with the maximum value of the curve. The arrow points at the position with the maximum displacement. In general, to extract responses from result files the Annotations tool of ETA is used.
25
20
21
22
23. The file manager opens. Enter the response name (Max_displacemet.ses) and press Save to confirm. This file contains all the actions that have been made in ETA since it was opened. This file will be read in every optimizations iteration and the sequence of actions will be repeated, using the respective solver results. So in this way, in each iteration the corresponding response value will be output. Upon confirmation another window opens, containing all the paths from which solver files have been read. (In this case there is only one path, the one that contains the .nas and the .op2 files which have been used.) 24. Select the path for the imported files that will be identified as the working directory. This is helpful when many solver results have been imported from different locations. 25. Pick OK to confirm. Two files will be created. The Max_displacement.ses which is the session file of ETA and the Max_displacement.ses.results that contains the value of the defined response.
26
7. Set up OPTIMUS
In this step it is demonstrated the connection of ANSA and ETA with OPTIMUS Rev 9 SL1 and the set up of the optimization problem run. Four special components, two for ANSA and two for ETA have been enhanced in OPTIMUS for the easy connection of the softwares with each other. The optimization sequence that has been defined through the Optimization Task is controlled from the ANSA component while the ETA actions from the ETA component. The OPTIMUS workflow is presented in the following picture.
It is composed of three input files ( biw.txt, biw.ansa and Max_displacement.ses ) three actions (ANSA, Nastran, ) and two output files (the mass value and the maximum displacement value). The set up of each node in the workflow, will be presented in the following pages.
27
All the components of the workflow can be found in the right side of OPTIMUS window. Pick a component, move the cursor to the position you want to place it and press the left mouse button. The component has been added to the workflow. Insert all the necessary components to create the workflow that appears in the picture and connect them with each other.
28
2
2.
3. 4.
5.
6.
The Input variable array window opens. It contains all the information for the design variables. Activate the Relaxed option in the respective field as appears in the picture. This has to be done since the initial values, give a non feasible solution, which means a solution that doesnt satisfy the design constraints. You can find more information about the relaxation of Design Variables in the OPTIMUS Theoretical Backroud.pdf at section 2.2.1.4. Press OK to confirm.
29
8.
Edit the File2 component, the one that is connected with the output variable. Press the Load button and select the mass.log file. The contents of the file appear in the window. Here you will specify where exactly in the file there is the mass value. So, OPTIMUS will read this value every time that is needed during the optimization loop.
11 8
10
9. Specify the value 8 in the Offset field since the mass value is 8 lines bellow the first one. 10. In the Extraction field leave the option to Word Nr and give the value 4. This is because the mass value is the fourth word in the line. (words are separated by comma). 11. In the end press the Verify button.
30
12
12. The mass value is highlighted. Press the Return button and OK to confirm. 13. Edit the Output1 component. The identified mass value appears in the Value field. Optionally rename the output variable and press OK to confirm.
31
15. Edit the ANSA component. The input and output files of the component are listed under the Inputs and Outputs fields. There are also three main fields, the Model database, the Input file and the Output file. Specify the biw.ansa, the biw.txt and the biw.nas respectively as value of these fields, by clicking in each value field and then selecting the respective file. Press OK to confirm.
32
17. Edit the File4 component. This is the nastran output file. Enter the name biw.op2 and press OK to confirm.
33
19. Edit the results component. Pick the Select button and specify the Max_displacement.ses.results file located in the tutorial folder. 20. The maximum displacement value appears in the Possible Results field. Select it and press the Add button. Now it appears also under the UCI Parameter and OPTIMUS Parameter fields. 21. Press OK to confirm.
19
20
21
34
23. Edit the component. Click in the Value field of the Session file option and select the Max_displacement.ses file from the Inputs list. Do the same with the Output file option by specifying the Max_displacement.ses.results file. Press OK to confirm.
35
The Optimization method window pops up. The Mixed Integer Programming algorithm is automatically selected, since this algorithm deals with discrete design variable values. Set the objective function to be the minimization of mass by selecting the mass_value output from the respective pull down menu and press the Apply button.
In the Start calculation window that appears, select the Save project and Run option and press OK. The optimization run starts.
36
8. Results
In the optimum design the weight of the four sheet metal parts have been increased by 7kg but at the same time a decrease of 40.9% at the maximum displacement has been achieved. It must be noted that this study case has been performed only for training purposes and the results are not of great importance. Furthermore if more design variables had been used, a weight reduction might have been achieved also. Many Post-process plots can be extracted directly form OPTIMUS. In the picture on the left, the values of the optimization parameters in the initial and final run are presented. In the plot that follows, the progress of these values during the optimization procedure is presented.
37
A 2d plot of the initial and final displacement in respect with frequency created in .
38