Skip to content

Commit

Permalink
No need to formulate flow for Terminal anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
visr committed Apr 4, 2024
1 parent 5d2bbef commit 9db22d3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 31 deletions.
9 changes: 0 additions & 9 deletions core/src/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,6 @@ function set_flow!(graph::MetaGraph, id_src::NodeID, id_dst::NodeID, q::Number):
return nothing
end

"""
Add the given flow q to the existing flow over the edge between the given nodes.
"""
function add_flow!(graph::MetaGraph, id_src::NodeID, id_dst::NodeID, q::Number)::Nothing
(; flow_dict, flow) = graph[]
get_tmp(flow, q)[flow_dict[(id_src, id_dst)]] += q
return nothing
end

"""
Get the flow over the given edge (val is needed for get_tmp from ForwardDiff.jl).
"""
Expand Down
23 changes: 1 addition & 22 deletions core/src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -502,24 +502,6 @@ function formulate_flow!(
return nothing
end

function formulate_flow!(
terminal::Terminal,
p::Parameters,
storage::AbstractVector,
t::Number,
)::Nothing
(; graph) = p
(; node_id) = terminal

for id in node_id
for upstream_id in inflow_ids(graph, id)
q = get_flow(graph, upstream_id, id, storage)
add_flow!(graph, id, -q)
end
end
return nothing
end

function formulate_flow!(
flow_boundary::FlowBoundary,
p::Parameters,
Expand Down Expand Up @@ -637,12 +619,10 @@ function formulate_flows!(p::Parameters, storage::AbstractVector, t::Number)::No
manning_resistance,
tabulated_rating_curve,
flow_boundary,
level_boundary,
pump,
outlet,
user_demand,
fractional_flow,
terminal,
) = p

formulate_flow!(linear_resistance, p, storage, t)
Expand All @@ -653,7 +633,6 @@ function formulate_flows!(p::Parameters, storage::AbstractVector, t::Number)::No
formulate_flow!(outlet, p, storage, t)
formulate_flow!(user_demand, p, storage, t)

# do these last since they rely on formulated input flows
# do this last since they rely on formulated input flows
formulate_flow!(fractional_flow, p, storage, t)
formulate_flow!(terminal, p, storage, t)
end

0 comments on commit 9db22d3

Please sign in to comment.