Skip to main content

DcOpfPreparation

Struct DcOpfPreparation 

Source
#[non_exhaustive]
pub struct DcOpfPreparation {
Show 24 fields pub name: String, pub n_buses: usize, pub n_source_generators: usize, pub n_source_branches: usize, pub base_mva: f64, pub units: Units, pub formula: BranchSusceptanceFormula, pub objective: PreparedObjective, pub skip_zero_impedance: bool, pub synthesize_unrated_limits: bool, pub synthesized_limit_window: SynthesizedLimitWindow, pub correct_angle_difference_bounds: bool, pub angle_difference_bounds: Option<AngleDifferenceBounds>, pub bus_ids: Vec<BusId>, pub bus_analysis_rows: Vec<usize>, pub bus_source_rows: Vec<Option<usize>>, pub reference_buses: ReferenceBuses, pub p_d: Vec<f64>, pub g_s: Vec<f64>, pub p_shift: Vec<f64>, pub hvdc_treatment: HvdcTreatment, pub p_hvdc: Vec<f64>, pub generators: DcGeneratorParameters, pub branches: DcBranchParameters,
}
Expand description

Matrix free DC OPF input data.

A problem instance is complete numerical input for one problem family. It is separate from the source network, a matrix projection, a solver formulation, and a solution.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String§n_buses: usize§n_source_generators: usize§n_source_branches: usize§base_mva: f64§units: Units§formula: BranchSusceptanceFormula

Formula used to calculate each branch susceptance.

§objective: PreparedObjective

The objective represented by the generator cost columns.

§skip_zero_impedance: bool§synthesize_unrated_limits: bool

Whether zero and negative source thermal ratings were replaced with synthesized limits while assembling this instance.

#[serde(default)] keeps documents written before this field readable; their limits retain the old unsynthesized meaning.

§synthesized_limit_window: SynthesizedLimitWindow

The angle difference interval those limits span. Omitted from a document when it is the stated one, so earlier documents read the window they were built with.

§correct_angle_difference_bounds: bool

Whether PowerModels’ angle difference correction was applied.

§angle_difference_bounds: Option<AngleDifferenceBounds>

Which angle difference bounds angle_min and angle_max carry. None only in a document written before the field existed, whose correct_angle_difference_bounds says whether the pad was applied.

§bus_ids: Vec<BusId>

Dense bus index to external bus ID.

§bus_analysis_rows: Vec<usize>

Dense bus index to row in the star-lowered analysis network.

§bus_source_rows: Vec<Option<usize>>

Dense bus index to source bus row. A synthetic star bus has no source row; an explicitly isolated source bus has no dense row here.

§reference_buses: ReferenceBuses§p_d: Vec<f64>

Nodal active demand in dense bus order.

§g_s: Vec<f64>

Nodal shunt conductance in dense bus order.

The DC power flow model holds voltage magnitude at one per unit, so a shunt draws the constant real power g_s and does not depend on the angle. It belongs in the injection: the bus susceptance matrix keeps zero row sums and carries no shunt. A nodal balance subtracts it beside Self::p_d, as MATPOWER runpf does.

§p_shift: Vec<f64>

Nodal phase shift injection in dense bus order. The complete fixed withdrawal in L theta = Cg pg - fixed is p_d + g_s + p_shift - p_hvdc.

§hvdc_treatment: HvdcTreatment

How in service HVDC lines entered Self::p_hvdc.

#[serde(default)] keeps documents written before this field readable.

§p_hvdc: Vec<f64>

Nodal fixed HVDC injection in dense bus order: -pf at each in service line’s from bus and +pt at its to bus (IndexedNetwork::p_hvdc). All zero under [HvdcTreatment::Ignore]. An injection, so the fixed withdrawal subtracts it.

#[serde(default)]: a document written before this field reads as empty, which Self::calc_fixed_nodal_withdrawal takes as zero.

§generators: DcGeneratorParameters§branches: DcBranchParameters

Implementations§

Source§

impl DcOpfPreparation

Source

pub fn n_generators(&self) -> usize

Source

pub fn n_branches(&self) -> usize

Source

pub fn calc_fixed_nodal_withdrawal(&self) -> Vec<f64>

Fixed nodal withdrawal in dense bus order.

With A oriented from bus to bus and L = A diag(b) A^T, the DC balance is L theta = Cg pg - (p_d + g_s + p_shift - p_hvdc). It is calc_device_withdrawal plus the phase shift withdrawal p_shift.

Source

pub fn calc_device_withdrawal(&self) -> Vec<f64>

The withdrawal of the bus devices in dense bus order, p_d + g_s - p_hvdc: the fixed nodal withdrawal without the phase shift term, which the branch flows carry rather than the bus. Net generation less this is the bus injection a solution reports.

Source

pub fn calc_branch_flow_offset(&self) -> Vec<f64>

Fixed branch flow offset in active branch column order.

The complete branch flow over this preparation’s internal positive weights is f = diag(b) A^T theta + branch_flow_offset, where the offset is -b * shift elementwise. In the public PowerModels sign spelling the same flow is p_branch = -Bf va + b .* shift with the negated susceptances (crate::DcOperators emits that form); the two agree term for term because this b is the negation of the public one.

Source

pub fn calc_phase_shift_withdrawal(&self) -> Vec<f64>

The nodal phase shift withdrawal A branch_flow_offset of this preparation’s branch columns, in dense bus order and the preparation’s power unit: each branch’s calc_branch_flow_offset leaves at its from bus and arrives at its to bus. This is the calculation behind Self::p_shift; a caller that edits the branch weights or shifts recomputes p_shift with it.

Source

pub fn calc_nodal_generator_data(&self) -> Result<NodalGeneratorParameters>

Project generator cost and bounds to bus space.

The bounds at a bus are the sum of the generator bounds, which is the range the bus total can reach. The cost curves at a bus combine by the parallel rule q = 1 / Σ(1/qᵢ), the curve that the least cost split of the bus total follows. That combination is an approximation: it agrees with generator space only while the split stays inside the bound of each generator. A bus with one generator keeps that generator’s own coefficients.

Source§

impl DcOpfPreparation

Source

pub fn calc_bus_branch_incidence(&self) -> SparseMatrix

The signed bus by branch incidence matrix A of this preparation, n_buses × n_branches CSR: column e has +1 at the branch’s from bus and -1 at its to bus, in active branch column order. Self-loops never reach the preparation, so every column has exactly two entries.

This is the matrix DcOpfMatrices::bus_branch_incidence carries, from the one incidence assembly every builder in the crate uses, read from the arrays the preparation already holds: one pass over the branch columns, with no network indexing and no DcOperators build. Row i of the CSR lists the (branch, sign) pairs at bus i in ascending branch order.

§Panics

Panics if a branch column names a bus >= n_buses, which no preparation builder produces.

Source

pub fn calc_generator_bus_incidence(&self) -> SparseMatrix

The generator to bus map Cg of this preparation, n_buses × n_generators CSR with a 1 at row bus_of_gen[g] of column g. Row i lists the generators at bus i in ascending column order. This is DcOpfMatrices::generator_bus.

§Panics

Panics if a generator names a bus >= n_buses, which no preparation builder produces.

Source

pub fn calc_matrices(&self) -> DcOpfMatrices

Every sparse DC OPF matrix of this preparation, as calc_dc_opf_matrices returns them for the instance the preparation came from, without preparing it again.

Source

pub fn calc_branch_flow(&self, theta: &[f64]) -> Vec<f64>

The branch flows at the bus angles theta (radians, dense bus order), in active branch column order and the preparation’s power unit: f = diag(b) Aᵀ theta + branch_flow_offset, with b the positive DcBranchParameters::susceptance_magnitude and the offset from Self::calc_branch_flow_offset. Positive flow runs from the from bus to the to bus.

§Panics

Panics if theta.len() is not n_buses.

Source

pub fn calc_angle_difference(&self, theta: &[f64], branch: usize) -> f64

The angle difference theta_from - theta_to across active branch column branch, its entry of Aᵀ theta, for any bus vector theta (angles, or a bus dual).

§Panics

Panics if branch is not an active branch column or theta is shorter than n_buses.

Source

pub fn calc_branch_flow_weight_derivative( &self, theta: &[f64], branch: usize, ) -> f64

The derivative of branch column branch’s flow (calc_branch_flow) at the bus angles theta with respect to its positive weight DcBranchParameters::susceptance_magnitude: theta_from - theta_to - shift, in radians.

§Panics

As calc_angle_difference.

Trait Implementations§

Source§

impl Clone for DcOpfPreparation

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DcOpfPreparation

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DcOpfPreparation

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for DcOpfPreparation

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DcOpfPreparation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DcOpfPreparation

Auto Trait Implementations§

Blanket Implementations§

§

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

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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

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

§

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

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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.

§

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

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
§

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

§

fn vzip(self) -> V