Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Nov 27, 2024
1 parent 9356ced commit cfe67e7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
13 changes: 11 additions & 2 deletions core/src/allocation_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions core/src/allocation_optim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions docs/concept/allocation.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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'
$$
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/usage.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions python/ribasim/ribasim/geometry/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit cfe67e7

Please sign in to comment.