SWAN GIS Running Simulations

From TUFLOW FV Wiki
Jump to navigation Jump to search

Introduction

This page shows you how to run SWAN using two differing methods as follows:

  1. Via the command line or
  2. Run from a Windows Batch file

Either methods are suitable, however the batch file method is typically more flexible and powerful and therefore recommended for this tutorial.

Install SWAN

Firstly we need to ensure SWAN is installed. It is assumed you will be running SWAN on Windows 10. For other operating systems please refer the to relevant instructions on the SWAN download page.

Running Simulations from the Command Line

Once installed, add SWAN to the Windows PATH environment variable by following the below steps (Note: If running from a batch file these steps are not mandatory). This allows the swanrun program to be called from the command line regardless of what directory you are in.

  1. In the windows search bar, type 'path'
  2. Open the 'system environment variables' editor
  3. Press the 'Environment Variables' button
  4. Select the 'Path' variable
  5. Press the 'edit' button
  6. Add the path of the SWAN folder

RUNNING SIMULATIONS 011.PNG
RUNNING SIMULATIONS 012.PNG

Open the windows command prompt by entering 'cmd' into the windows search bar.

RUNNING SIMULATIONS 014.PNG

Change the current working directory by entering: 'cd C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN\03_simulation'.

Run the first SWAN model by entering 'swanrun REGIONAL_20180901_20181001'. Make sure you exclude the '.swn' file extension. Swanrun will automatically append this when opening the file.
An example of navigating the command prompt is provided below, noting this snapshot runs a different model and file location to that specified in our tutorial, you can ignore this, the process is what's important here.

RUNNING SIMULATIONS 013.PNG

For this tutorial, we need to run all 4 nested models. This is best done using a batch file as explained in the section below.

Running Simulations with Batch File

Often we will want to run multiple simulations one after another. For these situations, batching the runs in a batch file is useful and this section will show how to batch up SWAN runs. Please note you don't need to complete the running from command line section above to be able to run via a batch file.
In your C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN\03_simulation folder, create a new file named 'run.bat'.

RUNNING SIMULATIONS 015.PNG

Edit the 'run.bat' file in a text editor, adding the following commands to stage the runs in order of nesting:

RUNNING SIMULATIONS 016b.PNG

To allow sequential running of models we need to make a slight change to the default swanrun.bat file installed with SWAN. Open C:\Program Files\swan\swanrun.bat (Note: Your installation may be located at C:\Users\USERNAME\AppData\Local\Programs\swan) in a text editor and navigate to the bottom of the file. Enter the command EXIT on the last line. Note, that you may need to open the file in Administrator mode to make and save this change. Save and close the file. An example of where to add the EXIT command is shown as follows:
RUNNING SIMULATIONS 099.PNG

To run the batch file either:

  1. Open the command prompt and change the current working directory by entering 'cd C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN\03_simulation'. Run the batch file by entering 'run.bat'
  2. Navigate to the batch file C:\Tutorial_Module_SWAN_GIS_Tools\Moreton_Bay_Waves\SWAN\03_simulation\run.bat in Windows Explorer and double click on the batch file.


Conclusion

Nice work! You have now run your suite of SWAN models. During the next stage of the tutorial we will investigate post processing options to help visualise SWAN results and also prepare the spectral wave outputs for input to the TUFLOW FV hydrodynamic model.