Comments (4)
Hi @kbonney
I have deleted my last message to you as I have just found out what I was doing wrong!
When specifying the valve status I had False as a string (pipe.check_valve="False") and of course it is a bool. I got it mixed up as when using pipe.initial_status before "CLose" and "Open" are strings.
I am not sure why it did not come up with an error message though!
Many thnaks!
from wntr.
Hi @DanielaBS1,
Check valve and initial status are treated as two different attributes in WNTR. If you query for check_valve
rather than initial_status
, you should see what you are expecting. In the same way, the check_valve
attribute is what you will want to modify so that your changes are reflected in the INP file you write out.
from wntr.
Thanks @kbonney
This should've solved my problem, however it didn't. Maybe I am writing the INP file incorrectly, or I am missing something else. I tell you all the steps I have taken.
I have split some pipes that had CV status :
(after defining the variables...)
for i,j,z in zip(range(len(pipe_to_split)),range(len(pipe_name_list)), range(len(junction_name_list))):
wntr.morph.link.split_pipe(wn, pipe_name_to_split=pipe_to_split[i], new_pipe_name=pipe_name_list[j], new_junction_name=junction_name_list[z],add_pipe_at_end=False, split_at_point=0.5, return_copy=False)
Then, I want some of the split pipes that have CV, not to have it. So as you suggested I did:
for name in wn.pipe_name_list:
if "NP" in name:
pipe= wn.get_link(name)
pipe.check_valve="False"
status=wn.query_link_attribute('check_valve') # This is just for checking and it shows it correctly the pipes with or without CV#
And them I save an INP file so I can see it all on EPANET software:
wntr.network.write_inpfile(wn,filename='G_modificado_teste.inp')
When I open the INP file created, the split pipes are shown correct, but the status of those pipes (named NP) I wish not to have a CV isn't.
If you could advise me, I will be very thankful.
PS. When splitting the pipes I have selected not to return a copy ( return_copy=False) as I am not sure how WNTR deals with this copy. If I select it to return a copy ( return_copy=True) then I ca not see the split pipes on the INP file created. If you could advise on that too it will be much appreciated.
from wntr.
I identified two issues in your comment:
- Updating
check_valve
on a pipe is not reflected in your inp file - Different io behavior depending on
return_copy
option
To 1., I was not able to replicate this on a basic network. I am able to successfully split pipes and change check valve status, and these changes show up in the INP file I write afterwards. If you want to provide your model and script that this issue is occuring on, or replicate the issue using a WNTR example model, I can try to take a look.
To 2., many WNTR functions have the option return_copy
. When this is true, the function will return a copy of the network with whatever update that the function performs. In this case it is necessary to capture the output of the function in a variable in order to use the result. When the option is false, then the update is performed directly on the network that is passed into the function so it isn't necessary to capture the output in a new or existing variable. In other words, the behavior you observed is correct and intended.
from wntr.
Related Issues (20)
- 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
- Version compatibility for dependencies HOT 1
- Pressure Threshold for Resilience indices like Todini and MRI HOT 2
- Problems to run parallel processing with WNTR / EPANET HOT 2
- WARNING - Writing a minimal INP file without saved non-WNTR options (energy, etc.) -- obselete?
- GIS files written with wrong column title for 'name' HOT 1
- Allow import of 'base_demand' and 'demand_pattern' from GIS files HOT 2
- Error checking HOT 3
- Tank Leak Hydraulic Solver Bug HOT 1
- No WHL on pypi for Python 3.12 HOT 1
- Geopandas/fiona incompatibility
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.