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.

Before you begin, copy the file(s) used in this tutorial to your working directory.

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.

The optimization problem for this tutorial is stated as:
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
Figure 1.

Launch HyperMath

  1. Launch HyperMath.
  2. From the menu bar, click File > Open.
  3. In the Open File dialog, open the dresp3_simple_h.hml file you saved to your working directory.
  4. Examine the HyperMath script to calculate external responses.
    The HyperMath script identified with the function MYSUM takes two inputs, rparam[1] and rparam[2], and returns two responses, rresp[1] - sum of the two inputs, and rresp[2] - average value of the two inputs. The calculated responses rresp[1] and rresp[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.

    os_4095_script
    Figure 2.

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.

Import the Model

  1. Click File > Import > Solver Deck.
    An Import tab is added to your tab menu.
  2. For the File type, select OptiStruct.
  3. Select the Files icon files_panel.
    A Select OptiStruct file browser opens.
  4. Select the dresp3_simple.fem file you saved to your working directory.
  5. Click Open.
  6. Click Import, then click Close to close the Import tab.

Set Up the Optimization

Attach the HyperMath Script Library to OptiStruct

OptiStruct will need the location of the HyperMath script for it to pass and receive the necessary inputs and outputs respectively. This is achieved using the LOADLIB card.
  1. From the Analysis page, click the control cards panel.
  2. In the Card Image dialog, click LOADLIB.
  3. Enter inputs.
    1. Set Type to DRESP3.
    2. In the GROUP field, enter HLIB.
    3. In the PATH field, enter the location of the .hml file.
      Example: c:/temp/dresp3_simple_h.hml
    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.
  4. Click return.

Create Design Variables

In this step you should still be in the Card Image dialog.

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.

Note: A '$' symbol indicates a comment and the following data will not be read by the solver.
  1. Click BULK_UNSUPPORTED_CARDS.
  2. In the Control Card dialog, enter in the following DRESP3 information:

    os_4095_control_card
    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 this step you should still be in the Control Card dialog.
Since the DRESP3 card is not supported in the current version of HyperMesh, the DCONSTR cards cannot be assigned to the DRESP3 responses from the dconstraints panel either. The DCONSTR cards are therefore also added using the BULK_UNSUPPORTED_CARDS panel.
  1. In the Control Card dialog, enter the following constraint data (DCONSTR and DCONADD) following the DRESP3 information:

    os_4095_add_contstraint
    Figure 4.
  2. Click OK.
  3. Click return.
The upper bound constraints of 50 and 25 on the SUMH response and the AVGH response are now defined.

Run the Optimization

  1. Export the dresp3_simple.fem file.
    1. From the menu bar, click File > Export > Solver Deck.
    2. Select the export directory for the solver file.
    3. In the Export browser, click files_panel, select the file dresp3_simple.fem, and click Save.
    4. Click Export.
    The .fem file name is used for OptiStruct input decks.
  2. Edit the dresp3_simple.fem file.
    1. In a text editor, open the dresp3_simple.fem file.
    2. Under the Subcase Information section, add DESSUB = 10.
    3. 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.
  3. Run the optimization.
    1. From the Start menu, click All Programs > Altair HyperWorks 2023.1 > OptiStruct.
    2. In OptiStruct, open the dresp3_simple.fem file.
    3. Click Run.
  4. 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.