Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

*.asv
*.un~
*.md~
Binary file added develop_feature_pdd.inp/BJUT.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added develop_feature_pdd.inp/BUT.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added develop_feature_pdd.inp/CACE.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
674 changes: 674 additions & 0 deletions develop_feature_pdd.inp/LICENSE.md

Large diffs are not rendered by default.

Binary file added develop_feature_pdd.inp/ORCID.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions develop_feature_pdd.inp/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
![](./BJUT.jpg)

# A new feature for epanet.m
I would like to add Pressur-Driven-Demand (PDD) analysis to the epanet.m. The PDD analysis is necessary when the pressurs of nodes in the Water Distribution Network (WDN) are insufficient.

There are 3 types of approaches to solve the PDD analysis model, and the method proposed by Paez et al.(2018 b) is used in this project, which is tested in BPDRR (Paze et al.2018 a)

## Table of Contents

- [How to cite](#how-to-cite)
- [Requirements](#requirements)
- [How to install necessary compilers](#How-to-install-necessary-compilers)
- [How to use the Toolkit](#How-to-use-the-Toolkit)
- [How to fix/report bugs](#How-to-fixreport-bugs)
- [Licenses](#Licenses)
- [Contributors](#Contributors)
- [Acknwledgements](#Acknowledgements)
- [Reference](#Reference)

## Requirements

* [Matlab](http://www.mathworks.com/)
* [EPANET 2.1](https://github.com/OpenWaterAnalytics/epanet)


↑ [Back to top](#table-of-contents)

## How to use the Toolkit

↑ [Back to top](#table-of-contents)

## How to install necessary compilers

In order to use the EPANET-MATLAB-Toolkit the <b> MinGW-w64 compiler </b> must be installed: <p>
<a href="http://www.youtube.com/watch?feature=player_embedded&v=R_RABL3_6EY
" target="_blank"><img src="http://img.youtube.com/vi/R_RABL3_6EY/0.jpg"
alt="How to install MinGW-w64 compiler #Matlab" width="280" height="220" border="5" /></a>

In case you have a version of matlab older than 2015b install the <b> Windows SDK compiler</b>: <p>
<a href="http://www.youtube.com/watch?feature=player_embedded&v=hc3OkDypd24
" target="_blank"><img src="http://img.youtube.com/vi/hc3OkDypd24/0.jpg"
alt="How to install Windows SDK compiler compiler #Matlab" width="280" height="220" border="5" /></a>

&uparrow; [Back to top](#table-of-contents)

## How to fix/report bugs

To fix a bug `Fork` the `EPANET-Matlab Toolkit`, `Edit` the code and make the appropriate change, and then `Pull` it so that we evaluate it.

Keep in mind that some bugs may exist in the `EPANET` libraries, in case you are not receiving the expected results.

&uparrow; [Back to top](#table-of-contents)

## Liences
* `EPANET`: Public Domain
* `EPANET-MSX`: GNU Lesser General Public License
* `EPANET-Matlab Toolkit`: EUPL
* `EPANET_PDD-Matlab Toolkit`:GPL-3.0

&uparrow; [Back to top](#table-of-contents)

## Contributors
* Zhao Han, [College of Architechture and Civil Engineering, Beijing University of Technology](http://bjut.edu.cn/)

![ORCID-QR Code](./ORCID.png)

The 'EPANET_PDD-Matlab Toolkit' is based/inspired on the [EPANET-Matlab Toolkt](https://github.com/KIOS-Research/CCWI2016), [EPANET-Matlab Toolkit](http://www.mathworks.com/matlabcentral/fileexchange/25100-epanet-matlab-toolkit) as well as the OpenWaterAnalytics [EPANET-Matlab Wrappers](https://github.com/OpenWaterAnalytics/epanet-matlab)

&uparrow; [Back to top](#table-of-contents)

## Acknowledgements

&uparrow; [Back to top](#table-of-contents)

## Reference

- Paez, D., Fillion, Y., & Hulley, M. (2018,a). Battle of post-disaster response and restauration (BPDRR): problem description and rules. In 1st International Water Distribution System Analysis / Computing and Control in the Water Industry Joint Conference, Kingston, Canada, July 23-25, 2018.
- Paez, D., Suribabu, C. R., & Filion, Y. (2018,b). Method for extended period simulation of water distribution networks with pressure driven demands. Water resources management, 32(8), 2837-2846
- D.G. Eliades, M. Kyriakou, S. Vrachimis and M.M. Polycarpou, "EPANET-MATLAB Toolkit: An Open-Source Software for Interfacing EPANET with MATLAB", in Proc. 14th International Conference on Computing and Control for the Water Industry (CCWI), The Netherlands, Nov 2016, p.8. (doi:10.5281/zenodo.831493)

&uparrow; [Back to top](#table-of-contents)
## How to cite



&uparrow; [Back to top](#table-of-contents)
![](./BUT.jpg)
![](./CACE.jpg)
226 changes: 226 additions & 0 deletions develop_feature_pdd.inp/epanet_pdd.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
classdef epanet_pdd < handle
%epanet_pdd-Matlab Toolkit v1.0: A Matlab Class for EPANET, EPANET-MSX AND EPANET-Matlab Toolkit v2.1
%libraries
% Notes:
% 1. The defaults settings for flow Unit is LPS, so the Units in the
% inp file should be change to LPS.---2019-7-15
% 2. The extened period simulations feature is waiting to
% add.---2019-7-15
%
% How to run:
% d = epanet_pdd('net03.inp');
% d.createAllNodePDD('net03PDD.inp')
% d.delete;
%
% To set global service head
% d.ServiceHead = 20;(Unit:meter)
%
% To set global minimum head
% d.MinimumHead = 0;(Unit:meter)
%
% EPANET is software that models water distribution piping systems
% developed by the US EPA and provided under a public domain licence.
% This Matlab Class serves as an interface between Matlab and
% EPANET/EPANET-MSX, to assist researchers and the industry when
% solving problems related with water distribution systems.
%
% EPANET and EPANET-MSX were developed by the Water Supply and Water
% Resources Division of the U.S. Environmental Protection Agency's
% National Risk Management Research Laboratory. EPANET is under the
% Public Domain and EPANET-MSX under GNU LGPL.
%
% The latest EPANET files can downloaded at:
% https://github.com/OpenWaterAnalytics/epanet
%
% EPANET-Matlab Class was developed by KIOS Research Center for
% Intelligent Systems and Networks, University of Cyprus
% (www.kios.org.cy)
%
% The latest EPANET-Matlab Class files can downloaded at:
% https://github.com/KIOS-Research/CCWI2016
%
% Inspired by:
% EPANET-Matlab Wrappers (Jim Uber)
% EPANET-Matlab Toolkit (Demetrios Eliades)
% getwdsdata (Philip Jonkergouw)
% Paez, D., Suribabu, C. R., & Filion, Y. (2018). Method for extended
% period simulation of water distribution networks with pressure
% driven demands.Water resources management, 32(8), 2837-2846.
%
% epanet_pdd Licence:
%
% Copyright Zhao Han, College of Architecture and Civil Engineering,
% Beijing Universiy of Technology
%
%
% Licensed under the GPL, Version 3.0
% You may not use this work except in compliance with the Licence.
% You may obtain a copy of the Licence at:
%
% http://www.gnu.org/licenses/gpl-3.0.html
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the Licence is distributed on an "AS IS" basis,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
% implied. See the Licence for the specific language governing
% permissions and limitations under the Licence.
properties
Epanet
end
properties
ServiceHead = 20
MinimumHead = 0
G = 9.8;%GravitationalAcceleration
Diameter_large = 1000;%(mm)
Diameter_arbitrary = 150;%(mm)
Length_short = 0.01 ;% (m)
end
properties
NodesInfo
LinksInfo
end
properties
FCVs
TCVs
DummyNodeAs
DummyNodeBs
Reservoirs
end


methods
function obj = epanet_pdd(varargin)
%Constructor of the EPANET_PDD Class
% Costructor of the EPANET class
switch nargin
case 1
obj.Epanet = epanet(varargin{1});
% obj.Epanet = epanet(varargin{1},'BIN');
case 2
obj.Epanet = epanet(varargin{1},varargin{2});
case 3
obj.Epanet = epanet(varargin{1},varargin{2},varargin{3});
end
obj.getInfo
end
function delete(obj)
obj.Epanet.unload;
end
end
methods
function createAllNodePDD(obj,InpFile)
JunctionCount = obj.NodesInfo.BinNodeJunctionCount;
for i = 1:JunctionCount
obj.addPDDElements(i);
end
obj.saveInp(InpFile);
end
end
methods
function getInfo(obj)
obj.NodesInfo = obj.Epanet.getBinNodesInfo;
obj.LinksInfo = obj.Epanet.getBinLinksInfo;
end
function addPDDElements(obj,NodeIndex,NodeID)
% NodeID is the ID of user junction which is needed to add elements
% keyboard
switch nargin
case 1
% disp(['nargin=',num2str(nargin)])
return
case 2
NodeID = obj.NodesInfo.BinNodeJunctionNameID(NodeIndex);
% disp(NodeID)
% return
case 3
if isempty(NodeIndex)
NodeIndex = obj.Epanet.getBinNodeIndex(NodeID);% the index of the junction
else

end
end
NodeX = obj.NodesInfo.BinNodeCoordinates{1}(NodeIndex);
NodeY = obj.NodesInfo.BinNodeCoordinates{2}(NodeIndex);
NodeBaseDemand = obj.NodesInfo.BinNodeJunctionsBaseDemands(NodeIndex);
NodeElevation = obj.NodesInfo.BinNodeJunctionElevation(NodeIndex);
K_tcv = (obj.G*pi^2*obj.ServiceHead*obj.Diameter_arbitrary^4)*(10^-6)/(8*NodeBaseDemand^2);
% bug: only account for LPS unit and single period simulations
NodeID = char(NodeID);
% information for DummyNodeA
DummyNodeA.x = NodeX;
DummyNodeA.y = NodeY;
DummyNodeA.ID = ['A',NodeID];
DummyNodeA.Elevation = NodeElevation+obj.MinimumHead;
DummyNodeA.BaseDemand = 0;
% information for DummyNodeB
DummyNodeB.x = NodeX;
DummyNodeB.y = NodeY;
DummyNodeB.ID = ['B',NodeID];
DummyNodeB.Elevation = NodeElevation+obj.MinimumHead;
DummyNodeB.BaseDemand = 0;
% information for Reservoir
Reservoir.x = NodeX;
Reservoir.y = NodeY;
Reservoir.ID = ['R',NodeID];
Reservoir.Elevation = NodeElevation+obj.MinimumHead;
% information for FCV
FCV.Diameter = obj.Diameter_large;
FCV.fromNode = NodeID;
FCV.toNode = DummyNodeA.ID;
FCV.Setting = NodeBaseDemand;
FCV.ID = ['F',NodeID];
FCV.Code = 'FCV';
% information for TCV
TCV.Diameter = obj.Diameter_arbitrary;
TCV.Setting = K_tcv;
TCV.fromNode = DummyNodeA.ID;
TCV.toNode = DummyNodeB.ID;
TCV.ID = ['T',NodeID];
TCV.Code = 'TCV';

% information for CV--Pipe
CV.Diameter = obj.Diameter_large;
CV.Length = obj.Length_short;
CV.fromNode = DummyNodeB.ID;
CV.toNode = Reservoir.ID;
CV.ID = ['C',NodeID];
CV.Code = 'PIPE';

% add element
% add junction A
NodeA_index = obj.Epanet.addNodeJunction(DummyNodeA.ID);
obj.Epanet.setNodeElevations(NodeA_index,DummyNodeA.Elevation);
obj.Epanet.setNodeBaseDemands(NodeA_index,DummyNodeA.BaseDemand);
obj.Epanet.setNodeCoordinates(NodeA_index,[DummyNodeA.x,DummyNodeA.y]);
% add FCV
FCV_index = obj.Epanet.addLinkValveFCV(FCV.ID,FCV.fromNode,FCV.toNode);
obj.Epanet.setLinkDiameter(FCV_index,FCV.Diameter);
obj.Epanet.setLinkInitialSetting(FCV_index,FCV.Setting);
% add junction B
NodeB_index = obj.Epanet.addNodeJunction(DummyNodeB.ID);
obj.Epanet.setNodeElevations(NodeB_index,DummyNodeB.Elevation);
obj.Epanet.setNodeBaseDemands(NodeB_index,DummyNodeB.BaseDemand);
obj.Epanet.setNodeCoordinates(NodeB_index,[DummyNodeB.x,DummyNodeB.y]);
% add TCV
TCV_index = obj.Epanet.addLinkValveTCV(TCV.ID,TCV.fromNode,TCV.toNode);
obj.Epanet.setLinkDiameter(TCV_index,TCV.Diameter);
obj.Epanet.setLinkInitialSetting(TCV_index,TCV.Setting);
% add Reservoir
R_index = obj.Epanet.addNodeReservoir(Reservoir.ID);
obj.Epanet.setNodeCoordinates(R_index,[Reservoir.x,Reservoir.y]);
obj.Epanet.setNodeElevations(R_index,Reservoir.Elevation);
% add Pipe--CV
newRoughness = 100;
CV_index = obj.Epanet.addLinkPipeCV(CV.ID,CV.fromNode,CV.toNode);
obj.Epanet.setLinkDiameter(CV_index,CV.Diameter);
obj.Epanet.setLinkLength(CV_index,CV.Length);
obj.Epanet.setLinkRoughnessCoeff(CV_index,newRoughness);
% set Junction Base Demand 0
obj.Epanet.setNodeBaseDemands(NodeIndex,0);
end
function saveInp(obj,fileName)
obj.Epanet.saveInputFile(fileName);
end
end
end

Loading