diff --git a/core/src/allocation_init.jl b/core/src/allocation_init.jl index eea232e5c..6ac9f2be0 100644 --- a/core/src/allocation_init.jl +++ b/core/src/allocation_init.jl @@ -393,9 +393,8 @@ function add_constraints_conservation_node!( end end - # If the node is a Basin, add basin in- and outflow - if node_id.type == NodeType.Basin && - has_external_demand(graph, node_id, :level_demand)[1] + # If the node is a Basin with a level demand, add basin in- and outflow + if has_external_demand(graph, node_id, :level_demand)[1] push!(inflows_node, F_basin_out[node_id]) push!(outflows_node, F_basin_in[node_id]) end diff --git a/core/src/allocation_optim.jl b/core/src/allocation_optim.jl index 2103f2b9f..01370c228 100644 --- a/core/src/allocation_optim.jl +++ b/core/src/allocation_optim.jl @@ -768,8 +768,7 @@ function save_demands_and_allocations!( #NOTE: instantaneous realized = get_flow(graph, inflow_id(graph, node_id), node_id, 0) - elseif node_id.type == NodeType.Basin && - has_external_demand(graph, node_id, :level_demand)[1] + elseif has_external_demand(graph, node_id, :level_demand)[1] basin_priority_idx = get_external_priority_idx(p, node_id) if priority_idx == 1 || basin_priority_idx == priority_idx diff --git a/core/src/read.jl b/core/src/read.jl index f9470f7c0..9b84fed30 100644 --- a/core/src/read.jl +++ b/core/src/read.jl @@ -988,8 +988,7 @@ function Allocation(db::DB, config::Config, graph::MetaGraph)::Allocation # Find basins with a level demand for node_id in values(graph.vertex_labels) - if node_id.type == NodeType.Basin && - has_external_demand(graph, node_id, :level_demand)[1] + if has_external_demand(graph, node_id, :level_demand)[1] mean_flows[(node_id, node_id)] = Ref(0.0) end end diff --git a/docs/core/allocation.qmd b/docs/core/allocation.qmd index 9a5947482..1399513b3 100644 --- a/docs/core/allocation.qmd +++ b/docs/core/allocation.qmd @@ -42,7 +42,11 @@ Sources are indicated by a set of edges in the subnetwork $$ E_S^\text{source} \subset E. $$ -That is, if $(i,j) \in E_S^\text{source}$, then $Q_{ij}$ (see the [formal model description](equations.qmd#formal-model-description)) is treated as a source flow in the allocation problem. These edges are either coming from a boundary/source node (e.g. a level or flow boundary) or connect the main network to a subnetwork. +That is, if $(i,j) \in E_S^\text{source}$, then the average over the allocation interval $\Delta t_{\text{alloc}}$ of the of the flow over this edge +$$ + \frac{1}{\Delta t_{\text{alloc}}}\int_{t - \Delta t_{\text{alloc}}}^tQ_{ij}(t') dt' +$$ + is treated as a source flow in the allocation problem. These edges are either coming from a boundary/source node (e.g. a level or flow boundary) or connect the main network to a subnetwork. For the definition of $Q_{ij}$ see [the formal model description](equations.qmd#formal-model-description). ### User demands @@ -71,12 +75,12 @@ for all $i \in FD_S$. Here $d^{p_{\text{df}}}$ is given by the original flow dem ### Vertical fluxes and local storage -Apart from the source flows denoted by edges, there are other sources of water in the subnetwork, associated with the basins in the subnetwork $B_S = B \cap S$. Firstly there is the sum of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each basin +Apart from the source flows denoted by edges, there are other sources of water in the subnetwork, associated with the basins in the subnetwork $B_S = B \cap S$. Firstly there is the average over the allocation interval $\Delta t_{\text{alloc}}$ of the vertical fluxes (precipitation, evaporation, infiltration and drainage) for each basin: $$ - \phi_i(t), \quad \forall i \in B_S. + \phi_i(t) = \frac{1}{\Delta t_{\text{alloc}}}\int_{t - \Delta t_{\text{alloc}}}^t \left[Q_{P,i}(t') - Q_{E,i}(t') + Q_{\text{drn},i}(t') - Q_{\text{inf},i}(t') \right] dt', \quad \forall i \in B_S. $$ -We consider fluxes into the basin to be positive and out of the basin to be negative. +We consider fluxes into the basin to be positive and out of the basin to be negative. For more information see [the natural water balance terms](equations.qmd#natural-water-balance-terms). Secondly, there is either a supply or demand from the storage in the basin. Given a minimum level $\ell_{\min, i}$ and a maximum level $\ell_{\max, i}$ which correspond to a minimum storage $s_{\min, i}$ and maximum storage $s_{\max, i}$ respectively, we get a flow supply of $$ @@ -88,7 +92,7 @@ $$ d^p_i = \max\left(0.0, \frac{s_{\min,i} - u_i(t)}{\Delta t_{\text{alloc}}} - \phi_i(t)\right), $$ -for all $i \in B_S$. Here $\Delta t_{\text{alloc}}$ is the simulated time between two consecutive allocation solves. Note that the basin demand has only a single priority, so for other priorities this demand is $0$. +for all $i \in B_S$. Note that the basin demand has only a single priority, so for other priorities this demand is $0$. ### Constraining factors diff --git a/docs/core/equations.qmd b/docs/core/equations.qmd index 1f395cd58..a2719a638 100644 --- a/docs/core/equations.qmd +++ b/docs/core/equations.qmd @@ -137,7 +137,7 @@ ax.hlines([0,1],x_min,x_max, color = "k", ls = ":", zorder=-1) ax.vlines([0,p], *y_lim, color = "k", ls = ":") ax.set_xlim(x_min,x_max) ax.set_xlabel("$x$", fontsize=fontsize) -ax.set_ylabel("$\phi(x;p)$", fontsize=fontsize) +ax.set_ylabel(r"$\phi(x;p)$", fontsize=fontsize) ax.set_ylim(y_lim) fig.tight_layout()