When updating EN_LEAK_AREA during an EPS hydraulic simulation using ENsetlinkvalue(), the leak area value appears to update successfully (as returned by ENgetlinkvalue()), and the reported EN_LINK_LEAKAGE / EN_LEAKAGEFLOW values also change accordingly. However, the hydraulic solution itself does not seem to reflect the updated leak condition.
Specifically, after setting EN_LEAK_AREA = 0 during the simulation, the reported leakage becomes zero, but the total pipe flow (EN_FLOW) remains unchanged, suggesting that the network hydraulics are still being solved using the previous leak configuration.
Example:
See attached model and following script (python wrapper based on owa-epanet):
inp_file = r"One branch.inp"
rpt_file = inp_file[:-4] + ".rpt"
out_file = inp_file[:-4] + ".out"
em.ENopen(inp_file, rpt_file, out_file)
id_pipe = em.ENgetlinkindex("C2")
em.ENsetlinkvalue(id_pipe, em.EN_LEAK_AREA, 30)
em.ENopenH()
em.ENinitH(flag=em.EN_SAVE)
t = 0
print(f"Time(s) \t LeakA(mm2) \t LeakFlow(Lps) \t TotFlow (Lps)")
while True:
if t < 6*60*60: #6hrs into simulation
em.ENsetlinkvalue(id_pipe, em.EN_LEAK_AREA, 30)
else:
em.ENsetlinkvalue(id_pipe, em.EN_LEAK_AREA, 0)
t = em.ENrunH()
leak_area = em.ENgetlinkvalue(id_pipe, em.EN_LEAK_AREA)
leak_flow = em.ENgetlinkvalue(id_pipe, em.EN_LINK_LEAKAGE)
tot_flow = em.ENgetlinkvalue(id_pipe, em.EN_FLOW)
print(f"{t} \t {leak_area} \t\t {leak_flow:.4f} \t\t {tot_flow:.4f}")
tstep = em.ENnextH()
if tstep <= 0:
break
em.ENcloseH()
em.ENsaveH()
em.ENclose()
Output
Time(s) LeakA(mm2) LeakFlow(Lps) TotFlow (Lps)
0 30.0 1.5828 5.7869
3600 30.0 1.5828 5.7869
7200 30.0 1.5828 5.7869
10800 30.0 1.5828 5.7869
14400 30.0 1.5828 5.7869
18000 30.0 1.5828 5.7869
21600 30.0 1.5828 5.7869
25200 0.0 0.0000 5.7869
28800 0.0 0.0000 5.7869
32400 0.0 0.0000 5.7869
...
86400 0.0 0.0000 5.7869
Note that at t = 25200 the EN_LEAK_AREA is zero, and the reported EN_LINK_LEAKAGE is zero, but the EN_FLOW remains as 5.7869 meaning there is still a computed leakage.
I think the behaviour of EN_LEAK_AREA should be the same as other properties like EN_DIAMETER which support being updated during the EPS simulation, but if not, the ENgetlinkvalue() and ENgetnodevalue() functions should return the actual unchanged values for EN_LEAK_AREA, EN_LINK_LEAKAGE, and EN_LEAKAGEFLOW.
One branch.inp.txt
When updating
EN_LEAK_AREAduring an EPS hydraulic simulation usingENsetlinkvalue(), the leak area value appears to update successfully (as returned byENgetlinkvalue()), and the reportedEN_LINK_LEAKAGE/EN_LEAKAGEFLOWvalues also change accordingly. However, the hydraulic solution itself does not seem to reflect the updated leak condition.Specifically, after setting
EN_LEAK_AREA = 0during the simulation, the reported leakage becomes zero, but the total pipe flow (EN_FLOW) remains unchanged, suggesting that the network hydraulics are still being solved using the previous leak configuration.Example:
See attached model and following script (python wrapper based on owa-epanet):
Output
Note that at
t = 25200theEN_LEAK_AREAis zero, and the reportedEN_LINK_LEAKAGEis zero, but theEN_FLOWremains as5.7869meaning there is still a computed leakage.I think the behaviour of
EN_LEAK_AREAshould be the same as other properties likeEN_DIAMETERwhich support being updated during the EPS simulation, but if not, theENgetlinkvalue()andENgetnodevalue()functions should return the actual unchanged values forEN_LEAK_AREA,EN_LINK_LEAKAGE, andEN_LEAKAGEFLOW.One branch.inp.txt