Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to remove leaks from network model #412

Open
JGHuke opened this issue Mar 19, 2024 · 3 comments
Open

Unable to remove leaks from network model #412

JGHuke opened this issue Mar 19, 2024 · 3 comments
Assignees
Labels

Comments

@JGHuke
Copy link

JGHuke commented Mar 19, 2024

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

@kbonney
Copy link
Collaborator

kbonney commented Mar 22, 2024

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__).

@JGHuke
Copy link
Author

JGHuke commented Mar 24, 2024

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

@kbonney
Copy link
Collaborator

kbonney commented Mar 25, 2024

@JGHuke try running wn.reset_initial_values() before you start the simulation again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants