Actual demand is not adjusted when emitter is added to node
I am testing the "Net1.inp" file by adding an emitter coefficient of 1.0 to node '23'. The pressure before and after the additional demand changes. However, the total actual nodal demand remains the same. I wanted to ask if you are aware of this limitation or is a pending issue.
To Reproduce Steps to reproduce the behavior: Read the input file with epanet('Net1.inp') Run the original network hydraulics and sample node '23' demand Set the emitter coefficient to a value (e.g., 1) with d.setNodeEmitterCoeff(node_index, emit_coefficient) Run the network hydraulics with d.getComputedHydraulicTimeSeries() Sample the new network hydraulics and sample again node '23' demand. Notice that '23' is the node ID, not the index
Expected behavior There should be a discrepancy between the two demand curves, as shown by the pressure values. However, they look the same.
Screenshots
Pressure
Demand
Hi, apologies for the delayed reply and thank you for raising this issue.
I tested the scenario you described using the Net1.inp file by setting an emitter coefficient of 1.0 at node '23', and I do observe a difference in the demand time series before and after adding the emitter. The pressure also changes accordingly, as expected.
Here’s a reproducible snippet that compares the demand and pressure at node '23' before and after applying the emitter coefficient, and plots both series:
from epyt import epanet
import matplotlib.pyplot as plt
d = epanet("Net1.inp")
nodeId = "23"
nodeIndex = d.getNodeIndex(nodeId)
comp_before = d.getComputedTimeSeries()
hrs_time = comp_before.Time / 3600
demand_before = comp_before.Demand[:, nodeIndex - 1]
pressure_before = comp_before.Pressure[:, nodeIndex - 1]
emit_coefficient = 1
d.setNodeEmitterCoeff(nodeIndex, emit_coefficient)
comp_after = d.getComputedTimeSeries()
demand_after = comp_after.Demand[:, nodeIndex - 1]
pressure_after = comp_after.Pressure[:, nodeIndex - 1]
plt.figure(figsize=(10, 6))
plt.plot(hrs_time, demand_before, label='Before Emitter', linestyle='-', linewidth=2)
plt.plot(hrs_time, demand_after, label='After Emitter', linestyle='--', linewidth=2)
plt.title(f"Demand Comparison at Node {d.getNodeNameID(nodeIndex)}")
plt.xlabel("Time (hrs)")
plt.ylabel(f"Demand ({d.units.NodeDemandUnits})")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
plt.figure(figsize=(10, 6))
plt.plot(hrs_time, pressure_before, label='Before Emitter', linestyle='-', linewidth=2)
plt.plot(hrs_time, pressure_after, label='After Emitter', linestyle='--', linewidth=2)
plt.title(f"Pressure Comparison at Node {d.getNodeNameID(nodeIndex)}")
plt.xlabel("Time (hrs)")
plt.ylabel(f"Pressure ({d.units.NodePressureUnits})")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()
Demand:
Pressure:
**Just a heads-up I think the issue might be coming from this line:
pressure_before = comp_before.Pressure[:, nodeIndex - 1]
Since getNodeIndex() returns a 1-based index, it's important to subtract 1 when accessing arrays like Pressure or Demand.