Simulating overland oil spills with OilFlow2D¶
This section provides a step-by-step guide for setting up an overland oil spill using OilFlow2D. The tutorial illustrates the model application to simulate a real spill from a pipeline leak. It includes instructions to enter the terrain elevation data, create the mesh, prepare the layers with the spill location, and run the OilFlow2D model.
Tutorial data¶
The files required to follow this tutorial can be extracted from the 'ExampleProjects' zip file under the 'OilSpillOnLandTutorial' folder. This zip file is downloaded separately from your installation materials. The folder contains the files shown:
Starting QGIS¶
The first step is to start the QGIS software. After loading the QGIS, you will get a window is similar to the one shown below:
Note the tool bar contains icons that give access to all the OilFlow2D components. Some of the icons have a drop down list that allow getting to more tools.
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. This tutorial creates only the Source/Sink layer: select None in Layers and check Source/Sink. -
Select the Projection: Coordinate Reference System (CRS) EPSG code: 2202 corresponding to REGVEN / UTM zone 19N - Projected
-
Select a working Project Directory:
ExampleProjects\OilSpillOnLandTutorialThis will be the folder where the model will write all results and output files. The dialog window should look like this:
Verify that Layers is set to None, Source/Sink is checked, the CRS is EPSG:2202, and the project directory is the extracted
OilSpillOnLandTutorialfolder. -
Provide a name for the Scenario: OilSpill for this tutorial.
-
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.
Copy all of the files from the OilSpillOnLandTutorial tutorial folder into the new scenario folder created. In this example, copy them into ExampleProjects\OilSpillOnLandTutorial\OilSpill.
Load elevation data¶
OilFlow2D uses elevation data in raster format.
-
To load an ASCII grid 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 extractedOilSpillOnLandTutorialfolder.If you don't have raster elevation data format, you can import it in any other format, and use QGIS to convert it to raster.
-
Click Add, then click Close on the dialog and click on the Zoom Full button
. -
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.
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.
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 :
Entering the spill data¶
In this tutorial we assume that the spill occurs near the upstream end of the domain. We enter the spill data in the Source/Sink Sources layer.
-
Click the Sources layer to activate it and then click Toggle Editing (pencil) in the toolbar:
-
Click on a point at coordinates () to set the spill location.
-
Then enter the spill name Source_1, and select the source/sink type: Discharge vs Time as shown:
-
While you are on this dialog, activate the Data panel and use the Import Source/Sink File button to select the 'SOURCE_1.txt' file. This file contains the oil spill discharge (flowrate vs time).
-
Once you select the 'SOURCE_1.txt' file, a dialog will appear to confirm the type of additional column data we are importing. Leave the default Temperature and click OK.
-
To complete entering the spill data, click again the Toggle Editing icon (pencil) and Save.
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.
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 8.Free outflow.
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.
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. After export completes, version 10 and later users see the
Open DIPdialog.QGIS DIPis selected by default; clickOKto open it inside QGIS. To use the historical standalone option, expandMore options, selectClassic DIP, and then clickOK.
With
QGIS DIPselected, the current interface is shown below:QGIS DIP and Classic DIP use the same project settings, but their interfaces look different. Older standalone or non-maintenance versions may open Classic DIP automatically. The project-specific Classic DIP settings below are retained as a legacy values reference; in this example,
Oilspill.DATshould already be set.Then the window with the input parameters of OilFlow2D are presented, as shown in the image below:
-
Ensure that the Oil Spill on Land Module is selected, the Sources/Sinks component is selected, that the Simulation time is set to 2 hours, and the Output Interval for components is set to 0.1.
-
Click [Save .DAT] and overwrite the 'Oilspill.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 kh/m\(^3\), and Yield stress: 0.1 N/m\(^2\) as indicated:
The following Classic DIP panel is retained as a legacy values reference:
-
Click [Save .DAT] and overwrite the 'Oilspill.dat' file. You will receive warnings for empty files, you may ignore these.
-
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 'Oilspill.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 Oilspill, in the same directory that you previously selected in the Create New Project dialog above.
Utilizing the Heat Transfer option for oil on land spills in OilFlow2D¶
In addition to modeling with density, viscosity, and yield stress, OilFlow2D can account for and simulate additional properties such as wind velocity, relative humidity, ambient temperature, and solar radiation effects over time.
Continue from the QGIS DIP or Classic DIP path selected in the export section; no second chooser is needed for this continuation.
The Heat Transfer model requires a temperature to be set on a third column for each row in the 'Source_1.txt' file. If the third column of data is missing, the model will not run.
-
In the selected DIP program with the project loaded, click on the Oil Spill on Land panel. Click on the Heat Transfer Model radial button and click Open .OILP. Select the OilHT.OILP file and click Open.
This will load a template with the environmental parameters file and a yield stress table to use in the subsequent simulation.
-
Click Save .OILP and select Oilspill.OILP to overwrite the file that the project is utilizing for the run.
-
Click on the Control Data panel and change the Simulation time (hours.): to 24.
We change the simulation time to account for the day/night cycle and observe how oil properties are affected by ambient temperature changes.
*OPTIONAL* Under Model Selection select GPU if your computer has an nVidia GPU installed. This can significantly accelerate the simulation
-
Click Run OilFlow2D, then click Yes to save the changes and overwrite the existing Oilspill.dat file.
Having run the Heat Transfer model, QGIS will be able to produce additional Results vs. time outputs. These will appear in QGIS, in the Results vs. time dropdown menu:
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 with OilFlow2D.
































