Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No need to formulate flow for Terminal anymore #1357

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading