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

remove_outage does not remove outage #324

Open
mi-les opened this issue Jan 18, 2023 · 2 comments
Open

remove_outage does not remove outage #324

mi-les opened this issue Jan 18, 2023 · 2 comments
Assignees

Comments

@mi-les
Copy link

mi-les commented Jan 18, 2023

I need to add and remove an outage on a pump and I noticed that while I can add an outage with the add_outage function, I cannot remove it with the remove_outage function.

My minimal example looks like this:

inp_file = 'net1.inp'
wn = wntr.network.WaterNetworkModel(inp_file)
wn.options.time.duration = 5*3600
wn.options.hydraulic.demand_model = 'PDD'
pump = wn.get_link('9')
pump.add_outage(wn, 2*3600)

sim = wntr.sim.WNTRSimulator(wn)
results_1 = sim.run_sim()

wn.options.time.duration = 10*3600
pump.remove_outage(wn)
results_2 = sim.run_sim()

I would expect results_2 to have a pump without outage but this is not the case.

I found a workaround with setting the pump._user_status to LinkStatus.Open after I call pump.remove_outage(wn) but this is surely not the intended usage of the function. Is this a bug or am I using the remove_outage function incorrectly?

@kaklise
Copy link
Collaborator

kaklise commented Jan 24, 2023

When I run this code, and plot the pump flowrate from results_1 and results_2 using the following lines, I get the figure below.

results_1.link['flowrate'].loc[:,'9'].plot()
results_2.link['flowrate'].loc[:,'9'].plot()

Figure_1
This shows that the pump is operating when the simulation restarts. It sounds like this is not the behavior you're seeing. What version of WNTR are you using?

We're working on updates that improve handling of initial conditions for step wise simulation using the EpanetSimulator and WNTRSimulator. This will make it more clear when initial conditions are reset and when they retain values from the end of a simulation. That should remove the need to use the pump._user_status.

It's also important to keep in mind that outages defined by add_outage do not turn a pump back on unless you set the input argument add_after_outage_rule to True. This adds an additional control that reopens the pump when the outage is over. If the additional control is not added, the pump can turn back on based on other existing controls (like a control associated with a tank level).

@mi-les
Copy link
Author

mi-les commented Jan 24, 2023

Thank you for the reply. That is not the behavior I see, but that's the behavior I would expect. Instead, the orange line (results_2) continues at 0.

I am using wntr version 0.5.0 on Windows in a conda environment.

Thanks for letting me know about the planned updates!

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

No branches or pull requests

3 participants