Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

SDK Overview

hydra-sdk is the umbrella crate for Hydra’s public API. Add it to your Cargo.toml:

[dependencies]
hydra-sdk = "1"

It re-exports every type needed to parse networks, run simulations, query results, and run post-simulation analytics — with all internal dependency versions pre-pinned.

Modules and Key Types

Session API

The primary entry point. Import Simulation to parse, run, and query a network.

Type / functionPurpose
SimulationCreates and drives a simulation session
SessionErrorError type returned by all session methods
SimWarning / WarningKindNon-fatal diagnostics produced during a run
NodeQuantityEnum of per-node result variables (Head, GaugePressure, Demand, Quality, …)
LinkQuantityEnum of per-link result variables (Flow, Velocity, Headloss, Quality, …)
NodeResult / LinkResultBatch result containers
ResultRangesMin/max envelopes across all nodes/links/time
HydSnapshotSingle-step hydraulic state snapshot
PumpEnergyPer-pump energy and efficiency metrics
FlowBalance / MassBalanceNetwork-wide accounting at simulation end
WritableSimulationTrait required by the I/O writers

Analytics

Post-simulation analysis functions that operate on a saved .out file.

Type / functionPurpose
compute_demand_reliability_from_outPer-junction demand reliability metrics
compute_service_compliance_from_outPer-node pressure compliance metrics
DemandReliabilityReport / DemandReliabilitySummaryDemand reliability results
ServiceComplianceReport / ServiceComplianceSummaryPressure compliance results
DemandReliabilityOptionsOptions for reliability computation (deficit tolerance)
ServiceComplianceThresholdsMin/max pressure thresholds for compliance check

Data Model

The full network data model, mirroring the EPANET .inp structure.

TypePurpose
NetworkTop-level container returned by io::parse
Node / NodeKindPolymorphic node (Junction, Reservoir, Tank)
Link / LinkKindPolymorphic link (Pipe, Pump, Valve)
Pattern / CurveTime patterns and XY curves
SimulationOptionsAll [OPTIONS] and [TIMES] settings
QualityModeChemical, age, or source-trace quality mode
FlowUnits / HeadLossFormulaUnit system and head-loss formula enums
ValidationErrorStructural network validation errors

I/O

#![allow(unused)]
fn main() {
use hydra_sdk::io;
}
Function / modulePurpose
io::parse(&bytes)Parse EPANET .inp bytes into a Network
io::write_inp(&network)Serialise a Network back to .inp bytes
io::rpt_writer::build_text_report(&sim)Build a plain-text .rpt report string
io::rpt_writer::build_json_report(&sim)Build a JSON report string
io::out_writer::write_binary_output(writer, &sim)Write EPANET-compatible .out binary
io::out_readerRead and inspect existing .out files