def merge_graph_by_branch(self, branch_list, graph_list_1, graph_list_2): g = Power_Graph() graph_list = [] graph_list.extend(graph_list_1) graph_list.extend(graph_list_2) for graph in graph_list: g.bus_id.extend(graph.bus_id) if len(g.bus) > 0: g.bus = np.append(g.bus, graph.bus, axis = 0) else: g.bus = np.array([line for line in graph.bus]) g.gen_id.extend(graph.gen_id) if len(g.gens) > 0: g.gens = np.append(g.gens, graph.gens, axis=0) else: g.gens = np.array([line for line in graph.gens]) if len(g.branch) > 0: g.branch = np.append(g.branch, graph.branch, axis=0) else: g.branch = np.array([line for line in graph.branch]) g.branch = np.append(g.branch, [self.ini_branch_dic[branch] for branch in branch_list], axis=0 ) g.m_Bus = self.ini_m_bus g.make_init() return g
def merge_graph_by_bus(self, fb_id, graph_list): g = Power_Graph() g.bus_id.append(fb_id) g.bus = np.array([self.ini_bus_dic[fb_id]]) if fb_id in self.ini_gen_id: g.gen_id.append(fb_id) g.gens = np.array([self.ini_gen_dic[fb_id]]) for graph in graph_list: connected_bus = self.connect_to_graph(fb_id, graph) for neighbor in connected_bus: link = (fb_id, neighbor) if link not in self.ini_branch_dic.keys(): link = (neighbor, fb_id) if len(g.branch) > 0: g.branch = np.append(g.branch, [self.ini_branch_dic[link]], axis=0) else: g.branch = np.array([self.ini_branch_dic[link]]) for graph in graph_list: g.bus_id.extend(graph.bus_id) g.bus = np.append(g.bus, graph.bus, axis=0) g.gen_id.extend(graph.gen_id) if len(g.gens) > 0: g.gens = np.append(g.gens, graph.gens, axis=0) else: g.gens = np.array([line for line in graph.gens]) g.branch = np.append(g.branch, graph.branch, axis=0) g.m_Bus = self.ini_m_bus g.make_init() return g