OS-T: 4095 Size Optimization using External Responses (DRESP3)
In this tutorial, the standard responses available in OptiStruct are passed to a HyperMath script and the newly created responses from the script are used as optimization constraints.
Since HyperMath is an interpreter, you can build custom responses without having to compile your HyperMath script.
You will load the structural model into HyperMesh. The materials, shell properties, loads and boundary conditions are already defined in this model. The thicknesses of the three components are identified as design variables. The von Mises stress of element numbers 58 and 59 (elements located on the circumference of the hole) are defined as responses, and a total volume response is defined as well.
The von Mises stress of elements 58 and 59 are passed as inputs to the HyperMath script which in turn, returns two values: the sum of the two von Mises stresses, and the average value of the two elemental von Mises stresses.
- Objective
- Minimize volume.
- Constraints
- Constraints on the sum of the von Mises stresses and the average von Mises stress.
- Design Variables
- Gauges of the three parts.
![os_4095_model](../../../images/solvers/os_4095_model.png)
Launch HyperMath
- Launch HyperMath.
- From the menu bar, click .
- In the Open File dialog, open the dresp3_simple_h.hml file you saved to your working directory.
-
Examine the HyperMath script to calculate external
responses.
The HyperMath script identified with the function
MYSUM
takes two inputs,rparam[1]
andrparam[2
], and returns two responses,rresp[1]
- sum of the two inputs, andrresp[2]
- average value of the two inputs. The calculated responsesrresp[1]
andrresp[2]
are sent back to OptiStruct for use in the optimization. The script above will be linked to the DRESP3 related cards in the OptiStruct input file, which will pass the two inputs to this script and then receive two outputs from this script.Note: In this script, it is possible to assign any name to the function, like MYSUM, myresponses, sumandavg, etc. However, the argument names to the function such as iparam, rresp, rparam, and so on. cannot be changed. External responses will now be set up using DRESP3.Figure 2.
Launch HyperMesh and Set the OptiStruct User Profile
-
Launch HyperMesh.
The User Profile dialog opens.
-
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.
Import the Model
-
Click
.An Import tab is added to your tab menu.
- For the File type, select OptiStruct.
-
Select the Files icon
.
A Select OptiStruct file browser opens. - Select the dresp3_simple.fem file you saved to your working directory.
- Click Open.
- Click Import, then click Close to close the Import tab.
Set Up the Optimization
Attach the HyperMath Script Library to OptiStruct
- From the Analysis page, click the control cards panel.
- In the Card Image dialog, click LOADLIB.
-
Enter inputs.
Note: There is a limited amount of space within the HyperMesh Desktop to enter the file path and name. If the full file path with file name does not fit, exit the panel and edit the rest manually.
- Click return.
Create Design Variables
The design variables for the thicknesses of the three components are already defined. The responses for the total volume and the von Mises stress of elements 58 and 59 have also been defined.
The DRESP3 Bulk Data Entry is not supported in the current version of HyperMesh. Therefore, these cards will be defined in the BULK_UNSUPPORTED_CARDS panel.
- Click BULK_UNSUPPORTED_CARDS.
-
In the Control Card dialog, enter in the following DRESP3
information:
Figure 3.
This defines two external responses: the sum of the von Mises stresses of elements 58 and 59 (SUMH) and the average von Mises stress for elements 58 and 59 (AVGH).
The DRESP3 responses have different IDs from the DRESP1 responses and point to the library called HLIB defined. Also, the function MYSUM is the same function name in the dresp3_simple_h.hml script.
This completes linking of the DRESP3 cards with the HyperMath Script.
Create Constraints
-
In the Control Card dialog, enter
the following constraint data
(DCONSTR and
DCONADD) following the
DRESP3 information:
Figure 4.
- Click OK.
- Click return.
Run the Optimization
-
Export the dresp3_simple.fem file.
- From the menu bar, click .
- Select the export directory for the solver file.
-
In the Export browser, click
, select the file dresp3_simple.fem, and click Save.
- Click Export.
The .fem file name is used for OptiStruct input decks. -
Edit the dresp3_simple.fem file.
- In a text editor, open the dresp3_simple.fem file.
-
Under the Subcase Information section, add
DESSUB = 10
. - Save the file.
The DRESP3s created are subcase dependent responses and therefore are to be referenced from within a subcase. The DESSUB command does this. This line has to be added manually since the current version of HyperMesh does not support the DRESP3 Bulk Data Entry. -
Run the optimization.
- From the Start menu, click .
- In OptiStruct, open the dresp3_simple.fem file.
- Click Run.
- When the job is complete, post-process the results.
Note: The complete FEM deck, dresp3_simple_complete.fem, is available and can be used as a reference.