Tutorial M08: Difference between revisions
Content deleted Content added
| (21 intermediate revisions by 4 users not shown) | |||
Line 2:
In this module, scenario management is introduced. This is a powerful functionality running different simulations using a single set of control files rather than creating a new set of control files for every simulation. This makes the management of the model easier, ensures consistency between the simulations and better quality control. Without implementing scenario management, six TCFs and six TGC files are required to run this module, using scenario management, only one each is needed:<br>
<br>
[[File:M08 ScenarioManagement 02.png]]<br>Scenarios are set up using an if scenario logic block - <font color="blue"><tt>If Scenario</tt></font> command followed by <font color="blue"><tt>Else If Scenario</tt></font> commands adding on different scenarios and terminated by <font color="blue"><tt>End If</tt></font>.
<br>▼
▲Scenarios are set up using an if scenario logic block - <font color="blue"><tt>If Scenario</tt></font> command followed by <font color="blue"><tt>Else If Scenario</tt></font> commands adding on different scenarios and terminated by <font color="blue"><tt>End If</tt></font>.<br>
Note: Scenarios can be added to most of TUFLOW’s control files. The only control files that do not support scenarios are the TUFLOW Rainfall Control File (.trcf), TUFLOW External Stress File (.tesf), Advection Control File (.adcf), or within a Define Control command inside a TUFLOW Operational Control (.toc) file.
The tutorial demonstrates two ways of using scenarios:<br>▼
:*Part 1: Single Scenario - cell size.
:*Part 2: Multiple Scenarios - cell size and topography updates.
Line 12:
The GIS layers are:
:*TGC layers:
<ol><ol><li>2d_zsh: A layer used to modify Zpt elevations using points, lines and polygons.
<li>2d_mat: A layer used to define the land use (material) types within the developmental area.</ol></ol>
'''Module 8 builds from the model created in <u>[[Tutorial_M02 | Module 2]]</u>. The completed Module 2 model is provided in the Module_08\TUFLOW folder.'''
<br>▼
=Part 1 - Single Scenario=
Line 36:
<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>
<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>
<li>Save the TGC.
</ol>
Line 44 ⟶ 48:
<li>Save a copy of '''M02_5m_001.tcf''' as '''M08_~s1~_001.tcf''' in the '''Module_08\TUFLOW\runs''' folder.
<li>Open the file '''M08_~s1~_001.tcf''' in a text editor.
<font color="blue"><tt>If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>10m </tt></font> <font color="green"><tt> ! Beginning of if statement - 10m scenario</tt></font> <br>▼
<ol><font color="blue"><tt>SGS Sample Frequency </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>21 </tt></font> <font color="green"><tt> ! Sets SGS Sample Frequency to 21</tt></font> <br></ol>▼
<font color="blue"><tt>Else If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>5m </tt></font> <font color="green"><tt> ! 5m scenario</tt></font> <br>▼
<ol><font color="blue"><tt>SGS Sample Frequency </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>11 </tt></font> <font color="green"><tt> ! Sets SGS Sample Frequency to 11</tt></font> <br></ol>▼
<font color="blue"><tt>Else If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>2.5m </tt></font> <font color="green"><tt> ! 2.5m scenario</tt></font> <br>▼
<ol><font color="blue"><tt>SGS Sample Frequency </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>5 </tt></font> <font color="green"><tt> ! Sets SGS Sample Frequency to 5</tt></font> <br></ol>▼
<font color="blue"><tt>Else </tt></font> <font color="green"><tt> ! Else statement</tt></font> <br>▼
<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>▼
<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>▼
<li>Update the TGC reference: <br>
<font color="blue"><tt>Geometry Control File </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>..\model\M08_001.tgc </tt></font> <font color="green"><tt> ! Reference the TUFLOW Geometry Control File</tt></font> <br>
Line 62 ⟶ 56:
<ol><font color="blue"><tt>Timestep </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>2 </tt></font> <font color="green"><tt> ! Specifies the first 2D computational timestep of 2 seconds</tt></font> <br></ol>
<font color="blue"><tt>Else If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>5m </tt></font> <font color="green"><tt> ! 5m scenario</tt></font> <br>
<ol><font color="blue"><tt>Timestep </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>1 </tt></font> <font color="green"><tt> ! Specifies the first 2D computational timestep of 1
<font color="blue"><tt>Else If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>2.5m </tt></font> <font color="green"><tt> ! 2.5m scenario</tt></font> <br>
<ol><font color="blue"><tt>Timestep </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>0.5 </tt></font> <font color="green"><tt> ! Specifies the first 2D computational timestep of 0.5 seconds</tt></font> <br></ol>
Line 68 ⟶ 62:
<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>
<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>
<li>Save the TCF.
</ol>
Line 75 ⟶ 73:
<li>Save a copy of '''_run_M02_HPC.bat''' as '''_run_M08_HPC.bat''' in the '''Module_08\TUFLOW\runs''' folder.
<li>Update the batch file to reference the '''M08_~s1~_001.tcf''' and include a scenario switch (-s1) defining cell size:<br>
<font color="blue"><tt>'''set'''</tt></font> <font color="black"><tt>exe</tt></font><font color="red"><tt>=</tt></font><font color="black"><tt>"..\..\..\exe\
<font color="blue"><tt>'''set'''</tt></font> <font color="black"><tt>run</tt></font><font color="red"><tt>=</tt></font><font color="black"><tt>start "TUFLOW" /wait</tt></font> <font color="orange"><tt> %exe%</tt></font> <font color="black"><tt> -b</tt></font> <br>
<font color="orange"><tt>%run% </tt></font> <font color="black"><tt> -s1 10m M08_~s1~_001.tcf </tt></font> <br>
Line 89 ⟶ 87:
== Check Files ==
While the model is running, review the added features are specified correctly:
:*<u>[[Tutorial_M08_001_Check_Files_QGIS | QGIS - SHP]]</u>
:*<u>[[Tutorial_M08_001_Check_Files_QGIS_GPKG | QGIS - GPKG]]</u>
Compare the model cell count:
<ol>
Line 110 ⟶ 109:
<li>The file shows the simulation times for all the simulations.
<br>
[[File:
▲<br>
</ol>
<br>
Line 120:
== GIS Inputs ==
Create, import and view input data:<br>
:*<u>[[Tutorial_M08_002_GIS_Inputs_QGIS | QGIS - SHP]]</u><br>
:*<u>[[Tutorial_M08_002_GIS_Inputs_QGIS_GPKG | QGIS - GPKG]]</u><br>
== Simulation Control Files ==
Line 127 ⟶ 128:
<li>Save a copy of '''M08_001.tgc''' as '''M08_002.tgc''' in the '''Module_08\TUFLOW\model''' folder. <br>
<li>Open the '''M08_002.tgc''' in a text editor.
<li>Include the following if scenario logic block for existing and developed case after the '<font color="blue"><tt>Read GIS Z Shape
<u>'''QGIS - SHP'''</u><br>
<font color="blue"><tt>If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>EXG </tt></font> <font color="green"><tt> ! Beginning of if statement - existing scenario</tt></font> <br>
<ol><font color="green"><tt> ! Defines a placeholder</tt></font> <br></ol>
<font color="blue"><tt>Else If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>DEV </tt></font> <font color="green"><tt> ! Development scenario</tt></font> <br>
<ol><font color="blue"><tt>
<font color="blue"><tt>Else </tt></font> <font color="green"><tt> ! Else statement</tt></font> <br>
<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>
<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>
<u>'''QGIS - GPKG'''</u><br>
▲<font color="blue"><tt>If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>
<ol><font color="green"><tt> ! Defines a placeholder</tt></font> <br></ol>
▲
<ol><font color="blue"><tt>Read GIS Z Shape </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>2d_zsh_M02_landscape_002_R | 2d_zsh_M02_landscape_002_L | 2d_zsh_M02_landscape_002_P </tt></font> <font color="green"><tt> ! Defines areas of complex landscaping</tt></font> <br></ol>
▲<font color="blue"><tt>Else </tt></font> <font color="green"><tt> ! Else statement</tt></font> <br>
▲<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>
▲<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>
<li>Include the following if scenario logic block for existing and developed case after the '<font color="blue"><tt>Read GIS Mat</tt></font>' command:<br>
<u>'''QGIS - SHP'''</u><br>
▲<font color="blue"><tt>
<ol><font color="green"><tt> ! Defines a placeholder</tt></font> <br></ol>
▲<font color="blue"><tt>Else If Scenario </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>
<ol><font color="blue"><tt>Read GIS Mat </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>gis\2d_mat_M02_landscape_002_R.shp </tt></font> <font color="green"><tt> ! Sets material values according to attributes in the GIS layer</tt></font> <br></ol>
<font color="blue"><tt>Else </tt></font> <font color="green"><tt> ! Else statement</tt></font> <br>
<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>
<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>
<u>'''QGIS - GPKG'''</u><br>
▲
<ol><font color="green"><tt> ! Defines a placeholder</tt></font> <br></ol>
▲
<ol><font color="blue"><tt>Read GIS Mat </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>2d_mat_M02_landscape_002_R </tt></font> <font color="green"><tt> ! Sets material values according to attributes in the GIS layer</tt></font> <br></ol>
<font color="blue"><tt>Else </tt></font> <font color="green"><tt> ! Else statement</tt></font> <br>
<ol><font color="blue"><tt>Pause </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>Error: Scenario Name Not Valid </tt></font> <font color="green"><tt> ! Displays specified text if different scenario name is called </tt></font> <br></ol>
<font color="blue"><tt>End If </tt></font> <font color="green"><tt> ! End of if statement</tt></font> <br>
<li>Save the TGC.
</ol>
Line 144 ⟶ 185:
<li>Update the TGC reference: <br>
<font color="blue"><tt>Geometry Control File </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>..\model\M08_002.tgc </tt></font> <font color="green"><tt> ! Reference the TUFLOW Geometry Control File</tt></font> <br>
<li>For GeoPackage users, update the Spatial Database reference: <br>
<u>'''QGIS - GPKG'''</u><br>
<font color="blue"><tt>Spatial Database </tt></font> <font color="red"><tt>== </tt></font> <font color="black"><tt>..\model\gis\M08_002.gpkg</tt></font> <font color="green"><tt> ! Specify the location of the GeoPackage Spatial Database</tt></font> <br>
<li>Save the TCF.
</ol>
Line 151 ⟶ 195:
<li>Open '''_run_M08_HPC.bat''' from the '''Module_08\TUFLOW\runs''' folder.
<li>Update the batch file to reference the '''M08_~s1~_~s2~_002.tcf''' and in addition to cell size scenario switch (-s1) include second scenario switch (-s2) defining topography:<br>
<font color="blue"><tt>'''set'''</tt></font> <font color="black"><tt>exe</tt></font><font color="red"><tt>=</tt></font><font color="black"><tt>"..\..\..\exe\
<font color="blue"><tt>'''set'''</tt></font> <font color="black"><tt>run</tt></font><font color="red"><tt>=</tt></font><font color="black"><tt>start "TUFLOW" /wait</tt></font> <font color="orange"><tt> %exe%</tt></font> <font color="black"><tt> -b</tt></font> <br>
<font color="orange"><tt>%run% </tt></font> <font color="black"><tt> -s1 2.5m -s2 EXG M08_~s1~_~s2~_002.tcf </tt></font> <br>
Line 178 ⟶ 222:
:*Single and multiple scenarios were set up and run with a range of cell sizes and designs.
:*Check files were assessed to view the changes based on each scenario.
:*Multiple scenario results were viewed using the TUFLOW Viewer.
:*For further training opportunities see <u>[https://tuflow.com/training/training-course-catalogue/ TUFLOW Training Catalogue]</u> and/or contact <u>[mailto:training@tuflow.com training@tuflow.com]</u>.
:*Alternatively, see the <u>[[TUFLOW_Example_Models#Example_Model_Catalogue | TUFLOW Example Models]]</u> to explore the full list of TUFLOW features.
=Looping Batch File (Optional)=
Looping batch file is a powerful tool running large number of simulations with the least amount of batch file text:
Line 187 ⟶ 231:
<li>Add the following commands. Indentation is important in batch files, insert tabs to match the below spacing:<br>
<font color="blue"><tt>echo </tt></font> <font color="black"><tt>off</tt></font><br>
<font color="blue"><tt>set </tt></font> <font color="black"><tt>exe</tt></font><font color="red"><tt>=</tt></font><font color="black"><tt>"..\..\..\exe\
<font color="blue"><tt>set </tt></font> <font color="black"><tt>run</tt></font><font color="red"><tt>=</tt></font><font color="black"><tt>start "TUFLOW" /wait </tt></font><font color="orange"><tt>%exe%</tt></font><font color="black"><tt> -b</tt></font><br>
<br>
Line 200 ⟶ 244:
</ol>)<br>
Note: The 'CSZ' and 'DES' are user defined batch file variables. The 'CSZ' refers to a cell size and 'DES' refers to a design scenario. <br>
<li>Save the batch file and double click it in file explorer to run the simulation.
</ol
= Variables (Optional) =
Variables provide a way to define values once and reuse them across control files, which helps manage models with multiple scenarios and events.
Scenarios and events are automatically available as variables. Variables can also be defined using the <font color="blue"><tt>Set Variable </tt></font>command as described in Section 13.2.3 Variables of the [https://docs.tuflow.com/classic-hpc/manual/latest/ <u>TUFLOW manual</u>]. They are referenced by enclosing the variable name within << and >>.
Note: The <font color="blue"><tt>Set Variable </tt></font>command can only be specified in the .tcf or within a read file (.trd) referenced from the .tcf. The variables can then be used in all control files (.tcf, .tgc, .tbc, .ecf, etc).
Example models using variables are provided in the [[TUFLOW Example Models#Bulk Simulation Management|<u>Bulk Simulation Management Example Model Dataset</u>]] on the TUFLOW Wiki.
▲<br>
{{Tips Navigation
| |||