diff --git a/core/src/allocation_init.jl b/core/src/allocation_init.jl index aea5afe44..9bf3ddb30 100644 --- a/core/src/allocation_init.jl +++ b/core/src/allocation_init.jl @@ -7,7 +7,7 @@ function find_subnetwork_connections!(p::Parameters)::Nothing # destination node subnetwork id ≠1 for node_id in graph[].node_ids[1] for outflow_id in outflow_ids(graph, node_id) - if graph[outflow_id].subnetwork_id != 1 + if (graph[outflow_id].subnetwork_id != 1) main_network_source_edges = get_main_network_connections(p, graph[outflow_id].subnetwork_id) edge = (node_id, outflow_id) diff --git a/core/src/allocation_optim.jl b/core/src/allocation_optim.jl index 59ae9dc7c..1653c989e 100644 --- a/core/src/allocation_optim.jl +++ b/core/src/allocation_optim.jl @@ -866,7 +866,9 @@ function save_allocation_flows!( end # Check whether the next edge is the current one reversed - if edge_2 == reverse(edge_1) + # and the edge does not have a UserDemand end + if edge_2 == reverse(edge_1) && + !(edge_1[1].type == NodeType.UserDemand || edge_1[2].type == NodeType.UserDemand) # If so, these edges are both processed in this iteration flow_rate += sign_2 * JuMP.value(F[edge_2]) skip = true diff --git a/core/src/util.jl b/core/src/util.jl index ee7191142..a52bdb277 100644 --- a/core/src/util.jl +++ b/core/src/util.jl @@ -572,8 +572,15 @@ is_flow_constraining(node::AbstractParameterNode) = hasfield(typeof(node), :max_ """Whether the given node is flow direction constraining (only in direction of edges).""" is_flow_direction_constraining(node::AbstractParameterNode) = ( - node isa - Union{Pump, Outlet, TabulatedRatingCurve, FractionalFlow, Terminal, UserDemand} + node isa Union{ + Pump, + Outlet, + TabulatedRatingCurve, + FractionalFlow, + Terminal, + UserDemand, + FlowBoundary, + } ) function has_main_network(allocation::Allocation)::Bool diff --git a/core/test/allocation_test.jl b/core/test/allocation_test.jl index 1ad3c8816..0a5069cc8 100644 --- a/core/test/allocation_test.jl +++ b/core/test/allocation_test.jl @@ -309,7 +309,7 @@ end # lower the subnetwork demands @test subnetwork_demands[(NodeID(:Basin, 2), NodeID(:Pump, 11))] ≈ [3.1, 4.0, 0.0] @test subnetwork_demands[(NodeID(:Basin, 6), NodeID(:Pump, 24))] ≈ [0.004, 0.0, 0.0] - @test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] ≈ [0.001, 0.002] + @test subnetwork_demands[(NodeID(:Basin, 10), NodeID(:Pump, 38))][1:2] ≈ [0.001, 0.001] end @testitem "Allocation level control" begin diff --git a/pixi.toml b/pixi.toml index 3b5de6041..5350c1b79 100644 --- a/pixi.toml +++ b/pixi.toml @@ -168,7 +168,7 @@ netCDF4 = "*" numpy = "*" pandas = "*" pandas-stubs = "*" -pandera = "*" +pandera = ">=0.18" pip = "*" pyarrow = "*" pydantic = ">=2" diff --git a/python/ribasim/pyproject.toml b/python/ribasim/pyproject.toml index 8508bf7ab..60dcd1493 100644 --- a/python/ribasim/pyproject.toml +++ b/python/ribasim/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "matplotlib", "numpy", "pandas", - "pandera != 0.16.0", + "pandera >= 0.18", "pyarrow", "pydantic ~= 2.0", "pyogrio",