pwrs.power_models.network#
Formulation-neutral PowerModels network preparation.
This module owns MATPOWER input cleanup, active-component indexing, topology, and branch admittance coefficients. It must not contain formulation variables, constraint ordering, solver state, or result-vector layouts.
- class pwrs.power_models.network.BranchAdmittance(g_ff, b_ff, g_ft, b_ft, g_tf, b_tf, g_tt, b_tt)[source]#
Bases:
objectReal and imaginary parts of the four branch admittance blocks.
- Parameters:
g_ff (ndarray)
b_ff (ndarray)
g_ft (ndarray)
b_ft (ndarray)
g_tf (ndarray)
b_tf (ndarray)
g_tt (ndarray)
b_tt (ndarray)
- class pwrs.power_models.network.PowerNetwork(source, bus_external, gen_external, branch_external, dcline_external, base_mva, bus, gen, branch, gencost, dcline, dclinecost, bus_rows, gen_rows, branch_rows, dcline_rows, gen_bus, f_bus, t_bus, dc_f_bus, dc_t_bus, dc_pmin_from, dc_pmax_from, dc_pmin_to, dc_pmax_to, dc_qmin_from, dc_qmax_from, dc_qmin_to, dc_qmax_to, dc_loss0, dc_loss1, refs, angle_pairs, angle_min, angle_max, branch_angle_min, branch_angle_max, rate, branch_reversed, tap, shift, b_fr, b_to, admittance, generators_at_bus, from_branches_at_bus, to_branches_at_bus, from_dclines_at_bus, to_dclines_at_bus)[source]#
Bases:
objectPrepared network data shared by all PowerModels formulations.
- Parameters:
source (dict[str, Any])
bus_external (ndarray)
gen_external (ndarray)
branch_external (ndarray)
dcline_external (ndarray)
base_mva (float)
bus (ndarray)
gen (ndarray)
branch (ndarray)
gencost (ndarray)
dcline (ndarray)
dclinecost (ndarray)
bus_rows (ndarray)
gen_rows (ndarray)
branch_rows (ndarray)
dcline_rows (ndarray)
gen_bus (ndarray)
f_bus (ndarray)
t_bus (ndarray)
dc_f_bus (ndarray)
dc_t_bus (ndarray)
dc_pmin_from (ndarray)
dc_pmax_from (ndarray)
dc_pmin_to (ndarray)
dc_pmax_to (ndarray)
dc_qmin_from (ndarray)
dc_qmax_from (ndarray)
dc_qmin_to (ndarray)
dc_qmax_to (ndarray)
dc_loss0 (ndarray)
dc_loss1 (ndarray)
refs (ndarray)
angle_pairs (ndarray)
angle_min (ndarray)
angle_max (ndarray)
branch_angle_min (ndarray)
branch_angle_max (ndarray)
rate (ndarray)
branch_reversed (ndarray)
tap (ndarray)
shift (ndarray)
b_fr (ndarray)
b_to (ndarray)
admittance (BranchAdmittance)
generators_at_bus (tuple[tuple[int, ...], ...])
from_branches_at_bus (tuple[tuple[int, ...], ...])
to_branches_at_bus (tuple[tuple[int, ...], ...])
from_dclines_at_bus (tuple[tuple[int, ...], ...])
to_dclines_at_bus (tuple[tuple[int, ...], ...])
- bus_index(bus_id)[source]#
Return the internal index for an active MATPOWER bus number.
- Parameters:
bus_id (int)
- Return type:
int
- generator_indices(rows=None)[source]#
Map zero-based source generator rows to active internal indexes.
- Parameters:
rows (Any | None)
- Return type:
tuple[int, …]
- pwrs.power_models.network.case_dict(mpc)[source]#
Return the populated fields of a MATPOWER case as a plain dictionary.
- Parameters:
mpc (Any)
- Return type:
dict[str, Any]
- pwrs.power_models.network.pad_matrix(matrix, columns)[source]#
Copy a MATPOWER matrix and append zero result columns when required.
- Parameters:
matrix (ndarray)
columns (int)
- Return type:
ndarray