Example #1
0
def test_ConstantRemoval_load():
    dict1 = {'Tank': {0: 0.5}}
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./inps/tank_variableinflow_notreatment.inp") as sim:
        CR = Node_Quality(sim, dict1)
        Outfall = Nodes(sim)["Outfall"]
        for step in sim:
            CR.ConstantRemoval()
            c = Outfall.pollut_quality
            conc.append(c['P1'])
            flow.append(sim._model.getNodeResult("Outfall", 0))
        load = [a * b for a, b in zip(conc, flow)]
        cum_load = np.cumsum(load)
    with Simulation("./inps/tank_variableinflow_constantremoval.inp") as sim:
        Outfall = Nodes(sim)["Outfall"]
        for step in sim:
            c = Outfall.pollut_quality
            conc1.append(c['P1'])
            flow1.append(sim._model.getNodeResult("Outfall", 0))
        load1 = [a * b for a, b in zip(conc1, flow1)]
        cum_load1 = np.cumsum(load1)
    error = (cum_load1[-1] / cum_load[-1]) / cum_load1[-1]
    print(error)
    assert error <= 0.03
Example #2
0
def test_CSTR_load():
    dict1 = {'Tank': {0: [-0.2, 1.0, 0.0]}}
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./inps/tank_constantinflow_notreatment.inp") as sim:
        CS = Node_Quality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        Valve = Links(sim)["Valve"]
        for index, step in enumerate(sim):
            CS.CSTR_solver(index)
            c = Tank.pollut_quality
            conc.append(c['P1'])
            c1 = Valve.pollut_quality
            conc1.append(c1['P1'])
            flow.append(sim._model.getNodeResult("Tank", 0))
            flow1.append(sim._model.getLinkResult("Valve", 0))
        load = [a * b for a, b in zip(conc, flow)]
        cum_load = np.cumsum(load)
        load1 = [a * b for a, b in zip(conc1, flow1)]
        cum_load1 = np.cumsum(load1)
    error = (cum_load1[-1] / cum_load[-1]) / cum_load1[-1]
    print(error)
    assert error <= 0.03
Example #3
0
def test_CSTR_steadystate():
    dict1 = {'Tank': {0: [-0.2, 1.0, 0.0]}}
    conc = []
    with Simulation("./inps/tank_constantinflow_notreatment.inp") as sim:
        CS = Node_Quality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for index, step in enumerate(sim):
            CS.CSTR_solver(index)
            c = Tank.pollut_quality
            conc.append(c['P1'])
    C_steadystate = 10.0 / (1 + (0.2 / (5 / 127)))
    print(C_steadystate)
    error = (C_steadystate - conc[-1]) / C_steadystate
    print(error)
    assert error <= 0.03
Example #4
0
def test_ConstantRemoval_conc():
    dict1 = {'Tank': {0: 0.5}}
    conc = []
    con = []
    with Simulation("./inps/tank_variableinflow_notreatment.inp") as sim:
        CR = Node_Quality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            CR.ConstantRemoval()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation("./inps/tank_variableinflow_constantremoval.inp") as sim:
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            co = Tank.pollut_quality
            con.append(co['P1'])
    error = mse(con, conc[1:])
    print(error)
    assert error <= 0.03
Example #5
0
def test_GravitySettling_conc():
    dict1 = {'Tank': {0: [0.01, 10.0]}}
    conc = []
    con = []
    with Simulation("./inps/tank_variableinflow_notreatment.inp") as sim:
        GS = Node_Quality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            GS.GravitySettling()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation("./inps/tank_variableinflow_gravsettling.inp") as sim:
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            co = Tank.pollut_quality
            con.append(co['P1'])
        error = mse(con, conc[1:])
        print(error)
        assert error <= 0.03
Example #6
0
def test_EventMeanConc_conc():
    dict1 = {'Tank': {0: 5.0}}
    conc = []
    con = []
    with Simulation("./inps/tank_variableinflow_notreatment.inp") as sim:
        EMC = Node_Quality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            EMC.EventMeanConc()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation("./inps/tank_variableinflow_emc.inp") as sim:
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            co = Tank.pollut_quality
            con.append(co['P1'])
    error = mse(con, conc)
    print(error)
    assert error <= 0.03
Example #7
0
def test_NthOrderReaction_conc():
    dict1 = {'Tank': {0: [0.01, 2.0]}}
    conc = []
    con = []
    with Simulation("./inps/tank_variableinflow_notreatment.inp") as sim:
        NOR = Node_Quality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            NOR.NthOrderReaction()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation("./inps/tank_variableinflow_nthorderreaction.inp") as sim:
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            co = Tank.pollut_quality
            con.append(co['P1'])
    error = mse(con, conc[1:])
    print(error)
    assert error <= 0.03
Example #8
0
def test_CoRemoval_conc():
    dict1 = {'Tank': {0: [0.75, 0.15]}}
    dict2 = {'Tank': {1: 0.15}}
    conc_P1 = []
    con_P1 = []
    with Simulation("./inps/tank_variableinflow_notreatment2.inp") as sim:
        CO = Node_Quality(sim, dict1)
        CR = Node_Quality(sim, dict2)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            CR.ConstantRemoval()
            CO.CoRemoval()
            c = Tank.pollut_quality
            conc_P1.append(c['P1'])
    with Simulation("./inps/tank_variableinflow_coremoval.inp") as sim:
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            co = Tank.pollut_quality
            con_P1.append(co['P1'])
    error = mse(con_P1, conc_P1[1:])
    print(error)
    assert error <= 0.03
Example #9
0
Wetland_depth = []
Wetland_flooding = []
Wetland_outflow = []
Wetland_cumload = []
Wtlnd_bp_inflows = []

Channel_flow = []
Channel_conc = []
Cannel_cuminload = []
Channel_depth = []
Channel_cumload = []

# Setup toolbox simulation
with Simulation("./modifiedMBDoyle_TSS_V2.inp") as sim:
    # Setup toolbox methods
    GS = Node_Quality(sim, dict1)
    ER_GS = Link_Quality(sim, dict2)

    # Get asset information
    Ellsworth = Nodes(sim)["93-50408"]
    DBasin = Nodes(sim)["93-50404"]
    Wetland = Nodes(sim)["93-49759"]
    Wtlnd_bypass = Links(sim)["95-70294"]
    Channel = Links(sim)["95-70277"]

    # Step through the simulation
    for index, step in enumerate(sim):

        # Calculate gravity settling in basins
        GS.GravitySettling()
        # Calculate erosion andn gravity settling in channels