def repair(self, index, timestep, epa): self.time_left -= timestep if self.time_left <= 0: if epa: et.ENsetlinkvalue(index, et.EN_STATUS, 1) self.functional = True else: if epa: et.ENsetlinkvalue(index, et.EN_STATUS, 0) self.functional = False return self
def setDiameter(id,value): errcode=et.ENopen(Inp,"BUFF.rpt","") [errcode,index]=et.ENgetlinkindex(id) # [errcode,diameter]=et.ENgetlinkvalue(index,et.EN_DIAMETER) et.ENsetlinkvalue(index,et.EN_DIAMETER,value) errcode=et.ENsaveinpfile(InpCopy) errcode=et.ENclose()
p_status_2 = [] for i in range(0, 25): p_status_2.append(randint(0, 0)) while True: ret, t = et.ENrunH() if t % 3600 != 0: ret, tstep = et.ENnextH() if (tstep <= 0): break else: time.append(t) #play with pump status to obtain diferent water level curves ret = et.ENsetlinkvalue(Pump1, et.EN_STATUS, p_status_1[inc]) ret = et.ENsetlinkvalue(Pump2, et.EN_STATUS, p_status_2[inc]) ret, T1 = et.ENgetnodevalue(Tank1, et.EN_PRESSURE) ret, T2 = et.ENgetnodevalue(Tank2, et.EN_PRESSURE) ret, T3 = et.ENgetnodevalue(Tank3, et.EN_PRESSURE) ret, P1 = et.ENgetlinkvalue(Pump1, et.EN_STATUS) ret, P2 = et.ENgetlinkvalue(Pump2, et.EN_STATUS) Pump_status1.append(P1) Pump_status2.append(P2) Tank_level1.append(T1) Tank_level2.append(T2) Tank_level3.append(T3) ret, tstep = et.ENnextH() inc = inc + 1 if (tstep <= 0):
et.ENopenH() et.ENinitH(0) while True : ret,t=et.ENrunH() if t%3600!=0: ret,tstep=et.ENnextH() if (tstep<=0): break else: time.append(t) # Retrieve hydraulic results for time t for i in range(0,len(nodes)): ret,p=et.ENgetnodevalue(i+1, et.EN_PRESSURE ) pres[i].append(p) ret,tstep=et.ENnextH() a=et.ENsetlinkvalue(nlinks,et.EN_STATUS,1) a,b=et.ENgetlinkvalue(nlinks,et.EN_STATUS) pump.append(b) if (tstep<=0): break ret=et.ENcloseH() print([round(x,4) for x in pres[94]]) for i in range(0,len(time)): print(time[i]/3600) print(pump[i]) #pumps id is 10 and 335
et.ENinitH(0) while True: ret, t = et.ENrunH() if t % 3600 != 0: ret, tstep = et.ENnextH() if (tstep <= 0): break else: time.append(t) #play with pump status to obtain diferent water level curves ret = et.ENsetlinkvalue(Pump_1A, et.EN_STATUS, Pump_status_1A_2[inc]) ret = et.ENsetlinkvalue(Pump_2A, et.EN_STATUS, p_status_2A[inc]) ret = et.ENsetlinkvalue(Pump_3A, et.EN_STATUS, p_status_3A[inc]) ret = et.ENsetlinkvalue(Pump_4B, et.EN_STATUS, Pump_status_4B_2[inc]) ret = et.ENsetlinkvalue(Pump_5C, et.EN_STATUS, Pump_status_5C_2[inc]) ret = et.ENsetlinkvalue(Pump_6D, et.EN_STATUS, Pump_status_6D_2[inc]) ret = et.ENsetlinkvalue(Pump_7F, et.EN_STATUS, Pump_status_7F_2[inc]) ret, TA = et.ENgetnodevalue(Tank_A, et.EN_PRESSURE) ret, P1A = et.ENgetlinkvalue(Pump_1A, et.EN_STATUS) ret, P2A = et.ENgetlinkvalue(Pump_2A, et.EN_STATUS) ret, P3A = et.ENgetlinkvalue(Pump_3A, et.EN_STATUS)
et.ENinitH(0) while True: ret, t = et.ENrunH() if t % 3600 != 0: ret, tstep = et.ENnextH() if (tstep <= 0): break else: time.append(t) #play with pump status to obtain diferent water level curves ret = et.ENsetlinkvalue(Pump_1A, et.EN_STATUS, p_status_1A[inc]) ret = et.ENsetlinkvalue(Pump_2A, et.EN_STATUS, p_status_2A[inc]) ret = et.ENsetlinkvalue(Pump_3A, et.EN_STATUS, p_status_3A[inc]) ret = et.ENsetlinkvalue(Pump_4B, et.EN_STATUS, p_status_4B[inc]) ret = et.ENsetlinkvalue(Pump_5C, et.EN_STATUS, p_status_5C[inc]) ret = et.ENsetlinkvalue(Pump_6D, et.EN_STATUS, p_status_6D[inc]) ret = et.ENsetlinkvalue(Pump_7F, et.EN_STATUS, p_status_7F[inc]) ret, TA = et.ENgetnodevalue(Tank_A, et.EN_PRESSURE) ret, TB = et.ENgetnodevalue(Tank_B, et.EN_PRESSURE) ret, TC = et.ENgetnodevalue(Tank_C, et.EN_PRESSURE) ret, TD = et.ENgetnodevalue(Tank_D, et.EN_PRESSURE) ret, TE = et.ENgetnodevalue(Tank_E, et.EN_PRESSURE) ret, TF = et.ENgetnodevalue(Tank_F, et.EN_PRESSURE) ret, P1A = et.ENgetlinkvalue(Pump_1A, et.EN_STATUS) ret, P2A = et.ENgetlinkvalue(Pump_2A, et.EN_STATUS)
def disable(self, index, epa): self.functional = False self.time_left = self.repair_time if epa: et.ENsetlinkvalue(index, et.EN_STATUS, 0)
def test_alter_with_ENset_and_check_with_a_file(self): self.Error(et.ENsaveinpfile("1.inp")) self.Error(et.ENsetlinkvalue(81, 0, 9999)) self.Error(et.ENsaveinpfile("2.inp")) self.assertEqual(tt.compareFiles("1.inp", "2.inp"), '16>1e+04; ')
def alter_epanet_friction_all_same(self, value): ret, no_links = epa.ENgetcount(epa.EN_LINKCOUNT) for index in range(1, no_links + 1): ret, epa.ENsetlinkvalue(index, epa.EN_ROUGHNESS, value)