Skip to main content

IndexedNetwork

Struct IndexedNetwork 

Source
pub struct IndexedNetwork<'n> { /* private fields */ }
Expand description

A Network paired with its derived IndexCore. Borrows the network; the core is either owned (the one-shot IndexedNetwork::new) or borrowed from a cached IndexCore (IndexedNetwork::with_core).

Implementations§

Source§

impl<'n> IndexedNetwork<'n>

Source

pub fn new(net: &'n Network) -> IndexedNetwork<'n>

Build a one-shot view that owns a freshly derived IndexCore. For repeated queries on a long-lived handle, cache an IndexCore and use with_core so the derivation isn’t rebuilt per call.

Source

pub fn with_core(net: &'n Network, core: &'n IndexCore) -> IndexedNetwork<'n>

Pair net with an already-built IndexCore — no allocation. The core must have been built from this same net.

Source

pub fn network(&self) -> &Network

The underlying network.

Source

pub fn n(&self) -> usize

Source

pub fn base_mva(&self) -> f64

Source

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.

Source

pub fn angle_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.

Source

pub fn name(&self) -> &str

Source

pub fn branches(&self) -> &[Branch]

All branches, in source order (column order for incidence-based builds).

Source

pub fn generators(&self) -> &[Generator]

All generators, in source order.

Source

pub fn bus_index(&self, bus_id: BusId) -> Option<usize>

Resolve a bus id to its dense [0, n) index.

Source

pub fn bus_id(&self, idx: usize) -> BusId

The bus id at dense index idx — the inverse of bus_index.

§Panics

Panics if idx >= n. Pass a dense index (e.g. from bus_index or a matrix row), not a raw bus id.

Source

pub fn pd(&self) -> &[f64]

Nodal active demand, length n.

Source

pub fn qd(&self) -> &[f64]

Nodal reactive demand, length n.

Source

pub fn gs(&self) -> &[f64]

Nodal shunt conductance, length n.

Source

pub fn bs(&self) -> &[f64]

Nodal shunt susceptance, length n.

Source

pub fn in_service_branches(&self) -> impl Iterator<Item = (usize, &Branch)>

In-service branches with their index into branches.

Source

pub fn in_service_gens(&self) -> impl Iterator<Item = (usize, &Generator)>

In-service generators with their index into generators.

Source

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.

Source

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.

Source

pub fn to_petgraph(&self) -> Graph<usize, usize, Undirected>

Undirected graph view: node weight = dense bus index, edge weight = index into branches. Out-of-service branches are skipped; parallel branches are kept as separate edges.

Source

pub fn n_connected_components(&self) -> usize

Number of connected components in the in-service topology.

Source

pub fn connected_component_labels(&self) -> Vec<usize>

Connected-component label per dense bus index (in-service topology): two buses share a label iff an in-service branch path 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).

Source

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.

Source

pub fn is_radial(&self) -> bool

True iff the in-service topology is a forest (|E| = |V| - components).

Source

pub fn connectivity_report(&self) -> ConnectivityReport

One-shot topological diagnostic.

Trait Implementations§

Source§

impl<'n> Debug for IndexedNetwork<'n>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'n> Freeze for IndexedNetwork<'n>

§

impl<'n> RefUnwindSafe for IndexedNetwork<'n>

§

impl<'n> Send for IndexedNetwork<'n>

§

impl<'n> Sync for IndexedNetwork<'n>

§

impl<'n> Unpin for IndexedNetwork<'n>

§

impl<'n> UnsafeUnpin for IndexedNetwork<'n>

§

impl<'n> UnwindSafe for IndexedNetwork<'n>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,