VeraGridEngine.Topology package๏ƒ

Subpackages๏ƒ

Submodules๏ƒ

VeraGridEngine.Topology.admittance_matrices module๏ƒ

class VeraGridEngine.Topology.admittance_matrices.AdmittanceMatrices(Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, Cf: csc_matrix, Ct: csc_matrix, yff: ndarray[tuple[Any, ...], dtype[complex128]], yft: ndarray[tuple[Any, ...], dtype[complex128]], ytf: ndarray[tuple[Any, ...], dtype[complex128]], ytt: ndarray[tuple[Any, ...], dtype[complex128]], Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]])[source]๏ƒ

Bases: object

Class to store admittance matrices

Cf๏ƒ
Ct๏ƒ
Ybus๏ƒ
Yf๏ƒ
Yshunt_bus๏ƒ
Yt๏ƒ
copy() AdmittanceMatrices[source]๏ƒ

Get a deep copy

modify_taps(m_prev: ndarray[tuple[Any, ...], dtype[float64]], m_new: ndarray[tuple[Any, ...], dtype[float64]], tau_prev: ndarray[tuple[Any, ...], dtype[float64]], tau_new: ndarray[tuple[Any, ...], dtype[float64]], idx: ndarray[tuple[Any, ...], dtype[int64]]) Tuple[csc_matrix, csc_matrix, csc_matrix][source]๏ƒ

Compute the new admittance matrix given the tap variation :param m_prev: previous tap module (length of idx) :param m_new: new tap module (length of idx) :param tau_prev: previous tap angle (length of idx) :param tau_new: new tap angle (length of idx) :param idx: branch indices that modify either m or tau.

There has to be a single indices array because it is very hard to maintain indices that apply only to m, indices that apply only to tau and indices that apply to both

Returns:

Ybus, Yf, Yt

modify_taps_all(m: ndarray[tuple[Any, ...], dtype[float64]], m2: ndarray[tuple[Any, ...], dtype[float64]], tau: ndarray[tuple[Any, ...], dtype[float64]], tau2: ndarray[tuple[Any, ...], dtype[float64]]) Tuple[csc_matrix, csc_matrix, csc_matrix][source]๏ƒ

Compute the new admittance matrix given the tap variation :param m: previous tap module (nbr) :param m2: new tap module (nbr) :param tau: previous tap angle (nbr) :param tau2: new tap angle (nbr) :return: Ybus, Yf, Yt

yff๏ƒ
yft๏ƒ
ytf๏ƒ
ytt๏ƒ
class VeraGridEngine.Topology.admittance_matrices.AdmittanceMatricesFast(Ybus: csc_matrix, Yf: csc_matrix, Yt: csc_matrix, F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], ys: ndarray[tuple[Any, ...], dtype[complex128]], ysh2: ndarray[tuple[Any, ...], dtype[complex128]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]], yff: ndarray[tuple[Any, ...], dtype[complex128]], yft: ndarray[tuple[Any, ...], dtype[complex128]], ytf: ndarray[tuple[Any, ...], dtype[complex128]], ytt: ndarray[tuple[Any, ...], dtype[complex128]], Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]])[source]๏ƒ

Bases: object

Class to store admittance matrices

F๏ƒ
T๏ƒ
Ybus๏ƒ
Yf๏ƒ
Yshunt_bus๏ƒ
Yt๏ƒ
copy() AdmittanceMatricesFast[source]๏ƒ

Get a deep copy

initialize_update()[source]๏ƒ

Build the indices to later update the matrix easily :return:

modify_taps_fast(idx, tap_module: ndarray[tuple[Any, ...], dtype[float64]], tap_angle: ndarray[tuple[Any, ...], dtype[float64]]) None[source]๏ƒ

Modify in-place Ybus, Yf and Yt :param idx: indices of the branches to modify. Both the tap angle and module are updated for every index. :param tap_module: Tap modules of the positions given by idx :param tap_angle: Tap angles of the positions given by idx

pos_b_ii๏ƒ
pos_b_ij๏ƒ
pos_b_ji๏ƒ
pos_b_jj๏ƒ
pos_yff๏ƒ
pos_yft๏ƒ
pos_ytf๏ƒ
pos_ytt๏ƒ
vtap_f๏ƒ
vtap_t๏ƒ
yff๏ƒ
yft๏ƒ
ys๏ƒ
ysh2๏ƒ
ytf๏ƒ
ytt๏ƒ
class VeraGridEngine.Topology.admittance_matrices.FastDecoupledAdmittanceMatrices(B1: csc_matrix, B2: csc_matrix)[source]๏ƒ

Bases: object

Admittance matrices for Fast decoupled method

B1๏ƒ
B2๏ƒ
class VeraGridEngine.Topology.admittance_matrices.LinearAdmittanceMatrices(Bbus: csc_matrix, Bf: csc_matrix, Gbus: csc_matrix, Gf: csc_matrix)[source]๏ƒ

Bases: object

Admittance matrices for linear methods (DC power flow, PTDF, โ€ฆ)

Bbus๏ƒ
Bf๏ƒ
Gbus๏ƒ
Gf๏ƒ
get_Bred(pqpv: ndarray[tuple[Any, ...], dtype[int64]]) csc_matrix[source]๏ƒ

Get Bred or Bpqpv for the PTDF and DC power flow :param pqpv: list of non-slack indices :return: B[pqpv, pqpv]

get_Bslack(pqpv: ndarray[tuple[Any, ...], dtype[int64]], vd: ndarray[tuple[Any, ...], dtype[int64]]) csc_matrix[source]๏ƒ

Get Bslack for the PTDF and DC power flow :param pqpv: list of non-slack indices :param vd: list of slack ndices :return: B[pqpv, vd]

class VeraGridEngine.Topology.admittance_matrices.SeriesAdmittanceMatrices(Yseries: csc_matrix, Yshunt: ndarray[tuple[Any, ...], dtype[complex128]])[source]๏ƒ

Bases: object

Admittance matrices for HELM and the AC linear methods

Yseries๏ƒ
Yshunt๏ƒ
VeraGridEngine.Topology.admittance_matrices.compute_admittances(R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], tap_module: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]], tap_angle: ndarray[tuple[Any, ...], dtype[float64]], Cf: csc_matrix, Ct: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], conn: ndarray[tuple[Any, ...], dtype[int64]], seq: int, add_windings_phase: bool = False) AdmittanceMatrices[source]๏ƒ

Compute the complete admittance matrices for the general power flow methods (Newton-Raphson based)

Parameters:
  • R โ€“ array of branch resistance (p.u.)

  • X โ€“ array of branch reactance (p.u.)

  • G โ€“ array of branch conductance (p.u.)

  • B โ€“ array of branch susceptance (p.u.)

  • tap_module โ€“ array of tap modules (for all Branches, regardless of their type)

  • vtap_f โ€“ array of virtual taps at the โ€œfromโ€ side

  • vtap_t โ€“ array of virtual taps at the โ€œtoโ€ side

  • tap_angle โ€“ array of tap angles (for all Branches, regardless of their type)

  • Cf โ€“ Connectivity branch-bus โ€œfromโ€ with the branch states computed

  • Ct โ€“ Connectivity branch-bus โ€œtoโ€ with the branch states computed

  • Yshunt_bus โ€“ array of shunts equivalent power per bus, from the shunt devices (p.u.)

  • seq โ€“ Sequence [0, 1, 2]

  • conn โ€“ array of windings connections codes (numpy array of WindingsConnection values)

  • add_windings_phase โ€“ Add the phases of the transformer windings (for short circuits mainly)

Returns:

Admittance instance

VeraGridEngine.Topology.admittance_matrices.compute_admittances_fast(nbus, R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], tap_module: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]], tap_angle: ndarray[tuple[Any, ...], dtype[float64]], Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]]) AdmittanceMatricesFast[source]๏ƒ

Hardcore build of admittance matrices :param nbus: number of nodes :param R: array of branch resistance (p.u.) :param X: array of branch reactance (p.u.) :param G: array of branch conductance (p.u.) :param B: array of branch susceptance (p.u.) :param tap_module: array of tap modules (for all Branches, regardless of their type) :param vtap_f: array of virtual taps at the โ€œfromโ€ side :param vtap_t: array of virtual taps at the โ€œtoโ€ side :param tap_angle: array of tap angles (for all Branches, regardless of their type) :param Yshunt_bus: array of shunts equivalent power per bus, from the shunt devices (p.u.) :param F: Array of branch-from bus indices :param T: Array of branch-to bus indices :param Cf: Cf to pass along :param Ct: Ct to pass along :return: Yf, Yt, Ybus

VeraGridEngine.Topology.admittance_matrices.compute_fast_decoupled_admittances(X: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], tap_module: ndarray[tuple[Any, ...], dtype[float64]], active: ndarray[tuple[Any, ...], dtype[int64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]], Cf: csc_matrix, Ct: csc_matrix) FastDecoupledAdmittanceMatrices[source]๏ƒ

Compute the admittance matrices for the fast decoupled method :param X: array of branch reactance (p.u.) :param B: array of branch susceptance (p.u.) :param tap_module: array of tap modules (for all Branches, regardless of their type) :param active: array of active branches (bool) :param vtap_f: array of virtual taps at the โ€œfromโ€ side :param vtap_t: array of virtual taps at the โ€œtoโ€ side :param Cf: Connectivity branch-bus โ€œfromโ€ with the branch states computed :param Ct: Connectivity branch-bus โ€œtoโ€ with the branch states computed :return: Bโ€™ and Bโ€™โ€™

VeraGridEngine.Topology.admittance_matrices.compute_linear_admittances(nbr: int, X: ndarray[tuple[Any, ...], dtype[float64]], R: ndarray[tuple[Any, ...], dtype[float64]], m: ndarray[tuple[Any, ...], dtype[float64]], active: ndarray[tuple[Any, ...], dtype[int64]], Cf: csc_matrix, Ct: csc_matrix, ac: ndarray[tuple[Any, ...], dtype[int64]], dc: ndarray[tuple[Any, ...], dtype[int64]]) LinearAdmittanceMatrices[source]๏ƒ

Compute the linear admittances for methods such as the โ€œDC power flowโ€ of the PTDF :param nbr: Number of Branches :param X: array of branch reactance (p.u.) :param R: array of branch resistance (p.u.) :param m: array of branch tap modules (p.u.) :param active: array of branch active (bool) :param Cf: Connectivity branch-bus โ€œfromโ€ with the branch states computed :param Ct: Connectivity branch-bus โ€œtoโ€ with the branch states computed :param ac: array of ac Branches indices :param dc: array of dc Branches indices :return: Bbus, Bf

VeraGridEngine.Topology.admittance_matrices.compute_split_admittances(R: ndarray[tuple[Any, ...], dtype[float64]], X: ndarray[tuple[Any, ...], dtype[float64]], G: ndarray[tuple[Any, ...], dtype[float64]], B: ndarray[tuple[Any, ...], dtype[float64]], active: ndarray[tuple[Any, ...], dtype[int64]], tap_module: ndarray[tuple[Any, ...], dtype[float64]], vtap_f: ndarray[tuple[Any, ...], dtype[float64]], vtap_t: ndarray[tuple[Any, ...], dtype[float64]], tap_angle: ndarray[tuple[Any, ...], dtype[float64]], Cf: csc_matrix, Ct: csc_matrix, Yshunt_bus: ndarray[tuple[Any, ...], dtype[complex128]]) SeriesAdmittanceMatrices[source]๏ƒ

Compute the complete admittance matrices for the helm method and others that may require them :param R: array of branch resistance (p.u.) :param X: array of branch reactance (p.u.) :param G: array of branch conductance (p.u.) :param B: array of branch susceptance (p.u.) :param active: array of active branches (bool) :param tap_module: array of tap modules (for all Branches, regardless of their type) :param vtap_f: array of virtual taps at the โ€œfromโ€ side :param vtap_t: array of virtual taps at the โ€œtoโ€ side :param tap_angle: array of tap angles (for all Branches, regardless of their type) :param Cf: Connectivity branch-bus โ€œfromโ€ with the branch states computed :param Ct: Connectivity branch-bus โ€œtoโ€ with the branch states computed :param Yshunt_bus: array of shunts equivalent power per bus (p.u.) :return: Yseries, Yshunt

VeraGridEngine.Topology.admittance_matrices.csc_equal(A: csc_matrix, B: csc_matrix, tol: float = 0.0) bool[source]๏ƒ

Return True iff two CSC matrices are equal (up-to a tolerance for floatingโ€“point data).

Parameters๏ƒ

A, Bscipy.sparse.csc_matrix

The matrices to compare.

tolfloat, optional

Absolute tolerance. If 0.0 an exact match is required otherwise the test is |A-B| > tol element-wise.

Notes๏ƒ

  • Both matrices are sorted first (sort_indices) so the result is independent of internal index ordering.

  • Works for any SciPy sparse subtype (CSR, COO โ€ฆ) after .tocsc().

VeraGridEngine.Topology.admittance_matrices.update_branch_admittances(idx: ndarray[tuple[Any, ...], dtype[int64]], new_yff: ndarray[tuple[Any, ...], dtype[complex128]], new_yft: ndarray[tuple[Any, ...], dtype[complex128]], new_ytf: ndarray[tuple[Any, ...], dtype[complex128]], new_ytt: ndarray[tuple[Any, ...], dtype[complex128]], Yf_data: ndarray[tuple[Any, ...], dtype[complex128]], Yt_data: ndarray[tuple[Any, ...], dtype[complex128]], Ybus_data: ndarray[tuple[Any, ...], dtype[complex128]], pos_yff: ndarray[tuple[Any, ...], dtype[int64]], pos_yft: ndarray[tuple[Any, ...], dtype[int64]], pos_ytf: ndarray[tuple[Any, ...], dtype[int64]], pos_ytt: ndarray[tuple[Any, ...], dtype[int64]], pos_b_ii: ndarray[tuple[Any, ...], dtype[int64]], pos_b_ij: ndarray[tuple[Any, ...], dtype[int64]], pos_b_ji: ndarray[tuple[Any, ...], dtype[int64]], pos_b_jj: ndarray[tuple[Any, ...], dtype[int64]])[source]๏ƒ

Update Yf, Yt, Ybus in place. All arrays are pre-allocated. :param idx: branches you change :param new_yff: :param new_yft: :param new_ytf: :param new_ytt: :param Yf_data: :param Yt_data: :param Ybus_data: :param pos_yff: :param pos_yft: :param pos_ytf: :param pos_ytt: :param pos_b_ii: :param pos_b_ij: :param pos_b_ji: :param pos_b_jj: :return:

VeraGridEngine.Topology.detect_substations module๏ƒ

VeraGridEngine.Topology.detect_substations.detect_facilities(grid: MultiCircuit) None[source]๏ƒ

Create facilities automatically In essence is packing all the injections connected to the same bus into a facility object :param grid: MultiCircuit

VeraGridEngine.Topology.detect_substations.detect_substations(grid: MultiCircuit, r_x_threshold=0.001) None[source]๏ƒ

Given a Grid with buses, it will detect all the missing substations and voltage levels :param grid: MultiCircuit :param r_x_threshold: sum of r+x under which a line is considered a jumper :return: (in-place)

VeraGridEngine.Topology.detect_substations.get_bus_group_substation(bus_indices: ndarray[tuple[Any, ...], dtype[int64]], buses: List[Bus]) Substation | None[source]๏ƒ

Given a list of buses, return the first substation available :param bus_indices: :param buses: list of bus objects :return:

VeraGridEngine.Topology.simulation_indices module๏ƒ

class VeraGridEngine.Topology.simulation_indices.SimulationIndices(bus_types: ndarray[tuple[Any, ...], dtype[int64]], Pbus: ndarray[tuple[Any, ...], dtype[float64]], tap_module_control_mode: ndarray[tuple[Any, ...], dtype[int64]], tap_phase_control_mode: ndarray[tuple[Any, ...], dtype[int64]], tap_controlled_buses: ndarray[tuple[Any, ...], dtype[int64]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], is_dc_bus: ndarray[tuple[Any, ...], dtype[bool]], force_only_pq_pv_vd_types=False)[source]๏ƒ

Bases: object

Class to handle the simulation indices

F๏ƒ
T๏ƒ
ac: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
bus_types๏ƒ
dc: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
get_branch_controls_indices() Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]๏ƒ

Analyze the control branches and compute the indices :return: k_m, k_tau, k_mtau

no_slack: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
p: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
pq: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
pqv: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
pv: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
tap_controlled_buses๏ƒ
tap_module_control_mode๏ƒ
tap_phase_control_mode๏ƒ
vd: ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
VeraGridEngine.Topology.simulation_indices.compile_types(Pbus: ndarray[tuple[Any, ...], dtype[float64]], types: ndarray[tuple[Any, ...], dtype[int64]]) Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]๏ƒ

Compile the types. :param Pbus: array of real power Injections per node used to choose the slack as

the node with greater generation if no slack is provided

Parameters:

types โ€“ array of tentative node types (it may be modified internally)

Returns:

ref, pq, pv, pqpv

VeraGridEngine.Topology.simulation_indices.replace_bus_types(bus_types, pq_val=1, pv_val=2, pqv_val=4, p_val=5)[source]๏ƒ
Parameters:
  • bus_types

  • pq_val

  • pv_val

  • pqv_val

  • p_val

Returns:

VeraGridEngine.Topology.topology module๏ƒ

class VeraGridEngine.Topology.topology.ConnectivityMatrices(Cf: csc_matrix, Ct: csc_matrix)๏ƒ

Bases: object

Connectivity matrices

property C: csc_matrix๏ƒ

Adjacency matrix :return:

property Cf: csc_matrix๏ƒ

Get the connectivity from matrix :return: sp.csc_matrix

Cf_๏ƒ
property Ct: csc_matrix๏ƒ

Get the connectivity to matrix :return: sp.csc_matrix

Ct_๏ƒ
get_adjacency(bus_active: ndarray[tuple[Any, ...], dtype[int64]]) csc_matrix๏ƒ
Parameters:

bus_active

Returns:

VeraGridEngine.Topology.topology.build_branches_C_coo_2(bus_active: ndarray[tuple[Any, ...], dtype[int64]], F1: ndarray[tuple[Any, ...], dtype[int64]], T1: ndarray[tuple[Any, ...], dtype[int64]], active1: ndarray[tuple[Any, ...], dtype[bool]], F2: ndarray[tuple[Any, ...], dtype[int64]], T2: ndarray[tuple[Any, ...], dtype[int64]], FN2: ndarray[tuple[Any, ...], dtype[int64]], active2: ndarray[tuple[Any, ...], dtype[bool]])๏ƒ

Build the COO coordinates of the C matrix :param bus_active: array of bus active values :param F1: Passive branches from bus indices array :param T1: Passive branches to bus indices array :param active1: Passive branches active array :param F2: VSC from buses indices array :param T2: VSC to buses indices array :param FN2: VSC from negative buses indices array :param active2: VSC active array :return:

VeraGridEngine.Topology.topology.build_branches_C_coo_3(bus_active: ndarray[tuple[Any, ...], dtype[int64]], F1: ndarray[tuple[Any, ...], dtype[int64]], T1: ndarray[tuple[Any, ...], dtype[int64]], active1: ndarray[tuple[Any, ...], dtype[bool]], F2: ndarray[tuple[Any, ...], dtype[int64]], T2: ndarray[tuple[Any, ...], dtype[int64]], FN2: ndarray[tuple[Any, ...], dtype[int64]], active2: ndarray[tuple[Any, ...], dtype[bool]], F3: ndarray[tuple[Any, ...], dtype[int64]], T3: ndarray[tuple[Any, ...], dtype[int64]], active3: ndarray[tuple[Any, ...], dtype[bool]])๏ƒ

Build the COO coordinates of the C matrix :param bus_active: array of bus active values :param F1: Passive branches from bus indices array :param T1: Passive branches to bus indices array :param active1: Passive branches active array :param F2: VSC from buses indices array :param FN2: VSC from negative buses indices array :param T2: VSC to buses indices array :param active2: VSC active array :param F3: HVDC from bus indices array :param T3: HVDC to bus indices array :param active3: HVDC active array :return: i, j, data, nelm to build C(nelm, nbus)

VeraGridEngine.Topology.topology.build_reducible_branches_C_coo(F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]], reducible: ndarray[tuple[Any, ...], dtype[int64]], active: ndarray[tuple[Any, ...], dtype[int64]])๏ƒ

Build the COO coordinates of the C matrix :param F: branches From indices :param T: branches To indices :param reducible: branches reducible array :param active: branches active array :return: i, j, data, n_red

VeraGridEngine.Topology.topology.compute_connectivity(branch_active: ndarray[tuple[Any, ...], dtype[int64]], Cf_: csc_matrix, Ct_: csc_matrix) ConnectivityMatrices๏ƒ

Compute the from and to connectivity matrices applying the branch states :param branch_active: array of branch states :param Cf_: Connectivity branch-bus โ€œfromโ€ :param Ct_: Connectivity branch-bus โ€œtoโ€ :return: Final Ct and Cf in CSC format

VeraGridEngine.Topology.topology.compute_connectivity_flexible(branch_active: ndarray[tuple[Any, ...], dtype[int64]] | None = None, Cf_: csc_matrix | None = None, Ct_: csc_matrix | None = None, hvdc_active: ndarray[tuple[Any, ...], dtype[int64]] | None = None, Cf_hvdc: csc_matrix | None = None, Ct_hvdc: csc_matrix | None = None, vsc_active: ndarray[tuple[Any, ...], dtype[int64]] | None = None, Cf_vsc: csc_matrix | None = None, Ct_vsc: csc_matrix | None = None) ConnectivityMatrices๏ƒ

Compute the from and to connectivity matrices applying the branch states :param branch_active: array of branch states :param Cf_: Connectivity branch-bus โ€œfromโ€ :param Ct_: Connectivity branch-bus โ€œtoโ€ :param hvdc_active: array of hvdc states :param Cf_hvdc: Connectivity hvdc-bus โ€œfromโ€ :param Ct_hvdc: Connectivity hvdc-bus โ€œtoโ€ :param vsc_active: array of hvdc states :param Cf_vsc: Connectivity hvdc-bus โ€œfromโ€ :param Ct_vsc: Connectivity hvdc-bus โ€œtoโ€ :return: Final Ct and Cf in CSC format

VeraGridEngine.Topology.topology.dev_per_bus(nbus: int, bus_indices: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[int64]]๏ƒ

Summation of magnitudes per bus (bool) :param nbus: number of buses :param bus_indices: elementsโ€™ bus indices :return: array of size nbus

VeraGridEngine.Topology.topology.find_different_states(states_array: ndarray[tuple[Any, ...], dtype[int64]]) Tuple[Dict[int, List[int]], ndarray[tuple[Any, ...], dtype[int64]]]๏ƒ

Find the different branch states in time that may lead to different islands :param states_array: bool array indicating the different grid states (time, device) :return: Dictionary with the time: [array of times] represented by the index, for instance

{0: [0, 1, 2, 3, 4], 5: [5, 6, 7, 8]} This means that [0, 1, 2, 3, 4] are represented by the topology of 0 and that [5, 6, 7, 8] are represented by the topology of 5

VeraGridEngine.Topology.topology.find_islands(adj: csc_matrix, active: ndarray[tuple[Any, ...], dtype[int64]]) List[ndarray[tuple[Any, ...], dtype[int64]]]๏ƒ

Method to get the islands of a graph This is the non-recursive version :param adj: adjacency :param active: active state of the nodes :return: list of islands, where each element is a list of the node indices of the island

VeraGridEngine.Topology.topology.find_islands_numba(node_number: int, indptr: ndarray[tuple[Any, ...], dtype[int64]], indices: ndarray[tuple[Any, ...], dtype[int64]], active: ndarray[tuple[Any, ...], dtype[int64]]) List[ndarray[tuple[Any, ...], dtype[int64]]]๏ƒ

Method to get the islands of a graph This is the non-recursive version :param node_number: :param indptr: index pointers in the CSC scheme :param indices: column indices in the CSCS scheme :param active: array of node active :return: list of islands, where each element is a list of the node indices of the island

VeraGridEngine.Topology.topology.get_adjacency_matrix(C_branch_bus_f: csc_matrix, C_branch_bus_t: csc_matrix, branch_active: ndarray[tuple[Any, ...], dtype[int64]], bus_active: ndarray[tuple[Any, ...], dtype[int64]]) csc_matrix๏ƒ

Compute the adjacency matrix :param C_branch_bus_f: Branch-bus_from connectivity matrix :param C_branch_bus_t: Branch-bus_to connectivity matrix :param branch_active: array of Branches availability :param bus_active: array of buses availability :return: Adjacency matrix

VeraGridEngine.Topology.topology.get_csr_bus_indices(C: csr_matrix) ndarray[tuple[Any, ...], dtype[int64]]๏ƒ

Get the bus indices given a CSR shunt-element->bus connectivity matrix :param C: CSR connectivity matrix :return: Bus indices

VeraGridEngine.Topology.topology.get_elements_of_the_island(C_element_bus: csc_matrix, island: ndarray[tuple[Any, ...], dtype[int64]], active: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[int64]]๏ƒ

Get the branch indices of the island :param C_element_bus: CSC elements-buses connectivity matrix with the dimensions: elements x buses :param island: array of bus indices of the island :param active: Array of bus active :return: array of indices of the elements that match that island

VeraGridEngine.Topology.topology.get_elements_of_the_island_numba(n_rows: int, indptr: ndarray[tuple[Any, ...], dtype[int64]], indices: ndarray[tuple[Any, ...], dtype[int64]], island: ndarray[tuple[Any, ...], dtype[int64]], active: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[int64]]๏ƒ

Get the element indices of the island :param n_rows: Number of rows of the connectivity matrix :param indptr: CSC index pointers of the element-node connectivity matrix :param indices: CSC indices of the element-node connectivity matrix :param island: island node indices :param active: Array of bus active :return: array of indices of the elements that match that island

VeraGridEngine.Topology.topology.get_island_branch_indices(bus_map: ndarray[tuple[Any, ...], dtype[int64]], elm_active: ndarray[tuple[Any, ...], dtype[bool]], F: ndarray[tuple[Any, ...], dtype[int64]], T: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[int64]]๏ƒ

Get the branches that should belong into an island

The conditions are: - is active (conducting electricity) - The from bus index > -1 - The to bus index > -1 - The from bus index != to bus index (is not connected in a loop, which happens after topology reduction)

Parameters:
  • bus_map

  • elm_active

  • F

  • T

Returns:

VeraGridEngine.Topology.topology.get_island_monopole_indices(bus_map: ndarray[tuple[Any, ...], dtype[int64]], elm_active: ndarray[tuple[Any, ...], dtype[bool]], elm_bus: ndarray[tuple[Any, ...], dtype[int64]]) ndarray[tuple[Any, ...], dtype[int64]]๏ƒ
Parameters:
  • bus_map

  • elm_active

  • elm_bus

Returns:

VeraGridEngine.Topology.topology.sum_per_bus(nbus: int, bus_indices: ndarray[tuple[Any, ...], dtype[int64]], magnitude: ndarray[tuple[Any, ...], dtype[float64]]) ndarray[tuple[Any, ...], dtype[float64]]๏ƒ

Summation of magnitudes per bus (real) :param nbus: number of buses :param bus_indices: elementsโ€™ bus indices :param magnitude: elementsโ€™ magnitude to add per bus :return: array of size nbus

VeraGridEngine.Topology.topology.sum_per_bus_bool(nbus: int, bus_indices: ndarray[tuple[Any, ...], dtype[int64]], magnitude: ndarray[tuple[Any, ...], dtype[bool]]) ndarray[tuple[Any, ...], dtype[bool]]๏ƒ

Summation of magnitudes per bus (bool) :param nbus: number of buses :param bus_indices: elementsโ€™ bus indices :param magnitude: elementsโ€™ magnitude to add per bus :return: array of size nbus

VeraGridEngine.Topology.topology.sum_per_bus_cx(nbus: int, bus_indices: ndarray[tuple[Any, ...], dtype[int64]], magnitude: ndarray[tuple[Any, ...], dtype[complex128]]) ndarray[tuple[Any, ...], dtype[complex128]]๏ƒ

Summation of magnitudes per bus (complex) :param nbus: number of buses :param bus_indices: elementsโ€™ bus indices :param magnitude: elementsโ€™ magnitude to add per bus :return: array of size nbus

Module contents๏ƒ