pub struct BalancedNetwork { /* private fields */ }Expand description
A balanced network with stable source bus IDs and separate element tables: an immutable cheap to clone owning handle over private shared tables.
Cloning the handle bumps one reference count and clones no table
allocation. Reads go through the per field accessors; the *_mut
accessors copy the shared tables once on first write to a shared handle
(copy on write), so no other handle ever observes a mutation. The choice
of whole value sharing is private: clone stays zero allocation because
the handle wraps its tables in one Arc.
Implementations§
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn apply_gen_cost_policy(
&mut self,
patches: &[GenCostPatch],
policy: MissingGenCostPolicy,
) -> Result<GenCostPolicyReport, Error>
pub fn apply_gen_cost_policy( &mut self, patches: &[GenCostPatch], policy: MissingGenCostPolicy, ) -> Result<GenCostPolicyReport, Error>
Apply explicit cost patches, then a missing-cost policy.
Patches replace the existing cost for the named generator. The missing-cost fill policy only touches generators still missing a cost after patching.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn to_geo_layer(&self) -> GeoLayer
pub fn to_geo_layer(&self) -> GeoLayer
Transform this network’s coordinates to a standalone GeoLayer:
one point per located bus, one route per routed branch. The layer
carries the network’s coordinate space and default origin.
Sourcepub fn apply_geo_layer(&mut self, layer: &GeoLayer) -> GeoApplyReport
pub fn apply_geo_layer(&mut self, layer: &GeoLayer) -> GeoApplyReport
Apply a GeoLayer onto this network: matched bus points land in
Bus.location, matched branch routes in Branch.route, and the
layer’s space becomes the network’s GeoMeta when anything matched.
Matching follows ElementKey. Substation features are not applied
here; join them through super::apply_substation_points.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn calc_hvdc_injections(&self) -> HvdcInjections
pub fn calc_hvdc_injections(&self) -> HvdcInjections
The fixed bus injections of every in service HVDC line whose two terminal buses are declared and not isolated, in the convention the module states, plus the rows of the lines that inject nothing. Powers are in the network’s unit, so a normalized network yields per unit.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn calc_islands(&self) -> IslandPartition
pub fn calc_islands(&self) -> IslandPartition
Partition the energized buses into AC islands.
Two buses share an island when a path of in-service branches, closed
switches, and in-service three winding transformers joins them. HVDC
lines do not join islands: they tie asynchronous systems. Buses typed
isolated belong to no island and are listed apart, and an element that
touches one does not join anything through it. A three winding
transformer joins the buses of its in-service windings
(Transformer3W::winding_in_service),
so one whose tertiary sits on an isolated bus or is out of service
still joins the other two. Carve an
island out with subset_buses, which
keeps such a transformer.
Sourcepub fn assign_island_references(
&mut self,
policy: IslandReferencePolicy,
) -> IslandReferenceReport
pub fn assign_island_references( &mut self, policy: IslandReferencePolicy, ) -> IslandReferenceReport
Give every island one reference bus under policy, returning what
changed.
Under IslandReferencePolicy::PerIsland, in a supplied island:
- A stated reference that hosts no in-service generator cannot balance the island and is demoted to PQ first. What follows counts only the references that remain.
- An island with one reference keeps it.
- An island with none gets the bus of its largest
pmaxin-service generator (the smallest bus id breaking ties) as its reference. - An island with several keeps the one hosting the most in-service
pmax(the smallest id breaking ties) and demotes the others to PV. - An island with no in-service generator has no source to balance it, so it is de-energized: its buses are typed isolated, and the in-service loads, shunts, static var compensators, storage, and every branch and HVDC line touching them are taken out of service. A three winding transformer loses the windings on those buses and goes out whole only when fewer than two windings remain.
Each change records one finding. Normalization under the same policy
picks the same reference buses. IslandReferencePolicy::Stated
changes nothing and reports the partition.
Sourcepub fn keep_island(&mut self, island: &BTreeSet<BusId>) -> Vec<BusId>
pub fn keep_island(&mut self, island: &BTreeSet<BusId>) -> Vec<BusId>
Keep island energized and de-energize every other bus not already
typed isolated, with de_energize_buses,
returning the buses de-energized in ascending order.
This is the in-place counterpart of
subset_buses: every table keeps all
its rows, so a source row index still names the same element, and the
elements outside island stay in the network out of service. Pass the
buses of one Island of calc_islands, or
the union of several.
Sourcepub fn de_energize_buses(&mut self, buses: &BTreeSet<BusId>)
pub fn de_energize_buses(&mut self, buses: &BTreeSet<BusId>)
De-energize buses, as assign_island_references does to an island
with no source.
Each bus is typed isolated, and the loads, shunts, static var compensators, storage, and generators at them, and every branch and HVDC line touching them, are taken out of service. A three winding transformer loses the windings on those buses and goes out whole only when fewer than two windings remain. Switches keep their state: a closed switch joins nothing through an isolated bus. No row is added or removed, so data keyed by source rows stays valid. Ids the network does not declare are ignored, and only a table with an element to change is copied.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn merge_buses(&self, rule: &BusMergeRule) -> Result<BusMerge, Error>
pub fn merge_buses(&self, rule: &BusMergeRule) -> Result<BusMerge, Error>
Merge every set of buses the elements rule selects connect.
Each set becomes one bus. The survivor is the set’s reference bus,
else a bus hosting an in-service generator, else a bus an in-service
generator regulates, with the smallest id breaking each tie
(MergeSurvivor::Strongest; BusMergeRule::with_survivor selects
another rule). It takes the strongest bus kind of the set (reference,
then PV, then PQ) and the intersection of the set’s voltage limits
(the largest vmin and the smallest vmax; when the limits do not
overlap it keeps its own). When the set holds a reference bus, the
survivor takes the reference’s voltage angle. It keeps its own other
attributes. Limits or reference angles that differ by more than 1e-9
are reported as CANONICALIZE.MERGE.ATTRIBUTE_CONFLICT, naming the
buses. Every element reference to a merged bus moves to the survivor: loads, shunts, static var compensators,
generators and their regulated buses, storage, branch, switch, and
HVDC endpoints, three winding transformer windings, control buses,
and area swing buses.
The merge removes the selected elements and any other branch or
switch whose two buses it joined; BusMerge::removed_branches and
BusMerge::removed_switches list each with its source row and
ratings. A removed in-service branch’s complete equivalent admittance
becomes a fixed shunt at the survivor; MergedCharging controls only
its terminal charging. An HVDC line whose two ends merged stays, with a diagnostic.
An element whose merge would join two windings of one three winding
transformer stays in place and is reported. Detailed connectivity
follows the survivors; when the merge joins buses its hierarchy keeps
apart, such as buses of two voltage levels, its calculated bus
assignments are dropped with a diagnostic.
The input is not modified, and a merge that joins nothing returns a shared handle to it. Merging the result again under the same rule joins nothing.
§Errors
Error::BusMergeRule for a threshold that is negative or not
finite. Error::UnknownBus when a selected element names a bus the
network does not declare.
Error::ZeroImpedance when bypassing an ideal transformer with a
nonunity tap or phase shift, which has no finite shunt equivalent.
Error::DegenerateTap or Error::NonFiniteSusceptance when a
removed branch’s equivalent cannot be represented finitely.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn name_mut(&mut self) -> &mut String
pub fn name_mut(&mut self) -> &mut String
Mutable access to the same table; a shared handle copies its tables once here, so no other handle observes the change.
Sourcepub fn geo_mut(&mut self) -> &mut Option<GeoMeta>
pub fn geo_mut(&mut self) -> &mut Option<GeoMeta>
Mutable access to the same table; a shared handle copies its tables once here, so no other handle observes the change.
Sourcepub fn case_metadata(&self) -> &CaseMetadata
pub fn case_metadata(&self) -> &CaseMetadata
Source neutral case metadata when the source records it.
Sourcepub fn case_metadata_mut(&mut self) -> &mut CaseMetadata
pub fn case_metadata_mut(&mut self) -> &mut CaseMetadata
Mutable access to the same table; a shared handle copies its tables once here, so no other handle observes the change.
Sourcepub fn solver(&self) -> &Option<SolverParams>
pub fn solver(&self) -> &Option<SolverParams>
Solver / solution-control metadata when the source carries it.
Sourcepub fn solver_mut(&mut self) -> &mut Option<SolverParams>
pub fn solver_mut(&mut self) -> &mut Option<SolverParams>
Mutable access to the same table; a shared handle copies its tables once here, so no other handle observes the change.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn detailed_connectivity(&self) -> &Option<Arc<DetailedConnectivity>>
pub fn detailed_connectivity(&self) -> &Option<Arc<DetailedConnectivity>>
Authoritative hierarchy and detailed connectivity when present.
Sourcepub fn detailed_connectivity_mut(
&mut self,
) -> &mut Option<Arc<DetailedConnectivity>>
pub fn detailed_connectivity_mut( &mut self, ) -> &mut Option<Arc<DetailedConnectivity>>
Mutable access to detailed connectivity. Taking mutable access clears source field omission records because a caller can change any of the corresponding values through this reference.
Source§impl BalancedNetwork
impl BalancedNetwork
Replace each element table’s allocation with donor’s wherever the
contents are equal, so equal tables across derived networks (the
scenarios of one dataset, the points of one series) are stored once.
No value changes; a table that differs anywhere keeps its own
allocation.
Source§impl BalancedNetwork
impl BalancedNetwork
pub fn buses(&self) -> &Vec<Bus>
Sourcepub fn buses_mut(&mut self) -> &mut Vec<Bus>
pub fn buses_mut(&mut self) -> &mut Vec<Bus>
Mutable access to the same table. A shared handle copies the table set spine and this one table here, so no other handle observes the change and untouched tables stay shared.
pub fn static_var_compensators(&self) -> &Vec<StaticVarCompensator>
Sourcepub fn static_var_compensators_mut(&mut self) -> &mut Vec<StaticVarCompensator>
pub fn static_var_compensators_mut(&mut self) -> &mut Vec<StaticVarCompensator>
Mutable access to the same table. A shared handle copies the table set spine and this one table here, so no other handle observes the change and untouched tables stay shared.
pub fn branches(&self) -> &Vec<Branch>
Sourcepub fn branches_mut(&mut self) -> &mut Vec<Branch>
pub fn branches_mut(&mut self) -> &mut Vec<Branch>
Mutable access to the same table. A shared handle copies the table set spine and this one table here, so no other handle observes the change and untouched tables stay shared.
pub fn switches(&self) -> &Vec<Switch>
Sourcepub fn switches_mut(&mut self) -> &mut Vec<Switch>
pub fn switches_mut(&mut self) -> &mut Vec<Switch>
Mutable access to the same table. A shared handle copies the table set spine and this one table here, so no other handle observes the change and untouched tables stay shared.
pub fn hvdc(&self) -> &Vec<Hvdc>
Sourcepub fn hvdc_mut(&mut self) -> &mut Vec<Hvdc>
pub fn hvdc_mut(&mut self) -> &mut Vec<Hvdc>
Mutable access to the same table. A shared handle copies the table set spine and this one table here, so no other handle observes the change and untouched tables stay shared.
Sourcepub fn transformers_3w(&self) -> &Vec<Transformer3W>
pub fn transformers_3w(&self) -> &Vec<Transformer3W>
Three-winding transformers, kept as typed records.
Sourcepub fn transformers_3w_mut(&mut self) -> &mut Vec<Transformer3W>
pub fn transformers_3w_mut(&mut self) -> &mut Vec<Transformer3W>
Mutable access to the same table. A shared handle copies the table set spine and this one table here, so no other handle observes the change and untouched tables stay shared.
Source§impl BalancedNetwork
impl BalancedNetwork
pub fn loads(&self) -> &Vec<Load>
Sourcepub fn loads_mut(&mut self) -> &mut Vec<Load>
pub fn loads_mut(&mut self) -> &mut Vec<Load>
Mutable load access makes source omission metadata conservative: a subsequent emission writes the numeric active and reactive power values.
pub fn generators(&self) -> &Vec<Generator>
Sourcepub fn generators_mut(&mut self) -> &mut Vec<Generator>
pub fn generators_mut(&mut self) -> &mut Vec<Generator>
Mutable generator access makes source omission metadata conservative: a subsequent emission writes all numeric generator assignments.
pub fn storage(&self) -> &Vec<Storage>
Sourcepub fn storage_mut(&mut self) -> &mut Vec<Storage>
pub fn storage_mut(&mut self) -> &mut Vec<Storage>
Mutable storage access makes source omission metadata conservative: a subsequent emission writes both numeric power assignments.
pub fn shunts(&self) -> &Vec<Shunt>
Sourcepub fn shunts_mut(&mut self) -> &mut Vec<Shunt>
pub fn shunts_mut(&mut self) -> &mut Vec<Shunt>
Mutable shunt access makes source omission metadata conservative: a subsequent emission writes conductance per section.
Source§impl BalancedNetwork
impl BalancedNetwork
pub fn base_mva_mut(&mut self) -> &mut f64
Sourcepub fn base_frequency(&self) -> f64
pub fn base_frequency(&self) -> f64
System base frequency in hertz (50 or 60).
pub fn base_frequency_mut(&mut self) -> &mut f64
Sourcepub fn source_format(&self) -> SourceFormat
pub fn source_format(&self) -> SourceFormat
The format the case was parsed from.
pub fn source_format_mut(&mut self) -> &mut SourceFormat
Sourcepub fn assign_missing_component_ids(&mut self)
pub fn assign_missing_component_ids(&mut self)
Assign persistent identities to records whose source format supplied none.
Source supplied identities are preserved. Generated identities use electrical identifiers such as a bus number or branch terminals and are stored on the record, so later table reordering does not change them. A suffix distinguishes several records attached to the same bus or terminal pair.
The identities are unique across the whole network, not only within one table: a load and a generator at bus 3 are two records, and formats that index every element by one identifier (XIIDM, CGMES) reject the same identifier twice. The first record to claim a stem keeps it and the next takes a numeric suffix.
Callers that assemble a network by pushing records can call this once after construction. PowerIO parsers call it before returning a module.
Sourcepub fn uid_is_generated(&self, uid: Option<&str>) -> bool
pub fn uid_is_generated(&self, uid: Option<&str>) -> bool
True when PowerIO generated this identity to make records addressable.
Source§impl BalancedNetwork
impl BalancedNetwork
pub fn new(name: impl Into<String>, base_mva: f64) -> BalancedNetwork
Sourcepub fn in_memory(
name: impl Into<String>,
base_mva: f64,
buses: Vec<Bus>,
branches: Vec<Branch>,
) -> BalancedNetwork
pub fn in_memory( name: impl Into<String>, base_mva: f64, buses: Vec<Bus>, branches: Vec<Branch>, ) -> BalancedNetwork
A network assembled in memory from buses and branches, with no loads,
shunts, generators, storage, HVDC, or retained source document. Synthetic
topology generators and tests use it instead of repeating the struct
literal. The caller owns reference integrity (run check_references if
the ids might be inconsistent).
Sourcepub fn is_normalized(&self) -> bool
pub fn is_normalized(&self) -> bool
Whether this is a normalized (per-unit, radian, filtered)
derived product from to_normalized, rather
than a raw network at the file’s unit basis. Unit-sensitive code that
takes a &BalancedNetwork can check this instead of silently assuming MW.
Sourcepub fn check_base_mva(&self) -> Result<(), Error>
pub fn check_base_mva(&self) -> Result<(), Error>
Error unless base_mva is a positive, finite number. It is every
per-unit divisor, so a malformed base would otherwise silently poison
downstream values with NaN/Inf or flipped signs. The per-unit
consumers (to_normalized, the gridfm
export) call this; any other unit-sensitive consumer should too.
Sourcepub fn validate_values(&self) -> Vec<Diagnostic>
pub fn validate_values(&self) -> Vec<Diagnostic>
Report element fields whose values fall outside their physical domain,
without changing anything, as coded VALIDATE.BALANCED.VALUE_DOMAIN
findings. Each record targets the element and carries the field, the
current value, the value a repair would set, and why in details.
This generalizes the per-reader value clamps (a bus voltage magnitude
outside [0, 2], an angle past ±2000°, a zero generator MVA base or
voltage setpoint) into one pass any consumer can run, separate from the
structural validate (which only checks
ids and references). It is non-mutating; repair_values applies the
fixes to a parsed module and records them.
Sourcepub fn validate(&self) -> Result<(), Error>
pub fn validate(&self) -> Result<(), Error>
Check structural integrity: bus ids are unique and every element
references an existing bus. File readers run this; a BalancedNetwork
built by hand (or mutated, e.g. by a scenario generator) should call it
before handing the network to
IndexedNetwork, whose dense indexing assumes it.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn to_normalized(&self) -> Result<BalancedNetwork, Error>
pub fn to_normalized(&self) -> Result<BalancedNetwork, Error>
A normalized, computation-ready copy of this network. The raw BalancedNetwork is
kept lossless (MATPOWER units, 1-based sparse ids, out-of-service elements
retained); to_normalized derives the form a solver or ML pipeline wants:
- Per unit (÷
base_mva): genpg/qg/pmax/pmin/qmax/qminand the ramp caps (GEN_PU_KEYS); loadp/q; shuntg/b; branchrate_a/b/c; storage energy/ratings/limits/losses; HVDCpf/pt/qf/qt, reactive limits,loss0; gen-cost coefficients (cost_to_pu). Storageps/qsand HVDC aggregatepmin/pmaxstay raw, matching the PowerModels per-unit convention. Voltages, impedances, tap, andloss1are already dimensionless. - Radians: bus
va; branchshift/angmin/angmax. - Tap:
0 → 1.0(an explicit1is kept). - Filtered: drop buses typed isolated (
BusType::Isolated) and every out-of-service element, then drop any element left referencing a dropped bus. A bus orphaned by the out-of-service filter (no in-service branch, but not typed isolated) is kept — its load is real — and surfaces as its own island, which the grounding check reports if it has no reference. - Closed switches: the buses a closed switch joins merge into one
(
ClosedSwitchPolicy::Merge, reported underCANONICALIZE.MERGE), whose survivor is the reference bus, else a generator bus, else a regulated bus, smallest id first. The matrix builders model no switches, so this keeps their buses together;BalancedNetwork::to_normalized_withkeeps or refuses them instead. - IDs: kept buses retain their source bus ids, and every surviving
endpoint stays in the same id space. Consumers that need dense rows should
use
IndexedNetwork, which derives[0, n)indices without destroying source ids. - Bus types: a bus hosting a surviving generator keeps
REFif the file marked itREF, otherwise becomesPV; a generator-less bus isPQ(so a generator-lessREFis demoted). APQbus retypedPVis reported asCANONICALIZE.NORMALIZE.GENERATOR_BUS_RETYPED. The file’sREFbuses are kept, several included, and the consumer picks the slack. Only when no reference bus survives is the largest-pmaxin-service generator’s bus promoted toREF;NormalizeSettings::island_referencesapplies that rule per island instead.
This is a derived product, not a source for write-back: source is dropped
and source_format is SourceFormat::Normalized, so writing it serializes
the per-unit/radian model instead of echoing the raw bytes, and a consumer
can tell it apart from a raw in-memory network.
Scope is the universal canonicalization only. It does not synthesize a
missing rate_a or restrict the gen-cost model — those are solver
preparation choices a consumer applies on top. Use
BalancedNetwork::to_normalized_with_options for the opt in PowerModels angle
bound repair. The cost rescale is
universal and lives here; the model restriction does not.
§Errors
Error::InvalidBaseMva if base_mva is not a positive, finite number
(every per-unit divisor), so a malformed base can’t silently poison the
whole network with NaN/Inf or sign-flipped values.
Error::NoReferenceBus if no reference bus can be established — no REF
survives and there is no in-service generator to anchor one.
Error::ClosedSwitch if a requested switch merge cannot complete,
such as a connection between windings of one three winding transformer.
Sourcepub fn to_normalized_with_options(
&self,
options: &NormalizeOptions,
) -> Result<NormalizedNetwork, Error>
pub fn to_normalized_with_options( &self, options: &NormalizeOptions, ) -> Result<NormalizedNetwork, Error>
Like BalancedNetwork::to_normalized, with opt in solver preparation repairs
that report fidelity warnings.
Sourcepub fn to_normalized_with(
&self,
settings: &NormalizeSettings,
) -> Result<(NormalizedNetwork, NormalizeReport), Error>
pub fn to_normalized_with( &self, settings: &NormalizeSettings, ) -> Result<(NormalizedNetwork, NormalizeReport), Error>
Like BalancedNetwork::to_normalized_with_options, under every
choice NormalizeSettings states, also returning what the pass
changed before normalizing (NormalizeReport), such as the closed
switch merge.
§Errors
As BalancedNetwork::to_normalized, and Error::ClosedSwitch
under ClosedSwitchPolicy::Refuse or an incomplete
ClosedSwitchPolicy::Merge.
Source§impl BalancedNetwork
impl BalancedNetwork
Sourcepub fn subset(&self, sel: &Selector, keep_boundary: bool) -> BalancedNetwork
pub fn subset(&self, sel: &Selector, keep_boundary: bool) -> BalancedNetwork
Carve out the sub-network whose buses match sel.
In-scope buses keep their loads, shunts, generators, and storage; a branch,
HVDC line, or 3-winding transformer is kept when every bus it touches is
kept. With keep_boundary, a branch or HVDC line straddling the selection
edge pulls its out-of-scope endpoint in as a tie bus (tagged
extras["tie_bus"] = true) so the carved island has no dangling branch
ends; without it, a straddling branch is dropped. A tie bus is a stub: its
own loads/generators are not pulled in. A control reference (regulated bus)
that falls outside the kept set is cleared so the result is
reference-consistent. Detailed connectivity is filtered with the electrical
tables; unassigned source topology remains, and an emptied voltage level
is removed when no retained topology uses it.
The result preserves normalized units for normalized input; otherwise it
is a fresh SourceFormat::InMemory network. An empty Selector returns
a clone-equivalent of the whole case,
and a selector matching no bus returns an empty network.
Sourcepub fn subset_buses(&self, buses: &BTreeSet<BusId>) -> BusSubset
pub fn subset_buses(&self, buses: &BTreeSet<BusId>) -> BusSubset
Carve out the sub-network and source-to-result row maps on buses, such as one island of
calc_islands: the
subset rules with no boundary buses, so a
branch, switch, HVDC line, or 3-winding transformer is kept when every
bus it touches is in the set. Ids the network does not declare are
ignored.
A 3-winding transformer with a winding in the set is also kept when
each of its other windings is dead: its bus is typed isolated, or the
winding is out of service (crate::Transformer3W::winding_in_service).
That winding’s bus comes along as an isolated stub (tagged
extras["tie_bus"]), so an island that such a transformer joins stays
one island. The returned BusSubset maps every source table row to
its result row, including stub buses and excluded injections.
Sourcepub fn merge_bus(&mut self, into: BusId, from: BusId)
pub fn merge_bus(&mut self, into: BusId, from: BusId)
Merge bus from into bus into: re-home every element on from (loads,
shunts, generators, storage, branch/HVDC/transformer endpoints, and control
references) onto into, drop the branches, switches, and HVDC lines that
ran directly between the two (now self-loops), and remove the from bus.
The surviving bus keeps the stronger of the two bus kinds (a slack is not
demoted).
A no-op when into == from. The other attributes of from (its voltage,
limits, name) are discarded; the topology and injections are what move.
merge_buses is the rule driven merge
that also reports what it removed.
Sourcepub fn reduce_zero_impedance(&mut self, threshold: f64) -> usize
pub fn reduce_zero_impedance(&mut self, threshold: f64) -> usize
Collapse every in-service, non-transformer branch whose series impedance
magnitude is at or below threshold by merging its endpoints (the to-bus
into the from-bus), returning the number of branches removed. Parallel
jumpers between the same pair go in the same step.
This is merge_buses under
ZeroImpedanceRule::ImpedanceMagnitude and MergeSurvivor::FromBus
with closed switches left alone, applied in place; prefer merge_buses,
which also returns the bus map, the removed elements, and diagnostics.
A threshold that is negative or not finite merges nothing.
An out-of-service jumper is an open switch whose endpoints are not electrically joined, so it is left in place. Transformers are never collapsed (a unity-ratio transformer is a real device, not a jumper); a jumper between two windings of the same 3-winding transformer is also kept, since merging would collapse that transformer onto one node.
When the merge fails, for example because a jumper shorts an ideal
transformer with a nonunity tap, nothing is merged and this returns
zero; reduce_zero_impedance_with_report
reports why.
Sourcepub fn reduce_zero_impedance_with_report(
&mut self,
threshold: f64,
) -> ZeroImpedanceReduction
pub fn reduce_zero_impedance_with_report( &mut self, threshold: f64, ) -> ZeroImpedanceReduction
reduce_zero_impedance with the merge’s
diagnostics. When the merge fails the network is left unchanged,
removed is zero, and the diagnostics hold the error under its own
code, so a failure is no longer indistinguishable from a network with
no jumpers.
Sourcepub fn reduce_passthrough_buses(&mut self) -> usize
pub fn reduce_passthrough_buses(&mut self) -> usize
Collapse degree-2 passthrough buses, returning the number removed. A passthrough bus carries nothing but two in-service line sections, so it is an electrically inert junction: the two sections fold into one equivalent branch between their outer endpoints and the middle bus is deleted.
This is the multi-section-line reduction. Exporters often split one circuit into segments joined at dummy buses; folding them back recovers the single branch. A bus qualifies only when it carries no load, generator, shunt, or storage, is not a control reference, area swing, HVDC endpoint, or 3-winding winding bus, is not the system slack, and is touched by exactly two ordinary branches (never transformers) that are both in service and run to two distinct other buses. The equivalent branch sums the series impedance and line charging, takes the more limiting thermal rating of the two sections, and intersects their angle limits. Chains of dummy buses collapse fully, one bus per step.
Sourcepub fn apply_impedance_correction(&mut self) -> usize
pub fn apply_impedance_correction(&mut self) -> usize
Scale every transformer’s series impedance by its impedance correction table, at the winding’s present turns ratio or phase shift, returning the number of two winding transformers and three winding correction targets (windings or pairs, according to ZCOD) scaled.
A two winding transformer’s factor multiplies r + jx. A three winding
transformer’s factor for a winding multiplies that winding’s star
impedance, and the pairwise impedances are restated from the scaled
star. With PSS/E ZCOD=1, TAB1/2/3 instead scale nominal Z12/Z23/Z31
at the sole winding with a nonfixed control (even if disabled).
A ZCOD=1 transformer with no unique adjustable winding is skipped;
the RAW reader refuses that ambiguous configuration.
The first call records each scaled transformer’s nominal
impedance under extras["impedance_correction_nominal"], and every
call scales that nominal value: a repeated call changes nothing, and a
call after a tap or shift change evaluates the table there. The
corrected impedance is recorded under
extras["impedance_correction_applied"]; an impedance edited after
the call no longer matches it and becomes the new nominal value. The
PSS/E writer states the nominal impedance beside the table, as the
format does.
Sourcepub fn retype_isolated_buses(&mut self) -> usize
pub fn retype_isolated_buses(&mut self) -> usize
Retype to BusType::Isolated every bus with no in-service electrical
connection — no in-service incident branch, closed switch, HVDC line,
or 3-winding transformer — returning the number retyped.
A stranded bus (retired or not-yet-built equipment, or the residue of a topology edit) otherwise keeps a PQ/PV/slack kind that tells a solver to include it, leaving an ungrounded singleton in the system. This only demotes a disconnected bus; it never promotes a connected one, and a bus the source already marks isolated is left untouched. Connectivity is judged on in-service equipment only, so opening the last branch into a bus makes it eligible.
Trait Implementations§
Source§impl Clone for BalancedNetwork
impl Clone for BalancedNetwork
Source§fn clone(&self) -> BalancedNetwork
fn clone(&self) -> BalancedNetwork
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BalancedNetwork
impl Debug for BalancedNetwork
Source§impl<'de> Deserialize<'de> for BalancedNetwork
impl<'de> Deserialize<'de> for BalancedNetwork
Source§fn deserialize<D>(
deserializer: D,
) -> Result<BalancedNetwork, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<BalancedNetwork, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl From<BalancedNetwork> for PioValue
impl From<BalancedNetwork> for PioValue
Source§fn from(value: BalancedNetwork) -> Self
fn from(value: BalancedNetwork) -> Self
Source§impl JsonSchema for BalancedNetwork
Available on crate feature schema only.
impl JsonSchema for BalancedNetwork
schema only.Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more