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

How to add PRV valve by interating the link #279

Closed
YanisaMadmay opened this issue Jul 3, 2022 · 4 comments
Closed

How to add PRV valve by interating the link #279

YanisaMadmay opened this issue Jul 3, 2022 · 4 comments
Labels

Comments

@YanisaMadmay
Copy link

YanisaMadmay commented Jul 3, 2022

Hi,
My question is

  1. I would like to add PRV by interating using the link of pipe, start from install 1 valve and random it to every location. And then get the result to see every pressure in node after this I will add the number of valve (i+1) and random it to every location on the pipe again.
    I follow this coding however I face the problem when it said

image

class valve_controller(): def __init__(self, wn): self.wn = wn def remove(self, pipe_name): self.wn.remove_link(pipe_name) def add_valve(self, name, start_node_name, end_node_name, diameter, valve_type, minor_loss, initial_setting, initial_status): self.wn.add_valve( name=name, start_node_name = start_node_name, end_node_name = end_node_name, diameter = diameter, valve_type = valve_type, minor_loss = minor_loss, initial_setting = initial_setting initial_status= initial_status ) def get_wn(self): return self.wn def get_name(self): return self.wn.name
As you can see i will get the error from this

  1. I would like to know what function is used to get the graphic to see the valve in the network
    Thank you for your supporting it mean a lot to me.
@kaklise
Copy link
Collaborator

kaklise commented Jul 6, 2022

For 1, it looks like you're missing a comma between "initial_setting = initial_setting" and "initial_status = initial_status"

For 2, WNTR graphics currently don't include different icons for different types of links (valves, pumps, pipes) and nodes (reservoirs, tanks, junctions). This would be a great feature to add to the WNTR graphics. We can look into that. You could use the plot_valve_layer function but that would require creating a "valve layer" that specifies the link and node the valve is associated with, see https://wntr.readthedocs.io/en/latest/graphics.html#valve-layers-and-segments for an example.

@YanisaMadmay
Copy link
Author

I really appreciate for your answer,
For 1, it really clear I correct it and it has been working.
For2, I already looked into the function. However, this "valve layer" cannnot allow me to setting the valve such as type and initial_setting. I am struggle with that becasue I would like to model by random the location of valve (first only one valve in the network) while random the initial setting each time from 20-60 m. And then add more than one valve to the model and random initial setting again. I did not know how to do this as simple way this is becasue in order to install valve I need to remove pipe first. Following this when I need to change the location of valve I need to change the past location valve to be pipe as original . And it was really complex task. I did not know WNTR have any function to help me dothis type of job more easilier.

@kaklise
Copy link
Collaborator

kaklise commented Jul 11, 2022

That is correct, the "valve layer" will only be helpful for graphics in this case. To add valves at different locations in the network, you will need to add and remove valves. However, you could keep the pipe and close it when a valve is added. That way when you want to remove the valve and use the pipe again, you just need to open it (instead of recreating it with the correct properties from scratch).

@YanisaMadmay
Copy link
Author

Thank you so much. It really helpful :)

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

No branches or pull requests

2 participants