Ejemplo n.º 1
0
def test_CoRemoval_load():
    dict1 = {'Culvert': {'pollutant': 1, 'method': 'ConstantRemoval', 'parameters': {'R': 0.15}},\
        'Culvert': {'pollutant': 0, 'method': 'CoRemoval', 'parameters': {'R1': 0.75, 'R2': 0.15}},
        }
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/LinkTest_variableinflow2.inp") as sim:
        CR = waterQuality(sim, dict1)
        culvert = Links(sim)["Culvert"]
        outlet = Nodes(sim)["Outlet"]
        for step in sim:
            CR.updateWQState()
            c = culvert.pollut_quality
            conc.append(c['P1'])
            c1 = outlet.pollut_quality
            conc1.append(c1['P1'])
            flow.append(sim._model.getLinkResult("Culvert", 0))
            flow1.append(sim._model.getNodeResult("Outlet", 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
Ejemplo n.º 2
0
def test_GravitySettling_load():
    dict1 = {
        'Culvert': {
            'pollutant': 0,
            'method': 'GravitySettling',
            'parameters': {
                'k': 0.01,
                'C_s': 10.0
            }
        }
    }
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/LinkTest_variableinflow.inp") as sim:
        GS = waterQuality(sim, dict1)
        culvert = Links(sim)["Culvert"]
        outlet = Nodes(sim)["Outlet"]
        for step in sim:
            GS.updateWQState()
            c = culvert.pollut_quality
            conc.append(c['P1'])
            c1 = outlet.pollut_quality
            conc1.append(c1['P1'])
            flow.append(sim._model.getLinkResult("Culvert", 0))
            flow1.append(sim._model.getNodeResult("Outlet", 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
Ejemplo n.º 3
0
def test_CSTR_steadystate():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'CSTR',
            'parameters': {
                'k': -0.2,
                'n': 1.0,
                'c0': 10.0
            }
        }
    }
    conc2 = []
    vol = []
    flow = []
    with Simulation("./tests/inps/tank_constantinflow_notreatment.inp") as sim:
        Tank = Nodes(sim)["Tank"]
        for index, step in enumerate(sim):
            v = Tank.volume
            vol.append(v)
            q = Tank.total_inflow
            flow.append(q)
    with Simulation("./tests/inps/tank_constantinflow_notreatment.inp") as sim:
        CS = waterQuality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for index, step in enumerate(sim):
            CS.updateWQState_CSTR(index)
            c = Tank.pollut_quality
            conc2.append(c['P1'])
    C_steadystate = dict1['Tank']['parameters']['c0'] / (
        (1 -
         (dict1['Tank']['parameters']['k'] *
          (np.mean(vol) / np.mean(flow))))**dict1['Tank']['parameters']['n'])
    error = (C_steadystate - conc2[-1]) / C_steadystate
    assert error <= 0.03
Ejemplo n.º 4
0
def test_ConstantRemoval_conc():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'ConstantRemoval',
            'parameters': {
                'R': 0.5
            }
        }
    }
    conc = []
    con = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        CR = waterQuality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            CR.updateWQState()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation(
            "./tests/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
Ejemplo n.º 5
0
def test_EventMeanConc_load():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'EventMeanConc',
            'parameters': {
                'C': 5.0
            }
        }
    }
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        EMC = waterQuality(sim, dict1)
        Outfall = Nodes(sim)["Outfall"]
        for step in sim:
            EMC.updateWQState()
            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("./tests/inps/tank_variableinflow_emc.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
Ejemplo n.º 6
0
def test_CSTR_load():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'CSTR',
            'parameters': {
                'k': -0.2,
                'n': 1.0,
                'c0': 10.0
            }
        }
    }
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/tank_constantinflow_notreatment.inp") as sim:
        CS = waterQuality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        Valve = Links(sim)["Valve"]
        for index, step in enumerate(sim):
            CS.updateWQState_CSTR(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
Ejemplo n.º 7
0
def test_GravitySettling_conc():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'GravitySettling',
            'parameters': {
                'k': 0.01,
                'C_s': 10.0
            }
        }
    }
    conc = []
    con = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        GS = waterQuality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            GS.updateWQState()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation(
            "./tests/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
Ejemplo n.º 8
0
def test_NthOrderReaction_conc():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'NthOrderReaction',
            'parameters': {
                'k': 0.01,
                'n': 2.0
            }
        }
    }
    conc = []
    con = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        NOR = waterQuality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            NOR.updateWQState()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation(
            "./tests/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
Ejemplo n.º 9
0
def test_EventMeanConc_conc():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'EventMeanConc',
            'parameters': {
                'C': 5.0
            }
        }
    }
    conc = []
    con = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        EMC = waterQuality(sim, dict1)
        Tank = Nodes(sim)["Tank"]
        for step in sim:
            EMC.updateWQState()
            c = Tank.pollut_quality
            conc.append(c['P1'])
    with Simulation("./tests/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
Ejemplo n.º 10
0
def test_CoRemoval_load():
    dict1 = {'Tank': {'pollutant': 1, 'method': 'ConstantRemoval', 'parameters': {'R': 0.15}},\
        'Tank': {'pollutant': 0, 'method': 'CoRemoval', 'parameters': {'R1': 0.75, 'R2': 0.15}}}
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        CO = waterQuality(sim, dict1)
        Outfall = Nodes(sim)["Outfall"]
        for step in sim:
            CO.updateWQState()
            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("./tests/inps/tank_variableinflow_coremoval.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
Ejemplo n.º 11
0
def test_Phosphorus_load():
    dict1 = {
        'Tank': {
            'pollutant': 0,
            'method': 'Phosphorus',
            'parameters': {
                'B1': 0.0000333,
                'Ceq0': 0.0081,
                'k': 0.00320,
                'L': 0.91,
                'A': 100,
                'E': 0.44
            }
        }
    }
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/tank_variableinflow_notreatment.inp") as sim:
        GS = waterQuality(sim, dict1)
        Outfall = Nodes(sim)["Outfall"]
        for step in sim:
            GS.updateWQState()
            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(
            "./tests/inps/tank_variableinflow_gravsettling.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
Ejemplo n.º 12
0
def test_Erosion_load():
    dict1 = {
        'Channel': {
            'pollutant': 0,
            'method': 'Erosion',
            'parameters': {
                'w': 10.0,
                'So': 0.001,
                'Ss': 2.68,
                'd50': 0.7
            }
        }
    }
    conc = []
    conc1 = []
    flow = []
    flow1 = []
    with Simulation("./tests/inps/LinkTest_variableinflow.inp") as sim:
        ER = waterQuality(sim, dict1)
        channel = Links(sim)["Channel"]
        tailwater = Nodes(sim)["TailWater"]
        for step in sim:
            ER.updateWQState()
            c = channel.pollut_quality
            conc.append(c['P1'])
            c1 = tailwater.pollut_quality
            conc1.append(c1['P1'])
            flow.append(sim._model.getLinkResult("Channel", 0))
            flow1.append(sim._model.getNodeResult("Tailwater", 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