Skip to main content

Network

Struct Network 

Source
pub struct Network {
Show 14 fields pub title: Vec<String>, pub options: SimulationOptions, pub patterns: Vec<Pattern>, pub curves: Vec<Curve>, pub nodes: Vec<Node>, pub links: Vec<Link>, pub controls: Vec<SimpleControl>, pub rules: Vec<Rule>, pub pattern_index: HashMap<String, usize>, pub report: ReportOptions, pub coordinates: HashMap<String, (f64, f64)>, pub vertices: HashMap<String, Vec<(f64, f64)>>, pub node_tags: HashMap<String, String>, pub link_tags: HashMap<String, String>,
}
Expand description

The complete network data model (§2). Populated once at load time.

Nodes and links are stored in Vecs; their base.index fields are 1-based, so vec[i] has base.index == i + 1.

Fields§

§title: Vec<String>

Up to 3 title lines from the [TITLE] section (for binary output prolog).

§options: SimulationOptions

Simulation parameters from [OPTIONS] and [TIMES] sections.

§patterns: Vec<Pattern>

All patterns from the [PATTERNS] section.

§curves: Vec<Curve>

All curves from the [CURVES] section.

§nodes: Vec<Node>

All nodes (junctions, reservoirs, tanks).

§links: Vec<Link>

All links (pipes, pumps, valves).

§controls: Vec<SimpleControl>

Simple controls from the [CONTROLS] section.

§rules: Vec<Rule>

Rule-based controls from the [RULES] section.

§pattern_index: HashMap<String, usize>

Index mapping pattern ID → position in patterns. Built once at load time via Network::build_pattern_index so hot-path lookups are O(1).

§report: ReportOptions

Report formatting options from the [REPORT] INP section.

§coordinates: HashMap<String, (f64, f64)>

Node coordinates from the [COORDINATES] INP section: node ID → (x, y).

§vertices: HashMap<String, Vec<(f64, f64)>>

Link vertex points from the [VERTICES] INP section: link ID → [(x, y), …].

§node_tags: HashMap<String, String>

Node tags from the [TAGS] INP section: node ID → tag string.

§link_tags: HashMap<String, String>

Link tags from the [TAGS] INP section: link ID → tag string.

Implementations§

Source§

impl Network

Source

pub fn build_pattern_index(&mut self)

Populates pattern_index from the current patterns vec. Must be called once after construction (before any simulation work).

Source

pub fn pattern_by_id(&self, id: &str) -> Option<&Pattern>

O(1) pattern lookup by ID. Returns None if the ID does not exist.

Source§

impl Network

Source

pub fn compute_favad(&self) -> FavadCoeffs

Computes per-junction FAVAD resistance coefficients (§2.10).

For each pipe, the $K_1$ and $K_2$ FAVAD coefficients are split between its two end nodes according to whether the opposite end is a junction or a fixed-grade node (reservoir or tank). Only junctions accumulate FAVAD coefficients; reservoirs and tanks are skipped.

Returns a FavadCoeffs whose c_fa and c_va vectors are indexed by the 0-based position of each node in self.nodes; non-junction entries are always 0.

Source§

impl Network

Source

pub fn validate(&self) -> Result<(), Vec<ValidationError>>

Validates the network against all topology and referential-integrity constraints.

Returns Ok(()) if every constraint is satisfied. Returns Err(errors) with every violation found — never stops at the first error, so the caller can report all problems at once. An invalid network must not be used for simulation.

The following constraints must all hold:

  1. Every node index referenced by a link exists in the node table.
  2. Every curve, pattern, or node ID referenced by any object exists in the corresponding table.
  3. No link connects a node to itself (from_nodeto_node).
  4. The network contains at least one fixed-grade node (reservoir or tank). Every junction is reachable from at least one fixed-grade node via the link graph.
  5. For each tank: min_levelinit_levelmax_level.
  6. All PUMP_HEAD curves are strictly decreasing in y.
  7. All curves have strictly increasing x-values.
  8. All patterns have at least one factor.
  9. Every rule action that references a link references a valid link index.
  10. wall_order is 0 or 1; no other value is valid.

Violations of any of the above are fatal — the simulation must not proceed.

Trait Implementations§

Source§

impl Clone for Network

Source§

fn clone(&self) -> Network

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Network

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.