Skip to main content

Crate hydra_sdk

Crate hydra_sdk 

Source
Expand description

Hydra — water distribution network simulation engine.

This crate is the published library for the Hydra workspace. It re-exports the complete user-facing API so that downstream users depend on a single crate with all internal dependency versions pre-pinned and known to be compatible.

§Quick start

use hydra_sdk::{io, Simulation, NodeQuantity, LinkQuantity};

let bytes = std::fs::read("network.inp").unwrap();
let network = io::parse(&bytes).unwrap();

let mut sim = Simulation::create();
sim.load(network).unwrap();
sim.run().unwrap();

for t in sim.snapshot_times() {
    let head = sim.get_node_result("J1", NodeQuantity::Head, t).unwrap();
    let flow = sim.get_link_result("P1", LinkQuantity::Flow, t).unwrap();
    println!("t={t:.0}s  head={head:.3}  flow={flow:.6}");
}

Modules§

io
Parsing and output-writing utilities.

Structs§

AnalysisSelection
Selects which result variables are included in an AnalysisArtifact.
Curve
A piecewise-linear mapping from x to y (§2.3). Static.
CurvePoint
A single (x, y) sample point on a curve.
DemandCategory
A single demand category attached to a junction (§2.5).
DemandReliabilityNode
Per-junction demand-reliability metrics for a single simulation run.
DemandReliabilityOptions
Options that control the demand-reliability computation.
DemandReliabilityReport
Complete demand-reliability report for a single simulation run.
DemandReliabilitySummary
Network-level demand-reliability summary aggregated across all junctions.
FavadCoeffs
Per-junction FAVAD resistance coefficients computed at load time (§2.10).
FlowBalance
Volumetric flow balance accumulated over the full simulation (§7.2).
FlowBalanceSummary
Derived flow balance results ready for display or serialisation.
HydSnapshot
Hydraulic state snapshot at a single simulation time (§8.2).
Junction
An ordinary demand node whose head is solved at each hydraulic step (§2.4.2).
Link
A link in the network graph (§2.6).
LinkBase
Properties common to all link types (§2.6.1). Static.
LinkResult
Per-link result at a single timestep.
LinkState
Per-step hydraulic and quality state for a single link (§2.6, per-step fields).
MassBalance
Running constituent mass balance (§6.9).
Network
The complete network data model (§2). Populated once at load time.
Node
A node in the network graph (§2.4).
NodeBase
Properties common to all node types (§2.4.1). Static.
NodeResult
Per-node result at a single timestep.
NodeState
Per-step hydraulic and quality state for a single node (§2.4, per-step fields).
Pattern
A repeating sequence of dimensionless multipliers (§2.2). Static.
Pipe
A pipe in the network (§2.6.2).
Premise
A single predicate clause in a rule (§2.8.2).
Pump
A pump link (§2.6.3).
PumpEnergy
Accumulated energy statistics for a single pump (§7.1).
QualitySource
A quality source attached to a node (§2.7).
ReportFieldOption
Per-field reporting options from the [REPORT] section.
ReportOptions
Options from the [REPORT] INP section. Controls .rpt file output formatting; does not affect simulation results.
Reservoir
A fixed-grade node whose head is known at all times (§2.4.3).
ResultRanges
Global min/max across all timesteps for each display variable.
Rule
A rule-based control (§2.8.2).
RuleAction
A single action applied by a rule (§2.8.2).
ServiceComplianceNode
Per-node service-compliance metrics for a single simulation run.
ServiceComplianceReport
Complete service-compliance report for a single simulation run.
ServiceComplianceSummary
Network-level service-compliance summary aggregated across all nodes.
ServiceComplianceThresholds
Pressure thresholds used to classify reporting-period samples as in-limit or out-of-limit in a service-compliance analysis.
SimWarning
Non-fatal diagnostic condition attached to a simulation time step (§8.4).
SimpleControl
A simple control that fires at most once per hydraulic time step (§2.8.1).
Simulation
A simulation session: owns network, solver context, results, and accounting.
SimulationOptions
Global simulation parameters (§2.1). All fields are static after loading.
Tank
A storage node whose head evolves over time (§2.4.4).
Valve
A valve link (§2.6.4).

Enums§

ActionValue
Value applied by a rule action (§2.8.2).
CurveKind
Semantic kind of a piecewise-linear curve (§2.3).
DemandModel
Demand model: demand-driven (DDA) or pressure-driven (PDA) (§2.1).
FlowUnits
Named user-facing flow unit variant (spec.md §3).
HeadLossFormula
Head-loss formula used by the hydraulic solver (§2.1).
HydraulicError
Hydraulic solver error.
LinkKind
Type-specific data for a link.
LinkProperty
Settable link properties via set_link_property.
LinkQuantity
Link result quantities available via get_link_result (§8.2.1).
LinkStatus
Operational status of a link (§2.6.1 and §3.9).
LogicOp
Logical connective joining consecutive premises (§2.8.2).
MixModel
Tank mixing model (§2.4.4).
NodeKind
Type-specific data for a node.
NodeProperty
Settable node properties via set_node_property.
NodeQuantity
Node result quantities available via get_node_result (§8.2.1).
PremiseAttribute
Attribute tested by a rule premise (§2.8.2).
PremiseObject
The object a rule premise refers to (§2.8.2).
PremiseOperator
Relational operator in a rule premise (§2.8.2).
PumpCurveType
Pump head-curve type (§2.6.3).
QualityError
Errors returned by the quality engine.
QualityMode
Water quality simulation mode (§2.1).
ReportSelection
Selection of nodes or links for reporting.
ReportStatus
Status reporting level in the [REPORT] section.
RuntimeEstimate
Deterministic advisory effort category for compute-heavy operations.
SessionError
Errors returned by the session API (§8.4).
SourceType
Quality source injection type (§2.7).
StatisticType
Report output statistic aggregation type (from TIMES STATISTIC).
TriggerType
Trigger kind for a simple control (§2.8.1).
ValidationError
A validation error produced by Network::validate (§2.9).
ValveType
Valve type (§2.6.4).
WallOrder
Wall reaction order: zero-order or first-order (§2.1).
WarningKind
Category of non-fatal diagnostic (§8.4).

Constants§

HYDRA_ANALYSIS_VERSION
Semver version of the analysis engine, taken from Cargo.toml at compile time.
HYDRA_HYDRAULICS_VERSION
Semver version of the hydraulics engine, taken from Cargo.toml at compile time.
HYDRA_QUALITY_VERSION
Semver version of the quality engine, taken from Cargo.toml at compile time.
HYDRA_SIMULATION_VERSION
Semver version of the simulation engine, taken from Cargo.toml at compile time.
HYDRA_VERSION
The crate version, taken from Cargo.toml at compile time.

Traits§

WritableSimulation
Read-only view of a completed (or in-progress) simulation that the writers need. Implemented by crate::simulation::Simulation.

Functions§

classify_simulation_runtime_millis
Classify a predicted runtime (milliseconds) into effort buckets.
compute_demand_reliability_from_out
Compute delivered-vs-required demand reliability metrics from a persisted .out file and the corresponding loaded network.
compute_demand_reliability_from_out_with_options
Like compute_demand_reliability_from_out but with explicit DemandReliabilityOptions.
compute_service_compliance_from_out
Compute node-pressure service compliance metrics from a persisted .out file.
estimate_analysis_runtime_millis
Estimate analysis effort from summary metadata and module selection.
estimate_simulation_runtime
Estimate simulation runtime from a fully loaded network.
estimate_simulation_runtime_from_summary
Estimate simulation runtime from summary metadata.
estimate_simulation_runtime_millis_from_summary
Estimate simulation runtime in milliseconds from summary metadata.
write_inp
Serialise a Network back to EPANET 2.3 INP bytes.