You are on page 1of 15

Truss Optimization

Problem:
Assuming that the compression members of the truss showing in the figure will not buckle, find the minimum cross sectional area of each member using an allowable stress of 50 MPa. The dimensions are OB = BC = 5 meters, AB = 6 meters. The force is F = 500 kN. Take E = 207 GPa.

Joseph Shigley and Charles Mischke. Mechanical Engineering Design 5th ed. New York: McGraw Hill, May 2002.

Truss Optimization
Overview

Anticipated time to complete this tutorial: 1 hour

Tutorial Overview
This tutorial is divided into six parts: 1) Tutorial Basics 2) Problem Planning 3) Log File 4) Solution 5) Optimization 6) Hand Calculations

Audience
This tutorial assumes familiarity of ANSYS 8.0; therefore, it does not go into step by step detail.

Prerequisites
1) ANSYS 8.0 in house Structural Tutorial 2) Completion of three or more Basic Machine Design Tutorials

Objectives
1) Write a log file to build the model 2) Use the ANSYS optimization tool to minimize the cross sectional area of each truss member 3) Calculate a percent error between the ANSYS solution and the theoretical solution

Outcomes
1) Learn how to set up the problem before starting Ansys 2) Increase familiarity with the graphical user interface (GUI) 3) Learn how to create and mesh more complex geometries 4) Increase familiarity with post processing tools

Truss Optimization
Tutorial Basics
In this tutorial: Instructions appear on the left. Visual aids corresponding to the text appear on the right. All commands on the toolbars are labeled. However, only operations applicable to the tutorial are explained. The instructions should be used as follows: Bold > Text in bold are buttons, options, or selections that the user needs to click on > Preprocessor > Element Type > Add/Edit/DeleteFile would mean to follow the options as shown to the right to get you to the Element Types window Text in italics are hints and notes Click on the left mouse button Click on the middle mouse button Click on the right mouse button

Example:

 Italics

MB1 MB2 MB3

Some basic ANSYS functions are: To rotate the models use Ctrl and MB3. To zoom use Ctrl and MB2 and move the mouse up and down. To translate the models use Ctrl and MB1.

Truss Optimization
Problem Planning
The ANSYS optimization tool requires the use of a log file. The log file contains commands that build, constrain, and solve the model. During the optimization process, this log file will be called by the optimization routine. Optimization in ANSYS requires three types of variables. They are: Design Variables Independent quantities, varied to achieve the optimum design. State Variables Quantities that constrain the design. Also known as "dependent variables," they are typically response quantities that are functions of the design variables. Objective Function The dependent variable that you are attempting to minimize. Take a few minutes to plan how you build a truss model that will have these three variables. 1) Plan a simple, representative geometry. The truss model can be created with 4 keypoints, 5 lines, and 3 areas (by symmetry you can assume that the stress in l1 is the same is the stress in l2, and that the stress in l4 is the same as the stress in l5). 2) Select an appropriate element for the mesh. Truss elements only need translational freedom in the X and Y directions. A link1 element would be suitable for this problem. 3) Determine the design and state variables, and the objective function. The design variables are the variables that can be adjusted during optimization. You want to adjust the cross sectional areas of the truss members, A1, A2, and A3. The state variables are the variables that will constrain the adjustment of the design variables. You want to constrain the stress in each truss member so that it does not exceed 50 MPa. You need to create an objective function that includes A1, A2, and A3. The objective function could be the volume of the truss. The volume would be determined by multiplying the length of each truss section by its cross sectional area.

Truss Optimization
Log File
1) Enter the preprocessor.
/PREP7

/PREP7 Enters the model creation preprocessor.

2) Define the element for the model. You are going to use a Link1 element for this model. ET, ITYPE, Ename, KOP1, KOP2, KOP3, KOP4,
ET,1,LINK1

KOP5, KOP6, INOPR Defines a local element type from the element library.

ITYPE Arbitrary local element type number. Defaults to 1 + current maximum. Ename Element name (or number) as given in the element library in Chapter 4 of the ANSYS Elements Reference. The name consists of a category prefix and a unique number, such as BEAM3. The category prefix of the name (BEAM for the example) may be omitted but is displayed upon output for clarity. If Ename = 0, the element is defined as a null element. KOP1, KOP2, KOP3, KOP4, KOP5, KOP6 KEYOPT values (1 through 6) for this element, as described in the ANSYS Elements Reference. INOPR If 1, suppress all element solution printout for this element type.

3) Now you are going to set scalar parameters that you will call during other parts of *SET, Par, VALUE the command sequence. Any scalar param- Assigns values to user-named parameters. eter is defined using the *SET command.
*SET,a1,.05 *SET,a2,.05 *SET,a3,.05 *SET,V,10*a1+6*a2+2*a3*sqrt(5**2+6**2)

Par An alphanumeric name used to identify this parameter. Par may be up to 32 characters, beginning with a letter and containing only letters, numbers, and underscores VALUE Numerical value or alphanumeric character string (up to 8 characters enclosed in single quotes) to be assigned to this parameter.

Truss Optimization
Log File
4) Define the real constants (i.e. the cross R, NSET, R1, R2, R3, R4, R5, R6 sectional areas for each real constant num- Defines the element real constants. ber). NSET
R,1,a1 R,2,a2 R,3,a3

Set identification number (arbitrary). If same as a previous set number, set is redefined. Set number relates to that defined with the element [REAL]. Note that the GUI automatically sets this value. R1, R2, R3, R4, R5, R6 Real constant values (interpreted as area, moment of inertia, thickness, etc., as required for the particular element type using this set), or table names for tabular input of boundary conditions. Use RMORE command if more than six real constants per set are to be input.

5) Define the material properties.


MP,EX,1,207e9 MP,PRXY,1,.292

MP, Lab, MAT, C0, C1, C2, C3, C4 Defines a linear material property as a constant or a function of temperature. Lab Valid material property label. Applicable labels are listed under "Material Properties" in the input table for each element type in the ANSYS Elements Reference. EX -Elastic moduli (also EY, EZ). PRXY -Major Poisson's ratios (also PRYZ, PRXZ).

Truss Optimization
Log File
6) You will now define keypoints used in the K, NPT, X, Y, Z Defines a keypoint. model.
K,1,0,0,0 K,2,5,0,0 K,3,10,0,0 K,4,5,6,0

NPT Reference number for keypoint. If zero, the lowest available number is assigned [NUMSTR]. X, Y, Z Keypoint location in the active coordinate system.

7) You will now create the five lines used in L, P1, P2, NDIV, SPACE, XV1, YV1, ZV1, XV2, YV2, ZV2 the model. Defines a line between two keypoints.
L,1,2 L,2,3 L,2,4 L,1,4 L,3,4

P1 Keypoint at the beginning of line. If P1 = P, graphical picking is enabled and all remaining command fields are ignored (valid only in the GUI). P2 Keypoint at the end of line.

8) You will now specify the number of element divisions per line. For this problem, you will use 1 element per line.

LESIZE, NL1, SIZE, ANGSIZ, NDIV, SPACE, KFORC, LAYER1, LAYER2, KYNDIV Specifies the divisions and spacing ratio on unmeshed lines. NL1 Number of the line to be modified. If ALL, modify all selected lines. SIZE If NDIV is blank, SIZE is the division (element edge) length. The number of divisions is automatically calculated from the line length (rounded upward to next integer) NDIV If positive, NDIV is the number of element divisions per line.

LESIZE,ALL,,,1,,,,,,

Truss Optimization
Log File
9) You will now assign different cross sectional areas (real constants) to certain lines. This step involves three commands. The first command specifies which line is selected (you can turn line numbers on if needed). The second command defines the attributes for the selected line. The third command reselects all lines.
LSEL,S,LINE,,1,2 LATT,1,1,1,,,, LSEL,ALL LSEL,S,LINE,,3 LATT,1,2,1,,,, LSEL,ALL LSEL,S,LINE,,4,5 LATT,1,3,1,,,, LSEL,ALL

LSEL, Type, Item, Comp, VMIN, VMAX, VINC, KSWP Type Label identifying the type of select: S -Select a new set (default). ALL -Restore the full set. The following fields are used only with Type = S, R, A, or U: Item Label identifying data. Defaults to LINE. Comp Component of the item (if required). VMIN Minimum value of item range. Ranges are line numbers, coordinate values, attribute numbers, etc., as appropriate for the item.

Lines 1 and 2 are assigned area 1. Line 3 is assigned area 2. Lines 4 and 5 are assigned VMAX area 3. The material number and type num- Maximum value of item range. ber are constant for all lines in this problem.

VINC Value increment within range. Used only with integer ranges (such as for line numbers). Defaults to 1. VINC cannot be negative.

LATT, MAT, REAL, TYPE, --, KB, KE, SECNUM Associates element attributes with the selected, unmeshed lines. MAT, REAL, TYPE Material number, real constant set number, and type number to be associated with selected, unmeshed lines.

10) Mesh all the lines.

LMESH, NL1, NL2, NINC Generates nodes and line elements along lines. NL1, NL2, NINC Mesh lines from NL1 to NL2 (defaults to NL1) in steps of NINC (defaults to 1). Use ALL to select all lines.

LMESH,ALL

Truss Optimization
Log File
11) Exit the preprocessor
FINISH

FINISH Exits normally from a processor.

12) Enter the solver.


/SOLU

/SOLU Enters the solution processor.

13) Add constraints to keypoints 1 and 3.


DK,1,ALL,0 DK,3,UY,0

DK, KPOI, Lab, VALUE, VALUE2, KEXPND, Lab2, Lab3, Lab4, Lab5, Lab6 Defines DOF constraints at keypoints. KPOI Keypoint at which constraint is to be specified. Lab Valid degree of freedom label. VALUE Degree of freedom value or table name reference for tabular boundary conditions.

14) Apply the force, F, to keypoint 2 in the FK, KPOI, Lab, VALUE, VALUE2 Defines force loads at keypoints. negative y direction.
FK,2,FY,-500000

KPOI Keypoint at which force is to be specified. Lab Valid force label. Structural labels: FX, FY, or FZ (forces) VALUE Force value or table name reference for specifying tabular boundary conditions.

15) Solve the model and exit the solver.


SOLVE FINISH

16) Enter the post processor.


/POST1

/POST1 Enters the database results postprocessor.

Truss Optimization
Log File
17) Specify the type of averaging that AVPRIN, KEY, EFFNU Specifies how principal and vector sums are to be ANSYS will use for the element table.
calculated.
AVPRIN,0, ,

KEY Averaging key: 0 -Average the component values from the elements at a common node, then calculate the principal or vector sum from the averaged components (default). 1 -Calculate the principal or vector sum values on a per element basis, then average these values from the elements at a common node.

18) Create an element table named Stress ETABLE, Lab, Item, Comp See ANSYS help for information regarding the arguments for this functhat will find the stress in each element.
tion (too long to list here).
ETABLE,Stress,LS, 1

19) Plot the element table named Stress.

PLETAB, Itlab, Avglab Displays element table items. Itlab User-defined label, as specified with the ETABLE command, of item to be displayed. Avglab Averaging operation: NOAV -Do not average element items at common nodes (default). AVG -Average the element items at common nodes.

PLETABLE,STRESS,NOAVG

10

Truss Optimization
Log File
20) You will now retrieve three different stress values that you will use during the optimization process. They will be called sigma12, sigma3, and sigma45 to correspond to the stresses in elements 1 or 2, element 3, and elements 4 or 5 respectively.
*GET,sigma12,ELEM,1,ETAB,STRESS *GET,sigma3,ELEM,3,ETAB,STRESS *GET,sigma45,ELEM,4,ETAB,STRESS

*GET, Par, Entity, ENTNUM, Item1, IT1NUM, Item2, IT2NUM Retrieves a value and stores it as a scalar parameter or part of an array parameter. Par The name of the resulting parameter. Entity Entity keyword. Valid keywords are NODE, ELEM, KP, LINE, AREA, VOLU, PDS, etc., as shown for Entity = in the tables below. ENTNUM The number or label for the entity (as shown for ENTNUM = in the tables below). In some cases, a zero (or blank) ENTNUM represents all entities of the set. Item1 The name of a particular item for the given entity. (ETAB for this problem) IT1NUM The number (or label) for the specified Item1 (STRESS for this problem).

21) Save the log file.

11

Truss Optimization
Solution
22) Copy the contents of the log file into the command line in ANSYS and press enter. Press enter to close the appropriate dialog boxes and proceed with the solution. Work out any bugs in your code at this point. Your solution should appear similar to the one shown below.

12

Truss Optimization
Optimization
You will now use the optimization tool in the GUI of ANSYS to define the optimization parameters. Take a moment to review the description of the optimization process given in the Problem Planning section of this tutorial. 23) Assign the log file you just created as the file to be used for optimization. > Design Opt > Analysis File > Assign Browse for your log file and select OK. 24) Define the design variables. > Design Opt > Design Variables The Design Variable window opens. Select Add to add a new variable. Another dialog box will open. You will create three design variables using A1, A2, and A3 and the following parameters: Minimum Value: 1e-6 Maximum Value: .1 Tolerance: Blank

25) Define the state variables. > Design Opt > State Variables The State Variable window opens. Select Add to add a new variable. Another dialog box will open. You will create three state variables using sigma 12, sigma 3, and sigma 45 and the following parameters: Sigma12, Sigma3 Minimum Value: 0 Maximum Value: 50e6 Tolerance: Blank Sigma45 Minimum Value: -50e6 Maximum Value: 50e6 Tolerance: Blank 13

Truss Optimization
Optimization
26) Define the Objective Function. > Design Opt > Objective The only remaining variable for use as the objective function is V. Set the tolerance value to .001. ANSYS will stop optimizing when the third digit after the decimal in the volume resultant stops fluctuating.

27) Set the optimization Tool/Method. > Design Opt > Method/Tool The Method/Tool window opens. Select the First Order method and select OK. Another window opens. Set the maximum number of iterations to 50.

28) Start the optimizer. > Design Opt > Run The optimizer will begin to run iterations. You can watch the screen as this occurs. 29) List the optimum design set. > Design Opt > Design Sets > List Click on All Sets, and select OK. A list of all design sets used will appear. The optimal design set will have asterisks next to it. Read off the values for A1, A2, A3, and V. They should be similar to (but probably not exact to) the following: A1: A2: A3: V: 0.41754E-02 0.10085E-01 0.63862E-02 0.20202

14

Truss Optimization
Hand Calculations

FAO

250
50.19 FOB

250 = FAO sin(50.19) FAC = FAO = FBC = FOB 250 = 325kN sin(50.19) 250 = = 208kN tan(50.19)

A=

208(10) 3 = .004160m 2 5000000 500(10) 3 AAB = = .010000 m 2 5000000 325(10) 3 AAO , AC = = .006500m 2 5000000 AOB , BC =

15