Comments (6)
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.
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.
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.
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.
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.
The docs include an example at the top of https://wntr.readthedocs.io/en/latest/waterquality.html.
from wntr.
Related Issues (20)
- Questions about optimal scheduling of pumping stations HOT 1
- runnin the program HOT 3
- wntr.network.options has some abnormal annotation contents HOT 1
- Writing an inp file 'self' argument error message HOT 2
- Create a control object or rule object from text input HOT 5
- Get the reactions tab in the inp file from a water network instance HOT 1
- Add PBV support to [VALVES] section
- Generating Interactive leaflet networks HOT 7
- Pipe status problem HOT 4
- AttributeError: 'WaterNetworkModel' object has no attribute 'write_inpfile' HOT 3
- Differences with my epanet from zero model and inp from wntr model HOT 4
- Values in [DEMANDS] section are repetead and others are missing HOT 8
- Unable to remove leaks from network model HOT 3
- Not able to save the network with modified elements as an INP file. HOT 2
- EPANET Error 110 HOT 1
- leaflet map popups HOT 5
- Todini Index Calculation for the Net6 network - Values outside the range [0,1] HOT 5
- Update EPANET binaries for MacOS arm64 HOT 1
- Check deprecation and future warnings, and version compatibility for dependencies
- Pressure Threshold for Resilience indices like Todini and MRI HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wntr.