Hi everyone,
In a large water distribution network with 1000 nodes, how can I determine the number of links connected to each node and their IDs with EPANET-MATLAB toolkit?
Best Regards,
Fatemeh Attarzadeh
Determine the number of links connected to each node and their IDs with EPANET-MATLAB toolkit
@Fatemeh, I suggest follow the below steps:
1- Make a matrix A, contain of pipeID, Node1, Node2: you can open the .inp file in excel and separate the mentioned columns above in a another file and then call in MATLAB.
-
Make a zero matrix B, contain of [number of row=number of junction, number of column=5]. Because of for a junction, can connect maximum 4 pipe and the first column is the id junction.
-
Search row by row the id of network junctions in matrix A, and save the number of rows which find the id junction in them in columns 2 to 5.
-
For every row in B matrix, the non-zero column is the number of pipe connect to every junction and number of every column is the pipe index which is connect to junction. Then, you can find the id pipe from pipe index, easily.
Hi @Fatemeh, the number of links connected to each node you can find from
connmatrix = d.getConnectivityMatrix; sum(connmatrix)
Example:
start_toolkit;
d = epanet('Net1.inp');
connmatrix = d.getConnectivityMatrix;
nodesConnectingLinksIndex = d.getNodesConnectingLinksIndex;
nodeConnLinkIDs = {};
for i=1:size(connmatrix, 1)
nodeIndices = find(connmatrix(: , i))';
linksconnFrom = find(nodesConnectingLinksIndex(:, 1) == i);
linksconnTo = find(nodesConnectingLinksIndex(:, 2) == i);
nodeConnLinkIDs{i} = d.getLinkNameID(unique([linksconnFrom', linksconnTo']));
end
links_connected_to_each_node = sum(connmatrix)
nodeConnLinkIDs
Regards,
Marios