Skip to main content

JacobianPattern

Struct JacobianPattern 

Source
pub struct JacobianPattern {
    pub n_unknowns: usize,
    /* private fields */
}
Expand description

A topology’s Jacobian sparsity pattern plus the per-entry recipes needed to refill its values. Build once per topology via analyze; call fill every iteration.

rows/cols/entries are parallel arrays of the same length, in the exact emission order solver::build_jacobian_triplets used, so a cached symbolic factorization keyed on that order stays valid — until permute puts them in a sparse LU’s own storage order.

Fields§

§n_unknowns: usize

Implementations§

Source§

impl JacobianPattern

Source

pub fn analyze(buses: &[Bus], ybus: &YBusSparse) -> Self

Derives the pattern from a topology and a bus-type assignment.

Must be recomputed if either changes — a different set of branches, or any bus switching PV↔PQ (which changes n_unknowns itself). This is the same validity condition solver::PersistentSolver documents for its cached factorization, and the two are reset together.

Source

pub fn permute(&mut self, order: &[usize])

Reorders the entries so that entry k is the one that was at order[k]: from then on fill writes, and to_triplets lists, in that order. What lu::SparseLu::adopt_storage_order returns, so the fill writes straight into the factorization’s own layout.

§Panics

If order is not a permutation of 0..len().

Source

pub fn len(&self) -> usize

Number of Jacobian nonzeros — the length of values that fill expects.

Source

pub fn is_empty(&self) -> bool

Source

pub fn rows(&self) -> &[u32]

Source

pub fn cols(&self) -> &[u32]

Source

pub fn entries(&self) -> &[Entry]

Source

pub fn fill( &self, buses: &[Bus], p_calc: &[f64], q_calc: &[f64], values: &mut Vec<f64>, )

Writes this iteration’s Jacobian values into values, which is resized to len and otherwise fully overwritten.

Every write is independent and lands at a fixed offset — no allocation, no index arithmetic, no branching beyond the eight-way kind dispatch. That independence is what makes this portable to one thread per entry.

Source

pub fn fill_into( &self, buses: &[Bus], p_calc: &[f64], q_calc: &[f64], values: &mut Vec<f64>, )

fill without the clear — appends this scenario’s values to values. What lets bde::BlockDiagonal concatenate B scenarios’ blocks into one flat array for a block-diagonal solve.

Source

pub fn fill_with( &self, v: &BusVoltages, p_calc: &[f64], q_calc: &[f64], values: &mut Vec<f64>, )

fill from voltages already taken, which the Newton loop shares with the power injections.

Source

pub fn fill_identity_into(&self, values: &mut Vec<f64>)

Appends an identity block in this pattern’s own layout: 1.0 at every stored diagonal position, 0.0 everywhere else.

This is how bde::BlockDiagonal masks a converged or diverged scenario out of a batch. Dropping its block outright would change the stacked matrix’s sparsity pattern and invalidate the cached symbolic factorization — the whole reason batching is cheap. Writing an identity into the same stored positions keeps the pattern bit-identical while making that scenario’s update exactly zero (with a zero right-hand side), and identity is perfectly conditioned so it cannot degrade the factorization.

Every diagonal position is structurally present: Hii supplies (r, r) for every angle row and Lii supplies it for every magnitude row, so no fill-in is required to write this.

Source

pub fn to_triplets(&self, values: &[f64]) -> Vec<(usize, usize, f64)>

Convenience for callers that still want (row, col, value) triplets, which is the shape every solver::LinearSolver backend consumes.

Auto Trait Implementations§

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

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

Source§

fn vzip(self) -> V