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

Step-wise simulation #204

Open
mortvif opened this issue Apr 14, 2021 · 9 comments
Open

Step-wise simulation #204

mortvif opened this issue Apr 14, 2021 · 9 comments

Comments

@mortvif
Copy link

mortvif commented Apr 14, 2021

Hi!

I am trying to run a Epanet simulation step by step using the same approach proposed in issue #59. However, step time execution increases linearlly with time in my tests, sugesting that simulation is completly recomputed in each step.

I haven't found any information on this step-wise approach in the documentation. After a quick code lookup I have found ENnextH and ENrunH methods in the internal epanet bindings (wntr.epanet.toolkit module) which might be useful. However, it seems to me that they are not used in the exposed high level interface (wntr.sim.epanet module).

Is it possible to perform this step-wise simulation? If so, which is the proper approach to achieve it?

Thanks!

@kaklise
Copy link
Collaborator

kaklise commented Apr 14, 2021

Right now, the step-wise simulation only works with the WNTRSimulator. We are currently working on features that will extend this to the EpanetSimulator. This includes the ability to initialize the water network model with simulation results (such as results from a previous timestep). We plan to push these updates to the dev branch in the next few weeks.

@mortvif
Copy link
Author

mortvif commented Apr 16, 2021

Thanks! I'll stay tuned for the upcoming changes.

@mortvif
Copy link
Author

mortvif commented Oct 15, 2021

I have looked at the repo history and couldn't find any related commits in the last few months. Did you finished this feature and I have missed it or is it still work in progress?

In any case, I would greatly appreciate if you could provide an update on the current state of this topic.
Thanks!

@dbhart
Copy link
Collaborator

dbhart commented Oct 15, 2021 via email

@mortvif
Copy link
Author

mortvif commented Oct 19, 2021

Thank you for your quick response!

After analyzing the code I understand the flag that is required is the until parameter in the run_sim function. I have adapted your test scenario to run it stepwise as follows (using same setup):

sim = rt.EpanetSimulator_RT(wn)
prov = rt.RealtimeProvider(timelimit=wn.options.time.duration,
    outfile="temp.out",
    infile="temp.in",
    controls=controls)
for sensor in nodesens:
    sim.add_sensor_instrument(sensor[0], 'node', sensor[1], sensor[2])
for sensor in linksens:
    sim.add_sensor_instrument(sensor[0], 'link', sensor[1], sensor[2])
for controller in controllers:
    sim.add_controller_instrument(controller[0], controller[1], controller[2])

sim.initialize(transmit=prov.proc_sensors, receive=prov.proc_controllers, stop=prov.check_time, file_prefix="temp")
for i in range(1, 101):
    try:
        sim.run_sim(until= i * 3600)      
        print("Simulating until " +str(i*3600) + " in "+str((end-start).seconds) + " seconds")
    except:
        print("Error")

res = sim.close()

However, this approach prompts what I understand is an EPANET convergence warning after the first timestep.

/home/mortvif/.local/share/virtualenvs/water_rt-0SEeEPjZ/lib/python3.9/site-packages/wntr/epanet/io.py:2777: UserWarning: Simulation did not converge at time 01:02:00.
warnings.warn('Simulation did not converge at time ' + self._get_time(t) + '.')

Execution seems to continue without raising an error but no further timesteps are simulated and results obtained after invoking sim.close() are limited to those times before the convergence warning.

I don't know if I am missing something or this still requires further work on the library to make it functional.

Thank you once again for your helpful attention!

@Naycat
Copy link

Naycat commented Apr 22, 2022

Is the step by step simulation for the Epanet simulator now available?

@kaklise
Copy link
Collaborator

kaklise commented Apr 22, 2022

We continue to develop the stepwise and realtime EPANET simulators in WNTR, but they are not quite ready to push to the USEPA main branch. It will take some time to get these updates fully documented and tested. We can create a separate branch with this capability as soon as it's ready, perhaps this summer.

@Pu-nk
Copy link

Pu-nk commented Jan 6, 2023

So maybe the step-wise simulator is avaliable now?

@kaklise
Copy link
Collaborator

kaklise commented Jan 17, 2023

The step-wise simulator is not available yet, we are finishing up documentation and tests.

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

No branches or pull requests

5 participants