From 8191e31f6f64ab5d485f64ea4c3a04ef871f292d Mon Sep 17 00:00:00 2001 From: Stefano Simonelli <16114781+s-simoncelli@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:56:50 +0100 Subject: [PATCH] Implement zero loss fix of PR #266 --- pywr-schema/src/nodes/river.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pywr-schema/src/nodes/river.rs b/pywr-schema/src/nodes/river.rs index 0e28fd01..598ebf99 100644 --- a/pywr-schema/src/nodes/river.rs +++ b/pywr-schema/src/nodes/river.rs @@ -111,6 +111,10 @@ impl RiverNode { ) -> Result<(), SchemaError> { if let Some(loss_factor) = &self.loss_factor { let factors = loss_factor.load(network, args)?; + if factors.is_none() { + // Loaded a constant zero factor; ensure that the loss node has zero flow + network.set_node_max_flow(self.meta.name.as_str(), Self::loss_node_sub_name(), Some(0.0.into()))?; + } network.set_aggregated_node_relationship(self.meta.name.as_str(), Self::agg_sub_name(), factors)?; }