Skip to content

Commit

Permalink
Add the function getFlowDirections
Browse files Browse the repository at this point in the history
Compute the adjacency matrix (connectivity graph) considering the flows, at different time steps or the mean flow
  • Loading branch information
Mariosmsk committed Sep 23, 2022
1 parent 9c35084 commit e9a4477
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ The `EPANET-Matlab Toolkit` is based/inspired on the [EPANET-Matlab Toolkit](htt
|getDemandModel|Retrieves the type of demand model in use and its parameters|
|getEN_functionsImpemented|Retrieves the epanet EN_ functions that have been developed|
|getENfunctionsImpemented|Retrieves the epanet functions that have been developed|
|getFlowDirections|Compute the adjacency matrix (connectivity graph) considering the flows, at different time steps or the mean flow|
|getFlowUnits|Retrieves the units used to express all flow rates|
|getGraph|Retrieves the graph of the current epanet network|
|getLibFunctions|Retrieves the functions of DLL|
Expand Down
16 changes: 15 additions & 1 deletion epanet_matlab_toolkit/epanet.m
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@

end
properties (Constant = true)
classversion='v2.2.3 - Last Update: 19/09/2022';
classversion='v2.2.3 - Last Update: 23/09/2022';

LOGOP={'IF', 'AND', 'OR'} % Constants for rule-based controls: 'IF', 'AND', 'OR' % EPANET Version 2.2
RULEOBJECT={'NODE', 'LINK', 'SYSTEM'}; % Constants for rule-based controls: 'NODE', 'LINK', 'SYSTEM' % EPANET Version 2.2
Expand Down Expand Up @@ -8635,6 +8635,20 @@ function setCurveValue(obj, index, curvePnt, value)
end
end
end
function A = getFlowDirections(obj)
% Compute the adjacency matrix (connectivity graph) considering the flows, at different time steps or the mean flow
Fmean = mean(obj.getComputedTimeSeries.Flow,1);
Fsign = sign(Fmean);
A = zeros(obj.getNodeCount);
Nidx = obj.getLinkNodesIndex;
for i = 1:size(Nidx,1)
if Fsign(i) == 1
A(Nidx(i,1),Nidx(i,2)) = 1;
else
A(Nidx(i,2),Nidx(i,1)) = 1;
end
end
end
function V = getLinkVolumes(obj)
% Get link volumes
% Link volume = pi * (diameter/2).^2 * length
Expand Down

0 comments on commit e9a4477

Please sign in to comment.