simplenet.generators¶
Move external generators to their nearest internal bus.
Port of matlab/NetworkReduction2/MoveExGen.m. The MATLAB code builds
a sparse network from the "second" reduction (where only the
non-generator externals are eliminated) and runs a layered shortest
electrical-distance search to attach every external generator to its
closest retained bus. We achieve the same result by collapsing parallel
lines and running multi-source Dijkstra (scipy.sparse.csgraph).
Inputs to :func:move_external_generators:
case_with_gens
The :class:PowerCase that resulted from the second reduction -
its bus set is internal U external-with-generator.
internal_bus_ids
Bus IDs (original numbering) that are truly internal (retained)
and serve as the multi-source set.
ac_flag
If True use |z| = sqrt(r^2 + x^2) as the edge weight, else
|x|. The MATLAB reduction_test.m always passes 0, but
we expose it for flexibility.
GenMoveResult
dataclass
¶
Output of :func:move_external_generators.
Attributes:
| Name | Type | Description |
|---|---|---|
new_gen_bus |
ndarray
|
Array of length |
link |
ndarray
|
2-D array of shape |
islanded |
ndarray
|
Bus IDs that could not reach any internal bus; their generators
are dropped from |
move_external_generators
¶
move_external_generators(case_with_gens: PowerCase, internal_bus_ids: ndarray, *, ac_flag: bool = False) -> GenMoveResult
Find the closest internal bus for every external generator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
case_with_gens
|
PowerCase
|
The :class: |
required |
internal_bus_ids
|
ndarray
|
Original-numbered bus IDs that should be treated as retained (multi-source set for the Dijkstra search). |
required |
ac_flag
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
GenMoveResult
|
|
Source code in src/simplenet/generators.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |