Analyzing simulation results using SQLs
Analyze simulation results using an SQL query.
Tutorial resources
These downloadable resources will be used to complete this tutorial:
Step-by-step guide
SQLs may be used to aggregate the simulation results you are interested in. For example, you can produce a grid that illustrates the average flow and velocity across the network, then compare the results with those found in another scenario.
- From the Model Group, double click SQL Control to open the Baseline simulation results.
Note: If the run icon on the left of the simulation is greyed out, right-click the run and select Re-run.
To create a query illustrating average flow and velocity in the network:
- Right-click the Stored Query Group and select New > Stored Query.
- In the popup, name the stored query “Baseline- Average”.
- In the Model Group, double-click Baseline- Average to open the Stored Query dialog box.
- From the Object Type drop-down, select Pipe.
- In the text box, type the following query:
SELECT SUM(length) as “Length”, AVG(sim.flow) as “Average Flow”, AVG(sim._Velocity) as “Average Velocity”
- Click Test.
A notification appears, indicating valid syntax.
- Click OK.
- Click Save.
- Click Run.
The SQL window closes and a results grid opens, containing the total length of pipes in the network, the average flow, and the average velocity.
- Close the grid window.
To compare these results with an alternative baseline scenario:
- From the Model Group, expand the Pipe Break Scenario.
- Right-click the [Pipe Break] SQL Control simulation and select Open as.
- In the Select Result dialog box, select As alternate results for comparison.
- Click OK.
- In the Model Group, double click Baseline- Average to open the SQL dialog box.
To extend the script to include the second scenario:
- In the text box, at the end of the last line, type a comma (,).
- After the comma, type the following, starting with a SPACE:
AVG(sim2.flow) as “Average Flow 2”, AVG(sim2._Velocity) as “Average Velocity 2”
- Click Test.
A notification appears, indicating valid syntax.
- Click OK.
- Click Save.
- Click Run.
The SQL window closes and a grid opens showing the average flow and average velocity for both simulations, and the total length of pipes in the network.
- When you are finished comparing the results, Close the grid window.