Ejemplo n.º 1
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
Ejemplo n.º 2
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