Skip to content

Commit

Permalink
Merge branch 'install-guide' of https://github.com/Deltares/Ribasim i…
Browse files Browse the repository at this point in the history
…nto install-guide
  • Loading branch information
Jingru923 committed Sep 5, 2024
2 parents f315401 + 63e3a35 commit 7b1f404
Show file tree
Hide file tree
Showing 42 changed files with 3,405 additions and 2,027 deletions.
16 changes: 11 additions & 5 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.10.5"
manifest_format = "2.0"
project_hash = "cb280eab35cc3e7e9591c656bf26e09cfd6deb26"
project_hash = "75c4e53353e65364a0312414f29d1fc1b1339d28"

[[deps.ADTypes]]
git-tree-sha1 = "99a6f5d0ce1c7c6afdb759daa30226f71c54f6b0"
Expand Down Expand Up @@ -557,9 +557,9 @@ version = "1.12.0"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[[deps.FindFirstFunctions]]
git-tree-sha1 = "fa0ba2042021409deb144f868abafde0b06be8f0"
git-tree-sha1 = "670e1d9ceaa4a3161d32fe2d2fb2177f8d78b330"
uuid = "64ca27bc-2ba2-4a57-88aa-44e436879224"
version = "1.3.0"
version = "1.4.1"

[[deps.FiniteDiff]]
deps = ["ArrayInterface", "LinearAlgebra", "Setfield", "SparseArrays"]
Expand Down Expand Up @@ -1505,16 +1505,22 @@ version = "1.10.0"

[[deps.SparseConnectivityTracer]]
deps = ["ADTypes", "DocStringExtensions", "FillArrays", "LinearAlgebra", "Random", "Requires", "SparseArrays"]
git-tree-sha1 = "1c2c4fe587a804116d409d8964efda83dfa156ab"
git-tree-sha1 = "b1394f6661cc11728a9b8827c001eeb515656f71"
uuid = "9f842d2f-2579-4b1d-911e-f412cf18a3f5"
version = "0.6.2"
version = "0.6.3"

[deps.SparseConnectivityTracer.extensions]
SparseConnectivityTracerDataInterpolationsExt = "DataInterpolations"
SparseConnectivityTracerLogExpFunctionsExt = "LogExpFunctions"
SparseConnectivityTracerNNlibExt = "NNlib"
SparseConnectivityTracerNaNMathExt = "NaNMath"
SparseConnectivityTracerSpecialFunctionsExt = "SpecialFunctions"

[deps.SparseConnectivityTracer.weakdeps]
DataInterpolations = "82cc6244-b520-54b8-b5a6-8a565e85f1d0"
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"

[[deps.SparseDiffTools]]
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
FindFirstFunctions = "64ca27bc-2ba2-4a57-88aa-44e436879224"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
Expand Down
2 changes: 1 addition & 1 deletion core/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ PreallocationTools = "0.4"
SQLite = "1.5.1"
SciMLBase = "2.36"
SparseArrays = "<0.0.1, 1"
SparseConnectivityTracer = "0.6.1"
SparseConnectivityTracer = "0.6.3"
StructArrays = "0.6.13"
TOML = "<0.0.1, 1"
Tables = "1"
Expand Down
39 changes: 27 additions & 12 deletions core/src/parameter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,20 @@ of Vectors or Arrow Primitives, and is added to avoid type instabilities.
node_id: node ID of the TabulatedRatingCurve node
inflow_edge: incoming flow edge metadata
The ID of the destination node is always the ID of the TabulatedRatingCurve node
outflow_edges: outgoing flow edges metadata
outflow_edge: outgoing flow edge metadata
The ID of the source node is always the ID of the TabulatedRatingCurve node
active: whether this node is active and thus contributes flows
max_downstream_level: The downstream level above which the TabulatedRatingCurve flow goes to zero
table: The current Q(h) relationships
time: The time table used for updating the tables
control_mapping: dictionary from (node_id, control_state) to Q(h) and/or active state
"""
@kwdef struct TabulatedRatingCurve{C} <: AbstractParameterNode
node_id::Vector{NodeID}
inflow_edge::Vector{EdgeMetadata}
outflow_edges::Vector{Vector{EdgeMetadata}}
outflow_edge::Vector{EdgeMetadata}
active::Vector{Bool}
max_downstream_level::Vector{Float64} = fill(Inf, length(node_id))
table::Vector{ScalarInterpolation}
time::StructVector{TabulatedRatingCurveTimeV1, C, Int}
control_mapping::Dict{Tuple{NodeID, String}, ControlStateUpdate}
Expand Down Expand Up @@ -448,47 +450,55 @@ end
node_id: node ID of the Pump node
inflow_edge: incoming flow edge metadata
The ID of the destination node is always the ID of the Pump node
outflow_edges: outgoing flow edges metadata
outflow_edge: outgoing flow edge metadata
The ID of the source node is always the ID of the Pump node
active: whether this node is active and thus contributes flow
flow_rate: target flow rate
min_flow_rate: The minimal flow rate of the pump
max_flow_rate: The maximum flow rate of the pump
min_upstream_level: The upstream level below which the Pump flow goes to zero
max_downstream_level: The downstream level above which the Pump flow goes to zero
control_mapping: dictionary from (node_id, control_state) to target flow rate
continuous_control_type: one of None, ContinuousControl, PidControl
"""
@kwdef struct Pump <: AbstractParameterNode
node_id::Vector{NodeID}
inflow_edge::Vector{EdgeMetadata} = []
outflow_edges::Vector{Vector{EdgeMetadata}} = []
outflow_edge::Vector{EdgeMetadata} = []
active::Vector{Bool} = fill(true, length(node_id))
flow_rate::Cache = cache(length(node_id))
min_flow_rate::Vector{Float64} = zeros(length(node_id))
max_flow_rate::Vector{Float64} = fill(Inf, length(node_id))
min_upstream_level::Vector{Float64} = fill(-Inf, length(node_id))
max_downstream_level::Vector{Float64} = fill(Inf, length(node_id))
control_mapping::Dict{Tuple{NodeID, String}, ControlStateUpdate}
continuous_control_type::Vector{ContinuousControlType.T} =
fill(ContinuousControlType.None, length(node_id))

function Pump(
node_id,
inflow_edge,
outflow_edges,
outflow_edge,
active,
flow_rate,
min_flow_rate,
max_flow_rate,
min_upstream_level,
max_downstream_level,
control_mapping,
continuous_control_type,
)
if valid_flow_rates(node_id, flow_rate[Float64[]], control_mapping)
return new(
node_id,
inflow_edge,
outflow_edges,
outflow_edge,
active,
flow_rate,
min_flow_rate,
max_flow_rate,
min_upstream_level,
max_downstream_level,
control_mapping,
continuous_control_type,
)
Expand All @@ -502,50 +512,55 @@ end
node_id: node ID of the Outlet node
inflow_edge: incoming flow edge metadata.
The ID of the destination node is always the ID of the Outlet node
outflow_edges: outgoing flow edges metadata.
outflow_edge: outgoing flow edge metadata.
The ID of the source node is always the ID of the Outlet node
active: whether this node is active and thus contributes flow
flow_rate: target flow rate
min_flow_rate: The minimal flow rate of the outlet
max_flow_rate: The maximum flow rate of the outlet
min_upstream_level: The upstream level below which the Outlet flow goes to zero
max_downstream_level: The downstream level above which the Outlet flow goes to zero
control_mapping: dictionary from (node_id, control_state) to target flow rate
continuous_control_type: one of None, ContinuousControl, PidControl
"""
@kwdef struct Outlet <: AbstractParameterNode
node_id::Vector{NodeID}
inflow_edge::Vector{EdgeMetadata} = []
outflow_edges::Vector{Vector{EdgeMetadata}} = []
outflow_edge::Vector{EdgeMetadata} = []
active::Vector{Bool} = fill(true, length(node_id))
flow_rate::Cache = cache(length(node_id))
min_flow_rate::Vector{Float64} = zeros(length(node_id))
max_flow_rate::Vector{Float64} = fill(Inf, length(node_id))
min_upstream_level::Vector{Float64} = fill(-Inf, length(node_id))
max_downstream_level::Vector{Float64} = fill(Inf, length(node_id))
control_mapping::Dict{Tuple{NodeID, String}, ControlStateUpdate} = Dict()
continuous_control_type::Vector{ContinuousControlType.T} =
fill(ContinuousControlType.None, length(node_id))

function Outlet(
node_id,
inflow_id,
outflow_ids,
inflow_edge,
outflow_edge,
active,
flow_rate,
min_flow_rate,
max_flow_rate,
min_upstream_level,
max_downstream_level,
control_mapping,
continuous_control_type,
)
if valid_flow_rates(node_id, flow_rate[Float64[]], control_mapping)
return new(
node_id,
inflow_id,
outflow_ids,
inflow_edge,
outflow_edge,
active,
flow_rate,
min_flow_rate,
max_flow_rate,
min_upstream_level,
max_downstream_level,
control_mapping,
continuous_control_type,
)
Expand Down
20 changes: 15 additions & 5 deletions core/src/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function TabulatedRatingCurve(
return TabulatedRatingCurve(;
node_id = node_ids,
inflow_edge = inflow_edge.(Ref(graph), node_ids),
outflow_edges = outflow_edges.(Ref(graph), node_ids),
outflow_edge = outflow_edge.(Ref(graph), node_ids),
active,
table = interpolations,
time,
Expand Down Expand Up @@ -464,7 +464,13 @@ end

function Pump(db::DB, config::Config, graph::MetaGraph)::Pump
static = load_structvector(db, config, PumpStaticV1)
defaults = (; min_flow_rate = 0.0, max_flow_rate = Inf, active = true)
defaults = (;
min_flow_rate = 0.0,
max_flow_rate = Inf,
min_upstream_level = -Inf,
max_downstream_level = Inf,
active = true,
)
parsed_parameters, valid = parse_static_and_time(db, config, Pump; static, defaults)

if !valid
Expand All @@ -480,11 +486,13 @@ function Pump(db::DB, config::Config, graph::MetaGraph)::Pump
return Pump(;
node_id,
inflow_edge = inflow_edge.(Ref(graph), node_id),
outflow_edges = outflow_edges.(Ref(graph), node_id),
outflow_edge = outflow_edge.(Ref(graph), node_id),
parsed_parameters.active,
flow_rate,
parsed_parameters.min_flow_rate,
parsed_parameters.max_flow_rate,
parsed_parameters.min_upstream_level,
parsed_parameters.max_downstream_level,
parsed_parameters.control_mapping,
)
end
Expand All @@ -495,6 +503,7 @@ function Outlet(db::DB, config::Config, graph::MetaGraph)::Outlet
min_flow_rate = 0.0,
max_flow_rate = Inf,
min_upstream_level = -Inf,
max_downstream_level = Inf,
active = true,
)
parsed_parameters, valid = parse_static_and_time(db, config, Outlet; static, defaults)
Expand All @@ -517,13 +526,14 @@ function Outlet(db::DB, config::Config, graph::MetaGraph)::Outlet
return Outlet(;
node_id,
inflow_edge = inflow_edge.(Ref(graph), node_id),
outflow_edges = outflow_edges.(Ref(graph), node_id),
outflow_edge = outflow_edge.(Ref(graph), node_id),
parsed_parameters.active,
flow_rate,
parsed_parameters.min_flow_rate,
parsed_parameters.max_flow_rate,
parsed_parameters.min_upstream_level,
parsed_parameters.control_mapping,
parsed_parameters.min_upstream_level,
parsed_parameters.max_downstream_level,
)
end

Expand Down
3 changes: 3 additions & 0 deletions core/src/schema.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ end
flow_rate::Float64
min_flow_rate::Union{Missing, Float64}
max_flow_rate::Union{Missing, Float64}
min_upstream_level::Union{Missing, Float64}
max_downstream_level::Union{Missing, Float64}
control_state::Union{Missing, String}
end

Expand All @@ -87,6 +89,7 @@ end
min_flow_rate::Union{Missing, Float64}
max_flow_rate::Union{Missing, Float64}
min_upstream_level::Union{Missing, Float64}
max_downstream_level::Union{Missing, Float64}
control_state::Union{Missing, String}
end

Expand Down
Loading

0 comments on commit 7b1f404

Please sign in to comment.