WNTR icon indicating copy to clipboard operation
WNTR copied to clipboard

`remove_outage` does not remove outage

Open mi-les opened this issue 2 years ago • 2 comments

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?

mi-les avatar Jan 18 '23 13:01 mi-les

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

kaklise avatar Jan 24 '23 17:01 kaklise

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!

mi-les avatar Jan 24 '23 17:01 mi-les