GithubHelp home page GithubHelp logo

usepa / wntr Goto Github PK

View Code? Open in Web Editor NEW
299.0 40.0 175.0 57.9 MB

An EPANET compatible python package to simulate and analyze water distribution networks under disaster scenarios.

License: Other

Python 62.96% Pascal 0.47% C++ 25.56% C 10.50% SWIG 0.08% Visual Basic 6.0 0.42%
ord water python modeling simulation

wntr's Introduction


build Coverage Status Documentation Status

The Water Network Tool for Resilience (WNTR) is a Python package designed to simulate and analyze resilience of water distribution networks. The software includes capability to:

  • Generate water network models
  • Modify network structure and operations
  • Add disruptive events including pipe leaks
  • Add response/repair strategies
  • Simulate pressure dependent demand and demand-driven hydraulics
  • Simulate water quality
  • Evaluate resilience
  • Visualize results

For more information, go to https://usepa.github.io/WNTR/

Installation

The latest release of WNTR can be installed from PyPI or Anaconda using one of the following commands in a command line or PowerShell prompt.

  • PyPI version Downloads

    pip install wntr

  • Anaconda version downloads

    conda install -c conda-forge wntr

See installation instructions for more details.

Citing WNTR

To cite WNTR, use one of the following references:

  • Klise, K.A., Hart, D.B., Bynum, M., Hogge, J., Haxton, T., Murray, R., Burkhardt, J. (2020). Water Network Tool for Resilience (WNTR) User Manual: Version 0.2.3. U.S. EPA Office of Research and Development, Washington, DC, EPA/600/R-20/185, 82p.

  • Klise, K.A., Murray, R., Haxton, T. (2018). An overview of the Water Network Tool for Resilience (WNTR), In Proceedings of the 1st International WDSA/CCWI Joint Conference, Kingston, Ontario, Canada, July 23-25, 075, 8p.

  • Klise, K.A., Bynum, M., Moriarty, D., Murray, R. (2017). A software framework for assessing the resilience of drinking water systems to disasters with an example earthquake case study, Environmental Modelling and Software, 95, 420-431, doi: 10.1016/j.envsoft.2017.06.022

License

WNTR is released under the Revised BSD license. See LICENSE.md for more details.

Organization

Directories

  • wntr - Python package
  • documentation - User manual
  • examples - Examples and network files

Contact

EPA Disclaimer

The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity , confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.

Sandia Funding Statement

Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy's National Nuclear Security Administration under contract DE-NA-0003525.

wntr's People

Contributors

aclong avatar arpanseth avatar bernardoct avatar buharis avatar carldlaird avatar carmine1990 avatar dbhart avatar dlvilla avatar dmmoria avatar galperelman avatar jamesuber avatar jckett avatar jhogge avatar jqortiz avatar jrings avatar kaklise avatar kbonney avatar kmruehl avatar mariocastrogama avatar michaelbynum avatar oops404 avatar pahbloo avatar pshassett avatar redcraft2374 avatar reganmurray avatar santiagoropb avatar terrahaxton avatar thaulino avatar this-josh avatar yuchuntsao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wntr's Issues

Run extended simulation with WNTR

I have no trouble running WNTRSimulator with the default 24-hour setting in my model. But when I tried to run extended simulation of 48 hours, the simulation cannot solve. Here's what I did.

inp_file = 'AvgDay_460MGD_March2018_original.inp'
wn_0 = wntr.network.WaterNetworkModel(inp_file)
wn_0.options.time.duration = 48*3600
sim_0 = wntr.sim.WNTRSimulator(wn_0, mode = 'PDD')
results_0 = sim_0.run_sim()

The error I received is "RuntimeError: Exceeded maximum number of trials." I don't know if it's because my water network has issues or it has something to do with WNTRSimulator.

My WNTR version is 2.0.1.

value error when reading existing .inp file

i try to run the following code
input = wntr.network.WaterNetworkModel("model.inp")
and get the resulting error
-packages/wntr/epanet/io.py", line 1680, in _read_options
setattr(opts, words[0].lower(), float(words[1]))
ValueError: could not convert string to float: 'psi'

any suggestions on how to resolve the error? should i be making changes to the .inp file?

Feature request: US customary units support

Then wouldn't have to do the conversion on wntr.add_* or on the results.
Something like: wn = wntr.network.WaterNetworkModel(units='USC')
Gets me EPANET inp files defaults.
(If only the US would have switched over with the Brit's these thoughts wouldn't even cross my mind :) )

cannot remove any link

i'm trying to remove a pipe from my epanet model using the following code
wntr.remove_link('pipeA')
however i get the error code back 'NoneType' object has no attribute 'update'

i tried to loop through every single pipe in my system and each trial gives me the same error back. i even tried re-exporting the .inp file multiples times on epanet. any pointers as to why?
the network im using is in the link below https://ceprofs.civil.tamu.edu/kbrumbelow/Micropolis/index.htm

Step-wise WNTR simulation problem

Hello,
I am experiencing a strange issue when performing a step-wise simulation. The set-up: a) I import a .inp file like example Net1 b) I set the time options to time.duration = 1 hour and same for hydraulic timestep c) I use WNTRSimulator d) I loop for 24 hours running the sim again for the same water network, but advancing the time.start_clocktime by one hour.
The problem: At certain steps, the results are empty data frames.
Strange behaviour: If you force the simulation to run again when the results are an empty dataframe, then the new results are not an empty dataframe and also correct hydraulically speaking.
You can replicate the issue with the code below and you can note that at hour 12 and 23 (starting count from 0) the results are empty dataframes.
I use Anaconda 5.1.0, python version 3.6 and I installed WNTR with pip.

import wntr
import pandas as pd

inp_file = 'C:/...../WNTR-master/examples/networks/Net1.inp'
wn.options.time.duration = 3600
wn.options.time.hydraulic_timestep = 3600
wn.options.time.pattern_timestep =7200

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

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

The strange solution is to add this check inside the loop after results=sim.run_sim() command:

while results.node["pressure"].empty:
        print("empty")
        results=sim.run_sim()

Any help would be more than welcome!

can not open an INP file

I use 'wntr.network.WaterNetworkModel' to load an inf file,but occured the error:

File "D:\anaconda\lib\site-packages\wntr\epanet\io.py", line 615, in _read_pipes
if current[7].upper() == 'CV':

IndexError: list index out of range
why?

Pump Attribute Calling

Hello, I am new to coding and am trying to utilize WNTR for a project. I am having issues calling into the pumps to pull the "power" attribute and have it match the model. Both units are in HP. It is either prints out "1" or "None."

wntr.network.model.Pump('~@Pump-1','I-Pump-1','O-Pump-1', wn)._base_power

print(wntr.network.elements.Pump('~@Pump-1','I-Pump-1','O-Pump-1', wn)._base_power)

I can have it call into the model for junction or pipe attributes and can modify those as desired. I am just unsure of the proper pathway to call for pumping power and how to modify it once I can call to it.

Calling Reservoir Attributes

Helo,
is possible to get atribute of reservoir e.g. elevation from imported WDS model? I can't use query_node_attribute because reservoir isn't a node in WNTR. Is any method to get this attribute?

Remove a pattern

Hello,
I am not sure how to remove a pattern from a wntr.network.model.WaterNetworkModel object. I get the error:
('cannot remove %s %s, still used by %s', 'PatternRegistry', 'PDD10', {('10', 'Junction'), }).
However, I cannot find a way to delete patterns from PatternRegistry.
Thanks in advance!
Dionysis

EPANET i/o error when running EpanetSimulator in Parallel

i'm trying to run simulations using the wntr.EpanetSimulator() function in parallel and i keep getting back epanet errors "EPANET Error 200" or "EPANET Error 224". the error implies i do not have a supply nodes but I explicitly call wntr.add_reservoir()/wntr.add_tank() beforehand, it's unclear to me why this is happening.
i also assert that the network is completely connected (using the wntr.to_undirected() function), and that there is at least one supply node (length of wntr.reservoir_name_list + wntr.tank_name_list).
the os im using is linux (ubuntu), any pointers as why this is happening? my hunch is the parallelization of writing and running multiple files at once

WNTR-psv WNTRSimulator issue

I successfully installed WNTR-psv and loaded WNTR-psv into python.

Here's my code

inp_file = 'AvgDay_460MGD_March2018_original.inp'

wn_0 = wntr.network.WaterNetworkModel(inp_file)

sim_0 = wntr.sim.WNTRSimulator(wn_0)

results_0 = sim_0.run_sim()

Here's what the screen shows

Traceback (most recent call last):

File "", line 2, in
results_0 = sim_0.run_sim()

File "C:\Users\ll69\AppData\Local\Continuum\anaconda3\lib\site-packages\wntr\sim\core.py", line 463, in run_sim
solver_status, mesg = _solver_helper(model, solver, solver_options)

File "C:\Users\ll69\AppData\Local\Continuum\anaconda3\lib\site-packages\wntr\sim\core.py", line 732, in _solver_helper
sol = _solver.solve(model)

File "C:\Users\ll69\AppData\Local\Continuum\anaconda3\lib\site-packages\wntr\sim\solvers.py", line 99, in solve
J = model.evaluate_jacobian(x=None)

File "C:\Users\ll69\AppData\Local\Continuum\anaconda3\lib\site-packages\wntr\sim\aml\aml.py", line 336, in evaluate_jacobian
raise ValueError('The number of constraints and variables must be equal.')

ValueError: The number of constraints and variables must be equal.

I don't quite understand what this error means. The INP file is based on a real drinking water distribution network that runs well with EpanetSimulator.

error: name 'plt' is not defined - Matplotlib is a hard dependency?

When Matplotlib is not installed, this error is generated upon import. According to the docs, Matplotlib is an optional dependency. However, I can find no way to use the WNTR package without installing Matplotlib.

I also see this when using the continuumio/anaconda3:5.0.1 docker image, which does have matplotlib pre-installed. So apparently there's some compatibility problems there as well.

Traceback (most recent call last):
  File "./epanet_worker.py", line 1, in <module>
    from wntr import network
  File "/opt/conda/lib/python3.6/site-packages/wntr/__init__.py", line 6, in <module>
    from wntr import graphics
  File "/opt/conda/lib/python3.6/site-packages/wntr/graphics/__init__.py", line 4, in <module>
    from wntr.graphics.network import plot_network, plot_interactive_network
  File "/opt/conda/lib/python3.6/site-packages/wntr/graphics/network.py", line 20, in <module>
    node_size=20, node_range = [None,None], node_cmap=plt.cm.jet, node_labels=False,
NameError: name 'plt' is not defined

[EpanetSimulator] result_types option does not change the results object

A few issues related to using the result_types option of EpanetSimulator:

  1. The documentation on wntr.sim.epanet.EpanetSimulator defines that result_types should be a dict, however documentation on wntr.epanet.io.BinFile, where result_types is passed, defines 'results_type' as a list. Possible typo(s)?

  2. When the user-specified result_types is passed from wntr.sim.epanet.EpanetSimulator as a parameter for wntr.epanet.io.BinFile:
    self.reader = wntr.epanet.io.BinFile(result_types=result_types), result_types is saved to wntr.epanet.io.BinFile attribute self.items. self.items however is only used in the custom handler methods.
    When wntr.sim.epanet.EpanetSimulator.run_sim() reaches its end and calls:
    return self.reader.read(outfile), wntr.epanet.io.BinFile.read() is executed with kwarg custom_handlers = False, resulting in the items specified by result_types are never being used.

  3. There doesn't seem to be any simple way to use the custom handlers without writing a custom child class of wntr.epanet.io.BinFile?

Maybe I am misunderstanding the intended use of result_types from the API documentation, in which case perhaps the related docs need to be updated to clarify.

Shape of passed values is (x, 1), indices imply (y, 25)

Hi,

I have successfully imported the network file (i.e. *.inp). However running the wntr simulator I keep on getting the following error:

Error:

ValueError Traceback (most recent call last)
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py in create_block_manager_from_blocks(blocks, axes)
1650 blocks = [make_block(values=blocks[0],
-> 1651 placement=slice(0, len(axes[0])))]
1652

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py in make_block(values, placement, klass, ndim, dtype, fastpath)
3094
-> 3095 return klass(values, ndim=ndim, placement=placement)
3096

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\blocks.py in init(self, values, placement, ndim)
86 'Wrong number of items passed {val}, placement implies '
---> 87 '{mgr}'.format(val=len(self.values), mgr=len(self.mgr_locs)))
88

ValueError: Wrong number of items passed 1, placement implies 25

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in
1 # Simulate hydraulics
2 sim = wntr.sim.EpanetSimulator(wn)
----> 3 results = sim.run_sim()

C:\ProgramData\Anaconda3\lib\site-packages\wntr\sim\epanet.py in run_sim(self, file_prefix, save_hyd, use_hyd, hydfile)
96 logger.debug('Completed run')
97 #os.sys.stderr.write('Finished Closing\n')
---> 98 return self.reader.read(outfile)
99

C:\ProgramData\Anaconda3\lib\site-packages\wntr\epanet\io.py in read(self, filename, custom_handlers)
2761 logger.exception('Failed to process file: %s', e)
2762
-> 2763 df = pd.DataFrame(data.transpose(), index =index, columns = reporttimes)
2764 df = df.transpose()
2765

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py in init(self, data, index, columns, dtype, copy)
422 else:
423 mgr = init_ndarray(data, index, columns, dtype=dtype,
--> 424 copy=copy)
425
426 # For data is list-like, or Iterable (will consume into list)

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\construction.py in init_ndarray(values, index, columns, dtype, copy)
165 values = maybe_infer_to_datetimelike(values)
166
--> 167 return create_block_manager_from_blocks([values], [columns, index])
168
169

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py in create_block_manager_from_blocks(blocks, axes)
1658 blocks = [getattr(b, 'values', b) for b in blocks]
1659 tot_items = sum(b.shape[0] for b in blocks)
-> 1660 construction_error(tot_items, blocks[0].shape[1:], axes, e)
1661
1662

C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\internals\managers.py in construction_error(tot_items, block_shape, axes, e)
1689 raise ValueError("Empty data passed with indices specified.")
1690 raise ValueError("Shape of passed values is {0}, indices imply {1}".format(
-> 1691 passed, implied))
1692
1693

ValueError: Shape of passed values is (1515727, 1), indices imply (151572, 25)

GPV Setting

Hello,
I have problem with Epanet Simulation of network, which contains a GPV.
In this network GPV has a string setting, which is a reference to defined headloss curve.
I get EPANET Error 200 as I guess only float value is accepted.
Any ideas of how to make it work? I would appreciate all suggestions ;)

Heres the exact error code:

  File "C:\DEV\Python\lib\site-packages\wntr\sim\epanet.py", line 81, in run_sim

  File "C:\DEV\Python\lib\site-packages\wntr\epanet\toolkit.py", line 187, in EN
open
  File "C:\DEV\Python\lib\site-packages\wntr\epanet\toolkit.py", line 156, in _e
rror
wntr.epanet.toolkit.EpanetException: EPANET Error 200

And here's the inp section with GPV

;ID              	Node1           	Node2           	Diameter    	Type	Setting     	MinorLoss   
 967             	16_71           	valve          	55.4        	GPV 	head_curve          	0           	;

run_sim() error

Hello,
I'm trying to run the Getting Started example and get the following error:

OSError: [WinError 126] The specified module could not be found

[wntr/epanet/io.py] Error converting float PRIORITY value in [RULES] section

Appropriately, ValueError: invalid literal for int() with base 10: is raised if a non-integer value is entered as a rule's Priority value in the inp file.

However, in cases where Priority is manually or programmaticaly assigned a float value such as '1.0', this still raises an error. The same inp file opens and runs fine in EPANET.

This can be resolved by converting the parsed string value for Priority to float first and then to int.

.bin file not writing when running epanet simulation

i notice that a .bin file is not writing to file when i call the following command on my wntr object "wn". the ".inp" and ".rpt" files are writing just fine.
simulation = wntr.sim.EpanetSimulator(wn)
results = simulation.run_sim()
as a result i keep getting an error back "enData.ENopen(inpfile, rptfile, outfile)...wntr.epanet.toolkit.EpanetException: EPANET Error 200".
any pointers as to why the .bin file is not saving?

iCode

I am new in programming. trying to use wntr for my research. running
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32 .
and using Spyder to code.
I am trying to use the epanet.toolkit to get values from an inp file however the command requires enter an iCode for the components. How do I get this input.

import wntr

inp_file = "umee/hanoi.inp"
wn = wntr.network.WaterNetworkModel(inp_file)

wntr.graphics.plot_network(wn, title=wn)

wntr.epanet.toolkit.runepanet(inp_file)
wntr.epanet.toolkit.ENepanet(inpfile="umee/hanoi.inp",rptfile="umee/hanoi.rpt",binfile="umee/hanoi.bin")
wntr.epanet.toolkit.ENepanet.ENgetcount() # trying to get linkcount

RuntimeError: Hydraulic_metrics

Hello. I want to inquire about error while studying WNTR Simulator.
An error occurs during the calculation of 'Compute water service availability, for each operation' in the hydraulics.

Warning (from warnings module):
File "C:\Users\syste\AppData\Local\Programs\Python\Python36\lib\site-packages\wntr\sim\hydraulics.py", line 713
last_segment = (-0.5)j_d/(nomP-minP)((P-minP)/(nomP-minP))**(-0.5)
RuntimeWarning: divide by zero encountered in power

Warning (from warnings module):
File "C:\Users\syste\AppData\Local\Programs\Python\Python36\lib\site-packages\wntr\sim\hydraulics.py", line 713
last_segment = (-0.5)j_d/(nomP-minP)((P-minP)/(nomP-minP))**(-0.5)
RuntimeWarning: invalid value encountered in multiply

I hope you will let me know the solution to this.
Thank you.

RuntimeError: networks/Net3.inp:9: Non-comment outside of valid section!

I installed WNTR 0.1.5 and I am using the following version of Python in Spyder 3:
3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45) [MSC v.1900 64 bit (AMD64)]

I re-created, without mistakes, the two scripts performing hydraulic simulations and the interaction with networkx, and have saved them in a folder. In the same folder, I created a sub-folder called "networks", where I saved the .inp files made available on GitHub.

However, when I run either script, I get the following error:
RuntimeError: networks/Net3.inp:9: Non-comment outside of valid section!

This same error occurs when I change .inp file, so I am not sure what happens - never played with .inp files before. That number 9 may point at row 9 in the .inp file, but I could not spot anything weird or that could match the error description.

Any help would be much appreciated.

Is there a way to explicitly assign the pumping energy to a variable?

Hello,
Thank you for developing this great tool. I'm wondering if there is a way to extract the pumping energy and assign it to a variable using the tool. I see that the cost of pumping is included in the results generated from "wntr.metrics.cost", however, I'm not able to separate the pumping energy consumption.
Thanks

Detect empty pipes

We should try to detect empty pipes and issue a warning. These can cause incorrect negative pressures due to differences in elevation.

WNTR-psv_support installation issue

@michaelbynum I downloaded psv_support from your folk. When I tried to install it. I got this error message

D:\Research_Y2\WNTR-psv_support>python setup.py install
running install
running bdist_egg
running egg_info
writing top-level names to wntr.egg-info\top_level.txt
writing wntr.egg-info\PKG-INFO
writing dependency_links to wntr.egg-info\dependency_links.txt
reading manifest file 'wntr.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'LICENSE.txt'
writing manifest file 'wntr.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
copying wntr\sim\aml\evaluator.cpp -> build\lib.win32-3.5\wntr\sim\aml
copying wntr\sim\aml\evaluator_wrap.cpp -> build\lib.win32-3.5\wntr\sim\aml
copying wntr\sim\network_isolation\network_isolation.cpp -> build\lib.win32-3.5\wntr\sim\network_isolation
copying wntr\sim\network_isolation\network_isolation_wrap.cpp -> build\lib.win32-3.5\wntr\sim\network_isolation
running build_ext
building 'wntr.sim.aml._evaluator' extension
error: [WinError 2] The system cannot find the file specified

Could you help me identify the problem?

WNTRSimulator not working for network with PSV valve

Here's my script

inp_file = 'AvgDay_460MGD_March2018.inp'
wn_0 = wntr.network.WaterNetworkModel(inp_file)

sim_0 = wntr.sim.WNTRSimulator(wn_0)
results_0 = sim_0.run_sim()

I got the following error message

"Traceback (most recent call last):

File "", line 13, in
results_0 = sim_0.run_sim()

File "C:\Users\ll69\AppData\Local\Continuum\anaconda2\lib\site-packages\wntr\sim\core.py", line 215, in run_sim
model = HydraulicModel(self._wn, self.mode)

File "C:\Users\ll69\AppData\Local\Continuum\anaconda2\lib\site-packages\wntr\sim\hydraulics.py", line 70, in init
self._set_link_attributes()

File "C:\Users\ll69\AppData\Local\Continuum\anaconda2\lib\site-packages\wntr\sim\hydraulics.py", line 383, in _set_link_attributes
raise ValueError('Currently only PRVs, FCVs, and TCVs are supported.')

ValueError: Currently only PRVs, FCVs, and TCVs are supported."

I notice I have a number of PSV valves in my network. How should I go about avoiding this error message? Thank you.

Pandas is deprecating Panels

WNTR uses Pandas Panels to store simulation results. The development team is looking at alternatives to replicate this functionality.

Cant use the EpanetSimulator after error: 302 occurs

Hello,

I am trying to run multiple simulations using the EpanetSimulator but some of the networks I am working on produce the following error: ERROR:wntr.epanet.toolkit: EPANET error: 302.

The problem is that once this error occurs I am unable to continue using the EpanetSimulator unless I reset the whole script. I was wondering if there is a work around this.

WNTR not plotting the network graph

Hello. I start work with WNTR. It will help me in my master thesis. I have a problem with plotting in Pycharm IDE. When I used a getting_started script in Pycharm I don't got any graph. I have every required python package. However When I used Spyder in terminal i got a small picture of graph.

What's the problem. Pycharm doesn't support WNTR or I have problem with python package?
(I use Python 3.6.7 in Ubuntu 18.04)

How to accurately model pipe breaks?

I'm trying to estimate the change in system pressure due to a pipe break and i'm struggling to figure out how to do this in a pressure-dependent way in WNTR. This is what I currently do:

  1. remove pipe using wn.remove_link()
  2. add two leakage nodes wn.add_junction() nearby the two nodes connecting the original pipe
  3. add two pipes connecting each leakage node to the original two nodes, the two leakage nodes remain disconnected. use wn.add_pipe().
  4. define a base demand, demand profile, and leakage at the leakage nodes.
  5. re-simulate.

While this works, I can't figure out a way to reasonably define the base demand and demand profile. These values are arbitrarily set. If i do not have demand at these junctions and only leaks, no flow will go to these points, which also doesn't make sense.

Any ideas on how to simulate water loss (and pressure changes) due to pipe breaks?

Cannot import the shortest_path

Hello.
While freezing code with cx_Freeze I encountered problem with WNTR and SciPy . While trying to launch windows returns traceback:

Traceback (most recent call last):
0 File "C:\DEV\Python\lib\site-packagesch_Freeze\initscripts_startup_.py", line 14, in run

module.run()

File "C:\DEV\Python\lib\site-packages\cx_Freeze\initscripts\ConsoIe.py", line 26, in run
e\ec(code, m.dict)

File "SampleAPP.py", line 18, in < module>

File "C:\DEV\Python\lib\site-packageszntrLinit_.py", line 1, in < module>
from wntr import epanet

File "C\DEV\Python\lib\site- packages\wntr\epanet_init_.py", line 4, in < module>
from .io import IoniIe #, BinFiIe, HydFile, RptFiIe

File "C:\DEV\Python\lib\site-packageszntr\epanet\io.py", line 32, in < module>
import wntr.network

File "C\DEV\Python\lib\site- packages\wntr\network_init_.py", line 6, in < module>
from .eIements import Junction, Reservoir, Tank, Pipe, Pump, Valve, Pattern, TimeSeries, Demands, Curve, Source

File "C\DEV\Python\lib\site- packages\wntr\network\elements.py", line 37, in < module>
from scipy.optimize import fsolve

File "C\DEV\Python\lib\site- packages\scipy\optimize_init_.py", line 271, in < module>
from ._minimize import *

File "C:\DEV\Python\lib\site-packages\scipy\optimize_minimize.py", line 21, in < module>
from scipy.sparse.linalg import LinearOperator

File "C\DEV\Python\lib\site-packages\scipy\parse_init_.py", line 241, in < module>
from . import csgraph

File "C\DEV\Python\lib\site-packages\scipstparse\csgraphLinit_.py", line 165, in < module>
from ._shortest_path import shortest_path, floyd_warshall, dijkstraA

ImportError: cannot import name 'shortest_path'

(Converted this traceback from image with ocr so it can contain some typos. Anyone encountered this problem and knows how to solve it? I would be really thankfull.

traceback

I can provide more information if needed.
Im using newest version of wntr, python 3.6.5. 64 bit.

Demand information in [JUNCTIONS] is lost

As discussed in #68, the demands defined in the [JUNCTIONS] section should be overwritten with demands defined in the [DEMANDS] section for a given node. #70 implements this but as a result deletes the node's demand information in the [JUNCTIONS] section.

Initial Quality not being read

When reading an INP file, the initial quality is not read. Probably because the function _read_quality() in io.py is never called.
I simply added a line 'self._read_quality()' below 'self._read_demands()' in io.py and this seems to solve the issue. Is this correct or do I miss something?

[DEMANDS] section does not replace demands in [JUNCTIONS]

According to EPAnet INP-file specifications, the demands in section [DEMANDS] should replace the demands as specified in [JUNCTIONS]. In io.py there is a line (1347) that makes sure that this happens based on category 'EN2 base', but it is commented out. Hence any demands in the [DEMANDS] sections is added to the node. Can this line be activated again safely or does this affect anything else?

Zero Demand causes Jacobian to be singular

Hello,
I came across a "Simulation did not converge. Jacobian is singular at iteration 0". I added a node with zero demand, and this occurs only in PDD mode and WNTR simulator. Changing the node's demand to something small e.g. 0.001 m3/s or 0.1 m3/s does not solve the problem. However, when I use the WNTR simulator or Epanet Simulator in Demand-driven mode no error occurs. Any known remedies to this issue?
I must clarify that the network i use is a modified Net1.inp.
This is my code:

wn=wntr.network.WaterNetworkModel('Net1.inp')
negative_demand=-0.005
wn.add_junction('10IN',base_demand=negative_demand,
                        demand_pattern=None, elevation=cpmodel.wn.get_node('10').elevation+1,
                        coordinates=(cpmodel.wn.get_node('10').coordinates[0]+0.5,cpmodel.wn.get_node('10').coordinates[1]+0.5))
wn.get_node('10IN').nominal_pressure=0
wn.get_node('10IN').minimum_pressure=1
wn.add_pipe('pipe1','10IN','10',length=1.225)
wn.add_junction('10F',base_demand=0,
                        demand_pattern=None, elevation=cpmodel.wn.get_node('10').elevation-0.5,
                        coordinates=(cpmodel.wn.get_node('10').coordinates[0]-0.5,cpmodel.wn.get_node('10').coordinates[1]-0.5))
wn.get_node('10F').nominal_pressure=0
wn.get_node('10F').minimum_pressure=1
wn.add_pipe('pipe2','10F','10',length=1.225)

Adding the following produces the problem

wn.add_junction('32F',base_demand=0.1,
                        demand_pattern=None, elevation=cpmodel.wn.get_node('32').elevation+0.5,
                        coordinates=(cpmodel.wn.get_node('32').coordinates[0]-0.5,cpmodel.wn.get_node('32').coordinates[1]-0.5))
wn.get_node('32F').nominal_pressure=0
wn.get_node('32F').minimum_pressure=1
wn.add_pipe('pipe3','32F','32',length=1.225)

sim = wntr.sim.WNTRSimulator(wn, mode='PDD')
results= sim.run_sim()

Also, when i remove the nominal and minimum pressure declarations it runs without problem.
Thanks in advance!

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.