def junctions(self): nodes = [] num_nodes = toolkit.getcount(self.ph, toolkit.NODECOUNT) for node in range(1, num_nodes + 1): if toolkit.getnodetype(self.ph, node) == toolkit.JUNCTION: nodes.append(toolkit.getnodeid(self.ph, node)) return nodes
def test_getnodeid(): epanet_proj = en.createproject() en.open(ph=epanet_proj, inpFile=example_1_path, rptFile='report.rpt', outFile='output.out') node_idx = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] node_id = [] for nidx in node_idx: node_id.append(en.getnodeid(ph=epanet_proj, index=nidx)) assert node_id == ['10', '11', '12', '13', '21', '22', '23', '31', '32', '9', '2'] clean_dir()
def getNodeID(self): value = range(1, self.NodeCount + 1) # print(value) nodeID = list() for i in value: # print(i) type = en.getnodeid(ph=self.epanet_proj, index=i) # print(type) nodeID.append(type) return nodeID
def print_node_heads(ph, time, node_count): print(f'Time: {time}') for i in range(1, node_count + 1): node_type = en.getnodetype(ph, i) node_id = en.getnodeid(ph, i) head = en.getnodevalue(ph, i, en.HEAD) pressure = en.getnodevalue(ph, i, en.PRESSURE) demand = en.getnodevalue(ph, i, en.DEMAND) print( f'Node: {i:2}, ID: {node_id}, type: {node_type_str[node_type]},', f'head: {head:8g}, pressure: {pressure:8g}, demand: {demand:8g}')
def getNodeNames(self): names = [] nodeCount = en.getcount(ph=self.project, object=en.NODECOUNT) for idx in range(nodeCount): index = idx + 1 # Get node id. nodeId = en.getnodeid(ph=self.project, index=index) # Get node type. nodeType = "Node" if en.getnodetype(ph=self.project, index=index) == en.TANK: nodeType = "Tank" elif en.getnodetype(ph=self.project, index=index) == en.JUNCTION: nodeType = "Junction" elif en.getnodetype(ph=self.project, index=index) == en.RESERVOIR: nodeType = "Reservoir" else: nodeType = "Unknown" names.append(nodeType + "-" + nodeId + " (tanklevel)") names.append(nodeType + "-" + nodeId + " (head)") names.append(nodeType + "-" + nodeId + " (demand)") names.append(nodeType + "-" + nodeId + " (pressure)") return names
def nodes(self, link_name): l_idx = toolkit.getlinkindex(self.ph, link_name) n1_n2_idx = toolkit.getlinknodes(self.ph, l_idx) return [toolkit.getnodeid(self.ph, idx) for idx in n1_n2_idx]