Unable to remove leaks from network model
Opened this issue · 3 comments
Summary
Describe your question.
I am attempting to run multiple simulations with different combinations of pipe leaks (these are then being scored based on how they meet demand against a minimum pressure threshold).
My code does not seem to be removing leaks (see the Remove leaks section of code). leak_1/2 are lists containing the names of nodes/ junctions.
# Setup A scenario
leak_node = wn.get_node(leak_1[sc])
leak_node.add_leak(wn, area,leak_coefficent, 0, 3*3600)
leak_node = wn.get_node(leak_2[sc])
leak_node.add_leak(wn, area,leak_coefficent, 0, 6*3600)
# Run A scenario
wn.sim_time = 0 # Reset simulation time
sim = wntr.sim.WNTRSimulator(wn)
results = sim.run_sim()
# Score A scenario
rating_A = 0
t=0
while t < (total_duration/3600) : # Cycle through readings each hour
n=0
while n < number_junctions: # Cycle through junctions
node_pressure = results.node['pressure'].loc[t*3600][n]
if node_pressure < minimum_pressure: # Record pressure diffrence if below target
rating_A += (minimum_pressure - node_pressure)
n+=1
print(t)
t+=1
# Remove leaks
leak_node = wn.get_node(leak_1[sc])
leak_node.remove_leak(wn)
leak_node = wn.get_node(leak_2[sc])
leak_node.remove_leak(wn)
I am using Spyder 5.4.3 running Python 3.11.5
Hi @JGHuke, I am able to successfully add and remove leaks using a testing network and the same function calls that you use in your example. Can you provide more details on what you are seeing? It will also be helpful to know your WNTR version: print(wntr.__version__)
.
Hello, thanks for getting back to me.
I run a simulation where the leaks begin midway through, once the leaks start the node pressures all drop to 0. The remove leak code then runs (using the same node as the leaks are applied to). The simulation time is reset and the simulation then runs again. However the node pressures are all 0 (for all nodes and times).
I am using WNTR version 1.1.0