SaintGeo¶
SaintGeo is a 1D hydraulic model of a river: it solves the equations of de Saint-Venant along the sections of RiverSectionsExtractor, and gives the water level and the discharge of each section, in time, for a discharge entering at the head of the river.
The simulation starts from the steady flow of the first discharge, found in each section with the formula of Gauckler-Strickler. Then each value of the head discharge is a step of the model: a semi-implicit finite difference scheme gives the new water levels of all the sections, and from them the discharges between the sections. Downstream, the flow passes through the critical depth or, when a downstream level is given, takes that level. Lateral inflows and outflows, and the inflows of confluences, can be added at given sections.
The length of the steps is set by the model, for the stability of the scheme, from the distance between the sections and the velocity of the water: the steps are not of a fixed time, and the timestamps of the discharge file only give the order of the values.
Warning
The model is meant for the subcritical flow of lowland rivers. In steep streams, where the flow is supercritical, the scheme diverges, or gives velocities without physical meaning: the mountain stream of the sample area is far too steep for it. The model stops with an error when the levels are no longer numbers, but check that the results make sense. The module is experimental.
Details¶
The river is described by the three vectors of RiverSectionsExtractor: its sections, their points with the elevations, and the points of the river between them. The sections are ordered by their distance along the river, from upstream.
The unsteady flow is solved with a semi-implicit finite difference scheme: at each step a tridiagonal system gives the new water levels of all the sections, and from them the discharges between the sections. Upstream, the discharge is given; downstream, the flow passes through the critical depth, or, when a downstream level is given, the level is imposed. The simulation starts from the steady flow of the first discharge, found with the formula of Gauckler-Strickler in each section.
The wetted area, the wetted perimeter and the width of each section are computed for its water level from the points of the section. The roughness of the section is the one of its Gauckler-Strickler field, set to 30 by RiverSectionsExtractor; pKs is used for the sections that have none. Where the water rises over the ends of the sections, the overflowing discharge is computed as over a side weir.
Each value of the head discharge is one step of the model: the length of the steps is set by the model, for the stability of the scheme, from the length of the reaches and the velocity of the water, so the steps are not of a fixed time and the timestamps of the discharge file only give the order of the values. The lateral inflows and outflows, and the inflows from the confluences, are given for the ids of the sections, with a value for each step.
The model is meant for the subcritical flow of lowland rivers, with sections that cross the valley without crossing each other. In steep streams, where the flow is supercritical, the scheme diverges, or gives velocities without physical meaning: the model stops with an error when the levels are no longer numbers.
Parameters¶
A 1D hydraulic model of a river, based on the equations of de Saint-Venant: water levels and discharges along its sections, in time, for a discharge entering at its head.
Toolbox folder: Hydro-Geomorphology
Status: Experimental
Keywords: 1D, Hydraulic
Authors: Silvia Franceschi, Andrea Antonello, Riccardo Rigon, Angelo Zacchia
Class: org.hortonmachine.modules.SaintGeo
Inputs
Parameter |
Type |
Unit |
Default |
Description |
|---|---|---|---|---|
|
vector file |
The points of the river between the sections, from RiverSectionsExtractor. |
||
|
vector file |
The section lines, from RiverSectionsExtractor. |
||
|
vector file |
The points of the sections, with their elevation, from RiverSectionsExtractor. |
||
|
CSV file |
The discharge entering at the head of the river, with a value for each step of the model. |
||
|
CSV file |
The water level at the last section, with a value for each step. If not given, the flow passes through the critical depth. |
||
|
CSV file |
The lateral inflows (positive) or outflows (negative), for the ids of the sections, with a value for each step. |
||
|
CSV file |
The inflows from confluences, for the ids of the sections, with a value for each step. |
||
|
Double |
The Gauckler-Strickler coefficient of the sections that have none. |
||
|
long |
millisec |
|
Not used: the model sets the length of its steps, for the stability of the scheme. |
|
String |
|
Name of the output results table in the geopackage (data are overwritten at each run). |
Outputs
Parameter |
Type |
Unit |
Description |
|---|---|---|---|
|
output file |
The output GeoPackage, with a row for each step and section: its timestep, sectionid, progressivedistance, waterlevel, discharge, celerity (the mean velocity), froudenumber, wettedarea, minsectionelevation, leftbankelevation and rightbankelevation. |
Example¶
The example builds a lowland river on the grid of the sample area, and follows all the steps from the elevation model to the flood: the network, the main channel, its sections and the simulation.
The river is made with Mapcalc: a meandering channel 3 m deep and 30 m wide, sloping by 0.2%, in a floodplain 500 m wide. Its network is extracted as for any elevation model, with Pitfiller, FlowDirections, DrainDir, Markoutlets, ExtractNetwork and NetworkAttributesBuilder:
import org.hortonmachine.modules.DrainDir
import org.hortonmachine.modules.ExtractNetwork
import org.hortonmachine.modules.FlowDirections
import org.hortonmachine.modules.Mapcalc
import org.hortonmachine.modules.Markoutlets
import org.hortonmachine.modules.NetworkAttributesBuilder
import org.hortonmachine.modules.Pitfiller
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// a lowland river, as SaintGeo is meant for: a meandering channel 3 m deep and 30 m wide,
// sloping by 0.2% towards the south, in a floodplain 500 m wide that falls towards it by 0.1%,
// between valley sides of 5%
var mapcalc = new Mapcalc()
// the elevation model only gives the grid: its values are not used
mapcalc.inRaster1 = folder + "dtm_flanginec.tif"
mapcalc.pFunction = """
images { river = write; }
cx = (xmin() + xmax()) / 2 + 150 * sin(2 * M_PI * (y() - ymin()) / 3000);
d = abs(x() - cx);
shape = d < 15 ? -3 : (d < 25 ? -3 + 0.3 * (d - 15) : (d < 250 ? 0.001 * (d - 25) : 0.225 + 0.05 * (d - 250)));
river = 200 + 0.002 * (y() - ymin()) + shape;
"""
mapcalc.outRaster = folder + "river.tif"
mapcalc.process()
// the network of the river, as for any elevation model
var pitfiller = new Pitfiller()
pitfiller.inElev = folder + "river.tif"
pitfiller.outPit = folder + "river_pit.tif"
pitfiller.process()
var flowDirections = new FlowDirections()
flowDirections.inPit = folder + "river_pit.tif"
flowDirections.outFlow = folder + "river_flow.tif"
flowDirections.process()
var drainDir = new DrainDir()
drainDir.inPit = folder + "river_pit.tif"
drainDir.inFlow = folder + "river_flow.tif"
drainDir.outFlow = folder + "river_drain.tif"
drainDir.outTca = folder + "river_tca.tif"
drainDir.process()
var markoutlets = new Markoutlets()
markoutlets.inFlow = folder + "river_drain.tif"
markoutlets.outFlow = folder + "river_drain_marked.tif"
markoutlets.process()
var extractNetwork = new ExtractNetwork()
extractNetwork.inTca = folder + "river_tca.tif"
extractNetwork.inFlow = folder + "river_drain_marked.tif"
extractNetwork.pThres = 5000
extractNetwork.outNet = folder + "river_net.tif"
extractNetwork.process()
var attributes = new NetworkAttributesBuilder()
attributes.inNet = folder + "river_net.tif"
attributes.inFlow = folder + "river_drain_marked.tif"
attributes.inTca = folder + "river_tca.tif"
attributes.doHack = true
attributes.outNet = folder + "river_net.shp"
attributes.process()
The synthetic river: the meandering channel in its floodplain, between the sides of the valley.¶
Its network, along the channel: with a high threshold, only the main channel.¶
The main channel, the reaches of Hack order 1, is smoothed and simplified, so that its sections cross the valley, and the sections are extracted with RiverSectionsExtractor, and written also for HEC-RAS with HecrasInputBuilder:
import org.hortonmachine.modules.HecrasInputBuilder
import org.hortonmachine.modules.LineSmootherMcMaster
import org.hortonmachine.modules.RiverSectionsExtractor
import org.hortonmachine.modules.VectorFilter
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// the main channel: the reaches of Hack order 1
var filter = new VectorFilter()
filter.inVector = folder + "river_net.shp"
filter.pCql = "hack = 1"
filter.outVector = folder + "river_main.shp"
filter.process()
// the network follows the cells in steps of 45 degrees: smooth it, so that the
// sections, perpendicular to the line, cross the valley
var smoother = new LineSmootherMcMaster()
smoother.inVector = folder + "river_main.shp"
smoother.pLookahead = 41
// then simplified, so that also its ends follow the direction of the river and not the cells
smoother.pSimplify = 20
smoother.outVector = folder + "river_main_smooth.shp"
smoother.process()
// a section every 100 m, reaching 350 m on each side: over the whole floodplain,
// up the sides of the valley, but not so far that they cross each other
var extractor = new RiverSectionsExtractor()
extractor.inElev = folder + "river.tif"
extractor.inRiver = folder + "river_main_smooth.shp"
extractor.pSectionsIntervalDistance = 100
extractor.pSectionsWidth = 350
extractor.outSections = folder + "river_sections.shp"
extractor.outSectionPoints = folder + "river_section_points.shp"
extractor.outRiverPoints = folder + "river_points.shp"
extractor.process()
// the same sections, also for HEC-RAS
var hecras = new HecrasInputBuilder()
hecras.inRiverPoints = folder + "river_points.shp"
hecras.inSections = folder + "river_sections.shp"
hecras.inSectionPoints = folder + "river_section_points.shp"
hecras.pTitle = "river"
hecras.outHecras = folder + "river.sdf"
hecras.process()
The network has also a short reach along the southern border, where the cells of the last row drain along it: RiverSectionsExtractor warns that the lines do not form a single line, and uses the longest one.
The sections, in red, every 100 m along the smoothed channel, in blue, across the floodplain and up the sides of the valley.¶
The simulation sends a flood wave of 400 m³/s down the river, over a base flow of 50 m³/s. The discharge is written as an OMS time series, the format of the input files of the module, and two tables of the results are extracted from the output GeoPackage for the charts:
import org.hortonmachine.dbs.compat.EDb
import org.hortonmachine.gears.utils.files.FileUtilities
import org.hortonmachine.modules.SaintGeo
// the folder with the elevation model: change it to yours
var folder = "/data/flanginec/"
// a flood wave entering at the head of the river: from 50 to 400 m3/s and back in 2 hours,
// then 2 hours at 50 m3/s, one value for each step of the model
var csv = new StringBuilder()
csv.append("@T,discharge\n")
csv.append("@H,timestamp,discharge\n")
csv.append("Type,Date,Double\n")
csv.append("Format,yyyy-MM-dd HH:mm,\n")
var steps = 2880
for (int i = 0; i < steps; i++) {
var q = i < 1440 ? 50 + 350 * Math.pow(Math.sin(Math.PI * i / 1440), 2) : 50.0
// the timestamps only give the order of the values: the model sets its own time step
var time = String.format("2026-01-%02d %02d:%02d", 1 + (int) (i / 1440), (int) (i / 60) % 24, i % 60)
csv.append(String.format(Locale.ROOT, ",%s,%.3f%n", time, q))
}
FileUtilities.writeFile(csv.toString(), new File(folder + "river_discharge.csv"))
var saint = new SaintGeo()
saint.inRiverPoints = folder + "river_points.shp"
saint.inSections = folder + "river_sections.shp"
saint.inSectionPoints = folder + "river_section_points.shp"
saint.inDischarge = folder + "river_discharge.csv"
saint.pKs = 30.0
saint.outGpkg = folder + "saintgeo.gpkg"
saint.outTableName = "flood"
saint.process()
// two tables of the results, for the charts
var db = EDb.GEOPACKAGE.getSpatialDb()
db.open(folder + "saintgeo.gpkg")
// along the river: the bottom, the level of the steady flow at the start and the highest level
db.runRawSqlToCsv("""
select progressivedistance as distance, min(minsectionelevation) as bottom,
min(case when timestep = 0 then waterlevel end) as start_level, max(waterlevel) as max_level
from flood group by sectionid order by distance
""", new File(folder + "flood_levels.csv"), true, ",")
// in time: the discharge at the head and at the end of the river
db.runRawSqlToCsv("""
select timestep as step,
max(case when progressivedistance = (select min(progressivedistance) from flood) then discharge end) as head,
max(case when progressivedistance = (select max(progressivedistance) from flood) then discharge end) as outlet
from flood group by timestep order by timestep
""", new File(folder + "flood_discharge.csv"), true, ",")
db.close()
Along the river: the bottom of the sections, the level of the steady flow of 50 m³/s at the start, and the highest level of the flood, which rises over the edge of the channel, 3 m over its bottom, into the floodplain. At the last section the level drops to the critical depth.¶
The discharge at the head and at the end of the river, at each step of the model: the wave arrives later and lower, spread by the storage of the floodplain. The steps are not of a fixed time, so the shape of the waves is distorted where the velocities change.¶