Giter Club home page Giter Club logo

Comments (6)

michaelbynum avatar michaelbynum commented on May 27, 2024

All you need to do is replace

wn.options.time.start_clocktime=wn.options.time.start_clocktime+3600

with

wn.options.time.duration += 3600

The start_clocktime should never change during a simulation. As the simulation progresses in time, the simulator will advance wn.sim_time as needed. The clocktime is simply wn.sim_time + wn.options.time.start_clocktime.

However, the simulator should never simulate past wn.options.time.duration. This is a bug, and I will fix it.

If you ever need to reset the network to its initial conditions, just use wn.reset_initial_values(). This will set wn.sim_time back to zero, change the tank levels back to their initial levels, etc. For example:

import wntr
import pandas as pd

solv_opts = {}

inp_file = 'Net1.inp'
wn = wntr.network.WaterNetworkModel(inp_file)
wn.options.time.duration = 3600*24
wn.options.time.hydraulic_timestep = 3600
wn.options.time.pattern_timestep =7200

sim = wntr.sim.WNTRSimulator(wn)
results_24= sim.run_sim(solver_options=solv_opts, convergence_error=True)

wn.reset_initial_values()

wn.options.time.duration = 0

pres=pd.DataFrame()
stat=pd.DataFrame()

for hour in range(0,25):
     sim = wntr.sim.WNTRSimulator(wn)
     results= sim.run_sim(solver_options=solv_opts, convergence_error=True)
     pres=pres.append(results.node["pressure"],ignore_index = False)
     stat=stat.append(results.link["status"],ignore_index = False)
     wn.options.time.duration += 3600

pres_24 = results_24.node["pressure"]
temp = pres-pres_24
print(temp)

Output:

        10   11   12   13   21   22   23   31   32    2    9
0      0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
3600   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
7200   0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
10800  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
14400  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
18000  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
21600  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
25200  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
28800  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
32400  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
36000  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
39600  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
43200  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
46800  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
50400  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
54000  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
57600  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
61200  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
64800  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
68400  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
72000  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
75600  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
79200  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
82800  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
86400  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0

from wntr.

dionikolop avatar dionikolop commented on May 27, 2024

Thanks for your prompt reply! It works as it should now. By the way, the WNTRSimulator is a very good tool, do you plan to also add quality simulation?

from wntr.

michaelbynum avatar michaelbynum commented on May 27, 2024

Thank you! We really appreciate that. You can run water quality simulations with the EpanetSimulator within WNTR. Given how well established, dependable, and efficient EPANET is, I think it is unlikely that we will implement our own water quality simulator. @kaklise Do you have anything to add?

from wntr.

dionikolop avatar dionikolop commented on May 27, 2024

I am asking because the WNTRSimulator also runs in pressure dependent demand mode and I would like to experiment with a combination of quality and pressure dependent simulation.

from wntr.

michaelbynum avatar michaelbynum commented on May 27, 2024

I think that is currently possible. I think you can use the EpanetSimulator with the hydraulics results from the WNTRSimulator. All we do is write an inp file with the demands modified to match the results of the pressure driven simulation from the WNTRSimulator. @dbhart Can you confirm that this has been implemented? Or did we just talk about it?

from wntr.

kaklise avatar kaklise commented on May 27, 2024

The docs include an example at the top of https://wntr.readthedocs.io/en/latest/waterquality.html.

from wntr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.