BETA CAE Systems S.A.
Tutorial 7
OPTIMIZATION WITH
ANSA
A FRONT RAIL
CRASH SIMULATION
Table of Contents
7.1. Introduction .................................................................................................................................2
7.1.1. Prerequisites .......................................................................................................................2
7.1.2. Problem description.............................................................................................................2
7.1.3. Data files .............................................................................................................................3
7.2. Defining parameters from Morphing Boxes ................................................................................4
7.3. Defining parameters from ANSA Cards ....................................................................................11
7.4. Output files ................................................................................................................................12
7.5. Simulation program ...................................................................................................................15
7.6. Set up the optimizer data flow...................................................................................................15
7.7. Results ......................................................................................................................................17
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-2 ANSA v.12.0.1 Tutorials
7.1. Introduction
This tutorial presents the coupling of ANSA with optimization software and the use of the Morphing Tool in shape optimization. There are three steps that needed to connect ANSA with optimization software. These steps include the definition of: Design variables
� Morphing Boxes definition � Morphing parameters definition � Parameters from ANSA Card entities � Declare parameters in ANSA_TRANSL
Constraints and objective parameters
� Output files � ANSA session file � Optimizer data flow � Boundaries of design variables
Simulation program
� Executable shell script
7.1.1. Prerequisites
The user must be familiar with the Morphing Tool functionality. In this tutorial the LS-DYNA solver has been used and the model have been prepared to run to this solver. If another solver has to be used, the user must update the model properly. An optimization program has been used. This program must be able to read the design variables, constraints and objective parameters through ascii files. The optimizer must also be able to control an external simulation program. The steps concerning the preparation of the model in LS-DYNA are not described.
7.1.2. Problem description
A front rail of a BiW will be tested in crash simulation. The target is to find the best arrangement of its embosses in order to minimize the acceleration that appears in that test. As constraints are used the mass of the rail and the intrusion. These constraints must be kept within a specific range.
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-3 ANSA v.12.0.1 Tutorials
The design variables that are used are: - The depth of the embosses - The width of the embosses - The distance between the embosses - The height of the rail - The width of the rail - The thickness of the rail
A first run of the nominal case (the rail without the embosses) can give an estimation of the values of acceleration, mass and intrusion. All measurements took place at a reference point as shown at the picture on the left. Output results have been created for this position which are written in the d3thdt result file of LS-DYNA. The values from the nominal run are: X acceleration : -447 m/s2 X coordinate : -323 mm Mass : 1.6285 Kg Rail height : 80 mm Rail width : 80 mm Barrier Mass : 400 Kg Initial velocity : 8 m/s Rail thickness : 1.3
The boundaries for the design variables are : -6 =<Emboss_depth =<0 -2 =<Emboss_width =<2 -5 =<Emboss_dist=<10 -20 =<Rail_height =<20 -20 =<Rail_width =<20 Thickness (0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4) The boundaries for the constraints are : Mass<1.8 X_coordinate<-300
7.1.3. Data files
The files of this tutorial are located in the directory íìíçêá~ä|ÑáäÉëLMTJçéíáãáòáåÖL. The files
are: rail.ansa initial ANSA database rail_final.ansa resulting ANSA database ANSA_TRANSL ANSA script file rail.ses ANSA session file META_output.ses µETA Post session file drive.sh executable shell script
Width
Depth
Distance
Rail height
Rail width Thickness
Reference point
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-4 ANSA v.12.0.1 Tutorials
7.2. Defining parameters from Morphing Boxes
Defining Morphing Boxes
In this example the solver LS-DYNA will be used. The model is prepared to run to this solver.
Isolate the part of the rail that is going to be modified with Morphing Boxes. The Part Manager can be used for this task.
Go to the Morphing Tool and create a Morphing Box using the BOXES>
ORTHO function. All the elements of the rail are loaded in this Box. Also the Connection Points that connect the two parts are loaded to the defined Box.
ORTHO
USER
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-5 ANSA v.12.0.1 Tutorials
Use the CONTROL POINTS> EXTEND function to enlarge
the Box in two directions as shown at the picture on the left.
In order to create splits exactly on the rail faces, define Control Points using
the CONTROL POINTS> PROJECT function.
Split the Box at the positions of the created Points. Use the
BOXES> SPLIT function and select the created Points with the right mouse button to snap on the Points.
EXTEND
PROJECT
NORMAL
SPLIT
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-6 ANSA v.12.0.1 Tutorials
Do the same for all the sides of the rail. Also a split must be created in each of the two planes of symmetry.
Now the required splits for the embosses will be created. Define the Control
Points where the splits will be created by projecting positions of the FE model to the Morphing Box Edges as shown at the picture on the left.
Use the BOXES> SPLIT function and select the created
Points with the right mouse button to snap on the Points. The splits are created.
PROJECT
NORMAL
SPLIT
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-7 ANSA v.12.0.1 Tutorials
Defining Morphing parameters
To handle the shape of the model, Morphing Parameters
will be created. Activate the CONSTAINTS> PARAMS function. The Parameter list opens where new parameters can be created, edited or listed.
Two Morphing parameters are needed to handle the depth of the embosses. To define the first parameter activate the NEW [LENGTH] function from the Parameters List and select the Control Points that will be handled from the parameter. Middle click to confirm and select the Morphing Box Edges where the selected Control Points will be moved on.
Middle click to confirm and enter a name the parameter. This parameter handles the depth of the horizontal embosses.
PARAMS
2
1
1
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-8 ANSA v.12.0.1 Tutorials
Define the second length parameter which handles the depth of the vertical embosses.
When the values of the parameters are modified, the embosses appear. The specified values represent the relative movement of the Control Points along the Edges. In that way Egdes with different length can be handled through one parameter. In this example the parameters will handled through the ^kp^|qo^kpi
script file.
The width of the embosses will be controlled with one Morphing Parameter. Activate the NEW [LENGTH] function of the Morphing Parameters List and select the Control Points that will be controlled from the parameter (red Control Points). Middle click to confirm and select the Edges where the Points will be moved on.
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-9 ANSA v.12.0.1 Tutorials
The distance between the embosses will defined as parameter. In this case the NEW [TRANSLATE] function is used. The selected Control Points will be moved along a specified vector. Select all the Control Points of the one emboss (white ones) and middle click to confirm. In the TRANSLATE window that appears define the vector of the translation. In this case the X axis. Middle click to confirm and another group of Control Points can be selected (blue ones) an another translation vector (-X axis). Middle click twice to give a name and exit the function.
Now the width and height of the rail will be connected with Morphing Parameters. Activate the NEW [LENGTH] function of the Parameters List and select the Control Points that will be moved (red ones). Middle click to confirm and select the Morphing Box Edges where the selected Control Points will be moved on.
In the same way a parameter is defined for the width of the rail.
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-10 ANSA v.12.0.1 Tutorials
All the parameters are defined and can be visualized, edited or modified through the Parameters List.
Declaring Morphing parameters in ANSA script file
The defined parameters can be declared in the ANSA script file (the ^kp^|qo^kpi). Through this file
the parameters can be accessed and handled by the optimizer. def optimizer(void) { /*----------------------------------------*/ /* INPUT VARIABLES */ /*----------------------------------------*/ /*----------------------------------------*/ /* Parameters for Morphing */ /*----------------------------------------*/ Emboss_depth = 0; Emboss_width = 0; Emboss_dist = 0; Rail_height = 0; Rail_width = 0; /*----------------------------------------*/ MorphParam(1, Emboss_depth); MorphParam(2, Emboss_depth); MorphParam(3, Emboss_width); MorphParam(4, Emboss_dist); MorphParam(5, Rail_height); MorphParam(6, Rail_width); }
Define a command in the ^kp^|qo^kpi file
which will be called in each iteration of the optimizer. In this case the command is the çéíáãáòÉêEîçáÇF as shown on the left. In
this command define the design variables as variables of the scripting language with an initial value (e.g. bãÄçëë|ÇÉéíÜZMX). Keep
in mind that the values of the parameters represent relative movement. So the value zero means no any modification. For each Morphing Parameter enter the function jçêéÜm~ê~ãEáåí=~I=Ñäç~í=ÄF.
This command modifies the value of a selected parameter. As áåí=~ enter the ID of
the parameter to be controlled and as Ñäç~í=
Ä enter one of the above variables.
One design variable can handle more that one jçêéÜm~ê~ã commands. In this
example the bãÄçëë|ÇÉéíÜ=ZMX handles
the jçêéÜm~ê~ãENI=bãÄçëë|ÇÉéíÜF and
the jçêéÜm~ê~ãEOI=bãÄçëë|ÇÉéíÜF.
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-11 ANSA v.12.0.1 Tutorials
7.3. Defining parameters from ANSA Cards
Design variables can be extracted from any entity of any ANSA card. In this example the thickness of the rail will be set as a design variable. A small script is added in the çéíáãáòÉêEîçáÇF
command for this. The updated command is shown below. def optimizer(void) { /*----------------------------------------*/ /* INPUT VARIABLES */ /*----------------------------------------*/ /*----------------------------------------*/ /* Parameters for Morphing */ /*----------------------------------------*/ Emboss_depth = 0; Emboss_width = 0; Emboss_dist = 0; Rail_height = 0; Rail_width = 0; /*----------------------------------------*/ MorphParam(1, Emboss_depth); MorphParam(2, Emboss_depth); MorphParam(3, Emboss_width); MorphParam(4, Emboss_dist); MorphParam(5, Rail_height); MorphParam(6, Rail_width); /*----------------------------------------*/ /* Parameters for entites */ /*----------------------------------------*/ Thickness = 1.2; /*----------------------------------------*/ prop2id = 2; /*-----------------------------------------*/ for (prop = GetFirstEntity(LS_DYNA,"SECTION_SHELL"); prop ; prop = GetNextEntity(LS_DYNA, prop) ) { GetEntityCardValues(LS_DYNA, prop, "PID",propid2); if(prop2id == propid2) SetEntityCardValues(LS_DYNA, prop, "T1", Thickness); }
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-12 ANSA v.12.0.1 Tutorials
7.4. Output files
The constraints and objective parameters that needed for the optimization problem can be extracted directly from the output files of the solver or from user defined files. In this section user defined output files will be defined.
To get information for the model that is not results of the solver, for example mass of elements, surface of sell elements etc., an ascii file can be defined with the contents of the DECK INFO report. In the command that used in every iteration (çéíáãáòÉêEîçáÇF)
the following function can be added. ab`hfkclE?LÇáêÉÅíçêóLÇÉÅâ|áåÑçKíñí?FX=
This function writes all the contents of the DECK INFO report to the ÇÉÅâ|áåÑçKíñt
file. In this example the optimizer’s file parser can extract the mass of the shell elements which will be used as a constraint.
The result files from the solver can be accessed directly through the optimizer’s file parser in order to extract specific values. Such values can be the stress or strain of selected nodes. However when calculations are needed in order to extract the constraints and objective parameters from the result files, a µETA Post session can be used.
In this example a µETA Post session is used in order to calculate the maximum displacement and the minimum acceleration of a node. The result file of LS-DYNA (d3thdt) contains information about a specific node. In that position all measurements take place. 1. To create the µETA Post session, open the µETA Post and invoke the 2Dplot window. 2. Open the d3thdt file. 3. Select results type Node. 2
3
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-13 ANSA v.12.0.1 Tutorials
4. The available results appear in the relative lists. Create one curve for the X acceleration (xa) and one for the X coordinate (xc).
5. Switch to the Functions tab of the 2Dplot window. 6. From the function list select maximum for the X coordinate curve. 7. Pick the APPLY to calculate the maximum value of the curve. 8. Select the result that appears in the list 9. Pick SAVE to write this value in an ascii file. Do the same for the acceleration. Use the function “Minimum” as the acceleration has negative values and quit µETA Post.
A session file with a default name is always created when µETA Post is used. Change the name of it in order not to be overwritten and add the command options quit at the end of the session file. This command quits the µETA Post after every execution. The created session is shown below.
4
5
6
78
9
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-14 ANSA v.12.0.1 Tutorials
jbq^|çìíéìíKëÉë= $ Session File written by META_post xyplot create "Window1" window active "Window1" window size 778,588 window active "MetaPost" xyplot layout "Window1" 2 window active "Window1" xyplot plotdeactive "Window1" 0 xyplot plotactive "Window1" 1 xyplot read lsdyna "Window1" "/directory/d3thdt" Node 7710 X_coordinate_(xc) xyplot plotdeactive "Window1" 1 xyplot plotactive "Window1" 0 xyplot read lsdyna "Window1" "/directory/d3thdt" Node 7710 X_acceleration_(xa) xyplot plotdeactive "Window1" 0 xyplot plotactive "Window1" 1 xyplot curve select "Window1" 1 xyplot curve function maxpoint "Window1" 1 xyplot output maxpoint "Window1" "/directory/Xcoordinate.txt" 1 xyplot plotdeactive "Window1" 1 xyplot plotactive "Window1" 0 xyplot curve select "Window1" 2 xyplot curve function minpoint "Window1" 1-2 xyplot output minpoint "Window1" "/directory/Xacceleration.txt" 2 window delete "Window1" options quit The defined output files are shown below:
u~ÅÅÉäÉê~íáçåKíñí= uÅççÇêáå~íÉKíñí=
$ Minimum Points File written by META_post "Min of Node 7710: X acceleration" "X","Min" 2.996747E-01,-4.472386E-01
$ Maximum Points File written by META_post "Max of Node 7710: X coordinate" "X","Max" 4.999967E+01,-3.236999E+02
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-15 ANSA v.12.0.1 Tutorials
7.5. Simulation program
In this section the simulation program for the optimizer will be defined. This is an executable shell script with the following commands: - Run an ANSA session - Run the solver - Run a µETA Post session The executable shell script is shown below.
The ANSA session contains the following commands: - Open ANSA - Read the ê~áäK~åë~ database
- Modifies the model by executing the çéíáãáòÉêEîçáÇFcommand
- Output the model in LS-DYNA format The ANSA session is shown below.
7.6. Set up the optimizer data flow
- Connect the defined files with the optimizer Extract the design variables from an ascii file. In this case the ascii file is the ^kp^|qo^kpi file. This file contains all the defined design variables
from the Morphing Tool or from ANSA cards. Use the optimizer’s file parser to extract the design variables. Define the simulation program The simulation program is the ÇêáîÉKëÜ that has been defined in the previous section.
Extract the constraints and objective parameters from ascii files.
#!/bin/csh –f #--------------------------- # run ANSA script file #--------------------------- /directory/ansa.sh -foregr -s ./rail.ses #--------------------------- # run solver #--------------------------- /directory/lsdyna_970 i=rail.key #--------------------------- # run META post session file #--------------------------- /directory/meta_post.sh -foregr -s /directory/META_output.ses echo "done"
NEW: discard OPEN: /directory/rail.ansa USER>optimizer: OUTPUT>LS-DYNA : filename= /directory/rail.key mode=visible write_comments=above_key format=970 QUIT:
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-16 ANSA v.12.0.1 Tutorials
The Mass constraint can be extracted from the ÇÉÅâ|áåÑçKíñí
The X_coordinate constraint can be extracted from the uÅççêÇáå~íÉKíñí
The X_acceleration objective parameter can be extracted from the u~ÅÅÉäÉê~íáçåKíñí
- Set up the boundaries of the design variables and constraints. - Set up the type of all variables. In this example all variables have REAL values except from the Thickness which has DISCRETE values. - Set up the optimization method. In this example the Adaptive Simulated Annealing has been used. The diagram below shows how the defined files are connected with the optimizer’s data flow :
Constraints & Objective Parameters
Optimizer
Xacceleration.txt Xcoordinate.txt
Optimal solution
Design Variables
Executable Shell Script (drive.sh)
ANSA_TRANSL
rail.ses LS-DYNA META_output.ses
deck_info.txt
Optimization
algorithm
OPTIMIZATION WITH ANSA – A Front Rail Crash Simulation
BETA CAE Systems S.A. Tutorial 7-17 ANSA v.12.0.1 Tutorials
7.7. Results
The results of the optimization process are shown below. The best values of the design variables can be stored to the ^kp^|qo^kpi file. By using the procedure that described in the previous
sections, the user can get the model of the optimal solution as shown at the picture below.
Emboss_depth = -5.511 Emboss_width = 0.833 Emboss_dist = -4.552 Rail_height = -14.366 Rail_width = -13.485 Thickness = 1.4 Mass = 1.614 X_coordinate = -341.287 X_acceleration = -289.2
Reduction of acceleration : 54.5% Reduction of intrusion (X coordinate) : 5.3% Reduction of mass : 0.89%