I would like to determine the flow rate released from a dam using measurements at sensors upstream and downstream from the dam.
- The dam = node 6
- Upstream rivers flowing into the retention lac : -- River 1 = nodes 1-2, 2 flowing into 1 -- River 2 = nodes 3-5, 5 flowing into 4 flowing into 3
- Downstream river : nodes 7-8, 7 flowing into 8
Basic assumption :
- If nodes n°7-8 measure lower flow rates than nodes 1 + 3, then the dam is holding back water.
- If nodes n°7-8 measure higher flow rates than nodes 1 + 3, then dam is releasing water.
The graph is relatively simple (figure below), unidirectional, and the edges do not have capacities nor weights.
- Input nodes are n° 2 and 5 (upstream rivers 1 and 2)
- Output node is n° 8
- Node 6 to be determined in an intermediate node.
I am using NetworkX to simulate the network graph flows (but if you know of a better way, let me know please), but I don't really understand how simulating flows work. Nodes represent flowmeters, edges represent directional flow (figure below).
Thank you for your inputs !

The output is a DataFrame that shows the calculated flow rates at different nodes for two different instances (or time steps):
Node2 and Node5 are the flow rates at the input nodes from upstream rivers 1 and 2, respectively. Node6 is the calculated flow rate at the dam. Node7 and Node8 are the flow rates at the downstream nodes. For each row:
Row 0 Interpretation:
At Node2, the flow rate is 150 units. At Node5, the flow rate is 500 units. The sum of the inflows from Node2 and Node5 is 650 units. At Node7, the flow rate is 600 units, which suggests that the dam (Node6) might be holding back water, as the outflow is less than the inflow. The calculated flow rate at the dam (Node6) is 50 units. This means that 50 units of water are being retained or released by the dam to balance the difference between the inflow (650 units) and the outflow (600 units) at this time step. At Node8, the flow rate is 900 units, which is not directly involved in the calculation of the flow at the dam but could be used for further analysis downstream. Row 1 Interpretation:
At Node2, the flow rate increases to 160 units. At Node5, the flow rate increases to 520 units. The sum of the inflows from Node2 and Node5 is 680 units. At Node7, the flow rate is 610 units, which again suggests that the dam (Node6) might be holding back water, as the outflow is less than the inflow. The calculated flow rate at the dam (Node6) is 70 units. This means that 70 units of water are being retained or released by the dam to balance the difference between the inflow (680 units) and the outflow (610 units) at this time step. At Node8, the flow rate is 910 units, again providing downstream data but not affecting the dam's flow rate calculation. In summary, at both time steps, the flow rate at the dam (Node6) is less than the inflow from Node2 and Node5, indicating that the dam is holding back water. The difference in flow rates is what is either being stored by the dam or possibly used for another purpose not described in the data (such as electricity generation or water diversion).
Output:
OTHER APPROACHES: depending on the complexity of the network and the problem at hand. Here are a few alternative approaches:
Hydraulic Modeling Software: There are specialized software tools designed for simulating water flow in networks, such as EPANET for water distribution systems or HEC-RAS for river systems. These tools can handle complex networks with multiple inflows and outflows, non-uniform geometries, and time-varying conditions.
Hydrodynamic Models: For a more detailed analysis that includes the physical characteristics of the river or channel, hydrodynamic models solve the Saint-Venant equations (a form of the shallow water equations) to describe the flow of water in open channels.
Simulation Models: Use of simulation software like MATLAB/Simulink or Python with libraries like SimPy can allow for time-series analysis of flows, where you can simulate the dynamic behavior of the river flow over time with varying conditions.
System Dynamics Models: These models use stocks and flows diagrams that can be simulated using software like Vensim or Stella. They are useful for understanding the behavior of systems over time, including feedback loops.
Machine Learning Models: With enough historical data, machine learning models could be trained to predict the flow rate at the dam based on upstream conditions. Time series forecasting models like ARIMA, SARIMA, or LSTM networks can be used for prediction.
Conservation Laws and Continuity Equation: Using the principles of conservation of mass and energy, one could set up a system of equations that reflects the balance between inflow, outflow, and storage. This can be solved analytically for simple systems or numerically using methods such as the finite difference method for more complex systems.
Linear Programming: If there are constraints on the capacities of the channels or requirements on minimum or maximum flow rates, linear programming could be used to optimize the flow through the network while satisfying these constraints.
Graph Theory Algorithms: Beyond just calculating the flow at a single node, you could use algorithms like the Ford-Fulkerson algorithm to calculate the maximum possible flow in the network or to find bottlenecks.