Struct IndexedNetwork
pub struct IndexedNetwork<'n> { /* private fields */ }Expand description
A BalancedNetwork paired with its derived IndexCore. The network is borrowed for
the common case, but owned when it had to be star-lowered (a 3-winding
transformer expanded into a star bus plus three branches via
BalancedNetwork::expand_transformers_3w); the core is owned (IndexedNetwork::new)
or borrowed from a cached IndexCore (IndexedNetwork::with_core).
Implementations§
§impl<'n> IndexedNetwork<'n>
impl<'n> IndexedNetwork<'n>
pub fn new(net: &'n BalancedNetwork) -> IndexedNetwork<'n>
pub fn new(net: &'n BalancedNetwork) -> IndexedNetwork<'n>
pub fn with_core(
net: &'n BalancedNetwork,
core: &'n IndexCore,
) -> IndexedNetwork<'n>
pub fn with_core( net: &'n BalancedNetwork, core: &'n IndexCore, ) -> IndexedNetwork<'n>
Pair net with an already-built IndexCore — no allocation when net
has no 3-winding transformer (the core must have been built from this same
net). When net does carry a 3-winding transformer, the view star-lowers
it and rebuilds the core over the expanded form, since the cached core was
derived from the unexpanded network.
pub fn network(&self) -> &BalancedNetwork
pub fn network(&self) -> &BalancedNetwork
The underlying network (the star-lowered form when a 3-winding transformer was expanded).
pub fn n(&self) -> usize
pub fn base_mva(&self) -> f64
pub fn per_unit_base(&self) -> f64
pub fn per_unit_base(&self) -> f64
The divisor for turning a power quantity (shunt, load, generation) into
per unit. base_mva for a raw network; 1.0 for a normalized one, whose
powers are already per unit (so a second division would scale them twice).
base_mva itself stays at the system base — for MW recovery and
write-back — so use this, not base_mva, wherever the intent is “÷ base
to get per unit”. The effect is that a per-unit matrix builder yields the
same matrix for a network and its to_normalized
form.
pub fn to_radians(&self, angle: f64) -> f64
pub fn to_radians(&self, angle: f64) -> f64
A branch/bus angle field (shift, va) in radians. The raw model stores
angles in degrees; a normalized network already stores radians, so for it
this is the identity. The angle analogue of
per_unit_base: a builder gets the same radians
whether it is handed a network or its
to_normalized form, so the matrix comes out
the same.
pub fn name(&self) -> &str
pub fn branches(&self) -> &[Branch]
pub fn branches(&self) -> &[Branch]
All branches, in source order (column order for incidence-based builds).
pub fn generators(&self) -> &[Generator]
pub fn generators(&self) -> &[Generator]
All generators, in source order.
pub fn p_hvdc(&self) -> &[f64]
pub fn p_hvdc(&self) -> &[f64]
Nodal fixed HVDC active injection, length n: -pf at each in
service line’s from bus and +pt at its to bus, summed per bus, in
the unit of pd. A calculation under
HvdcTreatment::FixedInjection adds it to the
net injection beside generation minus demand.
pub fn q_hvdc(&self) -> &[f64]
pub fn q_hvdc(&self) -> &[f64]
Nodal fixed HVDC reactive injection, length n: +qf at each in
service line’s from bus and +qt at its to bus, summed per bus, in
the unit of qd.
pub fn hvdc_injections(&self) -> &HvdcInjections
pub fn hvdc_injections(&self) -> &HvdcInjections
pub fn in_service_branches(&self) -> impl Iterator<Item = (usize, &Branch)>
pub fn in_service_branches(&self) -> impl Iterator<Item = (usize, &Branch)>
In-service branches with their index into branches.
pub fn is_analysis_branch(&self, row: usize) -> bool
pub fn is_analysis_branch(&self, row: usize) -> bool
Whether branch row row of this view’s network enters the AC
analysis: it is in service, joins two distinct buses that resolve and
are not typed isolated, and has a series impedance the pi model can
divide by (calc_series_admittance_of
returns a finite admittance, the guard every admittance builder
shares). An out of range row is not one.
This is the branch set an AC preparation keeps as branch columns. A DC formula that reads only the reactance can keep a purely resistive branch as a zero weight column in addition.
pub fn in_service_gens(&self) -> impl Iterator<Item = (usize, &Generator)>
pub fn in_service_gens(&self) -> impl Iterator<Item = (usize, &Generator)>
In-service generators with their index into generators.
pub fn reference_bus_indices(&self) -> Vec<usize>
pub fn reference_bus_indices(&self) -> Vec<usize>
Dense indices of every reference (slack) bus, in ascending order. A
network may carry more than one BusType::Ref (a slack per island, or
several the source file marked) — the matrix layer grounds one row/column
per entry. Empty when the network has no reference bus.
pub fn reference_bus_index(&self) -> Result<usize, Error>
pub fn reference_bus_index(&self) -> Result<usize, Error>
Dense index of the single reference (slack) bus. Errors unless exactly
one BusType::Ref exists; for the multi-reference case use
reference_bus_indices.
pub fn branch_edges(&self) -> impl Iterator<Item = (usize, usize, usize)>
pub fn branch_edges(&self) -> impl Iterator<Item = (usize, usize, usize)>
The in-service topology as undirected edges between dense bus
indices: (branch, from, to), where branch indexes the network’s
branch table. Out-of-service branches are skipped and parallel
branches stay separate edges, so a graph library of your choice can
build its graph from this without PowerIO exposing one.
pub fn closed_switches(&self) -> impl Iterator<Item = (usize, &Switch)>
pub fn closed_switches(&self) -> impl Iterator<Item = (usize, &Switch)>
In-service switches that are closed and join two distinct buses, with their index into the network’s switch table. A closed switch is an ideal connection: its two buses are one electrical node.
pub fn check_closed_switches(&self) -> Result<(), Error>
pub fn check_closed_switches(&self) -> Result<(), Error>
Error if a closed switch joins two buses.
The matrix builders and solver preparations stamp branches only, so on
a network that still carries a closed switch they leave its two buses
apart. Normalization merges closed switches by default
(ClosedSwitchPolicy::Merge), and
merge_buses merges them under a rule
that selects them; call this before building to refuse a network that
skipped both.
§Errors
[Error::ClosedSwitch] naming the first closed switch and the count,
with the calls that merge them.
pub fn calc_island_count(&self) -> usize
pub fn calc_island_count(&self) -> usize
Number of connected components in the in-service topology: buses joined by in-service branches or closed switches.
pub fn calc_island_labels(&self) -> Vec<usize>
pub fn calc_island_labels(&self) -> Vec<usize>
Connected-component label per dense bus index (in-service topology): two
buses share a label iff a path of in-service branches and closed
switches joins them, and an isolated bus is its own component. Labels
are representative indices in [0, n), not a dense [0, k) range — use
them for equality grouping (e.g. checking every island carries a
reference bus to ground).
pub fn check_reference_coverage(&self) -> Result<(), Error>
pub fn check_reference_coverage(&self) -> Result<(), Error>
Error unless every connected component of the in-service topology carries
at least one reference (slack) bus. This is the grounding precondition
for the DC Laplacian: an island with no reference leaves its all-ones
null vector in the system, so the reference-grounded Laplacian stays
singular. With one reference in a single island it reduces to the
single slack requirement. Reports the count of ungrounded components.
Closed switches join their buses here as they do in
calc_island_labels.
pub fn is_radial(&self) -> bool
pub fn is_radial(&self) -> bool
True iff the in-service topology, branches and closed switches alike,
is a forest (|E| = |V| - components).
pub fn calc_connectivity_report(&self) -> ConnectivityReport
pub fn calc_connectivity_report(&self) -> ConnectivityReport
Calculate a one-shot topological diagnostic. Closed switches join their
buses as they do in calc_island_labels.