Custom Inputs: Global Hook

In this tutorial, you will use custom input variables for training.

In HyperMesh 2024 and on, the following mechanisms exist for inputting variables to physicsAI models.
  • PhysicsAI can read the node coordinates and part IDs by default using the .h3d files provided. The coordinates are by default inputs to the physicsAI model. The part IDs can be enabled by selecting the box next to it.
  • A global property associated with all nodes in a model such as material properties (Young’s Modulus, Poisson’s ratio) can be supplied by creating a .json file with the same name and in the same location as each of the .h3d files. A custom python script, global_hook.py, is needed.

The detailed instructions for each of these cases are provided in this tutorial. Before you begin, copy the file(s) used in this tutorial to your working directory.

Before you begin, copy the file(s) used in this tutorial to your working directory.
Note: Unzip the project custom_inputs.zip and inspect the contents. The global_inputs folder contains the global_hook.py, .h3d, and .json files for Use Global Hook.

Default Inputs Imported from h3d

If only .h3d files are provided, the nodal coordinates and part ID are imported by default. Only the nodal coordinates are enabled by default.

Figure 1. Default Inputs Extracted from .h3d Files


Use Global Hook

For properties which are applied at the same value to every node in a model, like global properties, the global hook should be used.

  1. Open the global_inputs folder.
    Inside the training_files folder, there are seven .h3d files named run__000X_m_1_fillet_cantilever_2.h3d and seven .json files named run__000X_m_1_fillet_cantilever_2.json files. Each .json file contains exactly two material properties, Young’s modulus and Poisson ratio with different values. It is necessary to have consistent labels and number of properties across all the samples.
    Figure 2. Global Property Inputs


  2. Create a new project called global_inputs.
    1. Open HyperMesh.
    2. From the menu bar, click View > Ribbons > PhysicsAI to open the PhysicsAI ribbon.
    3. From the PhysicsAI ribbon, select the Create Project tool.
      Figure 3.


    4. In the Create Project dialog, enter global_inputs for Project Name.
    5. For Location, click Choose and select a save location for the project.
      Note: The save location for the project contains all files created by physicsAI, but the original files used for training do not need to reside in the project folder.
    6. Click OK.
  3. Copy the global_inputs_hook.py file into the _hooks folder inside the project folder.
  4. Create a new dataset using all seven samples and name it Beam.
    1. From the PhysicsAI ribbon, select the Create Dataset tool.
      Figure 4.


      The Create Dataset dialog opens.
    2. For Dataset Name, enter Beam.
    3. For File System, click and navigate to the training_files folder.
      The labels E and nu are now selectable inputs to the training.
    4. Select and transfer all of the .h3d files.
      Figure 5.


    5. Click OK.
      The dataset is extracted and the Datasets dialog opens.
    6. Click Close.
  5. Train the model.
    1. From the PhysicsAI ribbon, select the Train an ML Model tool.
      Figure 6.


      The Train Model dialog opens.
    2. For Model Name, enter Displacement.
    3. For Training Data, verify Beam is selected.
    4. For Inputs, select cae.coord, cae.model_data.nu, and cae.model_data.E.
    5. For Outputs, select Displacement.
    6. Click Train.
      Figure 7. Global Property Inputs


      The Model Training dialog opens.
      Tip: Once the status changes to Running, you can click Show Log view the training logs.
    7. Once the training is complete, click Set Active Model.
  6. Test the model.
    1. From the PhysicsAI ribbon, select the Test ML Model tool.
      Figure 8.


      The Test Model dialog opens.
    2. In the Models area, select Displacement.
    3. In the Datasets area, select Beam and click OK.
      Figure 9.


      The Model Testing dialog opens.
    4. In the Model Testing dialog, select Displacement, and click Display File to view the results in the modeling window.
    5. Close the Model Testing dialog.
    New samples can be generated by copying and renaming one or more training files. Ensure that the associated .json files are also present with different values of E and nu while creating the test dataset.
Currently, the prediction feature for a model is available through the HyperMesh GUI and in batch mode. The CAD or solver deck to be used for prediction should have an associated .json with the same name and _predict_inp.json appended, which should be saved in the _hooks folder.