HS-1695: Using Hooks in a physicsAI Model
Learn how to use hooks in physicsAI models.
By default, the physicsAI connection in HyperStudy only expects one argument, i.e., the input mesh file. If the physicsAI model is trained using hooks, it will expect the hook script, and the accompanying json/csv file needed by the hook. This is done by pointing to the hooks directory using the --hooks_dir argument in the Solver Input Arguments utility. The files required by the hook should also be placed in the same location.
Before you begin, copy the model files used in this tutorial from <hst.zip>/HS-1695/ to your working directory.
- gfem_wing_static.hm, a HyperMesh file for parametrically varying the applied loads
- nodal_inputs_hook.py, a python hook which parses the nodal loads
- Force_extraction.py, a python script that consumes the fem file to extract the applied loads and node IDs and export them in a csv file
- Wing_NL_VMT.psmdl, a physicsAI ML model trained to predict VMT on a wing
Create Study
In this tutorial, you will open HyperStudy and create a study.
- Launch HyperStudy.
-
Start a new study in one of the following ways:
- From the menu bar, click
- On the ribbon, click
- In the Label field, enter pAI_hooks.
-
In the Location field, click the
icon and navigate to your tutorial working folder.
Figure 1. - Click OK.
HyperMesh Model
- Go to the Define Models step.
-
Add a HyperMesh model.
- From the Directory, drag-and-drop the gfem_wing_static.hm into the work area.
- In the Solver input file column, enter wing.fem. This is the name of the solver input file HyperStudy writes during any evaluation.
- In the Solver execution script column, select None. Solver is not needed as HyperMesh model is responsible for only proving an input file for the physicsAI model.
Figure 2. - Click Import Variables.
-
In the Model Parameters dialog, select parameters to import into
HyperStudy.
- Select all the GRID force parameters. A total of 9 parameters should be selected.
- Click Add.
- Click OK.
Figure 3. - Go to the Define Input Variables step.
- Review lower and upper bounds for each input.
- Switch to Test Models, and click on All for the HyperMesh model.
Operator Model
- Add an Operator model.
-
Select python as the Solver Execution Script.
Figure 4. -
Add Force_Extraction.py in the study directory as the
input file for this model using the Model Resources utility. Add a link to the
wing.fem output file from HyperMesh model (m_1).
Figure 5. -
In the Solver Input Arguments, add the references to the files added
earlier.
Figure 6. - Switch to the Test Models tab and click on All for the Operator model.
physicsAI Model
- Add physicsAI model.
-
Select Wing_NL_VMT.psmdl (located in the study directory)
as the resource file.
Figure 7. -
In Model Resources, link wing.fem from HyperMesh
model(m_1) and predict_inp.csv from Operator Model (m_2).
Finally, add nodal_inputs_hook.py from the study directory.
The complete resources sharing chart should like:
Figure 8. -
In the Solver Input Arguments add the reference to the input file (fem file)
and the location of the hooks directory using the
--hooks_dir argument.
Figure 9. -
The completed workflow should look like the following:
Figure 10. - Switch to Test Models and click on All for the physcisAI model.
- Execution of phsyicsAI model will produce predicted results in wing_pred.xy and wing_pred.json files in the run directory and either file can be read with the appropriate tool to generate data sources.