Skip to content

Commit

Permalink
Merge branch 'main' into main_network_allocation_optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic committed Jan 17, 2024
2 parents 41c0809 + 76f4b32 commit 990de9c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
6 changes: 2 additions & 4 deletions python/ribasim_testmodels/ribasim_testmodels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ribasim_testmodels.allocation import (
allocation_example_model,
fractional_flow_subnetwork_model,
# looped_subnetwork_model,
looped_subnetwork_model,
main_network_with_subnetworks_model,
minimal_subnetwork_model,
subnetwork_model,
Expand Down Expand Up @@ -83,10 +83,8 @@
"subnetwork_model",
"minimal_subnetwork_model",
"fractional_flow_subnetwork_model",
# Disable until this issue is resolved:
# https://github.com/Deltares/Ribasim/issues/692
# "looped_subnetwork_model",
"main_network_with_subnetworks_model",
"looped_subnetwork_model",
]

# provide a mapping from model name to its constructor, so we can iterate over all models
Expand Down
19 changes: 13 additions & 6 deletions python/ribasim_testmodels/ribasim_testmodels/allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,15 @@ def looped_subnetwork_model():
dtype=np.int64,
)
lines = node.geometry_from_connectivity(from_id, to_id)
allocation_network_id = len(from_id) * [None]
allocation_network_id[0] = 1
edge = ribasim.Edge(
df=gpd.GeoDataFrame(
data={
"from_node_id": from_id,
"to_node_id": to_id,
"edge_type": len(from_id) * ["flow"],
"allocation_network_id": allocation_network_id,
},
geometry=lines,
crs="EPSG:28992",
Expand All @@ -460,21 +463,21 @@ def looped_subnetwork_model():
}
)

state = pd.DataFrame(data={"node_id": [2, 7, 9, 15, 17, 21], "level": 1.0})
state = pd.DataFrame(data={"node_id": [2, 7, 9, 11, 15, 17, 21], "level": 1.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)

# Setup the flow boundary:
flow_boundary = ribasim.FlowBoundary(
static=pd.DataFrame(data={"node_id": [5], "flow_rate": [4.5]})
static=pd.DataFrame(data={"node_id": [5], "flow_rate": [4.5e-3]})
)

# Setup the users:
user = ribasim.User(
static=pd.DataFrame(
data={
"node_id": [1, 12, 18, 20, 24],
"demand": 1.0,
"demand": 1.0e-3,
"return_factor": 0.9,
"min_level": 0.9,
"priority": [2, 1, 3, 3, 2],
Expand All @@ -487,16 +490,16 @@ def looped_subnetwork_model():
static=pd.DataFrame(
data={
"node_id": [6, 16],
"flow_rate": 4.0,
"max_flow_rate": 4.0,
"flow_rate": 4.0e-3,
"max_flow_rate": 4.0e-3,
}
)
)

# Setup the outlets:
outlet = ribasim.Outlet(
static=pd.DataFrame(
data={"node_id": [3, 8, 10, 22], "flow_rate": 3.0, "max_flow_rate": 3.0}
data={"node_id": [3, 8, 10, 22], "flow_rate": 3.0e-3, "max_flow_rate": 3.0}
)
)

Expand All @@ -520,6 +523,9 @@ def looped_subnetwork_model():
)
)

# Setup allocation:
allocation = ribasim.Allocation(use_allocation=True, timestep=86400)

model = ribasim.Model(
network=ribasim.Network(node=node, edge=edge),
basin=basin,
Expand All @@ -529,6 +535,7 @@ def looped_subnetwork_model():
outlet=outlet,
tabulated_rating_curve=rating_curve,
terminal=terminal,
allocation=allocation,
starttime="2020-01-01 00:00:00",
endtime="2021-01-01 00:00:00",
)
Expand Down

0 comments on commit 990de9c

Please sign in to comment.