Graphical Scripts-Tutorial
Previous (Parametric Runs-Tutorial) | Back to Start
Graphical Scripts-Tutorial
- Generate a model consisting of two tunnels, a ventilation shaft, and two entries at the portals.
The case should correspond to the available case,
…\tunnel\samples\tunnel\sample4.idm.

Figure 57. A schematic of the model consists of a middle ventilation shaft
- Set the PWind at the left portal equal to 10 Pa. Run the case. The volume flow rate in the ventilation shaft is 49.58 m3/s for the default parameters of the model.
- Then go to Tools → Parametric Runs and create a “New” case (Figure 52).
- From the outline in the section form of the ventilation shaft, by right-clicking on the tArea[1] (in areaPt>tArea[1:1]), add the tArea[1] to ParmRun_1 (Figure 78). This parameter will be added to the input list. In the Parametric Runs window, set a suitable range (e.g., from 5.0 to 20) and a suitable resolution (e.g., 4).

Figure 58. Adding the parameter to the parametric run form
- From the section form of the ventilation shaft, by right-clicking, add VFAir1 in m3/s to ParmRun_1 as output and set its role to SHOW (this will only display the result of the variables, without having any effect on the optimization).
- From the outline in the section form of the ventilation shaft, by right-clicking on the tDiamH[1] (in areaPt>tDiamH[1:1]), copy tDiamH[1].
- Then, in the ParmRun form, click on + sign in the output and select from the clipboard.
This parameter will be added to the output list. When ready, your window should look like the one below (Figure 59).

Figure 59. Parametric Runs setup
- Now, Run all
. This represents a brute force approach: all possible shaft areas, in this case 4, will be applied in 4 separate simulations. - Under the Result tab of the Parametric Runs (Figure 60), you can see the results of different simulations. We selected the shaft diameter to be shown in the output list to highlight an important issue. Despite the shaft area changes, the shaft diameter remains unchanged. To solve this issue, we use a graphical script.

Figure 60. Results of Parametric Runs
- Create a small Graphical Script
. Click on the left-side
, Scripts, and drag and drop/double-click on a new one from there. You will create a script like the one you see in Figure 61. The procedure will be explained in the next paragraph.

Figure 61: GS for shaft diameter.
- Optionally, rename the GS to shaft diameter (Figure 86). In the outline tab (section from of the shaft), add the “tArea[1], m2” (1) to Graphical Script. Insert a local parameter from the Utility palette (2). Change the parameter value to 1.2732 (the ratio of 4/π). Use a Product (3) and Sqrt (4) from the Math palette and insert an Output parameter (5) and Custom script (6) from the Utility palette. Connect them like Figure 86. The output parameter shows the shaft diameter assuming a circular cross-section. This calculated diameter now must be assigned to the shaft diameter parameter. The standard procedure is to select a parameter and map that to this output parameter (to check this, right-click on every parameter to see if the mapping to a built graphical script is available). However, this procedure does not work for some parameters in the IDA Tunnel, especially those set in the edit segment form. Hence, we can use a custom script to map the calculated output parameters in a graphical script to these types of parameters.

Figure 62: Different steps to build the GS for shaft diameter.
Click on the custom script to open the following form (Figure 63). Click the Edit tab. Enter the following script in the opened dialog form (Figure 64) and press OK. Now, the script has been added to the Code part of the Custom Script form (Figure 65).
The script sets the value of the shaft diameter to the output parameter (u_var is the input variable of the Custom Script that is equal to the output parameter.
(SET-VALUE [[[@ :SYSTEM] "Shaft"] |areaPt|] ('|tDiamH| 1) [|u_var| 1])
For general information on all script functions, please refer to this Link. The general format of this specific script function is,
(set-value base ref value)
This function changes the value of the parameter (or start value of a variable) referenced by ref relative to the given base object. The reference ref is either a parameter name or a list of names of nested components and indices.
In our example, base is the location of the parameter that must be put in square brackets like this: [[[@ :SYSTEM] "Shaft"] |areaPt|]. Ref is the parameter name ('|tDiamH| 1) for which we want to set a new value. The new value in our example is the input variable to the custom script. If you are doubtful about the name of the component for which you aim to set a new value, you can open a run script from the Tools menu and then left-click and drag that component to this form. The assigned name in the IDA Tunnel would be visible there.

Figure 63. Custom script form

Figure 64. Dialog form to enter script commands

Figure 65. Custom script form with added script command
Now, Run all
again in the parametric run form. Under the Result tab of the Parametric Runs (Figure 66), you can now see the results of different simulations using the graphical script for the shaft diameter. As the shaft area changes, the shaft diameter changes based on the graphical script.

Figure 66. Results of Parametric Runs updated by the added graphical script