Sei sulla pagina 1di 18

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

BETA CAE Systems S.A.

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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.

BETA CAE Systems S.A.

Tutorial 7-2

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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

Depth

Width
Distance
Rail height
Thickness

Rail width

Reference point

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 ~|LMTJL. 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

BETA CAE Systems S.A.

Tutorial 7-3

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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
USER
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

BETA CAE Systems S.A.

Tutorial 7-4

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


Use the CONTROL POINTS>
EXTEND function to enlarge
the Box in two directions as shown at the
picture on the left.
EXTEND

In order to create splits


exactly on the rail faces,
NORMAL define Control Points using
the CONTROL POINTS> PROJECT
function.

PROJECT

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

BETA CAE Systems S.A.

Tutorial 7-5

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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

PROJECT

Use the BOXES> SPLIT


function and select the created
Points with the right mouse button to snap
on the Points. The splits are created.
SPLIT

BETA CAE Systems S.A.

Tutorial 7-6

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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

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.

2
1

Middle click to confirm and enter a name the


parameter.
This parameter handles the depth of the
horizontal embosses.

BETA CAE Systems S.A.

Tutorial 7-7

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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.

BETA CAE Systems S.A.

Tutorial 7-8

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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.

BETA CAE Systems S.A.

Tutorial 7-9

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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)
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
/*
INPUT VARIABLES
*/
/*----------------------------------------*/
EF as shown on the left. In
/*----------------------------------------*/
this command define the design variables as
/* Parameters for Morphing */
variables of the scripting language with an
/*----------------------------------------*/
Emboss_depth = 0;
initial value (e.g. b|ZMX). Keep
Emboss_width = 0;
in mind that the values of the parameters
Emboss_dist = 0;
represent relative movement. So the value
Rail_height = 0;
zero means no any modification.
Rail_width = 0;
/*----------------------------------------*/
For each Morphing Parameter enter the
MorphParam(1, Emboss_depth);
function jm~~E=~I=~=F.
MorphParam(2, Emboss_depth);
This command modifies the value of a
MorphParam(3, Emboss_width);
selected parameter. As =~ enter the ID of
the
parameter to be controlled and as ~=
MorphParam(4, Emboss_dist);
enter one of the above variables.
MorphParam(5, Rail_height);
One design variable can handle more that
one jm~~ commands. In this
MorphParam(6, Rail_width);
example the b|=ZMX handles
}
the jm~~ENI=b|F and
the jm~~EOI=b|F.

BETA CAE Systems S.A.

Tutorial 7-10

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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 EF
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);
}

BETA CAE Systems S.A.

Tutorial 7-11

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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 (EF)
the following function can be added.

ab`hfkclE?LL|K?FX=

This function writes all the contents of the


DECK INFO report to the |Kt
file. In this example the optimizers 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 optimizers 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

BETA CAE Systems S.A.

Tutorial 7-12

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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.

6
8

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

BETA CAE Systems S.A.

Tutorial 7-13

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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

BETA CAE Systems S.A.

Tutorial 7-14

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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.
#!/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"

The ANSA session contains the following commands:


- Open ANSA
- Read the ~K~~ database
- Modifies the model by executing the EFcommand
- Output the model in LS-DYNA format
The ANSA session is shown below.
NEW: discard
OPEN: /directory/rail.ansa
USER>optimizer:
OUTPUT>LS-DYNA : filename= /directory/rail.key mode=visible write_comments=above_key format=970
QUIT:

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

BETA CAE Systems S.A.

Tutorial 7-15

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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 optimizers data flow :

Design Variables
Optimal
solution

ANSA_TRANSL

Optimizer
Executable Shell Script (drive.sh)

LS-DYNA

rail.ses

Optimization
algorithm

META_output.ses

Constraints &
Objective Parameters
deck_info.txt

BETA CAE Systems S.A.

Xacceleration.txt

Xcoordinate.txt

Tutorial 7-16

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation


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 =
Emboss_width =
Emboss_dist =
Rail_height =
Rail_width =
Thickness =
Mass =
X_coordinate =
X_acceleration =

-5.511
0.833
-4.552
-14.366
-13.485
1.4
1.614
-341.287
-289.2

Reduction of acceleration : 54.5%


Reduction of intrusion (X coordinate) : 5.3%
Reduction of mass : 0.89%

BETA CAE Systems S.A.

Tutorial 7-17

ANSA v.12.0.1 Tutorials

OPTIMIZATION WITH ANSA A Front Rail Crash Simulation

BETA CAE Systems S.A.

Tutorial 7-18

ANSA v.12.0.1 Tutorials

Potrebbero piacerti anche