flowchart LR a["Route links"] --> b["junctionify<br>merge shared parts<br>of links"] b --> c["tidy_layout"]
Layout
Ribasim does not use the location of nodes and the geometry of links in the simulation. But a model that follows the real water system is much easier to review, on the map and in the model viewer, so the regional models and the coupled model get a shared layout step. None of this changes the results.
Routing the links
The input model of a level controlled water authority has a connector node where a hydro-object crosses the boundary of a peilgebied, see Level controlled. The structure itself is often some distance along the hydro-object, so at the end of the forcing stage ribasim_nl.structure_locations.move_to_structures first moves these nodes to their structure:
- A Pump moves to the gemaal that its crossing is matched with, if that is within 100 m.
- An Outlet moves to the stuw that its crossing is matched with. An Outlet without one stands for all crossings between its two areas that have no structure of their own. It moves to a stuw within 250 m that lies on a hydro-object of one of these crossings, or on a hydro-object that touches it, such as the weir behind an inlet culvert.
- A structure gets one node, the nearest one.
A moved node keeps the location of its crossing in the columns meta_crossing_x and meta_crossing_y. The koppeltabel of the measured discharges refers to nodes by that location, so ribasim_nl.observations finds them there.
Then ribasim_nl.network_snapping.snap_model aligns the layout with the hydro-objects in verwerkt/profielen/network.gpkg, which are written by the profile generation:
- Links between a Basin and a connector node follow the hydro-objects. The Top10NL water lines fill the gaps between them: they cost 3 times as much per metre, since the Top10NL has every ditch, and the shortest route would leave the hydro-objects wherever a ditch cuts a corner. Hydro-objects are only connected where there is evidence: the culverts (
duikersifonhevel) of the crossings data, gaps of at most 2 m, and gaps across BGT water surfaces. Connector nodes far from the hydro-objects are connected over the BGT water surfaces, crossing at most 100 m of land. - Basin nodes are moved to the centre of this network within their basin area: the point from which the routes to their connector nodes are cheapest in total. The point of the network nearest to where the Basin node was counts as one more node to reach, so a Basin with a single connector node stays there.
- Links stay straight if no such route is found, or if it is not less than
ribasim_nl.link_geometries.MAX_STRAIGHT_LINE_RATIOtimes longer than the straight line, the same threshold as for the gravity controlled models. A Basin node also stays where it is if fewer than half of its links can be routed from the centre.
In the gravity controlled models, snap_to_waterways routes the links that are still straight along the Top10NL waterways, at the end of their dynamic stage.
Tidying
ribasim_nl.junctionify merges the shared parts of links into Junctions, and ribasim_nl.layout.tidy_layout makes sure no nodes are on top of each other and no links overlap.
The inflows and outflows of a Basin share one Junction tree, so each waterway is drawn once, see ribasim_nl.flow_paths.merge_basin_trees. The trees are merged after the last nodes are added to a model, so only the IDs of Junctions change. Ribasim connects a group of Junctions with one Basin as a neighbour with that Basin, in the direction of the link of each other neighbour with the group, see Junction. The direction of the links within the tree, and with the Basin, does not change the simulation, only the sign of their flow, see ribasim_nl.flow_paths.towards_basin. A link that only carries inflows points towards the Basin, and one that only carries outflows away from it. A link that carries both follows the main flow: the direction in which the waterway lines it follows are digitized, where they cover most of it, such as the network of Rijkswaterstaat. Elsewhere it points to the side that can drain the most, in the afvoer control state, where ManningResistances and placeholder capacities are unlimited. ribasim_nl.flow_paths.Routes follows the links through Junctions in the same way as Ribasim.
A measured series that adds the flows of several nodes is observed on a Junction that combines exactly those nodes, see ribasim_nl.observations. Where the merged tree has no such Junction, for instance because the links of a gemaal and the inlet next to it meet at the Basin node, ribasim_nl.flow_paths.combine_nodes makes one on the link of the first node, if the nodes are within 250 m of it.
- Bergend Basins are placed 100 m from their doorgaand Basin.
- Nodes that are still within 10 m of each other are moved apart.
- Links that still overlap, such as those of neighbouring Basins along a shared waterway, are offset 5 m.
The gravity controlled models get the same layout step at the end of their dynamic stage, and ribasim_nl.validation.validate_model checks it. It also checks that the Basin areas are valid and have no slivers: parts and holes that are on average at most 1 mm wide, which draw as lines on the map. Model.clean_basin_area fixes both in the regional models and the Rijkswaterstaat model. The coupling tidies the links between models in the same way, and first rebuilds the routes of the Basins of Rijkswaterstaat along Top10NL, as the Rijkswaterstaat model does, see ribasim_nl.flow_paths.rebuild_rws_junction_trees. A link between two regional models is routed along Top10NL, not along the lines that the links of its Basin follow, so the two have no point in common. Where the routes of the Basin pass within 100 m of the node of such a link, the link follows them up to that point and goes straight from there, see ribasim_nl.flow_paths.branch_off_routes. In the IJsselmeer, Markermeer, IJmeer and Gouwzee, the network of Rijkswaterstaat only has a few straight lines, so there the routes follow the fairways of OpenStreetMap (#1010). Nodes on the shore branch off straight from the nearest point of a fairway from which the line crosses at most 100 m of land, and nodes close together share such a line.

