diff --git a/swmm-toolkit/CMakeLists.txt b/swmm-toolkit/CMakeLists.txt index 3c9dc938..181f9ab7 100644 --- a/swmm-toolkit/CMakeLists.txt +++ b/swmm-toolkit/CMakeLists.txt @@ -15,7 +15,7 @@ cmake_minimum_required (VERSION 3.17) project(swmm-toolkit VERSION - 0.13.0 + 0.14.0 ) diff --git a/swmm-toolkit/setup.py b/swmm-toolkit/setup.py index 7152551f..a2282930 100644 --- a/swmm-toolkit/setup.py +++ b/swmm-toolkit/setup.py @@ -88,7 +88,7 @@ def exclude_files(cmake_manifest): setup( name = "swmm-toolkit", - version = "0.13.0", + version = "0.14.0", packages = ["swmm_toolkit", "swmm.toolkit"], package_dir = package_dir, diff --git a/swmm-toolkit/src/swmm/toolkit/__init__.py b/swmm-toolkit/src/swmm/toolkit/__init__.py index 5a395c88..91df118a 100644 --- a/swmm-toolkit/src/swmm/toolkit/__init__.py +++ b/swmm-toolkit/src/swmm/toolkit/__init__.py @@ -19,7 +19,7 @@ __credits__ = "Colleen Barr, Sam Hatchett" __license__ = "CC0 1.0 Universal" -__version__ = "0.13.0" +__version__ = "0.14.0" __date__ = "June 7, 2021" __maintainer__ = "Michael Tryby" diff --git a/swmm-toolkit/src/swmm/toolkit/shared_enum.py b/swmm-toolkit/src/swmm/toolkit/shared_enum.py index 8724e3b3..48a34d5d 100644 --- a/swmm-toolkit/src/swmm/toolkit/shared_enum.py +++ b/swmm-toolkit/src/swmm/toolkit/shared_enum.py @@ -739,3 +739,17 @@ class RainResult(Enum): TOTAL = 0 RAINFALL = 1 SNOWFALL = 2 + +class InletProperty(Enum): + NUM_INLETS = 0 + CLOG_FACTOR = 1 + FLOW_LIMIT = 2 + DEPRESSION_HEIGHT = 3 + DEPRESSION_WIDTH = 4 + + +class InletResult(Enum): + FLOW_FACTOR = 0 + FLOW_CAPTURE = 1 + BACK_FLOW = 2 + BLACK_FLOW_RATIO = 3 \ No newline at end of file diff --git a/swmm-toolkit/src/swmm/toolkit/solver.i b/swmm-toolkit/src/swmm/toolkit/solver.i index 53381c3b..2fc69d18 100644 --- a/swmm-toolkit/src/swmm/toolkit/solver.i +++ b/swmm-toolkit/src/swmm/toolkit/solver.i @@ -158,7 +158,9 @@ SM_LidLayerProperty, SM_LidUProperty, SM_LidUOptions, - SM_LidResult + SM_LidResult, + SM_InletProperty, + SM_InletResult } diff --git a/swmm-toolkit/src/swmm/toolkit/solver_docs.i b/swmm-toolkit/src/swmm/toolkit/solver_docs.i index e47d24be..d2f02a61 100644 --- a/swmm-toolkit/src/swmm/toolkit/solver_docs.i +++ b/swmm-toolkit/src/swmm/toolkit/solver_docs.i @@ -1293,3 +1293,57 @@ total_precip: double The new total precipitation intensity. " ) swmm_setGagePrecip; + + +%feature("autodoc", +"Get a property value for the inlet of a specified link. + +Parameters +---------- +index: int + The index of a link with desired inlets +param: SM_InletProperty + The property type code (See :ref: SM_InletProperty) + +Returns +------- +value: double * + The value of the inlet's property +" +) swmm_getInletParam; + + +%feature("autodoc", +"Get a property value for the inlet of a specified link. + +Parameters +---------- +index: int + The index of a link with desired inlets +param: SM_InletProperty + The property type code (See :ref: SM_InletProperty) + +Returns +------- +value: double * + The new value of the inlet's property +" +) swmm_setInletParam; + + +%feature("autodoc", +"Get a result value for specified link. + +Parameters +---------- +index: int + The index of a link with desired inlets +type: SM_InletResult + The result type code (See :ref: SM_InletResult) + +Returns +------- +result: double * + The value of the inlet's result at the current simulation timestep +" +) swmm_getInletResult; diff --git a/swmm-toolkit/src/swmm/toolkit/solver_rename.i b/swmm-toolkit/src/swmm/toolkit/solver_rename.i index 29259e7f..2d72a89b 100644 --- a/swmm-toolkit/src/swmm/toolkit/solver_rename.i +++ b/swmm-toolkit/src/swmm/toolkit/solver_rename.i @@ -68,6 +68,9 @@ %rename(link_set_target_setting) swmm_setLinkSetting; %rename(link_get_stats) swmm_getLinkStats; +%rename(inlet_get_parameter) swmm_getInletParam; +%rename(inlet_set_parameter) swmm_setInletParam; +%rename(inlet_get_result) swmm_getInletResult; %rename(pump_get_stats) swmm_getPumpStats; diff --git a/swmm-toolkit/swmm-solver b/swmm-toolkit/swmm-solver index d74e6363..2e5b21d5 160000 --- a/swmm-toolkit/swmm-solver +++ b/swmm-toolkit/swmm-solver @@ -1 +1 @@ -Subproject commit d74e6363fd4c7bfcee64f9fafa83b34f5e3cb92d +Subproject commit 2e5b21d5ce268428765f78b4e1ce6601e64e3c39 diff --git a/swmm-toolkit/tests/data/test_inlet_drains.inp b/swmm-toolkit/tests/data/test_inlet_drains.inp new file mode 100644 index 00000000..a60d798a --- /dev/null +++ b/swmm-toolkit/tests/data/test_inlet_drains.inp @@ -0,0 +1,502 @@ +[TITLE] +;;Project Title/Notes +A dual drainage model with street inlets. +See Inlet_Drains_Model.txt for more details. + +[OPTIONS] +;;Option Value +FLOW_UNITS CFS +INFILTRATION HORTON +FLOW_ROUTING DYNWAVE +LINK_OFFSETS DEPTH +MIN_SLOPE 0 +ALLOW_PONDING NO +SKIP_STEADY_STATE NO + +START_DATE 01/01/2007 +START_TIME 00:00:00 +REPORT_START_DATE 01/01/2007 +REPORT_START_TIME 00:00:00 +END_DATE 01/01/2007 +END_TIME 06:00:00 +SWEEP_START 01/01 +SWEEP_END 12/31 +DRY_DAYS 0 +REPORT_STEP 00:01:00 +WET_STEP 00:01:00 +DRY_STEP 01:00:00 +ROUTING_STEP 0:00:15 +RULE_STEP 00:00:00 + +INERTIAL_DAMPING PARTIAL +NORMAL_FLOW_LIMITED SLOPE +FORCE_MAIN_EQUATION H-W +VARIABLE_STEP 0.75 +LENGTHENING_STEP 0 +MIN_SURFAREA 12.566 +MAX_TRIALS 8 +HEAD_TOLERANCE 0.005 +SYS_FLOW_TOL 5 +LAT_FLOW_TOL 5 +MINIMUM_STEP 0.5 +THREADS 1 + +[EVAPORATION] +;;Data Source Parameters +;;-------------- ---------------- +CONSTANT 0.0 +DRY_ONLY NO + +[RAINGAGES] +;;Name Format Interval SCF Source +;;-------------- --------- ------ ------ ---------- +RainGage INTENSITY 0:05 1.0 TIMESERIES 2-yr + +[SUBCATCHMENTS] +;;Name Rain Gage Outlet Area %Imperv Width %Slope CurbLen SnowPack +;;-------------- ---------------- ---------------- -------- -------- -------- -------- -------- ---------------- +S1 RainGage Aux1 4.55 56.8 1587 2 0 +S2 RainGage Aux4 4.74 63.0 1653 2 0 +S3 RainGage Aux3 3.74 39.5 1456 3.1 0 +S4 RainGage J7 6.79 49.9 2331 3.1 0 +S5 RainGage J10 4.79 87.7 1670 2 0 +S6 RainGage J11 1.98 95.0 690 2 0 +S7 RainGage J10 2.33 0.0 907 3.1 0 + +[SUBAREAS] +;;Subcatchment N-Imperv N-Perv S-Imperv S-Perv PctZero RouteTo PctRouted +;;-------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- +S1 0.015 0.24 0.06 0.3 25 OUTLET +S2 0.015 0.24 0.06 0.3 25 OUTLET +S3 0.015 0.24 0.06 0.3 25 OUTLET +S4 0.015 0.24 0.06 0.3 25 OUTLET +S5 0.015 0.24 0.06 0.3 25 OUTLET +S6 0.015 0.24 0.06 0.3 25 OUTLET +S7 0.015 0.24 0.06 0.3 25 OUTLET + +[INFILTRATION] +;;Subcatchment Param1 Param2 Param3 Param4 Param5 +;;-------------- ---------- ---------- ---------- ---------- ---------- +S1 4.5 0.2 6.5 7 0 +S2 4.5 0.2 6.5 7 0 +S3 4.5 0.2 6.5 7 0 +S4 4.5 0.2 6.5 7 0 +S5 4.5 0.2 6.5 7 0 +S6 4.5 0.2 6.5 7 0 +S7 4.5 0.2 6.5 7 0 + +[JUNCTIONS] +;;Name Elevation MaxDepth InitDepth SurDepth Aponded +;;-------------- ---------- ---------- ---------- ---------- ---------- +Aux1 4975 0 0 0 0 +Aux2 4973 0 0 0 0 +Aux3 4968.5 0 0 0 0 +Aux4 4971.8 0 0 0 0 +Aux5 4970.7 0 0 0 0 +Aux6 4969 0 0 0 0 +Aux7 4963 0 0 0 0 +J1 4969 4 0 0 0 +J10 4957.8 0 0 0 0 +J11 4957 0 0 0 0 +J2 4965 4 0 0 0 +J2a 4966.7 4 0 0 0 +J3 4973 0 0 0 0 +J4 4965 0 0 0 0 +J5 4965.8 0 0 0 0 +J6 4969 0 0 0 0 +J7 4963.5 0 0 0 0 +J8 4966.5 0 0 0 0 +J9 4964.8 0 0 0 0 + +[OUTFALLS] +;;Name Elevation Type Stage Data Gated Route To +;;-------------- ---------- ---------- ---------------- -------- ---------------- +O1 4956 FREE NO + +[CONDUITS] +;;Name From Node To Node Length Roughness InOffset OutOffset InitFlow MaxFlow +;;-------------- ---------------- ---------------- ---------- ---------- ---------- ---------- ---------- ---------- +Street1 Aux1 Aux2 377.31 0.016 0 0 0 0 +Street2 Aux2 Aux4 286.06 0.016 0 0 0 0 +Street3 Aux4 Aux5 239.41 0.016 0 0 0 0 +Street4 Aux5 Aux6 157.48 0.016 0 0 0 0 +Street5 Aux6 Aux7 526.0 0.016 0 0 0 0 +C3 J3 J4 109.0 0.016 0 6 0 0 +C4 J4 J5 133.0 0.05 6 4 0 0 +C5 J5 J6 207.0 0.05 4 0 0 0 +C6 J7 J6 140.0 0.05 8 0 0 0 +C7 J6 J8 95.0 0.016 0 0 0 0 +C8 J8 J9 166.0 0.05 0 0 0 0 +C9 J9 J10 320.0 0.05 0 6 0 0 +C10 J10 J11 145.0 0.05 6 6 0 0 +C11 J11 O1 89.0 0.016 0 0 0 0 +C_Aux3 Aux3 J3 444.75 0.05 6 0 0 0 +P1 J1 J5 185.39 0.016 0 0 0 0 +P2 J2a J2 157.48 0.016 0 0 0 0 +P3 J2 J11 529.22 0.016 0 0 0 0 +P4 Aux3 J4 567.19 0.016 0 0 0 0 +P5 J5 J4 125.98 0.016 0 0 0 0 +P6 J4 J7 360.39 0.016 0 0 0 0 +P7 J7 J10 507.76 0.016 0 0 0 0 +P8 J10 J11 144.50 0.016 0 0 0 0 + +[XSECTIONS] +;;Link Shape Geom1 Geom2 Geom3 Geom4 Barrels Culvert +;;-------------- ------------ ---------------- ---------- ---------- ---------- ---------- ---------- +Street1 STREET FullStreet +Street2 STREET FullStreet +Street3 STREET FullStreet +Street4 STREET HalfStreet +Street5 STREET HalfStreet +C3 CIRCULAR 2.25 0 0 0 1 +C4 TRAPEZOIDAL 3 5 5 5 1 +C5 TRAPEZOIDAL 3 5 5 5 1 +C6 TRAPEZOIDAL 3 5 5 5 1 +C7 CIRCULAR 3.5 0 0 0 1 +C8 TRAPEZOIDAL 3 5 5 5 1 +C9 TRAPEZOIDAL 3 5 5 5 1 +C10 TRAPEZOIDAL 3 5 5 5 1 +C11 CIRCULAR 4.75 0 0 0 1 +C_Aux3 TRAPEZOIDAL 3 5 5 5 1 +P1 CIRCULAR 0.5 0 0 0 1 +P2 CIRCULAR 1.5 0 0 0 1 +P3 CIRCULAR 1.5 0 0 0 1 +P4 CIRCULAR 1.67 0 0 0 1 +P5 CIRCULAR 1.83 0 0 0 1 +P6 CIRCULAR 2 0 0 0 1 +P7 CIRCULAR 2 0 0 0 1 +P8 CIRCULAR 3.17 0 0 0 1 + +[STREETS] +;;Name Tcrown Hcurb Sx nRoad a W Sides Tback Sback nBack +;;-------------- -------- -------- -------- -------- -------- -------- -------- -------- -------- -------- +HalfStreet 20 0.5 4 0.016 0 0 1 20 4 0.016 +FullStreet 20 0.5 4 0.016 0 0 2 20 4 0.016 + +[INLETS] +;;Name Type Parameters: +;;-------------- ---------------- ----------- +ComboInlet GRATE 2 2 P_BAR-50 +ComboInlet CURB 2 0.5 HORIZONTAL + +[INLET_USAGE] +;;Conduit Inlet Node Number %Clogged Qmax aLocal wLocal Placement +;;-------------- ---------------- ---------------- --------- --------- --------- --------- --------- --------- --------- +Street1 ComboInlet J1 1 50 2.2 0.5 2 +Street3 ComboInlet J2a 1 0 0 0 0 +Street4 ComboInlet J2 1 0 0 0 0 +Street5 ComboInlet J11 2 0 0 0 0 + +[TIMESERIES] +;;Name Date Time Value +;;-------------- ---------- ---------- ---------- +2-yr 0:00 0.29 +2-yr 0:05 0.33 +2-yr 0:10 0.38 +2-yr 0:15 0.64 +2-yr 0:20 0.81 +2-yr 0:25 1.57 +2-yr 0:30 2.85 +2-yr 0:35 1.18 +2-yr 0:40 0.71 +2-yr 0:45 0.42 +2-yr 0:50 0.35 +2-yr 0:55 0.3 +2-yr 1:00 0.2 +2-yr 1:05 0.19 +2-yr 1:10 0.18 +2-yr 1:15 0.17 +2-yr 1:20 0.17 +2-yr 1:25 0.16 +2-yr 1:30 0.15 +2-yr 1:35 0.15 +2-yr 1:40 0.14 +2-yr 1:45 0.14 +2-yr 1:50 0.13 +2-yr 1:55 0.13 +; +10-yr 0:00 0.49 +10-yr 0:05 0.56 +10-yr 0:10 0.65 +10-yr 0:15 1.09 +10-yr 0:20 1.39 +10-yr 0:25 2.69 +10-yr 0:30 4.87 +10-yr 0:35 2.02 +10-yr 0:40 1.21 +10-yr 0:45 0.71 +10-yr 0:50 0.6 +10-yr 0:55 0.52 +10-yr 1:00 0.39 +10-yr 1:05 0.37 +10-yr 1:10 0.35 +10-yr 1:15 0.34 +10-yr 1:20 0.32 +10-yr 1:25 0.31 +10-yr 1:30 0.3 +10-yr 1:35 0.29 +10-yr 1:40 0.28 +10-yr 1:45 0.27 +10-yr 1:50 0.26 +10-yr 1:55 0.25 + +[REPORT] +;;Reporting Options +INPUT YES +SUBCATCHMENTS ALL +NODES ALL +LINKS ALL + +[TAGS] +Link Street1 Full_Street +Link Street2 Full_Street +Link Street3 Full_Street +Link Street4 Half_Street +Link Street5 Half_Street +Link C3 Culvert +Link C4 Swale +Link C5 Swale +Link C6 Swale +Link C7 Culvert +Link C8 Swale +Link C9 Swale +Link C10 Swale +Link C11 Culvert +Link C_Aux3 Swale + +[MAP] +DIMENSIONS -255.206 -70.199 1490.833 1514.231 +Units Feet + +[COORDINATES] +;;Node X-Coord Y-Coord +;;-------------- ------------------ ------------------ +Aux1 293.152 1161.023 +Aux2 653.046 1052.180 +Aux3 122.363 696.959 +Aux4 914.142 1058.025 +Aux5 1175.238 1120.376 +Aux6 1260.972 956.704 +Aux7 1381.777 514.399 +J1 647.200 1022.952 +J10 1254.058 640.029 +J11 1270.714 491.017 +J2 1218.105 950.859 +J2a 1159.651 1069.716 +J3 405.287 905.702 +J4 505.345 862.573 +J5 631.281 859.123 +J6 803.079 869.022 +J7 831.398 709.035 +J8 915.930 840.146 +J9 1072.918 867.749 +O1 1411.468 477.401 + +[VERTICES] +;;Link X-Coord Y-Coord +;;-------------- ------------------ ------------------ +Street1 382.860 1112.719 +Street1 514.703 1061.922 +Street2 806.976 1042.437 +Street3 1062.227 1091.149 +Street4 1210.311 1061.922 +Street5 1338.911 781.341 +Street5 1387.623 662.483 +Street5 1393.468 586.493 +C4 559.710 846.393 +C5 672.684 850.497 +C5 712.363 829.795 +C5 743.415 805.643 +C5 768.006 833.950 +C6 791.719 734.912 +C6 798.620 784.942 +C8 965.959 838.421 +C8 995.287 831.520 +C8 1038.415 850.497 +C9 1102.246 867.749 +C9 1131.573 852.222 +C9 1147.099 829.795 +C9 1162.626 809.094 +C9 1198.854 779.766 +C9 1219.556 757.339 +C9 1233.357 721.111 +C9 1238.532 715.936 +C9 1235.082 674.532 +C9 1247.158 646.930 +C_Aux3 163.003 699.992 +C_Aux3 208.620 726.287 +C_Aux3 239.673 793.567 +C_Aux3 251.749 876.374 +C_Aux3 291.427 912.602 +C_Aux3 355.257 929.854 +P3 1331.117 691.711 +P3 1329.168 590.390 +P4 275.901 572.749 +P4 472.567 824.620 +P7 886.602 800.468 + +[Polygons] +;;Subcatchment X-Coord Y-Coord +;;-------------- ------------------ ------------------ +S1 282.657 1334.810 +S1 111.700 1101.604 +S1 172.525 1062.743 +S1 231.660 1027.262 +S1 306.002 990.092 +S1 370.206 959.679 +S1 409.066 946.163 +S1 444.547 936.025 +S1 493.545 924.198 +S1 532.405 915.750 +S1 569.576 907.302 +S1 610.125 897.165 +S1 655.744 897.165 +S1 684.338 1318.700 +S1 651.043 1321.922 +S1 596.269 1332.662 +S1 551.160 1346.624 +S1 495.312 1367.030 +S1 455.573 1384.214 +S1 410.465 1409.991 +S1 386.836 1427.175 +S1 363.208 1442.211 +S2 678.967 1238.149 +S2 673.584 1152.903 +S2 655.744 897.165 +S2 758.808 893.786 +S2 817.943 895.475 +S2 880.458 898.855 +S2 921.007 905.613 +S2 978.453 920.819 +S2 1042.657 937.715 +S2 1103.482 959.679 +S2 1159.238 985.023 +S2 1225.131 1010.367 +S2 1109.646 1274.665 +S2 1052.723 1400.325 +S2 985.061 1370.252 +S2 924.916 1348.772 +S2 861.549 1331.588 +S2 815.367 1325.144 +S2 762.740 1319.774 +S2 719.780 1316.552 +S2 684.338 1317.626 +S3 109.199 1103.258 +S3 141.754 1081.555 +S3 190.586 1051.713 +S3 247.557 1019.158 +S3 304.528 989.317 +S3 354.716 964.900 +S3 398.123 949.980 +S3 490.166 922.509 +S3 477.743 883.275 +S3 501.993 816.065 +S3 556.059 778.895 +S3 488.476 679.210 +S3 422.582 729.897 +S3 282.348 557.560 +S3 179.734 633.927 +S3 153.962 651.561 +S3 107.843 693.610 +S3 71.218 742.443 +S3 48.159 785.849 +S3 31.881 837.394 +S3 29.168 886.226 +S3 31.881 933.702 +S3 38.664 967.613 +S3 50.872 1001.525 +S3 65.793 1035.436 +S3 87.496 1070.704 +S3 109.199 1103.258 +S4 282.348 559.250 +S4 420.893 729.897 +S4 488.476 680.899 +S4 556.828 779.067 +S4 501.213 814.335 +S4 479.468 885.000 +S4 491.718 922.851 +S4 616.511 898.434 +S4 668.056 897.078 +S4 783.355 895.722 +S4 815.909 898.434 +S4 857.959 899.791 +S4 890.595 897.165 +S4 968.316 915.750 +S4 1042.657 937.715 +S4 1074.759 849.857 +S4 1054.484 773.826 +S4 1020.692 702.864 +S4 963.247 623.454 +S4 689.536 256.816 +S5 1301.482 474.258 +S5 1271.677 445.380 +S5 1232.340 393.835 +S5 1241.835 384.340 +S5 1222.844 366.706 +S5 1233.696 355.854 +S5 1026.159 66.931 +S5 1008.525 56.079 +S5 708.750 275.824 +S5 1023.446 704.462 +S5 1150.644 618.812 +S5 1251.203 640.809 +S5 1328.193 519.824 +S6 1334.478 519.824 +S6 1306.266 488.956 +S6 1293.380 474.205 +S6 1232.340 393.835 +S6 1241.835 381.627 +S6 1222.844 365.350 +S6 1232.340 353.142 +S6 1027.516 65.574 +S6 1012.595 56.079 +S6 707.393 273.111 +S6 688.403 254.121 +S6 739.948 218.853 +S6 788.780 159.169 +S6 806.414 106.268 +S6 813.197 1.821 +S6 994.961 12.673 +S6 1228.270 27.594 +S6 1222.844 115.763 +S6 1228.270 167.308 +S6 1241.835 229.705 +S6 1255.399 254.121 +S6 1279.815 302.953 +S6 1309.657 354.498 +S6 1335.430 401.974 +S6 1359.846 448.093 +S6 1370.616 475.830 +S6 1381.615 491.542 +S7 1122.467 968.970 +S7 1174.012 987.282 +S7 1225.557 1005.594 +S7 1377.480 675.977 +S7 1391.044 642.065 +S7 1396.470 598.659 +S7 1381.615 491.542 +S7 1331.336 519.824 +S7 1249.632 640.809 +S7 1150.644 617.241 +S7 1020.733 704.462 +S7 1054.645 772.285 +S7 1076.796 848.212 +S7 1056.370 900.062 +S7 1040.658 937.772 + +[SYMBOLS] +;;Gage X-Coord Y-Coord +;;-------------- ------------------ ------------------ +RainGage -175.841 1212.778 + +[LABELS] +;;X-Coord Y-Coord Label +145.274 1129.896 "S1" "" "Arial" 14 0 0 +758.404 969.723 "S2" "" "Arial" 14 0 0 +247.369 666.226 "S3" "" "Arial" 14 0 0 +628.971 458.688 "S4" "" "Arial" 14 0 0 +952.552 257.845 "S5" "" "Arial" 14 0 0 +827.947 56.930 "S6" "" "Arial" 14 0 0 +1073.058 780.037 "S7" "" "Arial" 14 0 0 +1385.481 454.225 "Outfall" "" "Arial" 10 1 0 + diff --git a/swmm-toolkit/tests/test_solver.py b/swmm-toolkit/tests/test_solver.py index 992fbe41..6fcec9a9 100644 --- a/swmm-toolkit/tests/test_solver.py +++ b/swmm-toolkit/tests/test_solver.py @@ -24,6 +24,9 @@ INPUT_FILE_EXAMPLE_3 = os.path.join(DATA_PATH, 'test_Example3.inp') REPORT_FILE_TEST_3 = os.path.join(DATA_PATH, 'temp_Example3.rpt') OUTPUT_FILE_TEST_3 = os.path.join(DATA_PATH, 'temp_Example3.out') +INPUT_FILE_INLET = os.path.join(DATA_PATH, 'test_inlet_drains.inp') +REPORT_FILE_INLET = os.path.join(DATA_PATH, 'temp_inlet_drains.rpt') +OUTPUT_FILE_INLET = os.path.join(DATA_PATH, 'temp_inlet_drains.out') INPUT_FILE_FAIL = os.path.join(DATA_PATH, 'temp_nodata.inp') @@ -86,6 +89,27 @@ def close(): request.addfinalizer(close) +@pytest.fixture() +def inlet_handle(request): + solver.swmm_open(INPUT_FILE_INLET, REPORT_FILE_INLET, OUTPUT_FILE_INLET) + + + def close(): + solver.swmm_close() + + request.addfinalizer(close) + +@pytest.fixture() +def run_inlet_sim(request): + solver.swmm_open(INPUT_FILE_INLET, REPORT_FILE_INLET, OUTPUT_FILE_INLET) + solver.swmm_start(0) + + def close(): + solver.swmm_end() + solver.swmm_close() + + request.addfinalizer(close) + @pytest.fixture() def run_pollut_sim(request): solver.swmm_open(INPUT_FILE_EXAMPLE_3, REPORT_FILE_TEST_3, OUTPUT_FILE_TEST_3) @@ -109,6 +133,19 @@ def test_step(handle): solver.swmm_end() solver.swmm_report() +def test_stride(handle): + solver.swmm_start(0) + steps = 0 + while True: + time = solver.swmm_stride(60 * 60) + steps+=1 + if time == 0: + break + + solver.swmm_end() + solver.swmm_report() + # advancing a 36 hour simulation hourly should yeild 36 steps + assert steps == 36 def test_version(handle): major, minor, patch = solver.swmm_version_info().split('.') @@ -761,3 +798,38 @@ def test_gage_precipitation(run_sim): assert total == 1.0 assert snowfall == 0.0 assert rainfall == 1.0 + + + +def test_inlet_error(inlet_handle): + with pytest.raises(Exception) as e: + index = solver.project_get_index(shared_enum.ObjectType.LINK,"C3") + clogged = solver.inlet_get_parameter(index, shared_enum.InletProperty.CLOG_FACTOR) + assert "Specified link is not assigned an inlet" in str(e.value) + + +def test_inlet_clogging(inlet_handle): + index = solver.project_get_index(shared_enum.ObjectType.LINK,"Street1") + + num_inlets = solver.inlet_get_parameter(index, shared_enum.InletProperty.NUM_INLETS) + assert num_inlets == 1 + + clogged = solver.inlet_get_parameter(index, shared_enum.InletProperty.CLOG_FACTOR) + assert clogged == 50 + + solver.inlet_set_parameter(index, shared_enum.InletProperty.CLOG_FACTOR,0) + clogged = solver.inlet_get_parameter(index, shared_enum.InletProperty.CLOG_FACTOR) + assert clogged == 0 + + flow_limit = solver.inlet_get_parameter(index, shared_enum.InletProperty.FLOW_LIMIT) + assert flow_limit == 2.2 + + solver.inlet_set_parameter(index, shared_enum.InletProperty.FLOW_LIMIT,5.5) + flow_limit = solver.inlet_get_parameter(index, shared_enum.InletProperty.FLOW_LIMIT) + assert flow_limit == 5.5 + + dep_height = solver.inlet_get_parameter(index, shared_enum.InletProperty.DEPRESSION_HEIGHT) + assert dep_height == 0.5 + + dep_width = solver.inlet_get_parameter(index, shared_enum.InletProperty.DEPRESSION_WIDTH) + assert dep_width == 2 \ No newline at end of file