From cfe67e70002095ab6ca5b187061a753c4486e273 Mon Sep 17 00:00:00 2001 From: Bart de Koning Date: Wed, 27 Nov 2024 17:28:02 +0100 Subject: [PATCH] Update docs --- core/src/allocation_init.jl | 13 +++++++++++-- core/src/allocation_optim.jl | 2 -- docs/concept/allocation.qmd | 4 ++-- docs/reference/usage.qmd | 2 +- python/ribasim/ribasim/geometry/edge.py | 3 +-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/core/src/allocation_init.jl b/core/src/allocation_init.jl index 8d63b8d94..d80660861 100644 --- a/core/src/allocation_init.jl +++ b/core/src/allocation_init.jl @@ -268,18 +268,19 @@ function add_constraints_user_source!( end """ -Add the source constraints to the allocation problem. +Add the boundary source constraints to the allocation problem. The actual threshold values will be set before each allocation solve. The constraint indices are (edge_source_id, edge_dst_id). Constraint: -flow over source edge <= source flow in subnetwork +flow over source edge <= source flow in physical layer """ function add_constraints_boundary_source!( problem::JuMP.Model, p::Parameters, subnetwork_id::Int32, )::Nothing + # Source edges (without the basins) edges_source = [edge for edge in source_edges_subnetwork(p, subnetwork_id) if edge[1] != edge[2]] F = problem[:F] @@ -293,6 +294,14 @@ function add_constraints_boundary_source!( return nothing end +""" +Add main network source constraints to the allocation problem. +The actual threshold values will be set before each allocation solve. +The constraint indices are (edge_source_id, edge_dst_id). + +Constraint: +flow over main network to subnetwork connection edge <= either 0 or allocated amount from the main network +""" function add_constraints_main_network_source!( problem::JuMP.Model, p::Parameters, diff --git a/core/src/allocation_optim.jl b/core/src/allocation_optim.jl index 9b2a0eac7..7ecb3b885 100644 --- a/core/src/allocation_optim.jl +++ b/core/src/allocation_optim.jl @@ -202,8 +202,6 @@ function set_initial_capacities_source!( p::Parameters, )::Nothing (; sources) = allocation_model - (; allocation) = p - (; mean_input_flows) = allocation (; subnetwork_id) = allocation_model mean_input_flows_subnetwork_ = mean_input_flows_subnetwork(p, subnetwork_id) diff --git a/docs/concept/allocation.qmd b/docs/concept/allocation.qmd index f90a83cec..91318fd84 100644 --- a/docs/concept/allocation.qmd +++ b/docs/concept/allocation.qmd @@ -42,9 +42,9 @@ The allocation problem is solved per subnetwork, which is given by a subset $S \ Sources are indicated by a set of edges in the subnetwork $$ -E_S^\text{source} \subset E. +E_S^\text{source} \subset E, $$ -That is, if $(i,j) \in E_S^\text{source}$, then the average over the last allocation interval $\Delta t_{\text{alloc}}$ of the of the flow over this edge +which are automatically inferred as all edges that point out of LevelBoundary or FlowBoundary nodes. That is, if $(i,j) \in E_S^\text{source}$, then the average over the last 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' $$ diff --git a/docs/reference/usage.qmd b/docs/reference/usage.qmd index 63eeedd99..cd209650d 100644 --- a/docs/reference/usage.qmd +++ b/docs/reference/usage.qmd @@ -199,7 +199,7 @@ to_node_type | String | - to_node_id | Int32 | - edge_type | String | must be "flow" or "control" geom | LineString or MultiLineString | (optional) -name | String | (optional, does not have to be unique) +name | String | (deprecated) subnetwork_id | Int32 | (optional, denotes source in allocation network) Similarly to the node table, you can use a geometry to visualize the connections between the diff --git a/python/ribasim/ribasim/geometry/edge.py b/python/ribasim/ribasim/geometry/edge.py index 9142c6817..f89e6f6ee 100644 --- a/python/ribasim/ribasim/geometry/edge.py +++ b/python/ribasim/ribasim/geometry/edge.py @@ -91,8 +91,7 @@ def add( name : str An optional name for the edge. subnetwork_id : int | None - An optional subnetwork id for the edge. This edge indicates a source for - the allocation algorithm, and should thus not be set for every edge in a subnetwork. + Deprecated: Sources for allocation are automatically inferred and no longer have to be specified in the `Edge` table. **kwargs : Dict """ if not can_connect(from_node.node_type, to_node.node_type):