Beispiel #1
0
def test_system_runoff_routing():
    with Simulation(MODEL_WEIR_SETTING_PATH) as sim:
        stats = SystemStats(sim)

        print("\n\nRunoff Routing\n\n")
        print(stats.runoff_stats)

        sim.step_advance(1200)
        for ind, step in enumerate(sim):
            print(stats.runoff_stats)
Beispiel #2
0
def test_system_flow_routing():
    with Simulation(MODEL_WEIR_SETTING_PATH) as sim:
        stats = SystemStats(sim)

        print("\n\n\System\n")
        with pytest.raises(SWMMException):
            print(stats.routing_stats)

        sim.step_advance(1200)
        for ind, step in enumerate(sim):
            print(stats.routing_stats)
Beispiel #3
0
def test_rainfall():
    with Simulation(MODEL_RAIN) as sim:
        rg = RainGages(sim)["Gage1"]
        assert (rg.raingageid == "Gage1")

        sim.step_advance(3600)
        for ind, step in enumerate(sim):
            if 0 < ind < 5:
                assert (rg.total_precip == 1)
                assert (rg.rainfall == 1)
                assert (rg.snowfall == 0)

            if ind == 5:
                rg.total_precip = 10

            if ind >= 6:
                assert (int(rg.total_precip) == 10)
                assert (int(rg.rainfall) == 10)
                assert (int(rg.snowfall) == 0)

        stats = SystemStats(sim)
        assert (int(stats.runoff_stats['rainfall']) == 65)
Beispiel #4
0
def swmm(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16,
         x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30,
         x31, x32, x33, x34, x35, x36, x37, x38, x39, x40):
    # from pyswmm import Simulation, SystemStats, LidControls, LidGroups, Subcatchments, Nodes
    # 输入SWMM的input文件(路径)——交互输入
    with Simulation(filename1) as sim:
        system_routing = SystemStats(sim)
        node_object = Nodes(sim)
        # 选择规模变化的LID设施——交互输入,比如Out1=xxx(xxx为SWMM模型中outfall的name),
        # lid1=Sn(Sn为LID规模变化的subcatchment的name),lid2=Sm....
        # 最好设计成可以用户添加的交互,比如用户可以添加一个LID,也可以添加多个
        Out1 = node_object["Out1"]
        lid1 = LidGroups(sim)["S1"]
        lid9 = LidGroups(sim)["S9"]
        lid13 = LidGroups(sim)["S13"]
        lid19 = LidGroups(sim)["S19"]
        lid22 = LidGroups(sim)["S22"]
        lid24 = LidGroups(sim)["S24"]
        lid25 = LidGroups(sim)["S25"]
        lid87 = LidGroups(sim)["S87"]
        lid92 = LidGroups(sim)["S92"]
        lid93 = LidGroups(sim)["S93"]
        lid94 = LidGroups(sim)["S94"]
        lid95 = LidGroups(sim)["S95"]
        lid96 = LidGroups(sim)["S96"]
        lid99 = LidGroups(sim)["S99"]
        lid130 = LidGroups(sim)["S130"]
        lid64 = LidGroups(sim)["S64"]
        lid66 = LidGroups(sim)["S66"]
        lid108 = LidGroups(sim)["S108"]
        lid106 = LidGroups(sim)["S106"]
        lid110 = LidGroups(sim)["S110"]
        lid60 = LidGroups(sim)["S60"]
        lid112 = LidGroups(sim)["S112"]
        lid100 = LidGroups(sim)["S100"]
        lid107 = LidGroups(sim)["S107"]
        lid109 = LidGroups(sim)["S109"]
        lid14 = LidGroups(sim)["S14"]
        lid81 = LidGroups(sim)["S81"]
        lid4 = LidGroups(sim)["S4"]
        lid91 = LidGroups(sim)["S91"]
        lid15 = LidGroups(sim)["S15"]
        lid17 = LidGroups(sim)["S17"]
        lid18 = LidGroups(sim)["S18"]
        lid6 = LidGroups(sim)["S6"]
        lid12 = LidGroups(sim)["S12"]
        lid16 = LidGroups(sim)["S16"]
        lid11 = LidGroups(sim)["S11"]
        lid117 = LidGroups(sim)["S117"]
        lid101 = LidGroups(sim)["S101"]
        lid86 = LidGroups(sim)["S86"]
        lid50 = LidGroups(sim)["S50"]

        # 定义每个可变规模的LID的面积——内部运算(基于上述输入的可变规模的LID)
        for lid in lid1:
            lid.unit_area = x1
        for lid in lid9:
            lid.unit_area = x2
        for lid in lid13:
            lid.unit_area = x3
        for lid in lid19:
            lid.unit_area = x4
        for lid in lid22:
            lid.unit_area = x5
        for lid in lid24:
            lid.unit_area = x6
        for lid in lid25:
            lid.unit_area = x7
        for lid in lid87:
            lid.unit_area = x8
        for lid in lid92:
            lid.unit_area = x9
        for lid in lid93:
            lid.unit_area = x10
        for lid in lid94:
            lid.unit_area = x11
        for lid in lid95:
            lid.unit_area = x12
        for lid in lid96:
            lid.unit_area = x13
        for lid in lid99:
            lid.unit_area = x14
        for lid in lid130:
            lid.unit_area = x15
        for lid in lid64:
            lid.unit_area = x16
        for lid in lid66:
            lid.unit_area = x17
        for lid in lid108:
            lid.unit_area = x18
        for lid in lid106:
            lid.unit_area = x19
        for lid in lid110:
            lid.unit_area = x20
        for lid in lid60:
            lid.unit_area = x21
        for lid in lid112:
            lid.unit_area = x22
        for lid in lid100:
            lid.unit_area = x23
        for lid in lid107:
            lid.unit_area = x24
        for lid in lid109:
            lid.unit_area = x25
        for lid in lid14:
            lid.unit_area = x26
        for lid in lid81:
            lid.unit_area = x27
        for lid in lid4:
            lid.unit_area = x28
        for lid in lid91:
            lid.unit_area = x29
        for lid in lid15:
            lid.unit_area = x30
        for lid in lid17:
            lid.unit_area = x31
        for lid in lid18:
            lid.unit_area = x32
        for lid in lid6:
            lid.unit_area = x33
        for lid in lid12:
            lid.unit_area = x34
        for lid in lid16:
            lid.unit_area = x35
        for lid in lid11:
            lid.unit_area = x36
        for lid in lid117:
            lid.unit_area = x37
        for lid in lid101:
            lid.unit_area = x38
        for lid in lid86:
            lid.unit_area = x39
        for lid in lid50:
            lid.unit_area = x40
        for step in sim:
            pass
        y = round((Out1.cumulative_inflow * 7.47 * 0.0037854 / 1261), 6)
    return y
Beispiel #5
0
def pollutant(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15,
              x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28,
              x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x40):
    #from pyswmm import Simulation, SystemStats, LidControls, LidGroups, Subcatchments, Nodes
    #和上面是同一个路径的input文件
    with Simulation(filename1) as sim:
        system_routing = SystemStats(sim)
        node_object = Nodes(sim)
        #和上面同样定义的各个LID
        Out1 = node_object["Out1"]
        lid1 = LidGroups(sim)["S1"]
        lid9 = LidGroups(sim)["S9"]
        lid13 = LidGroups(sim)["S13"]
        lid19 = LidGroups(sim)["S19"]
        lid22 = LidGroups(sim)["S22"]
        lid24 = LidGroups(sim)["S24"]
        lid25 = LidGroups(sim)["S25"]
        lid87 = LidGroups(sim)["S87"]
        lid92 = LidGroups(sim)["S92"]
        lid93 = LidGroups(sim)["S93"]
        lid94 = LidGroups(sim)["S94"]
        lid95 = LidGroups(sim)["S95"]
        lid96 = LidGroups(sim)["S96"]
        lid99 = LidGroups(sim)["S99"]
        lid130 = LidGroups(sim)["S130"]
        lid64 = LidGroups(sim)["S64"]
        lid66 = LidGroups(sim)["S66"]
        lid108 = LidGroups(sim)["S108"]
        lid106 = LidGroups(sim)["S106"]
        lid110 = LidGroups(sim)["S110"]
        lid60 = LidGroups(sim)["S60"]
        lid112 = LidGroups(sim)["S112"]
        lid100 = LidGroups(sim)["S100"]
        lid107 = LidGroups(sim)["S107"]
        lid109 = LidGroups(sim)["S109"]
        lid14 = LidGroups(sim)["S14"]
        lid81 = LidGroups(sim)["S81"]
        lid4 = LidGroups(sim)["S4"]
        lid91 = LidGroups(sim)["S91"]
        lid15 = LidGroups(sim)["S15"]
        lid17 = LidGroups(sim)["S17"]
        lid18 = LidGroups(sim)["S18"]
        lid6 = LidGroups(sim)["S6"]
        lid12 = LidGroups(sim)["S12"]
        lid16 = LidGroups(sim)["S16"]
        lid11 = LidGroups(sim)["S11"]
        lid117 = LidGroups(sim)["S117"]
        lid101 = LidGroups(sim)["S101"]
        lid86 = LidGroups(sim)["S86"]
        lid50 = LidGroups(sim)["S50"]
        #根据上面输入的LID进行内部运算
        for lid in lid1:
            lid.unit_area = x1
        for lid in lid9:
            lid.unit_area = x2
        for lid in lid13:
            lid.unit_area = x3
        for lid in lid19:
            lid.unit_area = x4
        for lid in lid22:
            lid.unit_area = x5
        for lid in lid24:
            lid.unit_area = x6
        for lid in lid25:
            lid.unit_area = x7
        for lid in lid87:
            lid.unit_area = x8
        for lid in lid92:
            lid.unit_area = x9
        for lid in lid93:
            lid.unit_area = x10
        for lid in lid94:
            lid.unit_area = x11
        for lid in lid95:
            lid.unit_area = x12
        for lid in lid96:
            lid.unit_area = x13
        for lid in lid99:
            lid.unit_area = x14
        for lid in lid130:
            lid.unit_area = x15
        for lid in lid64:
            lid.unit_area = x16
        for lid in lid66:
            lid.unit_area = x17
        for lid in lid108:
            lid.unit_area = x18
        for lid in lid106:
            lid.unit_area = x19
        for lid in lid110:
            lid.unit_area = x20
        for lid in lid60:
            lid.unit_area = x21
        for lid in lid112:
            lid.unit_area = x22
        for lid in lid100:
            lid.unit_area = x23
        for lid in lid107:
            lid.unit_area = x24
        for lid in lid109:
            lid.unit_area = x25
        for lid in lid14:
            lid.unit_area = x26
        for lid in lid81:
            lid.unit_area = x27
        for lid in lid4:
            lid.unit_area = x28
        for lid in lid91:
            lid.unit_area = x29
        for lid in lid15:
            lid.unit_area = x30
        for lid in lid17:
            lid.unit_area = x31
        for lid in lid18:
            lid.unit_area = x32
        for lid in lid6:
            lid.unit_area = x33
        for lid in lid12:
            lid.unit_area = x34
        for lid in lid16:
            lid.unit_area = x35
        for lid in lid11:
            lid.unit_area = x36
        for lid in lid117:
            lid.unit_area = x37
        for lid in lid101:
            lid.unit_area = x38
        for lid in lid86:
            lid.unit_area = x39
        for lid in lid50:
            lid.unit_area = x40
        for step in sim:
            pass
        data = Out1.outfall_statistics
        a = data.get("pollutant_loading")
        data = a
        b = float(data["SS"])
        c = round(b / 13.9258, 6)
    return c