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§
- Analysis
Selection - Selects which result variables are included in an
AnalysisArtifact. - Curve
- A piecewise-linear mapping from x to y (§2.3). Static.
- Curve
Point - A single (x, y) sample point on a curve.
- Demand
Category - A single demand category attached to a junction (§2.5).
- Demand
Reliability Node - Per-junction demand-reliability metrics for a single simulation run.
- Demand
Reliability Options - Options that control the demand-reliability computation.
- Demand
Reliability Report - Complete demand-reliability report for a single simulation run.
- Demand
Reliability Summary - Network-level demand-reliability summary aggregated across all junctions.
- Favad
Coeffs - Per-junction FAVAD resistance coefficients computed at load time (§2.10).
- Flow
Balance - Volumetric flow balance accumulated over the full simulation (§7.2).
- Flow
Balance Summary - 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).
- Link
Base - Properties common to all link types (§2.6.1). Static.
- Link
Result - Per-link result at a single timestep.
- Link
State - Per-step hydraulic and quality state for a single link (§2.6, per-step fields).
- Mass
Balance - 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).
- Node
Base - Properties common to all node types (§2.4.1). Static.
- Node
Result - Per-node result at a single timestep.
- Node
State - 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).
- Pump
Energy - Accumulated energy statistics for a single pump (§7.1).
- Quality
Source - A quality source attached to a node (§2.7).
- Report
Field Option - Per-field reporting options from the
[REPORT]section. - Report
Options - Options from the
[REPORT]INP section. Controls.rptfile output formatting; does not affect simulation results. - Reservoir
- A fixed-grade node whose head is known at all times (§2.4.3).
- Result
Ranges - Global min/max across all timesteps for each display variable.
- Rule
- A rule-based control (§2.8.2).
- Rule
Action - A single action applied by a rule (§2.8.2).
- Service
Compliance Node - Per-node service-compliance metrics for a single simulation run.
- Service
Compliance Report - Complete service-compliance report for a single simulation run.
- Service
Compliance Summary - Network-level service-compliance summary aggregated across all nodes.
- Service
Compliance Thresholds - 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).
- Simple
Control - 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.
- Simulation
Options - 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§
- Action
Value - Value applied by a rule action (§2.8.2).
- Curve
Kind - Semantic kind of a piecewise-linear curve (§2.3).
- Demand
Model - Demand model: demand-driven (DDA) or pressure-driven (PDA) (§2.1).
- Flow
Units - Named user-facing flow unit variant (spec.md §3).
- Head
Loss Formula - Head-loss formula used by the hydraulic solver (§2.1).
- Hydraulic
Error - Hydraulic solver error.
- Link
Kind - Type-specific data for a link.
- Link
Property - Settable link properties via
set_link_property. - Link
Quantity - Link result quantities available via
get_link_result(§8.2.1). - Link
Status - 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).
- Node
Kind - Type-specific data for a node.
- Node
Property - Settable node properties via
set_node_property. - Node
Quantity - Node result quantities available via
get_node_result(§8.2.1). - Premise
Attribute - Attribute tested by a rule premise (§2.8.2).
- Premise
Object - The object a rule premise refers to (§2.8.2).
- Premise
Operator - Relational operator in a rule premise (§2.8.2).
- Pump
Curve Type - Pump head-curve type (§2.6.3).
- Quality
Error - Errors returned by the quality engine.
- Quality
Mode - Water quality simulation mode (§2.1).
- Report
Selection - Selection of nodes or links for reporting.
- Report
Status - Status reporting level in the
[REPORT]section. - Runtime
Estimate - Deterministic advisory effort category for compute-heavy operations.
- Session
Error - Errors returned by the session API (§8.4).
- Source
Type - Quality source injection type (§2.7).
- Statistic
Type - Report output statistic aggregation type (from
TIMESSTATISTIC). - Trigger
Type - Trigger kind for a simple control (§2.8.1).
- Validation
Error - A validation error produced by
Network::validate(§2.9). - Valve
Type - Valve type (§2.6.4).
- Wall
Order - Wall reaction order: zero-order or first-order (§2.1).
- Warning
Kind - Category of non-fatal diagnostic (§8.4).
Constants§
- HYDRA_
ANALYSIS_ VERSION - Semver version of the analysis engine, taken from
Cargo.tomlat compile time. - HYDRA_
HYDRAULICS_ VERSION - Semver version of the hydraulics engine, taken from
Cargo.tomlat compile time. - HYDRA_
QUALITY_ VERSION - Semver version of the quality engine, taken from
Cargo.tomlat compile time. - HYDRA_
SIMULATION_ VERSION - Semver version of the simulation engine, taken from
Cargo.tomlat compile time. - HYDRA_
VERSION - The crate version, taken from
Cargo.tomlat compile time.
Traits§
- Writable
Simulation - 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
.outfile and the corresponding loaded network. - compute_
demand_ reliability_ from_ out_ with_ options - Like
compute_demand_reliability_from_outbut with explicitDemandReliabilityOptions. - compute_
service_ compliance_ from_ out - Compute node-pressure service compliance metrics from a persisted
.outfile. - 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
Networkback to EPANET 2.3 INP bytes.