Code
include("../../../utils/plot_node_connectivity.jl")
plot_node_connectivity("UserDemand")A UserDemand takes water from the Basin that supplies it.
When allocation is not used, a UserDemand node attempts to extract the full demand from the connected Basin. When allocation is used, the amount a UserDemand node is allowed to abstract is determined by the allocation algorithm. This algorithm first tries to allocate from the directly connected basin, and then from other sources whose flow can reach the UserDemand node. Note that demand_priority is used to determine the order in which the UserDemands are allocated water. This parameter is only used when allocation is active and is optional, it defaults to 1.
When the connected Basin is almost empty or reaches the minimum level at which the UserDemand can extract water (min_level), it will stop extraction. The min_level must be provided when the UserDemand abstracts from Basin(s); it is not used for abstraction from a Junction.
UserDemands need an outgoing flow link along which they can send their return flow, this can also be to the same Basin from which it extracts water. The amount of return flow is always a fraction of the inflow into the UserDemand. The difference is consumed by the UserDemand.
The diagram below shows which node types are allowed directly upstream (left) and downstream (right) of this node. This is a connectivity illustration, not a valid simulation model.
This table contains the static form of the UserDemand node.
| column | type | unit | optional | default | restriction |
|---|---|---|---|---|---|
| node_id | Int32 | - | x | - | - |
| demand | Float64 | m³ s⁻¹ | ✓ | 0.0 | non-negative |
| return_factor | Float64 | - | x | - | between [0 - 1] |
| min_level | Float64 | m | ✓ | NaN | - |
| demand_priority | Int32 | - | ✓ | 1 | positive |
This table is the transient form of the UserDemand table. The only difference is that a time column is added. With this the demand and return factor can be updated over time. In between the given times the values are block interpolated (forward fill), and outside the demand is constant given by the nearest time value. The allocation algorithm evaluates the interpolation at the start of the allocation time step. The demand_priority is not allowed to change over time. Note that a node_id can be either in this table or in the static one, but not both.
| column | type | unit | optional | default | restriction |
|---|---|---|---|---|---|
| node_id | Int32 | - | x | - | - |
| time | DateTime | - | x | - | - |
| demand | Float64 | m³ s⁻¹ | x | - | non-negative |
| return_factor | Float64 | - | x | - | between [0 - 1] |
| min_level | Float64 | m | ✓ | NaN | - |
| demand_priority | Int32 | - | ✓ | 1 | positive |
Although it may seem that way, this table does not describe demands that change demand_priority over time. Rather, this table defines a demand(time) relationship for every occurring demand_priority in the table for a certain node_id.
UserDemand receive an allocated flow rate \(F^p\) per demand priority \(p=1,2,\ldots, p_{\max}\), which is either determined by allocation optimization or simply equal to the demand at time \(t\); \(F^p = d^p(t)\). The actual (supplied) abstraction rate of a UserDemand is given by \[ Q_\text{in} = \phi_\text{storage}\phi_\text{level}\sum_{p=1}^{p_{\max}} \min\left(F^p, d^p(t)\right). \]
From left to right:
depth_threshold to the Basin bottom.min_level + level_difference_threshold to min_level.For depth_threshold, level_difference_threshold see Solver settings.
UserDemands also have a return factor \(0 \le r \le 1\), which determines the return flow (outflow) of the UserDemand:
\[ Q_\text{out} = r \cdot Q_\text{in}. \]
Note that this means that the UserDemand has a consumption rate of \((1-r)Q_\text{in}\).
Without allocation, a UserDemand tries to abstract its full demand, summed over all demand priorities.
With allocation, a UserDemand gets an allocated flow rate for each demand priority, and abstracts at most this allocated flow rate until the next intervention time, set by intervention_interval in the allocation settings. Demands with an earlier demand_priority are met first. When there is not enough water for all demands with the same priority, each demand gets the same share of what it asked for. The water can come from the Basins or Junction the UserDemand abstracts from, and from further upstream. When a UserDemand abstracts from several Basins, allocation decides how much is taken from each. The return flow can be used again by demands downstream.
The demand, allocated and realized flow rates of each UserDemand are in allocation.nc. The realized flow rate can be lower than the allocated flow rate, for instance when the Basin it abstracts from is almost empty or reaches min_level, or because less water arrives than allocation predicted.