parametric modeling chapter two. training manual january 30, 2001 inventory #001449 2-2 2....
DESCRIPTION
Training Manual January 30, 2001 Inventory # Parametric Modeling A. Definition & Purpose What is a Parametric Model? A model built and analyzed in terms of parameters (variables) instead of numbers. By simply changing the values of certain parameters in the model, you can build and analyze a new model. H1 H2 A1 A2 A3 H1TRANSCRIPT
Parametric Modeling
Chapter Two
January 30, 2001
Inventory #001449
2-2
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual2. Parametric Modeling
• The basic requirement for optimization in ANSYS (except topological optimization) is a parametric model (in file form.)
• In this module, we will:A. Define parametric modelingB. Review some APDL basicsC. Present guidelines to build a parametric model and create an
analysis fileD. Work on one or two workshop exercises
January 30, 2001
Inventory #001449
2-3
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric ModelingA. Definition & Purpose
What is a Parametric Model?
• A model built and analyzed in terms of parameters (variables) instead of numbers.
• By simply changing the values of certain parameters in the model, you can build and analyze a new model.
H1 H2
A1
A2
A3H1
January 30, 2001
Inventory #001449
2-4
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Definition & Purpose
• ANSYS allows you to “parameterize” not only the geometry but also other characteristics, e.g:– material properties– loads– number of constraints– maximum vertical deflection– minimum temperature– maximum stress
January 30, 2001
Inventory #001449
2-5
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Definition & Purpose
• The basic requirement is that quantities to be used as DVs, SVs, and OBJ must be parameters.
For example:– If volume is to be minimized (objective function), then the total
volume must be available as a parameter.– If height H1 is to be declared as a design variable, the model
geometry must be built in terms of H1.– If the design is constrained by a limit on compressive stress
(state variable), the maximum compressive stress must be available as a parameter.
January 30, 2001
Inventory #001449
2-6
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Definition & Purpose
• Every optimization run begins with a parametric model.
• The “output” from the parametric model is the analysis file, which is used as “input” for the optimizer.
AnalysisFile
Explore theDesign Domain
Optimize theDesign
Initial Design
Parametric Model& Loading
Solution
ParametricResults
January 30, 2001
Inventory #001449
2-7
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Definition & Purpose
• The analysis file contains ANSYS commands for the complete parametric analysis:– Modeling– Loading– Solution– Results review
January 30, 2001
Inventory #001449
2-8
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Definition & Purpose
• Notes on the analysis file:– Same as the .log file with non-essential commands (plots, lists,
graphics controls, etc.) removed.– Think of the analysis file as a format in which the parametric
model must be “stored” for optimization purposes.– The optimizer runs the analysis file multiple times, using new
parameter values each time.
• Since parameters are the essence of a parametric model, we will first review some basic APDL concepts.
January 30, 2001
Inventory #001449
2-9
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling B. APDL Basics
What is APDL?
• Acronym for ANSYS Parametric Design Language, a scripting language that allows you to parameterize your model and automate common tasks.
• Using APDL, you can:– input model dimensions, material properties, etc. in terms of
parameters rather than numbers.– retrieve information from the ANSYS database, such as a node
location or maximum stress.
January 30, 2001
Inventory #001449
2-10
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling ...APDL Basics
• APDL also allows you to:– perform mathematical calculations among parameters.– use array parameters to create and operate on vectors and
matrices.– define abbreviations (short cuts) for frequently used commands
or macros.– create a macro to execute a sequence of tasks, with if-then-else
branching, do-loops, and user prompts.
January 30, 2001
Inventory #001449
2-11
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling ...APDL Basics
• In this section, we will concentrate on just the basic APDL capabilities:– how to define parameters– how to use them– how to retrieve information from the ANSYS database and
assign them to parameters
• For details on other APDL capabilities, please refer to your APDL Programmer’s Guide.
January 30, 2001
Inventory #001449
2-12
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics Defining Parameters
• To define a parameter, use the format
• Name=Value– Can be typed in the input
window or in the Scalar Parameters dialog (Utility Menu > Parameters > Scalar Parameters...)
– Name is the parameter name, eight alphanumeric characters or less.
– Value may be a number, a previously defined parameter, a mathematical function, a parametric expression, or a character string.
January 30, 2001
Inventory #001449
2-13
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Defining Parameters
• Examples:inrad=2.5
outrad=8.2
numholes=4
thick=outrad-inrad
e=2.7e6
density=0.283
bb=cos(30)
pi=acos(-1)
g=386
massdens=density/g
circumf=2*pi*rad
area=pi*r**2
dist=sqrt((y2-y1)**2+(x2-x1)**2)
slope=(y2-y1)/(x2-x1)
theta=atan(slope)
jobname=‘proj1’
January 30, 2001
Inventory #001449
2-14
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Defining Parameters
Some naming rules:
• Parameter names must be eight characters or less (see note), beginning with a letter.
• Only letters, numbers, and the underscore character _ are allowed.
• Avoid underscore _ as starting character… reserved for ANSYS use.
• Names are not case-sensitive, i.e, “RAD” and “Rad” are the same. All parameters are internally stored in capital letters.
• Avoid common ANSYS labels such as STAT, DEFA, and ALL.
Note: There are several undocumented features – use at your own risk!1. Design variable names with up to 16 characters are recognized2. Parameter names with a maximum of 32 characters may be entered
January 30, 2001
Inventory #001449
2-15
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics Using Parameters
• To use a parameter, simply enter its name in the appropriate field in the dialog box or on the command.
• For example, to define a rectangle using the parameters w=10 and h=5,
– you can use the menu:Preprocessor > Create > Rectangle > By 2 Corners +
– or commands:/prep7blc4,,,w,h
January 30, 2001
Inventory #001449
2-16
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Using ParametersNote:• Whenever you use parameters, ANSYS immediately
substitutes their values.• The rectangle in the previous example is stored as a 10x5
area, not as w x h. That is, if you change the value of w or h after creating the rectangle, the area will NOT be updated.
• This is true of most parametric substitutions and is the reason for storing the parametric model in the form of a command file (the analysis file).
January 30, 2001
Inventory #001449
2-17
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Using Parameters
• Other examples of using parameters:jobname=‘proj1’
/filnam,jobname ! Jobname
/prep7
ex=30e6 ! Exval would be safer
mp,ex,1,ex ! Young’s modulus
force=500
fk,2,fy,-force ! Force at KP 2
fk,6,fx,force/2 ! Force at KP 6
January 30, 2001
Inventory #001449
2-18
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Retrieving Database Information
• To retrieve information from the database and assign it to a parameter, use the *GET command or Utility Menu > Parameters > Get Scalar Data...
• A vast amount of information is available, including model and results data. Refer to the *GET command description for details.
January 30, 2001
Inventory #001449
2-19
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Retrieving Database Information
• Examples:*get,x1,node,1,loc,x ! x1 = X coordinate of node 1 [CSYS]*
/post1
*get,sx25,node,25,s,x ! sx25 = X stress at node 25 [RSYS]*
*get,uz44,node,44,u,z ! uz44 = UZ displacement at node 44 [RSYS]*
nsort,s,eqv ! Sort nodes by von Mises stress
*get,smax,sort,,max ! smax = maximum of last sort
etable,vol,volu ! Store element volumes as vol
ssum ! Sum all element table columns
*get,totvol,ssum,,ITEM,vol ! totvol = sum of vol column
*CSYS = In the active coordinate system (CSYS)
RSYS = In the active results coordinate system (RSYS)
January 30, 2001
Inventory #001449
2-20
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics ...Retrieving Database Information
• Some data can be retrieved with a get function.
Examples:x1=nx(1) ! x1 = X coordinate of node 1 [CSYS]*
nn=node(2.5,3,0) ! nn = node at or near (2.5,3,0) [CSYS]*
k1=kpnext(0) ! k1 = lowest numbered keypoint (of selected)
L1=lsnext(3) ! L1 = lowest numbered line > 3 (of selected lines)
/post1
ux25=ux(25) ! ux25 = UX at node 25 [RSYS]*
temp93=temp(93) ! temp93 = temperature at node 93
width=distnd(23,88) ! width = distance between nodes 23 & 88
*CSYS = In the active coordinate system (CSYS)
RSYS = In the active results coordinate system (RSYS)
January 30, 2001
Inventory #001449
2-21
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics...Retrieving Database Information
• You can use a get function directly in a field, just like a parameter. For example:
k,10,kx(1),ky(3) ! KP 10 at X of KP 1, Y of KP 3 [CSYS]*
k,11,kx(1)*2,ky(3) ! [CSYS]*
f,node(2,2,0),fx,100 ! FX force at node(2,2,0) [CSYS]*
lfillt,lsnext(0),lsnext(lsnext(0)),.5
! Forms a fillet between 2 selected lines
! without referring to their numbers
*CSYS = In the active coordinate system (CSYS)
January 30, 2001
Inventory #001449
2-22
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling - APDL Basics...Retrieving Database Information
• APDL Summary:– Define parameters using the format Name=Value.– Value may be a number, a previously defined parameter, a
mathematical function, a parametric expression, or a character string.
– Use *GET or get functions to retrieve data from the ANSYS database.
– ANSYS stores data in their actual form (numbers or strings), not in the form of parameter names.
January 30, 2001
Inventory #001449
2-23
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric ModelingC. Procedure / Guidelines
• The procedure to build and analyze a parametric model is the same as for a normal ANSYS analysis except that parameters are used wherever appropriate:
1. Define parameters
2. Build the model using parameters where appropriate
3. Apply loads and obtain the solution using parameters where appropriate
4. Review results and parameterize desired data
5. Create the analysis file.
January 30, 2001
Inventory #001449
2-24
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
Step 1 - Define Parameters• Use the standard Name=Value format to define parameters, in the
Input window or in the Scalar Parameters dialog ( Utility Menu > Parameters > Scalar Parameters… ).
• No need to define all parameters in this step, but keeping all parameter definitions together makes for easier editing later (if needed).
• For parameters to be used as DVs, the values specified are used for the initial design only.
January 30, 2001
Inventory #001449
2-25
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
Steps 2, 3 - Modeling, Meshing & Loading Using Parameters
• Use parameters instead of numbers wherever appropriate.
• Avoid using graphical picking or entity numbers for modeling and loading operations.
Use select logic, component names, or get functions instead.
January 30, 2001
Inventory #001449
2-26
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
For example, the following method is not recommended in a parametric model (except in very simple cases):SFL,4,PRES,500 ! Pressure on line 4
F,32,FY,-7500 ! Force on node 32
Instead, use select logic or get functions:LSEL,S,LOC,… ! Select line by location
SFL,ALL,PRES,500 ! Pressure on all selected lines
LSEL,ALL
F,NODE(1.5,3,0),FY,-7500 ! Node number by get function
January 30, 2001
Inventory #001449
2-27
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
H1 H2
A1, A2, A3
Parametric Modeling...Procedure / Guidelines
• Remember that you can use parametric expressions and/or if-then-else branching to modify the parameters. Example:– If diameter is defined as a parameter, you can use diameter/2 to
define a cylindrical volume using the CYLIND or CYL4 command.– If the truss bridge is modeled using half-symmetry, the cross-
sectional area of the vertical member at the symmetry plane would be A2/2.
January 30, 2001
Inventory #001449
2-28
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
– If thk is defined as a parameter in a shell model and only three shell thicknesses are available (e.g, 1/8”, 3/16”, 1/4”), you can use an if-then-else construct (along with the appropriate OPLOOP setting for optimization looping - discussed later):
et,1,63 ! Shell element type*if,thk,lt,2.5/16,then thk=1/8 ! Use 1/8 if thk < 2.5/16*elseif,thk,gt,3.5/16,then thk=1/4 ! Use 1/4 if thk > 3.5/16*else thk=3/16 ! Otherwise use 3/16*endifr,1,thk ! Define shell thickness
January 30, 2001
Inventory #001449
2-29
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
Step 4 - Parameterize the Results• This means to retrieve results data and store them in
parameters.• Usually done in POST1, the general postprocessor.• Results data, such as maximum deflection, maximum von
Mises stress, and total volume, are typically used as state variables and objective functions.
• Use the *GET command ( Utility Menu > Parameters > Get Scalar Data… ) or get functions to retrieve results data.
January 30, 2001
Inventory #001449
2-30
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
Step 5 - Create the Analysis file
• The analysis file contains the command input used to build and analyze the parametric model. The optimizer uses it to loop through multiple designs.
AnalysisFile
Explore theDesign Domain
Optimize theDesign
Initial DesignParametric Model& Loading
Solution
ParametricResults
January 30, 2001
Inventory #001449
2-31
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
• The sequence of commands on the analysis file follows the sequence you use to build and analyze the parametric model:– Parameter definitions (initial values)– Commands to define the geometry– Meshing commands– Commands for loads and boundary conditions– Solution commands– Commands to retrieve results data
January 30, 2001
Inventory #001449
2-32
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
• Two ways to create the analysis file:– “Dump out” the command log stored in the ANSYS database.– Edit a copy of the log file (jobname.log).
We will concentrate on the first method in this seminar.
January 30, 2001
Inventory #001449
2-33
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
• To dump out the command log stored in the database, choose Utility Menu > File > Write DB Log File (LGWRITE command).– The default file name is
jobname.lgw.– You can choose to write
essential commands only or to write non-essential commands (plots, lists, etc.) as comments.
January 30, 2001
Inventory #001449
2-34
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
• You might want to edit the analysis file using a text editor and:– Add descriptive comments using the ! character. Any text
following ! is ignored by ANSYS as a comment.– Add some plot commands such as EPLOT and contour plots
(PLNSOL,…).This way, when you run the optimization process interactively, you can see the model changing from one iteration to the next.
January 30, 2001
Inventory #001449
2-35
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Procedure / Guidelines
• Be sure to test your analysis file and make sure it doesn’t cause errors or unrealistic models.
• To test the analysis file, simply re-input it into a new ANSYS session.– Use the /INPUT command– Or Utility Menu > File > Read Input from…
January 30, 2001
Inventory #001449
2-36
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric ModelingSummary
• A parametric model, stored in the form of an analysis file, is required for ANSYS design optimization.
• APDL parameters are used to build and analyze the parametric model.
• The analysis file typically contains commands for:– Initial parameter values– Model geometry and meshing– Boundary conditions, loads, and solution– Results review and retrieval
…or it could be a single line defining the objective function in terms of the design variables with APDL: Obj = 0.5*dv1**3 - 21*dv2**2 + 210*dv3 - 100
January 30, 2001
Inventory #001449
2-37
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric ModelingD. Example• Shown here is the analysis file
for a rectangular plate model built with thickness defined as a discrete design variable thk. Other parameters defined are vol for volume and smax for maximum stress.
thk=.25/prep7 et,1,63*if,thk,lt,2.5/16,then
thk=1/8*elseif,thk,gt,3.5/16
thk=1/4*else
thk=3/16*endifvol=thk*400
r,1,thk ! Plate thicknessmp,ex,1,1e7rect,,20,,20amesh,1finish/solunsel,s,extd,all,all ! Fix exterior nodesnsel,allsf,all,pres,5 ! Pressure loadingsolvefinish/post1set,lasttopnsort,s,eqv*get,smax,sort,,maxfinish
January 30, 2001
Inventory #001449
2-38
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric Modeling...Example• Optimization input for the rectangular plate is shown here. Notice
the use of the OPLOOP,PREP,PROCESS command to make sure that the thk definitions are processed. Details of the optimization procedure are presented in the next chapter.
/opt ! Optimization commandsopvar,thk,dv,1/8,1/4 ! thk is the DVopvar,smax,sv,,21000 ! smax is the SVopvar,vol,obj ! vol is the objective functionoptype,subpoploop,prep,process ! Read analysis file from /PREP7, process DV settingsopexe ! Execute optimizationoplist,allfinish
January 30, 2001
Inventory #001449
2-39
DESIG
N O
PTIMIZA
TION
5.7D
ESIGN
OPTIM
IZATIO
N 5.7
Training Manual
Parametric ModelingE. Workshop
This workshop consists of two problems:
1. Parametric modeling of an axisymmetric rotating disk– A step-by-step description of the procedure.– You may choose to run this problem yourself, or your instructor
may show it as a demonstration.
2. Parametric modeling of a hexagonal steel plate– Step-by-step description of most of the procedure.
• See your Design Optimization Workshop Supplement for details.