Skip to content

Commit

Permalink
some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Apr 17, 2024
1 parent 14b3149 commit 7d72044
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions core/src/allocation_init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function get_subnetwork_capacity(
node_dst_idx = findsorted(node_dst.node_id, edge_metadata.to_id)
capacity_node_dst = node_dst.max_flow_rate[node_dst_idx]
capacity_edge = min(capacity_edge, capacity_node_dst)
elseif edge_metadata.to_id.type == NodeType.Terminal
# No flow to terminal nodes
capacity_edge = 0.0
end

capacity[edge_metadata.from_id, edge_metadata.to_id] = capacity_edge
Expand Down Expand Up @@ -413,7 +416,7 @@ The constraint indices are Basin node IDs.
Constraint:
sum(flows out of basin) == sum(flows into basin) + flow from storage and vertical fluxes
"""
function add_constraints_conservation_basin!(
function add_constraints_conservation_node!(
problem::JuMP.Model,
p::Parameters,
subnetwork_id::Int32,
Expand All @@ -422,7 +425,8 @@ function add_constraints_conservation_basin!(
F = problem[:F]
node_ids = graph[].node_ids[subnetwork_id]

node_ids_basin = [node_id for node_id in node_ids if node_id.type == NodeType.Basin]
node_ids_conservation =
[node_id for node_id in node_ids if node_id.type == NodeType.Basin]
problem[:flow_conservation_basin] = JuMP.@constraint(
problem,
[node_id = node_ids_basin],
Expand Down
6 changes: 4 additions & 2 deletions core/src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,10 @@ end
is_flow_constraining(node::AbstractParameterNode) = hasfield(typeof(node), :max_flow_rate)

"""Whether the given node is flow direction constraining (only in direction of edges)."""
is_flow_direction_constraining(node::AbstractParameterNode) =
(nameof(typeof(node)) [:Pump, :Outlet, :TabulatedRatingCurve, :FractionalFlow])
is_flow_direction_constraining(node::AbstractParameterNode) = (
nameof(typeof(node))
[:Pump, :Outlet, :TabulatedRatingCurve, :FractionalFlow, :Terminal]
)

function has_main_network(allocation::Allocation)::Bool
if !is_active(allocation)
Expand Down

0 comments on commit 7d72044

Please sign in to comment.