Skipping links connected to valves/tanks/reservoirs

Hi.
I am creating a code that optimally places PRVs within a network. The code however is trying to replace a link next to an existing PRV, which gives the error: ’ Error 220: function call contains illegal valve connection to another valve’.

I am using a for loop to test each pipe individually and, from the results, use the PRV with the highest pressure reduction to be permanently placed in the network. I would like to ‘skip’ certain linkID’s that are connected to existing valves to bypass this error.
How would I do this?

Thanks

Hi Ethan,
If you need to exclude all the links of PRV type, you can add the next condition:

int link_type;
EN_getlinktype(ph, i, &link_type);
if (link_type != EN_PRV)

You can find all types of links supported in the next link.

Greetings
Sergio

1 Like

Hi Sergio

This code excludes the links of PRV type. I would like to exclude all the links surrounding the PRV type link.

Any ideas on this?
EPANET has the condition that valves cannot be adjacent.

Thanks
Ethan

We should understand that this error state is not a death sentence - it just means that the action could not be applied. Nothing has crashed, and the network is still there. Your placement algorithm might want to handle this error as an expected outcome, and (perhaps after a small amount of cleanup) simply proceed to the next link. It is fortunate that there is a unique error code for this exact condition

Hi Sam

My code finds the optimal location for a PRV within a network. This works when placing PRVs automatically based on highest pressure reduction while considering limiting factors (Downstream conditions, demand etc.).

The code has the tendency to place a PRV on a pipe adjacent to an existing PRV. No errors are present, but when the program creates an output file, and that file is run in EPANET, there is a missing link where that PRV should be. This is due to EPANET not allowing this connection.

So to sum it up, the code places the PRV correctly, but EPANET rejectsits placement and just removes it, so I am left with a network that is missing a link.

I would like to find the adjacent pipes to existing valves and remove them from the list of possible locations.

Thanks

Ah, I see now - thanks for the explanation. It appears that you are using something other than the setlinktype api to add these PRVs.

Three options that occur to me:

  • use the setlinktype api which would safely manipulate the network and catch this error earlier
  • build a graph using something like networkX (in whatever your target language is) that makes this kind of query easy, or
  • use the getlinknodes api on a candidate link, and compare those nodes to the list of nodes that would come from querying every existing valve.

other options?

1 Like