Simulating overland oil spills from a tank break¶
This tutorial explains how to use the OilFlow2D model to simulate overland oil spills from a tank break. The steps to accomplish this are as follows:
-
Start QGIS and create a new OilFlow2D project.
-
Adding the terrain elevation data.
-
Create the limits of the modeling area (Domain Outline).
-
Setting the boundary conditions.
-
Assigning Manning's n roughness coefficients.
-
Using the Weirs layer to create the tank.
-
Filling the tank with oil utilizing the InitialWSE layer.
-
Generating the triangular mesh and exporting the data files to the OilFlow2D model.
-
Configuring parameters in the Hydronia Data Input Program.
-
Creating OilFlow2D maps and animations from results data.
The files required to follow this tutorial can be extracted from the 'ExampleProjects' zip file under the 'SimulatingTankbreaks' folder. This zip file is downloaded separately from your installation materials. The folder contains the files shown:
Start a new OilFlow2D project¶
-
To create a new OilFlow2D project, click on the New OilFlow2D Project button
in the toolbar. A dialog window appears where you select the layers that will be created, the Coordinate Reference System (CRS), and the directory path where the layers will be saved. Select None, then enable Domain Outline, Manning N, BoundaryConditions, InitialWSE, and Weirs. This tutorial uses the InitialWSE layer to define the oil level and the Weirs layer to outline the tank. -
Select the Projection: Coordinate Reference System (CRS) EPSG code: 2202 corresponding to REGVEN / UTM zone 19N - Projected
-
Use the same working Project Directory:
ExampleProjects\SimulatingTankbreaks -
After clicking OK, the templates of the layers are created, and displayed on the Layers Panel:
OilFlow2D will use the unit system defined in the projection you selected. If the projection has coordinates in feet, units will be set to English. If the projection coordinates are in meters, units will be set to Metric/SI.
Load elevation data¶
OilFlow2D uses elevation data in raster format.
-
To load the raster elevation file, from the Layer menu, click Add Layer, and then click Add Raster Layer.... You may also click the Add Raster Layer button
.The following dialog will appear where you can select the raster file containing elevations. In this case, select
DEM.tiffrom the extractedSimulatingTankbreaksfolder. -
Click Add, then click Close on the dialog and click on the Zoom Full button
or by right-clicking the DEM layer and selecting Zoom to layer. -
The raster will be displayed on the screen, by default it is rendered in gray gradient and will need to be changed in the layer properties by right-clicking the DEM layer and selecting Properties. Under Symbology, select the drop down menu for Render Type and select Hillshade, then click OK.
The layer should look like the following figure:
It is convenient to move the raster layer to the end of the list of layers, thus it does not interfere with the display of other layers.
-
Save the QGIS project by clicking on the Save Project
icon in the toolbar. Make sure it is saved in the same directory that you previously selected in the Create New Project dialog above.
Create the limits of the modeling area (Domain Outline)¶
The limits of the modeling area are defined using a polygon on the Domain Outline layer. To create it do as follows:
-
Click the Domain Outline layer to activate it and then click Toggle Editing (pencil) in the toolbar:
-
Clicking on the button activates the rest of the editing buttons. Now click the Add Polygon Feature tool which is the bean looking polygon
.Proceed to delineate the outline of the polygon by marking the vertices clicking with the left mouse button.
Make sure that the polygon is contained within the limits of the raster layer since OilFlow2D will not extrapolate elevations to areas that are outside of the available data on the raster layer.
-
To finalize and close the polygon, right-click anywhere on the screen. A dialog window to input the cell size attribute of the newly created polygon. The value for the reference size of the mesh cell is indicated. Enter a value of 10 m.
If you want to make any correction to the polygon, use the Node tool
to move, add or remove nodes as necessary. -
Save the polygon by clicking the Save button
.and click on Toggle Editing icon
to deactivate the layer edit mode and complete the Domain Outline.
Setting the boundary conditions¶
To define the boundary conditions:
Inflow boundary conditions. Draw a polygon that includes the nodes or vertices at the lower end of the mesh as indicated in the figure:
-
Select the BoundaryConditions layer in the Layers panel.
-
Click the Toggle Editing button
to add the polygons that are going to indicate the nodes on which the outflow conditions are established. -
To finish the polygon, right-click on desired location. A window to enter the attributes of the newly created polygon is displayed.
-
The window contains a list to input the ID of this BC (Boundary Cond. ID). Click the dropdown menu for Type of Open Boundary select the boundary condition Type 5.Uniform flow condition. Enter the value 0.0025 in the So field.
The window should appear as shown in Figure below:
-
Click OK to close the dialog box.
-
Click the Save icon
and then click the Editing Tool icon
to deactivate editing mode.
Assigning Manning's n roughness coefficients¶
Manning's coefficients are used in OilFlow2D to represent the terrain roughness. To assign Manning's n values, we will enter polygons with particular n's. There can be as many polygons as required to reproduce the spatial variability of this parameter. In this example, a single polygon will be used for the entire area.
-
Select the Manning N layer and click the Toggle Editing button
. -
Draw the polygon around the entire domain taking care that it covers all the cells.
-
Close the last vertices on the polygon by right-clicking on the desired position. The following dialog window is presented where you must input the Manning's n value associated to the polygon ():
-
Click the Save icon
and then click the Editing Tool icon
to deactivate editing mode.
Using the Weirs layer to create the tank¶
In this tutorial we assume that the spill occurs in a tank. We will use the Weirs layer to draw the tank in the northern part of the domain.
-
Click the Weirs layer to activate it and then click Toggle Editing (pencil) in the toolbar:
-
Left-click to create the vertices of the tank, starting from the bottom left corner and moving in the direction shown in the figure.
-
Right-click to close the polyline, ensuring that there is a gap between the last and first vertices as shown in the figure below:
-
Then enter the Cell Size attribute, in this case we will use 5 m:
-
Click on the tab Weir crest elevation for vertex, enter the number as shown in the following figure before clicking Set a weir crest elevation for all the weir
This will populate the WCREST column with the value entered.
To determine the appropriate weir crest elevation, first use the Identify Features tool on the DEM to find the ground elevation where the tank will be placed. The weir crest elevation should be that ground elevation plus the desired height of the tank wall (e.g., ground elevation + 10m).
-
To complete entering the Weir, click Save
and then the Toggle Editing icon (pencil)
.
Generating the triangular-cell mesh¶
Now that the Domain Outline layer has been created, proceed to create the mesh.
-
To generate the mesh, click on the icon
.The following figure shows the generated mesh. You will also find the Layers panel one new layers: Trimesh :
Inspect the weir feature to ensure that it has a minimum of two cells in between the first and last vertices.
Filling the tank with oil utilizing the InitialWSE layer¶
This layer is used to define the initial water surface elevation within the created polygon, in this tutorial it will be used to fill the tank with oil.
-
Click the InitialWSE layer to activate it and then click Toggle Editing (pencil) in the toolbar:
-
Left-click inside the Weirs polygon, staying close to each vertices to create the internal polygon of the tank.
-
Right-click to close the polygon.
-
A dialog window is presented where you must input the initial water surface elevation, in this case we will use 909 m. This value may need to be different depending on where you place the tank within the domain.
-
To complete entering the InitialWSE, click Save
and then the Toggle Editing icon (pencil)
.
Exporting the files to OilFlow2D¶
Once the layers with the input information to the model have been created, the next step is to run the tool that exports the data files in the proper format required by OilFlow2D. The process is as follows:
-
Make sure all of your required layers are active before performing this step.
-
Run the Export Hydrodynamic OilFlow2D plugin:
-
A dialog window is presented, where we will indicate the raster layer with the Digital Elevation Model (DEM), as this layer is not created by the plugin and its name may be arbitrary.
-
Make sure to indicate a file name (e.g. Oilspill) including the path where the generated files will be stored, and click OK.
While exporting the data, you will be able to see the task progress at the top of the message bar. Once the process of creating the files is completed, the Hydronia Data Input Program (DIP) is opened automatically and a dialog window is presented with the model project to run. In this case: 'base.DAT' should already be set.
After export completes, version 10 and later users see the
Open DIPdialog. KeepQGIS DIPselected and click OK. To use the historical standalone option, expand More options, select Classic DIP, and click OK.
The OilFlow2D input settings are then available in QGIS DIP:
The legacy configuration figure below is retained as a values reference.
-
Ensure that the Oil Spill on Land Module is selected, the Simulation time is set to 2 hours, and the Output Interval is set to 0.1.
-
Click Save .DAT and overwrite the 'base.dat' file.
-
Now click on the Oil Spill on Land panel, make sure Basic Model radial button is selected, and enter the data the following data: Oil viscosity: 0.009966468 Pa.s, Flow Resistance Relation Quadratic, Oil density: 893.19 kg/m\(^3\), and Yield stress: 0.1 N/m\(^2\). In the Tables section, make sure to fill in the values as seen in the figure below:
The following Classic DIP Oil Spill on Land panel is retained as a legacy values reference:
-
Click Save .DAT. This will create the TemperatureViscosityDensityQQ.txt and TemperatureTimeSeriesQQ.txt files in your scenario folder.
-
Click the Run OilFlow2D button to run the model. An image similar to the one shown below should appear:
-
When you have finalized reviewing the information included in this window, close it. The following post processing window will appear indicating the final post-processed task performed by the OilFlow2D model. The window will close automatically.
Creating OilFlow2D maps¶
Once OilFlow2D has finished running, you may want to create maps using the model results. OilFlow2D QGIS plugin offers several tools to create maps and animations. In this section we will show how to create depth maps.
-
Click the OilFlow2D Maps
button dropdown menu and select Results vs Time Maps. -
A dialog window is presented where we will indicate the output files list 'base.OUTFILES' and the desired parameter, that will be Depth for time 2 hours. Also indicate the Raster Map option as shown.
-
Click OK to start the process. After a few seconds a new layer with the requested map will be created.
-
Right-click the newly generated layer and select Properties. In the Properties window, click on the Symbology tab and change the Mode to Equal Count (Quantile) option.
Save the project in QGIS to continue. On the QGIS Project menu, click Save, to save the project assigning the name SimulatingTankBreaks, in the same directory that you previously selected in the Create New Project dialog above. The saved project file will be SimulatingTankBreaks.qgz.
Animating oil spill on land results in OilFlow2D¶
Sometimes it is better to view an animation of the results for a different audience, or to view all of the results quickly. Animations can also be exported to a movie file for maximum portability. To create an animation, complete the steps as follows:
-
In QGIS, click on the Oil Animation Button
in the OilFlow2D toolbar. -
A panel will open on the bottom left side of the QGIS interface.
-
Click on the Select Layer dropdown menu and select Depth. Click on the Add Layer button.
-
After the animation loads, it will be listed in the list window under the Select layer button.
-
in the Layers panel above, there will be a new group named ANIMATION which will contain the newly created Depth animation layer.
-
The layer needs to be moved above the DEM layer so that it is visible when being played. Click and drag the ANIMATION group and make sure to drop it above the layers that would need to be underneath it, such as the DEM and satellite imagery layers as in the following figure:
-
To play the animation, click the Play
button in the OilFlow2D Animation panel. Make sure all other output layers have been disabled.
The user can change the speed of the animation, export the animation as a shape file, export an image of a particular frame of an animation, and finally export a video via the buttons located at the bottom of the OilFlow2d Animation panel.
This concludes the tutorial: Simulating overland oil spills from a tank break.




























