powerio_dist/lib.rs
1//! Multiconductor distribution network models and converters for OpenDSS
2//! `.dss`, PowerModelsDistribution ENGINEERING
3//! JSON ("PMD JSON"), and the draft JSON schema of the IEEE PES Task Force on
4//! Benchmarking Multiconductor OPF ("BMOPF JSON",
5//! <https://github.com/frederikgeth/bmopf-report>).
6//!
7//! The model uses wire coordinates: string bus IDs, ordered terminal names,
8//! explicit grounding, terminal maps on every element, SI units, and radians.
9//! The transmission model in `powerio` is positive sequence and remains a
10//! separate type.
11//!
12//! ```no_run
13//! let net = powerio_dist::parse_file("feeder.dss", None)?;
14//! for w in &net.warnings {
15//! eprintln!("parse: {w}");
16//! }
17//! let conv = net.to_format(powerio_dist::DistTargetFormat::PmdJson);
18//! # Ok::<(), powerio_dist::Error>(())
19//! ```
20//!
21//! # Fidelity rules
22//!
23//! Writing to the retained source format returns the original bytes. Cross
24//! format conversion writes from the typed model and reports fields the target
25//! cannot represent in [`Conversion::warnings`]. The DSS reader expands OpenDSS
26//! class defaults into explicit model values and records them in
27//! [`MulticonductorNetwork::defaulted`]. BMOPF output includes those values.
28//! The per fixture results live in `docs/conversion-matrix.md`.
29//!
30//! # Float formatting
31//!
32//! Canonical output formats every number as its shortest round trip
33//! representation: Rust's `Display` for `.dss`, serde_json (ryu) for both
34//! JSON formats. The readers parse with serde_json's `float_roundtrip`
35//! feature, so a parse of canonical output recovers the exact bit pattern
36//! and canonical writes are idempotent. JSON cannot carry `Inf`/`NaN`: the
37//! PMD writer emits `null` (PMD restores the value from the field name
38//! suffix), and the BMOPF writer emits `0` with a warning, since the schema
39//! requires numbers. The byte exact echo tier is unaffected; it never
40//! reformats.
41
42pub mod bmopf;
43pub mod convert;
44pub mod diagnostics;
45pub mod dss;
46pub mod error;
47pub mod geo;
48pub mod graph;
49pub mod model;
50pub(crate) mod nonfinite;
51pub mod pmd;
52
53pub use bmopf::{
54 BMOPF_SCHEMA_ID, BMOPF_SCHEMA_VERSION, BmopfWriteOptions, parse_bmopf_file, parse_bmopf_str,
55 write_bmopf_json, write_bmopf_json_with_options,
56};
57pub use convert::{
58 Conversion, ConversionSidecar, DistTargetFormat, classify_distribution_json, convert_file,
59 convert_str, dist_target_from_name, parse_file, parse_str,
60};
61pub use diagnostics::{DiagnosticCode, DiagnosticSeverity, DiagnosticStage, StructuredDiagnostic};
62pub use dss::{
63 DssLoadVoltageBounds, DssWriteOptions, parse_dss_file, parse_dss_str, write_dss,
64 write_dss_with_options,
65};
66pub use error::{Error, Result};
67pub use geo::{Canvas, CoordinateSpace, CoordsKind, GeoMeta, Location};
68pub use graph::{
69 DistGraph, DistGraphAttachment, DistGraphAttachmentKind, DistGraphBus, DistGraphEdge,
70 DistGraphEdgeKind,
71};
72pub use model::{
73 ActivePowerReference, ActivePowerUnit, Configuration, ControlVoltageReference, DistBus,
74 DistCapacitor, DistControlProfile, DistGenerator, DistIbr, DistLine, DistLineCode, DistLoad,
75 DistLoadVoltageModel, DistShunt, DistSourceFormat, DistSwitch, DistTransformer, Extras,
76 IbrPrimeMover, IbrTopology, IbrVoltageAggregation, Mat, MulticonductorNetwork,
77 PowerFactorControl, ReactivePowerReference, ReactivePowerUnit, UntypedObject, VoltVarControl,
78 VoltWattControl, VoltageSource, Winding, WindingConn,
79};
80pub use pmd::{parse_pmd_file, parse_pmd_str, write_pmd_json};