BASEMENT

Two-dimensional (2d) numerical simulation methods described on these pages use the freely available software BASEMENT 3.x, which is developed at the ETH Zurich in Switzerland . Visit their website to download the program and documentation. The here provided online material guides through a numerical simulation exercise with BASEMENT v3.0.2. The guidance describes:

  • Pre-process data: From point clouds to computational meshes

  • Set up and run a numerical simulation with BASEMENT v.3

  • Post-process simulation results: Visualize, understand and analyze the model output.

  • Calibration & validation is here only mentioned as an integral part of numerical studies.

Requirements

To complete the tutorial, the following software is needed (all software can be run on Windows and Linux platforms): -BASEMENt v3.0.2-QGIS v3.16, and -ParaView.

This tutorial uses BASEMENT’s BASEplane module (version 3.0.2) to perform a two-dimensional (2d) hydrodynamic numerical simulation.

Pre-processing: Mesh Generation

Prepare a 2dm mesh file as described in the QGIS data pre-processing section.

Steady 2d Simulation with BASEMENT

In addition to the mesh (2dm file), the numerical engine of BASEMENT needs a model setup file (model.json) and a simulation file (simulation.json), which both are created automatically by BASEMENT. The following sections describe how to make BASEMENT creating the two .json files. Before getting there, create a new project folder of your choice (e.g., C:/BM/irme-exercise/).

Tip

The defined project folder directory must not contain any dots nor special characters nor spaces. Only use letters, numbers, *_* (underscore) or - (minus) in folder names.” %}

Make sure to place the two input files in the folder:

  • The 2d mesh .2dm file (i.e., the finalmesh.2d from the pre-processing).

  • A discharge inflow file (flat hydrograph) for the upstream boundary condition can be downloaded here (if necessary, copy the file contents locally into a text editor and save the file as SteadyVanillaInflow.txt in the local project directory).

Setup the Model File

This section walks you through the model setup of a hydrodynamic 2d BASEMENT simulation. The model setup is saved in a file called model.json.

Regularly save setting by clicking on the Write button (bottom-right corner). - Open BASEMENT and select the Scenario Directory. Then click on SETUP, right-click and Add DOMAIN. - Use the average elevation of each mesh triangle: GEOMETRY > Add item > Interpolation > select WEIGHTED (other options: MEDIAN, MAXIMUM, MINIMUM, MEAN). - GEOMETRY > MESH_FILE > select finalmesh.2dm. - GEOMETRY > right-click > Add item REGIONDEF > Add item (5 times) and define the items as:

INDEX

1

2

3

4

5

NAME

riverbed

lower_bank

upper_bank

floodplain

street

The window should now look like this:

basement regions

Fig. 47 Region definitions.

  • Next, we need to define inflow and outflow boundary condition with stringdefs. In the GEOMETRY section right-click – Add item STRINGDEF

  • Add item (2 times) and define item [0] as:

    • name = Inflow

    • upstream_direction = right

  • Define STRINGDEF item [1] as:

    • name = Outflow

    • upstream_direction = right

Note

If you used BASEmesh’s Stringdef tool, the upstream direction must be defined as right.

  • Add the initial condition in the HYDRAULICS section with by right-clicking > Add item > INITIAL (if not yet present) and set type: “DRY (i.e., the river is dry at the beginning of the simulation).

  • Add upstream and downstream boundary conditions with a right-click on the HYDRAULICS section > Add item > BOUNDARY (if not yet present), then right-click on the new BOUNDARY section > Add item STand ARD > Add item (2 times)

  • Define BOUNDARY item [0] as:
    • discharge_file = C:/.../SteadyVanillaInflow.txt (select by clicking on the folder symbol that occurs when the field is activated)

    • name = Inflow

    • slope = 0.0056

    • string_name = Inflow

    • type = uniform_n`

  • Define BOUNDARY item [1] as:
  • Define a global Strickler-based friction value of kst=30m1/3/s: In the HYDRAULICS section right-click > Add item FRICTION and define FRICTION with:
    • default_friction = 30.0

    • type = strickler

  • Assign particular Strickler values with a right-click on regions and Add item (5 times). Then define the five regions items ([0] through [4]) as

friction

28

15

20

40

85

region_name

riverbed

lower_bank

upper_bank

floodplain

street

../_images/bm-mod-frc.png

Fig. 48 Assignment of friction (roughness) values to model regions.

  • In the PARAMETER section define:
    • CFL = 0.95

    • fluid_density = 1000.0

    • max_time_step = 100.0

    • minimum_water_depth =0.01

  • Define a simulation_name (e.g., SteadyVanilla)

Note that the definitions of PHYSICAL_PROPERTIES and BASEPLANE_2d are mandatory. Click on the Write button (bottom-right corner) to save the model setup (see image below). If everything is correctly set up, the Console tab will automatically open and the Error Output canvas is empty.

../_images/bm-mod-sum.png

Fig. 49 Final model setup

Setup the Simulation File

The simulation file in BASEMENT v.3.x is called simulation.json (different from previous versions of BASEMENT) and located in the same folder as model.json (model setup file). To setup the simulation file: - In BASEMENT go to the SIMULATION Tab (situated in left window pane) and unfold the OUTPUT and TIME items. - Right-click on the OUTPUT item an Add item (5 times). Then define exactly in that irder (important for results export later on): * [0] = water_depth * [1] = water_surface * [2] = bottom_elevation * [3] = flow_velocity * [4] = ns_hyd_discharge - Define the TIME item as: * end = 5000.0 * out = 200.0 * start = 0.0 The BASEMENT window should now look like this:

../_images/bm-sim-set.png

Fig. 50 The Simulation tab setup. In order to export results with BASEMENT’s Python scripts, the OUTPUT parameters must be defined in exactly that order.

Run the simulation

After the successful simulation setup, select an appropriate Number of CPU cores (bottom-right in the above figure). If a high-quality graphics card with a powerful GPU is available, the GPu (high-performance hardware) has a much faster performance. Otherwise (no powerful GPU available), do not select GPU because it may significantly slow down the simulation speed. For faster simulations, select Single precision (bottom-right in the above figure), but in this example, Double precision will work sufficiently fast as well. Click on the Run button to start the simulation and wait for approximately 2-10 minutes. BASEMENT will prompt the simulation progress, while the Error Output canvas should remain white (see below figure). If any error occurs, go back to the above sections (or even to the mesh generation) and fix error message issues.

../_images/bm-sim-end.png

Fig. 51 BASEMENT after successful simulation.

Export results

Once the simulation successfully finished, go to BASEMENT’s Results tab and make sure that the xdmf output format is defined. Then click on the Export button (see also below figure). BASEMENT will inform about the export success.

../_images/bm-res-exp.png

Fig. 52 Export results after successful simulation.

BASEMENT’s developers at the ETH Zurich provide a suite of Python scripts for post-processing the simulation results. Here, we need the Python script `BMv3NodestringResults.py <http://people.ee.ethz.ch/~basement/baseweb/download/tools/python-scripts/BMv3NodestringResults.py>`__ (click to download).
To run the Python script, a Python3 installation with the numpy and h5py packages is required. To learn more about the installation and usage of Python, have a look at the instructions on this website to install Python. Note that working with the provided Python file requires that the output variables must be exactly defined as shown in the above figure of BASEMENT’s SIMULATION tab.

Post-processing with ParaView

ParaView is a freely available visualization software, which enables plotting BASEMENT v.3.x results in the shape of xdmf (eXtensible Data Model and Format) files. Download and install the latest version of ParaView from their website, if not yet done.

Load BASEMENT Results

Open ParaView and click on the folder icon (top left of the window) to open the simulation results file (results.xdmf). ParaView might ask to choose an appropriate XMDF read plugin. Select XDMF Reader here and click OK:

To explore the model results: - Select variables (e.g., flow_velocity, water_depth, or water_surface) in ParaView’s Cell Arrays canvas (green-highlighted circle in the below figure). - Click the Apply button (red-highlighted circle in the Properties tab in the below figure). All variables are now loaded and can be plotted. - To plot a variable, select one (e.g., flow_velocity) in the toolbar (light-blue-highlighted circle in the upper part of the below figure). Then click the play button in the toolbar (dark-blue-highlighted circle around the green arrow in the upper part of the below figure) to cycle through the time steps.

../_images/pv-vis.png

Fig. 53 ParaView after successful import of the model results (results.xdmf) - see above descriptions.

All available time steps are listed in the Blocks tab (bottom-left in Figure 1). Anything should be visible at the beginning because the initial conditions were defined as dry (see the setup of inital conditions ). The above figure shows the last time step (Timestep[25]), with water flowing at a peak velocity of 3.7 m/s. The 25 available time steps result from the definition made in BASEMENT’s SIMULATION tab with a total duration of 5000.0 and an output step of 200.0. Note that the time units have no dimension here because they correspond to computational time steps.

Export Visualizations

The animations can be saved as movie (e.g., avi) or image (e.g., jpg, png, tiff) files via File > Save Animation.... The current state (variable, Timestep[i]) can be saved as pvsm file via File > Save State File. The state file can also be saved as Python script for external execution and implementation in Python programs.

Export Data

For geospatial calculations (e.g., calculate habitat suitability indices for target fish species based on flow velocity and water depth), the simulation results must be converted to geospatial data formats. The first conversion step is to extract relevant point data in ParaView:

  1. With the results.xdmf file opened in ParaView, right-click on results.xdmf in the Pipeline Browser, then Add Filter > Alphabetical > Cell Centers.

  2. With the CellCenters1 filter enabled in the Pipeline Browser (blue-highlighted circle in the figure below), set the Time in the menu bar to the end time step (here: 5000, i.e., step no. 25, see the red-highlighted circle in the figure below)).

  3. In the Properties tab (green-highlighted circle in the figure below), check the Vertex Cells box, and click the Apply button.

  4. Press CTRL + S on the keyboard > a Save File dialogue window opens:

    • Navigate to the folder where you want to save the data

    • Enter a File name (e.g., bm-steady-vanilla)

    • In the Files of type drop-down field, select Comma or Tab Delimited Files(*.csv *.tsv *.txt)

    • Click OK

  5. The Configure Writer (CSVWriter) window opens. Make sure that Point Data is selected as Field Association. Optionally, check the Choose Arrays To Write box and select relevant fields only. Press the OK button.

The point data export is now complete. The next step is to import the data (here: bm-steady-vanilla.csv) in QGIS (next section).

../_images/pv-exp-steps.png

Fig. 54 The CellCenters (dark-blue circle) filter in ParaView, with the maximum Time step setting (red circle) and the Properties definitions (green circle).

Post-processing with QGIS

Tip

Ensure that the Crayfish plugin is correctly installed and available in the Toolbox.

There are two (to three) options to import the results in QGIS:

  1. Use ParaView Outputs

  2. Modify ``results.xdmf` and directly import results in QGIS <#qigs-imp-steps>`__

  3. Use an import tool (currently only available on demand )

Use ParaView export (here: bm-steady-vanilla.csv)

After data export from ParaView: - In QGIS, click on the Layer menu > Add Layer > Add Delimited Text Layer....

add qgis layer basement

Fig. 55 Open the Add Delimited Text Layer import wizard.

  • The Data Source Manager | Delimited Text window opens (see figure below)

  • In the File name field select bm-steady-vanilla.csv

  • Enter a Layer name (e.g., bm-steady-vanilla-csv)

  • In the File Format canvas, check the CSV (comma separated values) box

  • In the Record and Field Options canvas, activate the First record has field names checkbox

  • In the Geometry Definition canvas, define the Point Coordinates as X field = Points:0, Y field = Points:1 and Z field = Points:2 (verify the correctness: X-data should be in the order of 4.2 to 4.4·106, Y-data should be in the order of 5.5·106, and Z-data should be in the order of 100.0 to 200.0)

  • Set the Geometry CRS to the Project CRS (ESRI:31493 - Germany_Zone_3).

  • Click the Add and the Close buttons on the bottom of the window. The points should now be plotted in the main QGIS window.

../img/QGIS-import-csv.png

Fig. 56 The Data Source Manager: Delimited Text window with required settings highlighted with the green marker.

Klaus Schmalzl’s Basement_post_W.exe

Another option in the future will be Klaus Schmalzl’s ``Basement_post_W.exe` <http://people.ee.ethz.ch/~basement/baseweb/users-meetings/30-01-2020/6_Schmalzl.pdf>`__, which is currently only available on demand.

Convert results to geospatial formats (SHP and TIF)

To analyze the imported results, they need to be converted to geo-spatial data format such as ESRi Shapefiles or GeoTIFF rasters. There are two options available depending on how data were imported:

  1. Conversion with the Crayfish plugin after direct import of ``results.xdmf` <#QGIS-imp-steps>`__ (recommended)

  2. Conversion of ParaView exports (not recommended)

Result interpretation

In ParaView (renders faster) or QGIS, look at all variables (flow_velocity, water_depth, and water_surface), explore their evolution over time, different coloring and answer the following questions:

  • Are the results are in a physically reasonable and meaningful range?

  • When did the simulation become stable?To save time, the simulation duration can be shortened (BASEMENT’s ``SIMULATION`` tab), down to the time step when stability was reached.

  • Are there particularities such as rapids that correspond (qualitatively) to field observations (are rapids on confinements and /or terrain drops)?

  • Zoom into the final tif raster and have a look at the triangulation artifacts. The artifacts are not realistic. How can the problem be addressed?

After post-processing, the model still needs to be calibrated and validated before it can be used for scientific or engineering purposes in river ecosystem analyses.