Skip to main content

Validation

The diagram and tables below show the validation rules applied to the input to the Julia core before running the model. Some node types have more complex connectivity validation than shown here. See the Junction and UserDemand pages for their additional rules.

1 Allowed connectivity

The diagram below shows every allowed upstream and downstream node type for each node type that can have flow links. Each group has its own nodes, with upstream neighbors on the left, downstream neighbors on the right, and flow directed from left to right. This is a connectivity illustration, not a valid simulation model.

Code
%run ../../utils/plot_node_connectivity.py
import matplotlib.pyplot as plt

fig = plot_all_node_connectivity()
plt.show()
plt.close(fig)

2 Neighbor amounts

The tables below show the minimum and maximum numbers of incoming and outgoing neighbors for each node type, per link type. ∞ means there is no upper bound.

Code
from ribasim.validation import link_neighbor_amount


for link_type in ("flow", "control", "listen"):
    node_bounds = link_neighbor_amount[link_type]
    print(f"\n## {link_type.title()} links\n")
    print("| Node type | in_min | in_max | out_min | out_max |")
    print("|:----------|-------:|-------:|--------:|--------:|")
    for node_type, bounds in node_bounds.items():
        values = ["∞" if value == 2**63 - 1 else str(value) for value in bounds]
        print(f"| {node_type} | {' | '.join(values)} |")
    print()

3 Other validation rules

Besides connectivity, the Julia core checks the input values and the combinations of values. A model that violates one of these rules is not run, and the log lists the offending nodes. The rules below are grouped by topic. Each node page documents its own parameters; this overview lists the checks that go beyond a single column.

3.1 Tables and nodes

  • Every node_id occurs once in the Node table, and every node ID in another table exists in the Node table and has the node type of that table.
  • Tables have no duplicate rows, where a row is identified by the columns it is sorted by. The Variable tables of ContinuousControl and DiscreteControl are exempt, since the same variable can be listened to multiple times, for instance with a different look_ahead.
  • A node has its parameters in either the Static or the Time table, not in both and not in neither.
  • A node with multiple control_states must be controlled by DiscreteControl; otherwise use a row without control_state.
  • There is at most one Link between any two nodes, with the exception of UserDemand, where there can be Links from a Basin to the UserDemand and back.
  • A model needs at least one state, so it needs a Basin, a connector node or a UserDemand next to FlowBoundary nodes.

3.2 Configuration

  • The starttime is before the endtime.
  • reduced_implicit_solve = true is only allowed for solver algorithms that support it (see solver settings).
  • The allocation intervention_interval is positive and finite, and the allocation timesteps satisfy 0 < dtmin ≤ dtmax, with dt positive if given. A dtmin, dtmax or dt larger than the intervention_interval is reduced to it, with a warning.
  • The results compression_level is between 0 and 9, and significant_bits between 0 and 52.

3.3 Basin

  • The initial level, from the Basin / state table, is not below the lowest level of the Basin profile.
  • Each subgrid element refers to an existing Basin and has no repeated levels, since these cannot be interpolated.
  • Negative concentrations are not allowed in Basin / concentration_external.

3.4 Connector nodes

  • Flow rates of a Pump, Outlet and FlowBoundary are non-negative, also for every control state.
  • A TabulatedRatingCurve has at least two points, starts at a flow rate of 0, and its flow rate does not decrease with increasing level.
  • The first and last rating curve are equal when cyclic_time is used.
  • A Pump or Outlet that takes water from a Basin has a min_upstream_level that is not below the Basin bottom.
  • The lowest level of a TabulatedRatingCurve that takes water from a Basin is not below the Basin bottom.
  • For a ManningResistance, profile_width and profile_slope are not both zero, also not after a control state update.

3.5 Control

  • A PidControl listens to a Basin that is directly upstream or downstream of the controlled Pump or Outlet.
  • A ContinuousControl function has at least two points and one controlled_variable.
  • A condition in the DiscreteControl condition table refers to a DiscreteControl node and to a compound_variable_id in its variable table.
  • A node has at most one control node, not counting a FlowDemand (see the note above).

3.6 Allocation

  • Subnetwork IDs are positive integers, and all nodes in a subnetwork are connected when allocation is active.
  • The nodes that connect the primary network to a secondary network are Pumps or Outlets with allocation_controlled set to true. Flow is only from the primary network into a secondary network, not between secondary networks.
  • A Pump or Outlet that is allocation controlled has a finite max_flow_rate, also in every control state.
  • The demands of a UserDemand are non-negative.
  • For a UserDemand, return_factor is between 0 and 1, and return_factor and min_level are equal for all demand priorities. The min_level of a UserDemand that takes water from a Basin is empty or not below the Basin bottom.
  • For a LevelDemand, the minimum and maximum levels of subsequent demand priorities define nested windows.

3.7 Junction

See the Junction connectivity rules for the rules on Junction groups and on the Junctions that divide the flow, including the rules on their fractions.