@@ -859,7 +859,7 @@ def flow_demand_model() -> Model:
859
859
return model
860
860
861
861
862
- def linear_resistance_demand_model ():
862
+ def linear_resistance_demand_model () -> Model :
863
863
"""Small model with a FlowDemand for a node with a max flow rate."""
864
864
model = Model (
865
865
starttime = "2020-01-01 00:00:00" ,
@@ -895,7 +895,7 @@ def linear_resistance_demand_model():
895
895
return model
896
896
897
897
898
- def fair_distribution_model ():
898
+ def fair_distribution_model () -> Model :
899
899
"""See the behavior of allocation with few restrictions within the graph."""
900
900
model = Model (
901
901
starttime = "2020-01-01 00:00:00" ,
@@ -994,7 +994,7 @@ def fair_distribution_model():
994
994
return model
995
995
996
996
997
- def allocation_training_model ():
997
+ def allocation_training_model () -> Model :
998
998
model = Model (
999
999
starttime = "2022-01-01" ,
1000
1000
endtime = "2023-01-01" ,
@@ -1173,7 +1173,7 @@ def allocation_training_model():
1173
1173
return model
1174
1174
1175
1175
1176
- def bommelerwaard_model ():
1176
+ def bommelerwaard_model () -> Model :
1177
1177
model = Model (
1178
1178
starttime = "2016-01-01" ,
1179
1179
endtime = "2016-03-31" ,
@@ -1368,7 +1368,7 @@ def get_node_data(node_id):
1368
1368
return model
1369
1369
1370
1370
1371
- def cyclic_demand_model ():
1371
+ def cyclic_demand_model () -> Model :
1372
1372
"""Create a model that has cyclic User- Flow- and LevelDemand."""
1373
1373
model = Model (
1374
1374
starttime = "2020-01-01" ,
@@ -1442,3 +1442,50 @@ def cyclic_demand_model():
1442
1442
model .link .add (ud , bsn2 )
1443
1443
1444
1444
return model
1445
+
1446
+
1447
+ def allocation_control_model ():
1448
+ """Create a model that has a pump controlled by allocation."""
1449
+ model = Model (
1450
+ starttime = "2020-01-01" ,
1451
+ endtime = "2023-01-01" ,
1452
+ crs = "EPSG:28992" ,
1453
+ allocation = Allocation (use_allocation = True ),
1454
+ )
1455
+
1456
+ lb = model .level_boundary .add (
1457
+ Node (1 , Point (0 , 0 ), subnetwork_id = 1 ), [level_boundary .Static (level = [1.0 ])]
1458
+ )
1459
+
1460
+ out = model .outlet .add (
1461
+ Node (2 , Point (1 , 0 ), subnetwork_id = 1 ),
1462
+ [outlet .Static (flow_rate = [0.0 ], control_state = "Ribasim.allocation" )],
1463
+ )
1464
+
1465
+ bsn = model .basin .add (
1466
+ Node (3 , Point (2 , 0 ), subnetwork_id = 1 ),
1467
+ [
1468
+ basin .State (level = [1.0 ]),
1469
+ basin .Profile (level = [0.0 , 1.0 ], area = [100.0 , 100.0 ]),
1470
+ ],
1471
+ )
1472
+
1473
+ user = model .user_demand .add (
1474
+ Node (4 , Point (2 , - 1 ), subnetwork_id = 1 , cyclic_time = True ),
1475
+ [
1476
+ user_demand .Time (
1477
+ time = ["2020-01-01" , "2020-06-01" , "2021-01-01" ],
1478
+ demand = [0.0 , 10.0 , 0.0 ],
1479
+ return_factor = 0.0 ,
1480
+ min_level = - 5.0 ,
1481
+ demand_priority = 1 ,
1482
+ )
1483
+ ],
1484
+ )
1485
+
1486
+ model .link .add (lb , out )
1487
+ model .link .add (out , bsn )
1488
+ model .link .add (bsn , user )
1489
+ model .link .add (user , bsn )
1490
+
1491
+ return model
0 commit comments