def split_into_islands(self, ignore_single_node_islands=False ) -> List["SnapshotData"]: """ Split circuit into islands :param numeric_circuit: NumericCircuit instance :param ignore_single_node_islands: ignore islands composed of only one bus :return: List[NumericCircuit] """ # compute the adjacency matrix A = tp.get_adjacency_matrix( C_branch_bus_f=self.Cf, C_branch_bus_t=self.Ct, branch_active=self.branch_data.branch_active[:, 0], bus_active=self.bus_data.bus_active[:, 0]) # find the matching islands idx_islands = tp.find_islands(A) if len(idx_islands) == 1: # numeric_circuit.compute_all() # compute the internal magnitudes return [self] else: circuit_islands = list() # type: List[SnapshotData] for bus_idx in idx_islands: if ignore_single_node_islands: if len(bus_idx) > 1: island = self.get_island(bus_idx) # island.compute_all() # compute the internal magnitudes circuit_islands.append(island) else: island = self.get_island(bus_idx) # island.compute_all() # compute the internal magnitudes circuit_islands.append(island) return circuit_islands
def split_into_islands_acdc( numeric_circuit: AcDcSnapshotCircuit, ignore_single_node_islands=False) -> List[AcDcSnapshotCircuit]: """ Split circuit into islands :param numeric_circuit: NumericCircuit instance :param ignore_single_node_islands: ignore islands composed of only one bus :return: List[NumericCircuit] """ # compute the adjacency matrix A = tp.get_adjacency_matrix(C_branch_bus_f=numeric_circuit.C_branch_bus_f, C_branch_bus_t=numeric_circuit.C_branch_bus_t, branch_active=numeric_circuit.branch_active, bus_active=numeric_circuit.bus_active) # find the matching islands idx_islands = tp.find_islands(A) if len(idx_islands) == 1: numeric_circuit.consolidate() # compute the internal magnitudes return [numeric_circuit] else: circuit_islands = list() # type: List[AcDcSnapshotCircuit] for bus_idx in idx_islands: if ignore_single_node_islands: if len(bus_idx) > 1: island = get_acdc_pf_island(numeric_circuit, bus_idx) island.consolidate() # compute the internal magnitudes circuit_islands.append(island) else: island = get_acdc_pf_island(numeric_circuit, bus_idx) island.consolidate() # compute the internal magnitudes circuit_islands.append(island) return circuit_islands
def split_opf_time_circuit_into_islands( numeric_circuit: OpfTimeCircuit, ignore_single_node_islands=False) -> List[OpfTimeCircuit]: """ Split circuit into islands :param numeric_circuit: NumericCircuit instance :param ignore_single_node_islands: ignore islands composed of only one bus :return: List[NumericCircuit] """ circuit_islands = list() # type: List[OpfTimeCircuit] all_buses = np.arange(numeric_circuit.nbus) all_time = np.arange(numeric_circuit.ntime) # find the probable time slices states = find_different_states( branch_active_prof=numeric_circuit.branch_active) if len(states) == 1: # compute the adjacency matrix A = tp.get_adjacency_matrix( C_branch_bus_f=numeric_circuit.C_branch_bus_f, C_branch_bus_t=numeric_circuit.C_branch_bus_t, branch_active=numeric_circuit.branch_active[0, :], bus_active=numeric_circuit.bus_active[0, :]) # find the matching islands idx_islands = tp.find_islands(A) if len( idx_islands ) == 1: # only one state and only one island -> just copy the data -------------------------- numeric_circuit.consolidate() # compute the internal magnitudes return [numeric_circuit] else: # one state, many islands -> split by bus index, keep the time ------------------------------------------ for bus_idx in idx_islands: if ignore_single_node_islands: if len(bus_idx) > 1: island = get_opf_time_island(numeric_circuit, bus_idx, all_time) island.consolidate() # compute the internal magnitudes circuit_islands.append(island) else: island = get_opf_time_island(numeric_circuit, bus_idx, all_time) island.consolidate() # compute the internal magnitudes circuit_islands.append(island) else: # ----------------------------------------------------------------------------------------------------------- for t, t_array in states.items(): # compute the adjacency matrix A = tp.get_adjacency_matrix( C_branch_bus_f=numeric_circuit.C_branch_bus_f, C_branch_bus_t=numeric_circuit.C_branch_bus_t, branch_active=numeric_circuit.branch_active[t_array, :], bus_active=numeric_circuit.bus_active[t_array, :]) # find the matching islands idx_islands = tp.find_islands(A) if len( idx_islands ) == 1: # many time states, one island -> slice only by time ---------------------------- island = get_opf_time_island( numeric_circuit, all_buses, t_array) # convert the circuit to an island island.consolidate() # compute the internal magnitudes circuit_islands.append(island) else: # any time states, many islands -> slice by both time and bus index --------------------------------- for bus_idx in idx_islands: if ignore_single_node_islands: if len(bus_idx) > 1: island = get_opf_time_island( numeric_circuit, bus_idx, t_array) island.consolidate( ) # compute the internal magnitudes circuit_islands.append(island) else: island = get_opf_time_island(numeric_circuit, bus_idx, t_array) island.consolidate() # compute the internal magnitudes circuit_islands.append(island) return circuit_islands
def split_into_islands(self, ignore_single_node_islands=False ) -> List["TimeCircuit"]: """ Split circuit into islands :param ignore_single_node_islands: ignore islands composed of only one bus :return: List[NumericCircuit] """ circuit_islands = list() # type: List[TimeCircuit] all_buses = np.arange(self.nbus) all_time = np.arange(self.ntime) # find the probable time slices states = find_different_states( branch_active_prof=self.branch_data.branch_active.T) if len(states) == 1: # compute the adjacency matrix A = tp.get_adjacency_matrix( C_branch_bus_f=self.Cf, C_branch_bus_t=self.Ct, branch_active=self.branch_data.branch_active[:, 0], bus_active=self.bus_data.bus_active[:, 0]) # find the matching islands idx_islands = tp.find_islands(A) if len( idx_islands ) == 1: # only one state and only one island -> just copy the data return [self] else: # one state, many islands -> split by bus index, keep the time for bus_idx in idx_islands: if ignore_single_node_islands: if len(bus_idx) > 1: island = self.get_island(bus_idx, all_time) circuit_islands.append(island) else: island = self.get_island(bus_idx, all_time) circuit_islands.append(island) return circuit_islands else: # ------------------------------------------------------------------------------------------------------ for t, t_array in states.items(): # compute the adjacency matrix A = tp.get_adjacency_matrix( C_branch_bus_f=self.Cf, C_branch_bus_t=self.Ct, branch_active=self.branch_data.branch_active[:, t_array], bus_active=self.bus_data.bus_active[:, t_array]) # find the matching islands idx_islands = tp.find_islands(A) if len( idx_islands ) == 1: # many time states, one island -> slice only by time ------------------------ island = self.get_island( all_buses, t_array) # convert the circuit to an island circuit_islands.append(island) else: # any time states, many islands -> slice by both time and bus index ----------------------------- for bus_idx in idx_islands: if ignore_single_node_islands: if len(bus_idx) > 1: island = self.get_island(bus_idx, t_array) circuit_islands.append(island) else: island = self.get_island(bus_idx, t_array) circuit_islands.append(island) return circuit_islands