# OS-T: 4000 3D Size Optimization of a Rail Joint

In this tutorial you will perform a size optimization on an automobile rail joint modeled with shell elements.

Before you begin, copy the file(s) used in this tutorial to your working directory.
A structural model with loads and constraints is used in this tutorial. The deflection at the end of the tubular cross-member should be limited. The optimal solution would be to use as little material as possible.

You will load the structural model into HyperMesh. The constraints, loads, material properties, and subcases (loadsteps) are already defined in the model. Size design variables and optimization parameters are defined, and OptiStruct determines the optimal gauges for the components. The results are then reviewed in HyperView.

The optimization problem for this tutorial is stated as:
Objective
Minimize volume.
Constraints
Design Variables
Gauges of the two parts.

## Launch HyperMesh and Set the OptiStruct User Profile

1. Launch HyperMesh.
The User Profile dialog opens.
2. Select OptiStruct and click OK.
This loads the user profile. It includes the appropriate template, macro menu, and import reader, paring down the functionality of HyperMesh to what is relevant for generating models for OptiStruct.

## Open the Model

1. Click File > Open > Model.
2. Select the joint_size.hm file you saved to your working directory.
3. Click Open.
The joint_size.hm database is loaded into the current HyperMesh session, replacing any existing data.

## Set Up the Optimization

### Create Size Design Variables

1. From the Analysis page, click the optimization panel.
2. Click the size panel.
3. Select the desvar subpanel.
4. Create the design variable, tube.
1. In the desvar = field, enter tube.
2. In the initial value = field, enter 1.0.
3. In the lower bound = field, enter 0.1.
4. In the upper bound = field, enter 5.0.
5. Set the move limit toggle to move limit default.
6. Set the discrete design variable (ddval) toggle to no ddval.
7. Click create.
5. Create the design variable, rail.
1. In the desvar = field, enter rail.
2. In the initial value = field, enter 1.0.
3. In the lower bound = field, enter 0.1.
4. In the upper bound = field, enter 5.0.
5. Set the move limit toggle to move limit default.
6. Set the discrete design variable (ddval) toggle to no ddval.
7. Click create.
6. Select the generic relationship subpanel.
7. Create a design variable property relationship, tube_th.
1. In the name = field, enter tube_th.
2. Using the prop selector, select tube2.
3. Under the props selector, select Thickness T.
4. Click designvars.
5. Select tube.
Note: The linear factor is automatically set to 1.000.
6. Click return.
7. Click create.
A design variable property relationship, tube_th, has been created relating the design variable tube to the thickness entry on the PSHELL card for the property tube2.
8. Create a design variable property relationship, rail_th.
1. In the name = field, enter rail_th.
2. Using the prop selector, select tube1.
3. Under the props selector, select Thickness T.
4. Click designvars.
5. Select rail.
6. Click return.
7. Click create.
A design variable property relationship, rail_th, has been created relating the design variable rail to the thickness entry on the PSHELL card for the property tube1.

### Create Responses

1. Click the responses panel.
2. Create the response, volume.
1. In the response= field, enter volume.
2. Set the response type to volume.
3. Set the regional selection to total.
4. Click create.
The response, volume, is defined for the total volume of the model.
3. Create the response, X_Disp.
1. In the response= field, enter X_Disp.
2. Set the response type to static displacement.
3. Click nodes > by id, then enter 3143 in the id= field.
This is the node at center of rigid spider at loading point.
4. Select dof1.
5. Click create.
The response, X_Disp, is defined for the x-displacement of the node 3143.
4. Create the response, Z_Disp.
1. In the response= field, enter Z_Disp.
2. Set the response type to static displacement.
3. Click nodes > by id, then enter 3143 in the id= field.
This is the node at center of rigid spider at loading point.
4. Select dof3.
5. Click create.
The response, Z_Disp, is defined for the z-displacement of the node 3143.

### Create Constraints

A response defined as the objective cannot be constrained. In this case, you cannot constrain the response volume.

Upper bound constraints are to be defined for the responses X_Disp and Z_Disp.

1. Click the dconstraints subpanel.
2. Define a constraint on the response X_Disp.
1. In the constraints= field, enter Disp_X.
2. Check the box next to upper bound, then enter 0.9.
3. Click response = and select X_Disp.
4. Using the loadsteps selector, select Force_X.
5. Click create.
The constraint is an upper bound with a value of 0.9. The constraint applies to the subcase Force_X.
3. Define a constraint on the response Z_Disp.
1. In the constraints= field, enter Disp_Z.
2. Check the box next to upper bound, then enter 1.6.
3. Click response = and select Z_Disp.
4. Using the loadsteps selector, select Force_Z.
5. Click create.
The constraint is an upper bound with a value of 1.6. The constraint applies to the subcase Force_Z.

### Define the Objective Function

1. Click the objective panel.
2. Verify that min is selected.
3. Click response and select volume.
4. Click create.
5. Click return twice to exit the Optimization panel.

## Save the Database

1. From the menu bar, click File > Save As > Model.
2. In the Save As dialog, enter joint_sizeOPT.hm for the file name and save it to your working directory.

## Run the Optimization

1. From the Analysis page, click OptiStruct.
2. Click save as.
3. In the Save As dialog, specify location to write the OptiStruct model file and enter joint_sizeOPT for filename.
For OptiStruct input decks, .fem is the recommended extension.
4. Click Save.
The input file field displays the filename and location specified in the Save As dialog.
5. Set the export options toggle to all.
6. Set the run options toggle to optimization.
7. Set the memory options toggle to memory default.
8. Click OptiStruct to run the optimization.
The following message appears in the window at the completion of the job:
OPTIMIZATION HAS CONVERGED.
FEASIBLE DESIGN (ALL CONSTRAINTS SATISFIED).
OptiStruct also reports error messages if any exist. The file joint_sizeOPT.out can be opened in a text editor to find details regarding any errors. This file is written to the same directory as the .fem file.
9. Click Close.
The default files that get written to your run directory include:
joint_sizeOPT.hgdata
HyperGraph file containing data for the objective function, percent constraint violations, and constraint for each iteration.
joint_sizeOPT.prop
OptiStruct property output file containing all updated property data from the last iteration for size optimization.
joint_sizeOPT.hist
The OptiStruct iteration history file containing the iteration history of the objective function and of the most violated constraint. Can be used for a xy plot of the iteration history.
joint_sizeOPT.out
OptiStruct output file containing specific information on the file setup, the setup of the optimization problem, estimates for the amount of RAM and disk space required for the run, information for all optimization iterations, and compute time information. Review this file for warnings and errors that are flagged from processing the joint_sizeOPT.fem file.
joint_sizeOPT.res
HyperMesh binary results file.
joint_sizeOPT.stat
Contains information about the CPU time used for the complete run and also the break-up of the CPU time for reading the input deck, assembly, analysis, convergence, and so on.
joint_sizeOPT_des.h3d
HyperView binary results file that contain optimization results.
joint_sizeOPT_s#.h3d
HyperView binary results file that contains from linear static analysis, and so on.

## View the Results

Displacement and stress results are output by OptiStruct (by default) for linear static analyses. You will view those results in HyperView. Size optimization results from OptiStruct are given in the .h3d files and joint_sizeOPT.out.
joint_sizeOPT_des.h3d
Contains the element thickness for all five iterations.
joint_sizeOPT_s1.h3d
Contains displacement and stress results for the linear static analysis for iteration 0 and iteration 4 of subcase with ID 1 (subcase Force_X).
joint_sizeOPT_s2.h3d
Contains displacement and stress results for the linear static analysis for iteration 0 and iteration 4 of subcase with ID 2 (subcase Force_Z).
joint_sizeOPT.out
Contains gauge and volume information for all iterations.
The results contained in the HyperView binary results file will be examined first. Then the gauge history in the joint_sizeOPT.out file will be reviewed.

### View the Size Optimization Results

1. From the OptiStruct panel, click HyperView.
HyperView launches within the HyperMesh Desktop and loads the result files. All three .h3d files get loaded into a different page in HyperView. The files joint_sizeOPT_des.h3d, joint_sizeOPT_s1.h3d, and joint_sizeOPT_s2.h3d get loaded in page 2, page 3, and page 4, respectively. The optimization iteration results (gauge thickness) are loaded in the first page. The name of the page is displayed as Design History to indicate that the results correspond to optimization iterations.
2. On the Results toolbar, click to open the Contour panel.
3. Set the Result type to Element Thicknesses (s) and Thickness.
4. Set the Averaging method to None.
5. In the Results Browser, select the last load case simulation.
6. In the Contour panel, click Apply.
A contoured image representing shell thickness should be visible. Each element in the model is assigned a legend color, indicating the thickness value for that element for the current iteration.

### View the Displacement Results

It is helpful to view the deformations of the model to determine if the boundary conditions have been met and also to see if the model is deforming as expected. These analysis results are available in pages 3 and 4.
1. In the top, right of the application, click to proceed to third page.
The third page, which has results loaded from the file joint_sizeOPT_s1.h3d, is displayed. The name of the page is displayed as Subcase 1 - FORCE_X to indicate that the results correspond to subcase 1.
2. From the Animation toolbar, set the animation mode to Linear Static.
3. On the Results toolbar, click to open Contour panel.
4. Set the Result type to Displacement [v] and X.
5. Click Apply.
The resulting contours represent the x component displacement field resulting from the applied loads and boundary conditions.
6. Measure the displacement at node 3143 for which you have constrained the displacement.
1. On the Annotations toolbar, click to open the Measure panel.
3. Select Nodal Contour.
4. Click Nodes > by id, then enter 3143 in the Node ID field and click OK.
The x-displacement value for 3143 (center of rigid spider, where loading is applied) displays. The x-displacement is larger than the upper bound constraint, which was defined earlier, of 0.9.
7. In the Results Browser, select the last iteration.
The contour now shows the x-displacement results for Subcase 1 (FORCE_X) and iteration 4, which corresponds to the end of the optimization iterations. The x-displacement is now less than 0.9.
8. In the top, right of the application, click to proceed to fourth page.
The fourth page shows the results loaded from the joint_sizeOPT_s2.h3d file. The name of the page is displayed as Subcase 2 - Force_Z to indicate that the results correspond to subcase 2.
9. On the Results toolbar, click to open the Contour panel.
10. Set the Result type to Displacement [v] and Z.
11. Click Apply.
The resulting contours represent the z component displacement field resulting from the applied loads and boundary conditions.
12. Measure and display the z-displacement value for node 3143.

### View the Gauge Thickness Results

In this step you will learn an alternate way to view the gauge thickness results.
1. From the Unix or MSDOS shell, open the joint_sizeOPT.out file in a text editor.
2. Review all five iterations, noting the volume, constraint information, and gauge at each iteration.

Has the volume been minimized for the given constraints?

Have the displacement constraints been met?

What are the resulting gauges for the rail and tube?