Source code for epyt_flow.data.networks

   1"""
   2Module provides functions for loading different water distribution networks.
   3"""
   4import os
   5
   6from ..simulation import ScenarioConfig, ScenarioSimulator, SensorConfig
   7from ..utils import get_temp_folder, download_if_necessary
   8
   9
[docs] 10def create_empty_sensor_config(f_inp: str) -> SensorConfig: 11 """ 12 Creates an empty sensor configuration for a given .inp file. 13 14 Parameters 15 ---------- 16 f_inp : `str` 17 Path to the .inp file. 18 19 Returns 20 ------- 21 :class:`~epyt_flow.simulation.sensor_config.SensorConfig` 22 Sensor configuration. 23 """ 24 with ScenarioSimulator(f_inp_in=f_inp) as sim: 25 return sim.sensor_config
26 27
[docs] 28def get_default_hydraulic_options(flow_units_id: int = None, pressure_units: int = None) -> dict: 29 """ 30 Gets standard hydraulic default options. 31 32 Parameters 33 ---------- 34 flow_units_id : `int`, optional 35 Specifies the flow units to be used in this scenario. 36 If None, the units from the .inp file will be used. 37 38 Must be one of the following EPANET toolkit constants: 39 40 - EN_CFS = 0 (cubic foot/sec) 41 - EN_GPM = 1 (gal/min) 42 - EN_MGD = 2 (Million gal/day) 43 - EN_IMGD = 3 (Imperial MGD) 44 - EN_AFD = 4 (ac-foot/day) 45 - EN_LPS = 5 (liter/sec) 46 - EN_LPM = 6 (liter/min) 47 - EN_MLD = 7 (Megaliter/day) 48 - EN_CMH = 8 (cubic meter/hr) 49 - EN_CMD = 9 (cubic meter/day) 50 - EN_CMS = 10 (cubic meter/sec) 51 52 The default is None. 53 pressure_units_id : `int`, optional 54 Specifies the pressure units to be used in this scenarios. 55 If None, the units from the .inp file will be used. 56 57 Must be one of the following EPANET constants: 58 59 - EN_PSI = 0 (Pounds per square inch) 60 - EN_KPA = 1 (Kilopascals) 61 - EN_METERS = 2 (Meters) 62 - EN_BAR = 3 (Bar) 63 - EN_FEET = 4 (Feet) 64 65 Returns 66 ------- 67 `dict` 68 Dictionary with default hydraulics options that can be passed to 69 :func:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator.set_general_parameters`. 70 """ 71 params = {} 72 if flow_units_id is not None: 73 params |= {"flow_units_id": flow_units_id, 74 "pressure_units_id": pressure_units} 75 76 return params
77 78
[docs] 79def load_inp(f_in: str, include_empty_sensor_config: bool = True, 80 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 81 """ 82 Loads an .inp file and wraps it into a scenario configuration. 83 84 Parameters 85 ---------- 86 f_in : `str` 87 Path to the .inp file. 88 include_empty_sensor_config : `bool`, optional 89 If True, an empty sensor configuration will be included in the returned 90 scenario configuration. 91 92 The default is True. 93 flow_units_id : `int`, optional 94 Specifies the flow units to be used in this scenario. 95 If None, the units from the .inp file will be used. 96 97 Must be one of the following EPANET toolkit constants: 98 99 - EN_CFS = 0 (cubic foot/sec) 100 - EN_GPM = 1 (gal/min) 101 - EN_MGD = 2 (Million gal/day) 102 - EN_IMGD = 3 (Imperial MGD) 103 - EN_AFD = 4 (ac-foot/day) 104 - EN_LPS = 5 (liter/sec) 105 - EN_LPM = 6 (liter/min) 106 - EN_MLD = 7 (Megaliter/day) 107 - EN_CMH = 8 (cubic meter/hr) 108 - EN_CMD = 9 (cubic meter/day) 109 - EN_CMS = 10 (cubic meter/sec) 110 111 The default is None. 112 pressure_units_id : `int`, optional 113 Specifies the pressure units to be used in this scenarios. 114 If None, the units from the .inp file will be used. 115 116 Must be one of the following EPANET constants: 117 118 - EN_PSI = 0 (Pounds per square inch) 119 - EN_KPA = 1 (Kilopascals) 120 - EN_METERS = 2 (Meters) 121 - EN_BAR = 3 (Bar) 122 - EN_FEET = 4 (Feet) 123 124 The default is None. 125 126 Returns 127 ------- 128 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 129 Scenario configuration for the .inp file. 130 """ 131 if not os.path.isfile(f_in): 132 raise ValueError(f"Can not find {f_in}") 133 134 if include_empty_sensor_config is True: 135 return ScenarioConfig(f_inp_in=f_in, sensor_config=create_empty_sensor_config(f_inp=f_in), 136 general_params=get_default_hydraulic_options(flow_units_id, 137 pressure_units_id)) 138 else: 139 return ScenarioConfig(f_inp_in=f_in, 140 general_params=get_default_hydraulic_options(flow_units_id, 141 pressure_units_id))
142 143
[docs] 144def load_net1(download_dir: str = get_temp_folder(), verbose: bool = True, 145 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 146 """ 147 Loads (and downloads if necessary) the Net1 network. 148 149 Parameters 150 ---------- 151 download_dir : `str`, optional 152 Path to the directory where the .inp file is stored. 153 154 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 155 verbose : `bool`, optional 156 If True, a progress bar is shown while downloading the file. 157 158 The default is True. 159 flow_units_id : `int`, optional 160 Specifies the flow units to be used in this scenario. 161 If None, the units from the .inp file will be used. 162 163 Must be one of the following EPANET toolkit constants: 164 165 - EN_CFS = 0 (cubic foot/sec) 166 - EN_GPM = 1 (gal/min) 167 - EN_MGD = 2 (Million gal/day) 168 - EN_IMGD = 3 (Imperial MGD) 169 - EN_AFD = 4 (ac-foot/day) 170 - EN_LPS = 5 (liter/sec) 171 - EN_LPM = 6 (liter/min) 172 - EN_MLD = 7 (Megaliter/day) 173 - EN_CMH = 8 (cubic meter/hr) 174 - EN_CMD = 9 (cubic meter/day) 175 - EN_CMS = 10 (cubic meter/sec) 176 177 The default is None. 178 pressure_units_id : `int`, optional 179 Specifies the pressure units to be used in this scenarios. 180 If None, the units from the .inp file will be used. 181 182 Must be one of the following EPANET constants: 183 184 - EN_PSI = 0 (Pounds per square inch) 185 - EN_KPA = 1 (Kilopascals) 186 - EN_METERS = 2 (Meters) 187 - EN_BAR = 3 (Bar) 188 - EN_FEET = 4 (Feet) 189 190 The default is None. 191 192 Returns 193 ------- 194 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 195 Net1 network loaded into a scenario configuration that can be passed on to 196 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 197 """ 198 f_in = os.path.join(download_dir, "Net1.inp") 199 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net1.inp" 200 backup_urls = ["https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/refs/heads/dev/epyt/networks/asce-tf-wdst/Net1.inp"] 201 202 download_if_necessary(f_in, url, verbose, backup_urls) 203 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
204 205
[docs] 206def load_net2(download_dir: str = get_temp_folder(), verbose: bool = True, 207 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 208 """ 209 Loads (and downloads if necessary) the Net2 network. 210 211 Parameters 212 ---------- 213 download_dir : `str`, optional 214 Path to the directory where the .inp file is stored. 215 216 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 217 verbose : `bool`, optional 218 If True, a progress bar is shown while downloading the file. 219 220 The default is True. 221 flow_units_id : `int`, optional 222 Specifies the flow units to be used in this scenario. 223 If None, the units from the .inp file will be used. 224 225 Must be one of the following EPANET toolkit constants: 226 227 - EN_CFS = 0 (cubic foot/sec) 228 - EN_GPM = 1 (gal/min) 229 - EN_MGD = 2 (Million gal/day) 230 - EN_IMGD = 3 (Imperial MGD) 231 - EN_AFD = 4 (ac-foot/day) 232 - EN_LPS = 5 (liter/sec) 233 - EN_LPM = 6 (liter/min) 234 - EN_MLD = 7 (Megaliter/day) 235 - EN_CMH = 8 (cubic meter/hr) 236 - EN_CMD = 9 (cubic meter/day) 237 - EN_CMS = 10 (cubic meter/sec) 238 239 The default is None. 240 pressure_units_id : `int`, optional 241 Specifies the pressure units to be used in this scenarios. 242 If None, the units from the .inp file will be used. 243 244 Must be one of the following EPANET constants: 245 246 - EN_PSI = 0 (Pounds per square inch) 247 - EN_KPA = 1 (Kilopascals) 248 - EN_METERS = 2 (Meters) 249 - EN_BAR = 3 (Bar) 250 - EN_FEET = 4 (Feet) 251 252 The default is None. 253 254 Returns 255 ------- 256 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 257 Net2 network loaded into a scenario configuration that can be passed on to 258 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 259 """ 260 f_in = os.path.join(download_dir, "Net2.inp") 261 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net2.inp" 262 backup_urls = ["https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/refs/heads/dev/epyt/networks/asce-tf-wdst/Net2.inp"] 263 264 download_if_necessary(f_in, url, verbose, backup_urls) 265 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
266 267
[docs] 268def load_net3(download_dir: str = get_temp_folder(), verbose: bool = True, 269 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 270 """ 271 Loads (and downloads if necessary) the Net3 network. 272 273 Parameters 274 ---------- 275 download_dir : `str`, optional 276 Path to the directory where the .inp file is stored. 277 278 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 279 verbose : `bool`, optional 280 If True, a progress bar is shown while downloading the file. 281 282 The default is True. 283 flow_units_id : `int`, optional 284 Specifies the flow units to be used in this scenario. 285 If None, the units from the .inp file will be used. 286 287 Must be one of the following EPANET toolkit constants: 288 289 - EN_CFS = 0 (cubic foot/sec) 290 - EN_GPM = 1 (gal/min) 291 - EN_MGD = 2 (Million gal/day) 292 - EN_IMGD = 3 (Imperial MGD) 293 - EN_AFD = 4 (ac-foot/day) 294 - EN_LPS = 5 (liter/sec) 295 - EN_LPM = 6 (liter/min) 296 - EN_MLD = 7 (Megaliter/day) 297 - EN_CMH = 8 (cubic meter/hr) 298 - EN_CMD = 9 (cubic meter/day) 299 - EN_CMS = 10 (cubic meter/sec) 300 301 The default is None. 302 pressure_units_id : `int`, optional 303 Specifies the pressure units to be used in this scenarios. 304 If None, the units from the .inp file will be used. 305 306 Must be one of the following EPANET constants: 307 308 - EN_PSI = 0 (Pounds per square inch) 309 - EN_KPA = 1 (Kilopascals) 310 - EN_METERS = 2 (Meters) 311 - EN_BAR = 3 (Bar) 312 - EN_FEET = 4 (Feet) 313 314 The default is None. 315 316 Returns 317 ------- 318 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 319 Net3 network loaded into a scenario configuration that can be passed on to 320 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 321 """ 322 f_in = os.path.join(download_dir, "Net3.inp") 323 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net3.inp" 324 backup_urls = ["https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/refs/heads/dev/epyt/networks/asce-tf-wdst/Net3.inp"] 325 326 download_if_necessary(f_in, url, verbose, backup_urls) 327 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
328 329
[docs] 330def load_net6(download_dir: str = get_temp_folder(), verbose: bool = True, 331 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 332 """ 333 Loads (and downloads if necessary) the Net6 network. 334 335 Parameters 336 ---------- 337 download_dir : `str`, optional 338 Path to the directory where the .inp file is stored. 339 340 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 341 verbose : `bool`, optional 342 If True, a progress bar is shown while downloading the file. 343 344 The default is True. 345 flow_units_id : `int`, optional 346 Specifies the flow units to be used in this scenario. 347 If None, the units from the .inp file will be used. 348 349 Must be one of the following EPANET toolkit constants: 350 351 - EN_CFS = 0 (cubic foot/sec) 352 - EN_GPM = 1 (gal/min) 353 - EN_MGD = 2 (Million gal/day) 354 - EN_IMGD = 3 (Imperial MGD) 355 - EN_AFD = 4 (ac-foot/day) 356 - EN_LPS = 5 (liter/sec) 357 - EN_LPM = 6 (liter/min) 358 - EN_MLD = 7 (Megaliter/day) 359 - EN_CMH = 8 (cubic meter/hr) 360 - EN_CMD = 9 (cubic meter/day) 361 - EN_CMS = 10 (cubic meter/sec) 362 363 The default is None. 364 pressure_units_id : `int`, optional 365 Specifies the pressure units to be used in this scenarios. 366 If None, the units from the .inp file will be used. 367 368 Must be one of the following EPANET constants: 369 370 - EN_PSI = 0 (Pounds per square inch) 371 - EN_KPA = 1 (Kilopascals) 372 - EN_METERS = 2 (Meters) 373 - EN_BAR = 3 (Bar) 374 - EN_FEET = 4 (Feet) 375 376 The default is None. 377 378 Returns 379 ------- 380 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 381 Net6 network loaded into a scenario configuration that can be passed on to 382 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 383 """ 384 f_in = os.path.join(download_dir, "Net6.inp") 385 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net6.inp" 386 387 download_if_necessary(f_in, url, verbose) 388 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
389 390
[docs] 391def load_richmond(download_dir: str = get_temp_folder(), verbose: bool = True, 392 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 393 """ 394 Loads (and downloads if necessary) the Richmond network. 395 396 Parameters 397 ---------- 398 download_dir : `str`, optional 399 Path to the directory where the .inp file is stored. 400 401 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 402 verbose : `bool`, optional 403 If True, a progress bar is shown while downloading the file. 404 405 The default is True. 406 flow_units_id : `int`, optional 407 Specifies the flow units to be used in this scenario. 408 If None, the units from the .inp file will be used. 409 410 Must be one of the following EPANET toolkit constants: 411 412 - EN_CFS = 0 (cubic foot/sec) 413 - EN_GPM = 1 (gal/min) 414 - EN_MGD = 2 (Million gal/day) 415 - EN_IMGD = 3 (Imperial MGD) 416 - EN_AFD = 4 (ac-foot/day) 417 - EN_LPS = 5 (liter/sec) 418 - EN_LPM = 6 (liter/min) 419 - EN_MLD = 7 (Megaliter/day) 420 - EN_CMH = 8 (cubic meter/hr) 421 - EN_CMD = 9 (cubic meter/day) 422 - EN_CMS = 10 (cubic meter/sec) 423 424 The default is None. 425 pressure_units_id : `int`, optional 426 Specifies the pressure units to be used in this scenarios. 427 If None, the units from the .inp file will be used. 428 429 Must be one of the following EPANET constants: 430 431 - EN_PSI = 0 (Pounds per square inch) 432 - EN_KPA = 1 (Kilopascals) 433 - EN_METERS = 2 (Meters) 434 - EN_BAR = 3 (Bar) 435 - EN_FEET = 4 (Feet) 436 437 The default is None. 438 439 Returns 440 ------- 441 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 442 Richmond network loaded into a scenario configuration that can be passed on to 443 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 444 """ 445 f_in = os.path.join(download_dir, "Richmond_standard.inp") 446 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Richmond_standard.inp" 447 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/Richmond_standard.inp"] 448 449 download_if_necessary(f_in, url, verbose, backup_urls) 450 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
451 452
[docs] 453def load_micropolis(download_dir: str = get_temp_folder(), verbose: bool = True, 454 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 455 """ 456 Loads (and downloads if necessary) the MICROPOLIS network. 457 458 Parameters 459 ---------- 460 download_dir : `str`, optional 461 Path to the directory where the .inp file is stored. 462 463 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 464 verbose : `bool`, optional 465 If True, a progress bar is shown while downloading the file. 466 467 The default is True. 468 flow_units_id : `int`, optional 469 Specifies the flow units to be used in this scenario. 470 If None, the units from the .inp file will be used. 471 472 Must be one of the following EPANET toolkit constants: 473 474 - EN_CFS = 0 (cubic foot/sec) 475 - EN_GPM = 1 (gal/min) 476 - EN_MGD = 2 (Million gal/day) 477 - EN_IMGD = 3 (Imperial MGD) 478 - EN_AFD = 4 (ac-foot/day) 479 - EN_LPS = 5 (liter/sec) 480 - EN_LPM = 6 (liter/min) 481 - EN_MLD = 7 (Megaliter/day) 482 - EN_CMH = 8 (cubic meter/hr) 483 - EN_CMD = 9 (cubic meter/day) 484 - EN_CMS = 10 (cubic meter/sec) 485 486 The default is None. 487 pressure_units_id : `int`, optional 488 Specifies the pressure units to be used in this scenarios. 489 If None, the units from the .inp file will be used. 490 491 Must be one of the following EPANET constants: 492 493 - EN_PSI = 0 (Pounds per square inch) 494 - EN_KPA = 1 (Kilopascals) 495 - EN_METERS = 2 (Meters) 496 - EN_BAR = 3 (Bar) 497 - EN_FEET = 4 (Feet) 498 499 The default is None. 500 501 Returns 502 ------- 503 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 504 MICROPOLIS network loaded into a scenario configuration that can be passed on to 505 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 506 """ 507 f_in = os.path.join(download_dir, "MICROPOLIS_v1.inp") 508 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/MICROPOLIS_v1.inp" 509 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/MICROPOLIS_v1.inp"] 510 511 download_if_necessary(f_in, url, verbose, backup_urls) 512 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
513 514
[docs] 515def load_balerma(download_dir: str = get_temp_folder(), verbose: bool = True, 516 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 517 """ 518 Loads (and downloads if necessary) the Balerma network. 519 520 Parameters 521 ---------- 522 download_dir : `str`, optional 523 Path to the directory where the .inp file is stored. 524 525 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 526 verbose : `bool`, optional 527 If True, a progress bar is shown while downloading the file. 528 529 The default is True. 530 flow_units_id : `int`, optional 531 Specifies the flow units to be used in this scenario. 532 If None, the units from the .inp file will be used. 533 534 Must be one of the following EPANET toolkit constants: 535 536 - EN_CFS = 0 (cubic foot/sec) 537 - EN_GPM = 1 (gal/min) 538 - EN_MGD = 2 (Million gal/day) 539 - EN_IMGD = 3 (Imperial MGD) 540 - EN_AFD = 4 (ac-foot/day) 541 - EN_LPS = 5 (liter/sec) 542 - EN_LPM = 6 (liter/min) 543 - EN_MLD = 7 (Megaliter/day) 544 - EN_CMH = 8 (cubic meter/hr) 545 - EN_CMD = 9 (cubic meter/day) 546 - EN_CMS = 10 (cubic meter/sec) 547 548 The default is None. 549 pressure_units_id : `int`, optional 550 Specifies the pressure units to be used in this scenarios. 551 If None, the units from the .inp file will be used. 552 553 Must be one of the following EPANET constants: 554 555 - EN_PSI = 0 (Pounds per square inch) 556 - EN_KPA = 1 (Kilopascals) 557 - EN_METERS = 2 (Meters) 558 - EN_BAR = 3 (Bar) 559 - EN_FEET = 4 (Feet) 560 561 The default is None. 562 563 Returns 564 ------- 565 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 566 Balerma network loaded into a scenario configuration that can be passed on to 567 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 568 """ 569 f_in = os.path.join(download_dir, "Balerma.inp") 570 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Balerma.inp" 571 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/Balerma.inp"] 572 573 download_if_necessary(f_in, url, verbose, backup_urls) 574 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
575 576
[docs] 577def load_rural(download_dir: str = get_temp_folder(), verbose: bool = True, 578 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 579 """ 580 Loads (and downloads if necessary) the Rural network. 581 582 Parameters 583 ---------- 584 download_dir : `str`, optional 585 Path to the directory where the .inp file is stored. 586 587 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 588 verbose : `bool`, optional 589 If True, a progress bar is shown while downloading the file. 590 591 The default is True. 592 flow_units_id : `int`, optional 593 Specifies the flow units to be used in this scenario. 594 If None, the units from the .inp file will be used. 595 596 Must be one of the following EPANET toolkit constants: 597 598 - EN_CFS = 0 (cubic foot/sec) 599 - EN_GPM = 1 (gal/min) 600 - EN_MGD = 2 (Million gal/day) 601 - EN_IMGD = 3 (Imperial MGD) 602 - EN_AFD = 4 (ac-foot/day) 603 - EN_LPS = 5 (liter/sec) 604 - EN_LPM = 6 (liter/min) 605 - EN_MLD = 7 (Megaliter/day) 606 - EN_CMH = 8 (cubic meter/hr) 607 - EN_CMD = 9 (cubic meter/day) 608 - EN_CMS = 10 (cubic meter/sec) 609 610 The default is None. 611 pressure_units_id : `int`, optional 612 Specifies the pressure units to be used in this scenarios. 613 If None, the units from the .inp file will be used. 614 615 Must be one of the following EPANET constants: 616 617 - EN_PSI = 0 (Pounds per square inch) 618 - EN_KPA = 1 (Kilopascals) 619 - EN_METERS = 2 (Meters) 620 - EN_BAR = 3 (Bar) 621 - EN_FEET = 4 (Feet) 622 623 The default is None. 624 625 Returns 626 ------- 627 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 628 Rural network loaded into a scenario configuration that can be passed on to 629 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 630 """ 631 f_in = os.path.join(download_dir, "RuralNetwork.inp") 632 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/RuralNetwork.inp" 633 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/RuralNetwork.inp"] 634 635 download_if_necessary(f_in, url, verbose, backup_urls) 636 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
637 638
[docs] 639def load_bwsn1(download_dir: str = get_temp_folder(), verbose: bool = True, 640 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 641 """ 642 Loads (and downloads if necessary) the BWSN-1 network. 643 644 Parameters 645 ---------- 646 download_dir : `str`, optional 647 Path to the directory where the .inp file is stored. 648 649 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 650 verbose : `bool`, optional 651 If True, a progress bar is shown while downloading the file. 652 653 The default is True. 654 flow_units_id : `int`, optional 655 Specifies the flow units to be used in this scenario. 656 If None, the units from the .inp file will be used. 657 658 Must be one of the following EPANET toolkit constants: 659 660 - EN_CFS = 0 (cubic foot/sec) 661 - EN_GPM = 1 (gal/min) 662 - EN_MGD = 2 (Million gal/day) 663 - EN_IMGD = 3 (Imperial MGD) 664 - EN_AFD = 4 (ac-foot/day) 665 - EN_LPS = 5 (liter/sec) 666 - EN_LPM = 6 (liter/min) 667 - EN_MLD = 7 (Megaliter/day) 668 - EN_CMH = 8 (cubic meter/hr) 669 - EN_CMD = 9 (cubic meter/day) 670 - EN_CMS = 10 (cubic meter/sec) 671 672 The default is None. 673 pressure_units_id : `int`, optional 674 Specifies the pressure units to be used in this scenarios. 675 If None, the units from the .inp file will be used. 676 677 Must be one of the following EPANET constants: 678 679 - EN_PSI = 0 (Pounds per square inch) 680 - EN_KPA = 1 (Kilopascals) 681 - EN_METERS = 2 (Meters) 682 - EN_BAR = 3 (Bar) 683 - EN_FEET = 4 (Feet) 684 685 The default is None. 686 687 Returns 688 ------- 689 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 690 BWSN-1 network loaded into a scenario configuration that can be passed on to 691 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 692 """ 693 f_in = os.path.join(download_dir, "BWSN_Network_1.inp") 694 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/BWSN_Network_1.inp" 695 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/BWSN_Network_1.inp"] 696 697 download_if_necessary(f_in, url, verbose, backup_urls) 698 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
699 700
[docs] 701def load_bwsn2(download_dir: str = get_temp_folder(), verbose: bool = True, 702 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 703 """ 704 Loads (and downloads if necessary) the BWSN-2 network. 705 706 Parameters 707 ---------- 708 download_dir : `str`, optional 709 Path to the directory where the .inp file is stored. 710 711 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 712 verbose : `bool`, optional 713 If True, a progress bar is shown while downloading the file. 714 715 The default is True. 716 flow_units_id : `int`, optional 717 Specifies the flow units to be used in this scenario. 718 If None, the units from the .inp file will be used. 719 720 Must be one of the following EPANET toolkit constants: 721 722 - EN_CFS = 0 (cubic foot/sec) 723 - EN_GPM = 1 (gal/min) 724 - EN_MGD = 2 (Million gal/day) 725 - EN_IMGD = 3 (Imperial MGD) 726 - EN_AFD = 4 (ac-foot/day) 727 - EN_LPS = 5 (liter/sec) 728 - EN_LPM = 6 (liter/min) 729 - EN_MLD = 7 (Megaliter/day) 730 - EN_CMH = 8 (cubic meter/hr) 731 - EN_CMD = 9 (cubic meter/day) 732 - EN_CMS = 10 (cubic meter/sec) 733 734 The default is None. 735 pressure_units_id : `int`, optional 736 Specifies the pressure units to be used in this scenarios. 737 If None, the units from the .inp file will be used. 738 739 Must be one of the following EPANET constants: 740 741 - EN_PSI = 0 (Pounds per square inch) 742 - EN_KPA = 1 (Kilopascals) 743 - EN_METERS = 2 (Meters) 744 - EN_BAR = 3 (Bar) 745 - EN_FEET = 4 (Feet) 746 747 The default is None. 748 749 Returns 750 ------- 751 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 752 BWSN-2 network loaded into a scenario configuration that can be passed on to 753 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 754 """ 755 f_in = os.path.join(download_dir, "BWSN_Network_2.inp") 756 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/BWSN_Network_2.inp" 757 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/BWSN_Network_2.inp"] 758 759 download_if_necessary(f_in, url, verbose, backup_urls) 760 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
761 762
[docs] 763def load_anytown(download_dir: str = get_temp_folder(), verbose: bool = True, 764 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 765 """ 766 Loads (and downloads if necessary) the Anytown network. 767 768 Parameters 769 ---------- 770 download_dir : `str`, optional 771 Path to the directory where the .inp file is stored. 772 773 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 774 verbose : `bool`, optional 775 If True, a progress bar is shown while downloading the file. 776 777 The default is True. 778 flow_units_id : `int`, optional 779 Specifies the flow units to be used in this scenario. 780 If None, the units from the .inp file will be used. 781 782 Must be one of the following EPANET toolkit constants: 783 784 - EN_CFS = 0 (cubic foot/sec) 785 - EN_GPM = 1 (gal/min) 786 - EN_MGD = 2 (Million gal/day) 787 - EN_IMGD = 3 (Imperial MGD) 788 - EN_AFD = 4 (ac-foot/day) 789 - EN_LPS = 5 (liter/sec) 790 - EN_LPM = 6 (liter/min) 791 - EN_MLD = 7 (Megaliter/day) 792 - EN_CMH = 8 (cubic meter/hr) 793 - EN_CMD = 9 (cubic meter/day) 794 - EN_CMS = 10 (cubic meter/sec) 795 796 The default is None. 797 pressure_units_id : `int`, optional 798 Specifies the pressure units to be used in this scenarios. 799 If None, the units from the .inp file will be used. 800 801 Must be one of the following EPANET constants: 802 803 - EN_PSI = 0 (Pounds per square inch) 804 - EN_KPA = 1 (Kilopascals) 805 - EN_METERS = 2 (Meters) 806 - EN_BAR = 3 (Bar) 807 - EN_FEET = 4 (Feet) 808 809 The default is None. 810 811 Returns 812 ------- 813 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 814 Anytown network loaded into a scenario configuration that can be passed on to 815 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 816 """ 817 f_in = os.path.join(download_dir, "Anytown.inp") 818 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Anytown.inp" 819 backup_urls = ["https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/refs/heads/dev/epyt/networks/asce-tf-wdst/Anytown.inp"] 820 821 download_if_necessary(f_in, url, verbose, backup_urls) 822 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
823 824
[docs] 825def load_dtown(download_dir: str = get_temp_folder(), verbose: bool = True, 826 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 827 """ 828 Loads (and downloads if necessary) the D-Town network. 829 830 Parameters 831 ---------- 832 download_dir : `str`, optional 833 Path to the directory where the .inp file is stored. 834 835 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 836 verbose : `bool`, optional 837 If True, a progress bar is shown while downloading the file. 838 839 The default is True. 840 flow_units_id : `int`, optional 841 Specifies the flow units to be used in this scenario. 842 If None, the units from the .inp file will be used. 843 844 Must be one of the following EPANET toolkit constants: 845 846 - EN_CFS = 0 (cubic foot/sec) 847 - EN_GPM = 1 (gal/min) 848 - EN_MGD = 2 (Million gal/day) 849 - EN_IMGD = 3 (Imperial MGD) 850 - EN_AFD = 4 (ac-foot/day) 851 - EN_LPS = 5 (liter/sec) 852 - EN_LPM = 6 (liter/min) 853 - EN_MLD = 7 (Megaliter/day) 854 - EN_CMH = 8 (cubic meter/hr) 855 - EN_CMD = 9 (cubic meter/day) 856 - EN_CMS = 10 (cubic meter/sec) 857 858 The default is None. 859 pressure_units_id : `int`, optional 860 Specifies the pressure units to be used in this scenarios. 861 If None, the units from the .inp file will be used. 862 863 Must be one of the following EPANET constants: 864 865 - EN_PSI = 0 (Pounds per square inch) 866 - EN_KPA = 1 (Kilopascals) 867 - EN_METERS = 2 (Meters) 868 - EN_BAR = 3 (Bar) 869 - EN_FEET = 4 (Feet) 870 871 The default is None. 872 873 Returns 874 ------- 875 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 876 D-Town network loaded into a scenario configuration that can be passed on to 877 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 878 """ 879 f_in = os.path.join(download_dir, "d-town.inp") 880 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/d-town.inp" 881 backup_urls = ["https://raw.githubusercontent.com/KIOS-Research/EPANET-Benchmarks/refs/heads/master/collect-epanet-inp/d-town.inp"] 882 883 download_if_necessary(f_in, url, verbose, backup_urls) 884 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
885 886
[docs] 887def load_ctown(download_dir: str = get_temp_folder(), verbose: bool = True, 888 flow_units_id: int = None, pressure_units_id: int = None) -> ScenarioConfig: 889 """ 890 Loads (and downloads if necessary) the C-Town network. 891 892 Parameters 893 ---------- 894 download_dir : `str`, optional 895 Path to the directory where the .inp file is stored. 896 897 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 898 verbose : `bool`, optional 899 If True, a progress bar is shown while downloading the file. 900 901 The default is True. 902 flow_units_id : `int`, optional 903 Specifies the flow units to be used in this scenario. 904 If None, the units from the .inp file will be used. 905 906 Must be one of the following EPANET toolkit constants: 907 908 - EN_CFS = 0 (cubic foot/sec) 909 - EN_GPM = 1 (gal/min) 910 - EN_MGD = 2 (Million gal/day) 911 - EN_IMGD = 3 (Imperial MGD) 912 - EN_AFD = 4 (ac-foot/day) 913 - EN_LPS = 5 (liter/sec) 914 - EN_LPM = 6 (liter/min) 915 - EN_MLD = 7 (Megaliter/day) 916 - EN_CMH = 8 (cubic meter/hr) 917 - EN_CMD = 9 (cubic meter/day) 918 - EN_CMS = 10 (cubic meter/sec) 919 920 The default is None. 921 pressure_units_id : `int`, optional 922 Specifies the pressure units to be used in this scenarios. 923 If None, the units from the .inp file will be used. 924 925 Must be one of the following EPANET constants: 926 927 - EN_PSI = 0 (Pounds per square inch) 928 - EN_KPA = 1 (Kilopascals) 929 - EN_METERS = 2 (Meters) 930 - EN_BAR = 3 (Bar) 931 - EN_FEET = 4 (Feet) 932 933 The default is None. 934 935 Returns 936 ------- 937 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 938 C-Town network loaded into a scenario configuration that can be passed on to 939 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 940 """ 941 f_in = os.path.join(download_dir, "CTOWN.INP") 942 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/CTOWN.INP" 943 944 download_if_necessary(f_in, url, verbose) 945 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
946 947
[docs] 948def load_kentucky(wdn_id: int = 1, download_dir: str = get_temp_folder(), 949 verbose: bool = True, flow_units_id: int = None, 950 pressure_units_id: int = None) -> ScenarioConfig: 951 """ 952 Loads (and downloads if necessary) the specified Kentucky network. 953 954 Parameters 955 ---------- 956 wdn_id : `int`, optional 957 The ID (1-15) of the particular network. 958 959 The default is wdn_id=1 960 download_dir : `str`, optional 961 Path to the directory where the .inp file is stored. 962 963 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 964 verbose : `bool`, optional 965 If True, a progress bar is shown while downloading the file. 966 967 The default is True. 968 flow_units_id : `int`, optional 969 Specifies the flow units to be used in this scenario. 970 If None, the units from the .inp file will be used. 971 972 Must be one of the following EPANET toolkit constants: 973 974 - EN_CFS = 0 (cubic foot/sec) 975 - EN_GPM = 1 (gal/min) 976 - EN_MGD = 2 (Million gal/day) 977 - EN_IMGD = 3 (Imperial MGD) 978 - EN_AFD = 4 (ac-foot/day) 979 - EN_LPS = 5 (liter/sec) 980 - EN_LPM = 6 (liter/min) 981 - EN_MLD = 7 (Megaliter/day) 982 - EN_CMH = 8 (cubic meter/hr) 983 - EN_CMD = 9 (cubic meter/day) 984 - EN_CMS = 10 (cubic meter/sec) 985 986 The default is None. 987 pressure_units_id : `int`, optional 988 Specifies the pressure units to be used in this scenarios. 989 If None, the units from the .inp file will be used. 990 991 Must be one of the following EPANET constants: 992 993 - EN_PSI = 0 (Pounds per square inch) 994 - EN_KPA = 1 (Kilopascals) 995 - EN_METERS = 2 (Meters) 996 - EN_BAR = 3 (Bar) 997 - EN_FEET = 4 (Feet) 998 999 The default is None. 1000 1001 Returns 1002 ------- 1003 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 1004 Kentucky network loaded into a scenario configuration that can be passed on to 1005 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 1006 """ 1007 if not isinstance(wdn_id, int): 1008 raise ValueError("'wdn_id' must be an integer in [1, 15]") 1009 if wdn_id < 1 or wdn_id > 15: 1010 raise ValueError(f"Unknown network 'ky{wdn_id}.inp'") 1011 1012 f_in = os.path.join(download_dir, f"ky{wdn_id}.inp") 1013 url = f"https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/ky{wdn_id}.inp" 1014 backup_urls = [f"https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/refs/heads/dev/epyt/networks/asce-tf-wdst/ky{wdn_id}.inp"] 1015 1016 download_if_necessary(f_in, url, verbose, backup_urls) 1017 return load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id)
1018 1019
[docs] 1020def load_hanoi(download_dir: str = get_temp_folder(), 1021 include_default_sensor_placement: bool = False, 1022 verbose: bool = True, flow_units_id: int = None, 1023 pressure_units_id: int = None) -> ScenarioConfig: 1024 """ 1025 Loads (and downloads if necessary) the Hanoi network. 1026 1027 Parameters 1028 ---------- 1029 download_dir : `str`, optional 1030 Path to the directory where the .inp file is stored. 1031 1032 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 1033 include_default_sensor_placement : `bool`, optional 1034 If True, a default sensor placement will be included in the returned scenario configuration. 1035 1036 The default is False 1037 verbose : `bool`, optional 1038 If True, a progress bar is shown while downloading the file. 1039 1040 The default is True. 1041 flow_units_id : `int`, optional 1042 Specifies the flow units to be used in this scenario. 1043 If None, the units from the .inp file will be used. 1044 1045 Must be one of the following EPANET toolkit constants: 1046 1047 - EN_CFS = 0 (cubic foot/sec) 1048 - EN_GPM = 1 (gal/min) 1049 - EN_MGD = 2 (Million gal/day) 1050 - EN_IMGD = 3 (Imperial MGD) 1051 - EN_AFD = 4 (ac-foot/day) 1052 - EN_LPS = 5 (liter/sec) 1053 - EN_LPM = 6 (liter/min) 1054 - EN_MLD = 7 (Megaliter/day) 1055 - EN_CMH = 8 (cubic meter/hr) 1056 - EN_CMD = 9 (cubic meter/day) 1057 - EN_CMS = 10 (cubic meter/sec) 1058 1059 The default is None. 1060 pressure_units_id : `int`, optional 1061 Specifies the pressure units to be used in this scenarios. 1062 If None, the units from the .inp file will be used. 1063 1064 Must be one of the following EPANET constants: 1065 1066 - EN_PSI = 0 (Pounds per square inch) 1067 - EN_KPA = 1 (Kilopascals) 1068 - EN_METERS = 2 (Meters) 1069 - EN_BAR = 3 (Bar) 1070 - EN_FEET = 4 (Feet) 1071 1072 The default is None. 1073 1074 Returns 1075 ------- 1076 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 1077 Hanoi network loaded into a scenario configuration that can be passed on to 1078 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 1079 """ 1080 f_in = os.path.join(download_dir, "Hanoi.inp") 1081 url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Hanoi.inp" 1082 backup_urls = ["https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/refs/heads/dev/epyt/networks/asce-tf-wdst/Hanoi.inp"] 1083 1084 download_if_necessary(f_in, url, verbose, backup_urls) 1085 config = load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id) 1086 1087 if include_default_sensor_placement is True: 1088 sensor_config = config.sensor_config 1089 sensor_config.pressure_sensors = ["13", "16", "22", "30"] 1090 sensor_config.flow_sensors = ["1"] 1091 1092 config = ScenarioConfig(scenario_config=config, sensor_config=sensor_config) 1093 1094 return config
1095 1096
[docs] 1097def load_ltown(download_dir: str = get_temp_folder(), use_realistic_demands: bool = False, 1098 include_default_sensor_placement: bool = False, 1099 verbose: bool = True, flow_units_id: int = None, 1100 pressure_units_id: int = None) -> ScenarioConfig: 1101 """ 1102 Loads (and downloads if necessary) the L-TOWN_v2 network. 1103 1104 Parameters 1105 ---------- 1106 download_dir : `str`, optional 1107 Path to the directory where the .inp file is stored. 1108 1109 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 1110 use_realistic_demands : `bool`, optional 1111 If True, realistic demands from the BattLeDIM challenge will be included, 1112 toy demands will be included otherwise. 1113 1114 The default is False 1115 include_default_sensor_placement : `bool`, optional 1116 If True, the L-TOWN default sensor placement will be included 1117 in the returned scenario configuration. 1118 1119 The default is False 1120 verbose : `bool`, optional 1121 If True, a progress bar is shown while downloading the file. 1122 1123 The default is True. 1124 flow_units_id : `int`, optional 1125 Specifies the flow units to be used in this scenario. 1126 If None, the units from the .inp file will be used. 1127 1128 Must be one of the following EPANET toolkit constants: 1129 1130 - EN_CFS = 0 (cubic foot/sec) 1131 - EN_GPM = 1 (gal/min) 1132 - EN_MGD = 2 (Million gal/day) 1133 - EN_IMGD = 3 (Imperial MGD) 1134 - EN_AFD = 4 (ac-foot/day) 1135 - EN_LPS = 5 (liter/sec) 1136 - EN_LPM = 6 (liter/min) 1137 - EN_MLD = 7 (Megaliter/day) 1138 - EN_CMH = 8 (cubic meter/hr) 1139 - EN_CMD = 9 (cubic meter/day) 1140 - EN_CMS = 10 (cubic meter/sec) 1141 1142 The default is None. 1143 pressure_units_id : `int`, optional 1144 Specifies the pressure units to be used in this scenarios. 1145 If None, the units from the .inp file will be used. 1146 1147 Must be one of the following EPANET constants: 1148 1149 - EN_PSI = 0 (Pounds per square inch) 1150 - EN_KPA = 1 (Kilopascals) 1151 - EN_METERS = 2 (Meters) 1152 - EN_BAR = 3 (Bar) 1153 - EN_FEET = 4 (Feet) 1154 1155 The default is None. 1156 1157 Returns 1158 ------- 1159 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 1160 L-TOWN_v2 network loaded into a scenario configuration that can be passed on to 1161 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 1162 """ 1163 f_inp = "L-TOWN_v2_Model.inp" if use_realistic_demands is False else "L-TOWN_v2_Real.inp" 1164 1165 f_in = os.path.join(download_dir, f_inp) 1166 if not use_realistic_demands: 1167 url = "https://zenodo.org/records/4017659/files/L-TOWN.inp?download=1" 1168 else: 1169 url = "https://zenodo.org/records/4017659/files/L-TOWN_Real.inp?download=1" 1170 1171 download_if_necessary(f_in, url, verbose) 1172 config = load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id) 1173 1174 if include_default_sensor_placement is True: 1175 sensor_config = config.sensor_config 1176 sensor_config.pressure_sensors = ["n54", "n105", "n114", "n163", "n188", "n229", "n288", 1177 "n296", "n332", "n342", "n410", "n415", "n429", "n458", 1178 "n469", "n495", "n506", "n516", "n519", "n549", "n613", 1179 "n636", "n644", "n679", "n722", "n726", "n740", "n752", 1180 "n769"] 1181 sensor_config.flow_sensors = ["p227", "p235"] 1182 sensor_config.tank_volume_sensors = ["T1"] 1183 sensor_config.demand_sensors = ["n1", "n2", "n3", "n4", "n6", "n7", "n8", "n9", "n10", 1184 "n11", "n13", "n16", "n17", "n18", "n19", "n20", "n21", 1185 "n22", "n23", "n24", "n25", "n26", "n27", "n28", "n29", 1186 "n30", "n31", "n32", "n33", "n34", "n35", "n36", "n39", 1187 "n40", "n41", "n42", "n43", "n44", "n45", "n343", "n344", 1188 "n345", "n346", "n347", "n349", "n350", "n351", "n352", 1189 "n353", "n354", "n355", "n356", "n357", "n358", "n360", 1190 "n361", "n362", "n364", "n365", "n366", "n367", "n368", 1191 "n369", "n370", "n371", "n372", "n373", "n374", "n375", 1192 "n376", "n377", "n378", "n379", "n381", "n382", "n383", 1193 "n384", "n385", "n386", "n387", "n388", "n389"] 1194 1195 config = ScenarioConfig(scenario_config=config, sensor_config=sensor_config) 1196 1197 return config
1198 1199
[docs] 1200def load_ltown_a(download_dir: str = get_temp_folder(), use_realistic_demands: bool = False, 1201 include_default_sensor_placement: bool = False, 1202 verbose: bool = True, flow_units_id: int = None, 1203 pressure_units_id: int = None) -> ScenarioConfig: 1204 """ 1205 Loads (and downloads if necessary) the L-TOWN-A network (area "A" of the L-TOWN network). 1206 1207 Parameters 1208 ---------- 1209 download_dir : `str`, optional 1210 Path to the directory where the .inp file is stored. 1211 1212 The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.) 1213 use_realistic_demands : `bool`, optional 1214 If True, realistic demands from the BattLeDIM challenge will be included, 1215 toy demands will be included otherwise. 1216 1217 The default is False 1218 include_default_sensor_placement : `bool`, optional 1219 If True, the L-TOWN default sensor placement will be included 1220 in the returned scenario configuration. 1221 1222 The default is False 1223 verbose : `bool`, optional 1224 If True, a progress bar is shown while downloading the file. 1225 1226 The default is True. 1227 flow_units_id : `int`, optional 1228 Specifies the flow units to be used in this scenario. 1229 If None, the units from the .inp file will be used. 1230 1231 Must be one of the following EPANET toolkit constants: 1232 1233 - EN_CFS = 0 (cubic foot/sec) 1234 - EN_GPM = 1 (gal/min) 1235 - EN_MGD = 2 (Million gal/day) 1236 - EN_IMGD = 3 (Imperial MGD) 1237 - EN_AFD = 4 (ac-foot/day) 1238 - EN_LPS = 5 (liter/sec) 1239 - EN_LPM = 6 (liter/min) 1240 - EN_MLD = 7 (Megaliter/day) 1241 - EN_CMH = 8 (cubic meter/hr) 1242 - EN_CMD = 9 (cubic meter/day) 1243 - EN_CMS = 10 (cubic meter/sec) 1244 1245 The default is None. 1246 pressure_units_id : `int`, optional 1247 Specifies the pressure units to be used in this scenarios. 1248 If None, the units from the .inp file will be used. 1249 1250 Must be one of the following EPANET constants: 1251 1252 - EN_PSI = 0 (Pounds per square inch) 1253 - EN_KPA = 1 (Kilopascals) 1254 - EN_METERS = 2 (Meters) 1255 - EN_BAR = 3 (Bar) 1256 - EN_FEET = 4 (Feet) 1257 1258 The default is None. 1259 1260 Returns 1261 ------- 1262 :class:`~epyt_flow.simulation.scenario_config.ScenarioConfig` 1263 L-TOWN-A network loaded into a scenario configuration that can be passed on to 1264 :class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`. 1265 """ 1266 f_inp = "L-TOWN_v2-A_Model.inp" if use_realistic_demands is False else "L-TOWN_v2-A_Real.inp" 1267 1268 f_in = os.path.join(download_dir, f_inp) 1269 url = f"https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/{f_inp}" 1270 1271 download_if_necessary(f_in, url, verbose) 1272 config = load_inp(f_in, flow_units_id=flow_units_id, pressure_units_id=pressure_units_id) 1273 1274 if include_default_sensor_placement is True: 1275 sensor_config = config.sensor_config 1276 sensor_config.pressure_sensors = ["n54", "n105", "n114", "n163", "n188", "n229", "n288", 1277 "n296", "n332", "n342", "n410", "n415", "n429", "n458", 1278 "n469", "n495", "n506", "n516", "n519", "n549", "n613", 1279 "n636", "n644", "n679", "n722", "n726", "n740", "n752", 1280 "n769"] 1281 sensor_config.flow_sensors = ["p227", "p235"] 1282 1283 config = ScenarioConfig(scenario_config=config, sensor_config=sensor_config) 1284 1285 return config