Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Sep 27, 2023
1 parent 51eda03 commit a6062a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions core/src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ return_factor: the factor in [0,1] of how much of the abstracted water is given
min_level: The level of the source basin below which the user does not abstract
priority: integer > 0, the lower the number the higher the priority of the users demand
"""
struct User
struct User <: AbstractParameterNode
node_id::Vector{Int}
active::BitVector
demand::Vector{ScalarInterpolation}
Expand Down Expand Up @@ -527,7 +527,7 @@ Currently at less than 0.1 m.
function formulate!(du::AbstractVector, basin::Basin, storage::AbstractVector)::Nothing
(; current_level, current_area) = basin
current_level = get_tmp(current_level, storage)
current_area = get_tmp(current_level, storage)
current_area = get_tmp(current_area, storage)

for i in eachindex(storage)
# add all precipitation that falls within the profile
Expand Down Expand Up @@ -578,7 +578,9 @@ function continuous_control!(
max_flow_rate_outlet = outlet.max_flow_rate
(; graph_control, graph_flow, flow) = connectivity
(; node_id, active, target, pid_params, listen_node_id, error) = pid_control
(; current_area) = basin

current_area = get_tmp(current_area, u)
storage = u.storage
flow = get_tmp(flow, u)
outlet_flow_rate = get_tmp(outlet.flow_rate, u)
Expand Down Expand Up @@ -1134,8 +1136,12 @@ function water_balance!(

# First formulate intermediate flows
for nodefield in nodefields(p)
if nodefield == :fractional_flow
continue
end
formulate_flow!(getfield(p, nodefield), p, storage, t)
end
formulate_flow!(p.fractional_flow, p, storage, t)

# Now formulate du
formulate!(du, connectivity, flow, basin)
Expand Down
2 changes: 1 addition & 1 deletion core/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ Upstream basins always depend on themselves.
function update_jac_prototype!(
jac_prototype::SparseMatrixCSC{Float64, Int64},
p::Parameters,
node::Union{Pump, Outlet, TabulatedRatingCurve},
node::Union{Pump, Outlet, TabulatedRatingCurve, User},
)::Nothing
(; basin, fractional_flow, connectivity) = p
(; graph_flow) = connectivity
Expand Down

0 comments on commit a6062a0

Please sign in to comment.