Run TUFLOW From PowerShell: Difference between revisions

Content deleted Content added
 
(9 intermediate revisions by 2 users not shown)
Line 12:
</pre>
 
Assuming the PowerShell script filename is runrun_TUFLOW_simulations.ps1, this can be run from the PowerShell command line with this command:
<pre>
.\run_TUFLOW_simulations.ps1
Line 18:
 
{{Video|name=TUFLOW Run_Edited.mp4|width=850}}<br>
 
<br>
A Windows batch file can also be used to execute a PowerShell script, avoiding the need to work in the PowerShell command line.
* Create a text file with a *.bat file extension, saved in your TUFLOW\runs folder (alongside your TCF)
* Add the following syntax to the batch file (if your ps1 file uses a different name, specify it instead of run_TUFLOW_simulations.ps1):
<pre>
@powershell -File .\run_TUFLOW_simulations.ps1
</pre>
* Double left mouse click the batch file from Window Explorer to execute the batch file that calls the PowerShell script
 
=Simple Example=
Line 33 ⟶ 40:
 
=Multiple Simulations=
Running multiple simulations in series can be handled by adding new lines to run.ps1. Use a –b (batch) switch to suppressessuppress the need to press the return key at the end of each simulation:
<pre>
C:\bin\TUFLOW\2025.0.3\TUFLOW_iSP_w64.exe -b model_001.tcf
Line 42 ⟶ 49:
To alter the behaviour of TUFLOW, switches can be used in the same way as a batch file (see <u>[[Run_TUFLOW_From_a_Batch-file#TUFLOW_switches_in_a_batch_file | Batch File Switches]]</u>):
<pre>
C:\bin\TUFLOW\2025.0.3\TUFLOW_iSP_w64.exe -b -x -s1 5m -s2 D01 model_~s1~_~s2~_001.tcf
</pre>
 
=Looping=
Looping is undertaken in a similar way to batch files. The following PowerShell script contains a nested loop, so thatwhere TUFLOW runs a simulation for all combinations of scenarioscenarios and eventevents.
Comments can be added using #.
 
Line 72 ⟶ 79:
$Mail.Send()
</pre>
It is also possible to send the contents of a log file (for example, the simulation TLF or _ TUFLOW Simulations.log) as the body of the email. To do this, you must pre-empt the name and path of the TLF file that will be produced:
<pre>
$Mail.Body = Get-Content -Raw .\log\model_001.tlf