def test_CoRemoval_load(): dict1 = {'Tank': {0: [0.75, 0.15]}} dict2 = {'Tank': {1: 0.15}} conc = [] conc1 = [] flow = [] flow1 = [] with Simulation("./inps/tank_variableinflow_notreatment.inp") as sim: CO = Node_Quality(sim, dict1) CR = Node_Quality(sim, dict2) Outfall = Nodes(sim)["Outfall"] for step in sim: CR.ConstantRemoval() CO.CoRemoval() 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_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
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