powerio-dist 0.10.0

Multiconductor distribution network model and lossless converters for OpenDSS, PMD JSON, and BMOPF JSON.
Documentation
//! Multiconductor distribution network models and converters for OpenDSS
//! `.dss`, PowerModelsDistribution ENGINEERING
//! JSON ("PMD JSON"), and the draft JSON schema of the IEEE PES Task Force on
//! Benchmarking Multiconductor OPF ("BMOPF JSON",
//! <https://github.com/frederikgeth/bmopf-report>).
//!
//! The model uses wire coordinates: string bus IDs, ordered terminal names,
//! explicit grounding, terminal maps on every element, SI units, and radians.
//! The transmission model in `powerio` is positive sequence and remains a
//! separate type.
//!
//! ```no_run
//! let source = powerio_core::Source::open("feeder.dss")?;
//! let module = powerio_dist::parse(source)?;
//! for line in powerio_dist::diagnostics::render_diagnostics(module.diagnostics()) {
//!     eprintln!("parse: {line}");
//! }
//! let conv = powerio_dist::write_as(&module, powerio_dist::DistTargetFormat::PmdJson);
//! # Ok::<(), powerio_core::Error>(())
//! ```
//!
//! # Fidelity rules
//!
//! Writing to the retained source format returns the original bytes. Cross
//! format conversion writes from the typed model and reports fields the target
//! cannot represent in [`Conversion::diagnostics`]. The DSS reader expands OpenDSS
//! class defaults into explicit model values and records them in
//! [`MulticonductorNetwork::defaulted`]. BMOPF output includes those values.
//! The per fixture results live in `docs/conversion-matrix.md`.
//!
//! # Float formatting
//!
//! Canonical output formats every number as its shortest round trip
//! representation: Rust's `Display` for `.dss`, serde_json (ryu) for both
//! JSON formats. The readers parse with serde_json's `float_roundtrip`
//! feature, so a parse of canonical output recovers the exact bit pattern
//! and canonical writes are idempotent. JSON cannot carry `Inf`/`NaN`: the
//! PMD writer emits `null` (PMD restores the value from the field name
//! suffix), and the BMOPF writer emits `0` with a warning, since the schema
//! requires numbers. The byte exact echo tier is unaffected; it never
//! reformats.

pub mod bmopf;
mod collect;
pub mod convert;
pub mod diagnostics;
pub mod dss;
pub mod error;
pub mod geo;
pub mod graph;
pub mod model;
pub(crate) mod nonfinite;
pub mod pmd;
#[cfg(test)]
pub(crate) mod testkit;

pub use bmopf::{
    BMOPF_SCHEMA_ID, BMOPF_SCHEMA_VERSION, BmopfWriteOptions, write_bmopf_json,
    write_bmopf_json_with_options,
};
pub use convert::{
    Conversion, ConversionSidecar, DistTargetFormat, classify_distribution_json, convert_source,
    dist_target_from_name, parse, write, write_as, write_network,
};
pub use diagnostics::{Diagnostic, DiagnosticCode, DiagnosticSeverity, DiagnosticStage};
pub use dss::{DssLoadVoltageBounds, DssWriteOptions, write_dss, write_dss_with_options};
pub use error::{Error, Result};
pub use geo::{CoordinateSpace, DistCanvas, DistCoordsKind, DistGeoMeta, DistLocation};
pub use graph::{
    DistGraph, DistGraphAttachment, DistGraphAttachmentKind, DistGraphBus, DistGraphEdge,
    DistGraphEdgeKind,
};
pub use model::{
    ActivePowerReference, ActivePowerUnit, Configuration, ControlVoltageReference, DistBus,
    DistCapacitor, DistControlProfile, DistGenerator, DistIbr, DistLine, DistLineCode, DistLoad,
    DistLoadVoltageModel, DistShunt, DistSourceFormat, DistSwitch, DistTransformer, DistWinding,
    DistWindingConn, Extras, IbrPrimeMover, IbrTopology, IbrVoltageAggregation, Mat,
    MulticonductorNetwork, PowerFactorControl, ReactivePowerReference, ReactivePowerUnit,
    UntypedObject, VoltVarControl, VoltWattControl, VoltageSource, unresolved_references,
};
pub use pmd::write_pmd_json;