+
+
+In case you have a version of matlab older than 2015b install the Windows SDK compiler:
+
+
+↑ [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.
+
+↑ [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
+
+↑ [Back to top](#table-of-contents)
+
+## Contributors
+* Zhao Han, [College of Architechture and Civil Engineering, Beijing University of Technology](http://bjut.edu.cn/)
+
+
+
+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)
+
+↑ [Back to top](#table-of-contents)
+
+## Acknowledgements
+
+↑ [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)
+
+↑ [Back to top](#table-of-contents)
+## How to cite
+
+
+
+↑ [Back to top](#table-of-contents)
+
+
\ No newline at end of file
diff --git a/develop_feature_pdd.inp/epanet_pdd.m b/develop_feature_pdd.inp/epanet_pdd.m
new file mode 100644
index 0000000..f157905
--- /dev/null
+++ b/develop_feature_pdd.inp/epanet_pdd.m
@@ -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
+
diff --git a/develop_feature_pdd.inp/net03.inp b/develop_feature_pdd.inp/net03.inp
new file mode 100644
index 0000000..d6ee47d
--- /dev/null
+++ b/develop_feature_pdd.inp/net03.inp
@@ -0,0 +1,155 @@
+[TITLE]
+
+
+[JUNCTIONS]
+;ID Elev Demand Pattern
+ 1 90 25 ;
+ 2 90 25 ;
+ 3 90 25 ;
+ 4 88 25 ;
+ 5 88 25 ;
+ 6 88 25 ;
+ 7 85 25 ;
+ 8 85 25 ;
+ 9 85 25 ;
+
+[RESERVOIRS]
+;ID Head Pattern
+ R10 100 ;
+ R11 98 ;
+
+[TANKS]
+;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve
+
+[PIPES]
+;ID Node1 Node2 Length Diameter Roughness MinorLoss Status
+ 1 R10 1 1000 300 130 0 Open ;
+ 2 R11 3 1000 300 130 0 Open ;
+ 3 1 2 1000 300 130 0 Open ;
+ 4 1 4 1000 300 130 0 Open ;
+ 5 2 3 1000 300 130 0 Open ;
+ 6 2 5 1000 300 130 0 Open ;
+ 7 3 6 1000 300 130 0 Open ;
+ 8 4 5 1000 250 130 0 Open ;
+ 9 4 7 1000 250 130 0 Open ;
+ 10 5 6 1000 250 130 0 Open ;
+ 11 5 8 1000 250 130 0 Open ;
+ 12 6 9 1000 250 130 0 Open ;
+ 13 7 8 1000 200 130 0 Open ;
+ 14 8 9 1000 200 130 0 Open ;
+
+[PUMPS]
+;ID Node1 Node2 Parameters
+
+[VALVES]
+;ID Node1 Node2 Diameter Type Setting MinorLoss
+
+[TAGS]
+
+[DEMANDS]
+;Junction Demand Pattern Category
+
+[STATUS]
+;ID Status/Setting
+
+[PATTERNS]
+;ID Multipliers
+
+[CURVES]
+;ID X-Value Y-Value
+
+[CONTROLS]
+
+[RULES]
+
+[ENERGY]
+ Global Efficiency 75
+ Global Price 0
+ Demand Charge 0
+
+[EMITTERS]
+;Junction Coefficient
+
+[QUALITY]
+;Node InitQual
+
+[SOURCES]
+;Node Type Quality Pattern
+
+[REACTIONS]
+;Type Pipe/Tank Coefficient
+
+
+[REACTIONS]
+ Order Bulk 1
+ Order Tank 1
+ Order Wall 1
+ Global Bulk 0
+ Global Wall 0
+ Limiting Potential 0
+ Roughness Correlation 0
+
+[MIXING]
+;Tank Model
+
+[TIMES]
+ Duration 0
+ Hydraulic Timestep 1:00
+ Quality Timestep 0:05
+ Pattern Timestep 1:00
+ Pattern Start 0:00
+ Report Timestep 1:00
+ Report Start 0:00
+ Start ClockTime 12 am
+ Statistic None
+
+[REPORT]
+ Status No
+ Summary No
+ Page 0
+
+[OPTIONS]
+ Units LPS
+ Headloss H-W
+ Specific Gravity 1
+ Viscosity 1
+ Trials 40
+ Accuracy 0.001
+ CHECKFREQ 2
+ MAXCHECK 10
+ DAMPLIMIT 0
+ Unbalanced Continue 10
+ Pattern 1
+ Demand Multiplier 1.0
+ Emitter Exponent 0.5
+ Quality None mg/L
+ Diffusivity 1
+ Tolerance 0.01
+
+[COORDINATES]
+;Node X-Coord Y-Coord
+ 1 4000 7000
+ 2 3000 7000
+ 3 2000 7000
+ 4 4000 6000
+ 5 3000 6000
+ 6 2000 6000
+ 7 4000 5000
+ 8 3000 5000
+ 9 2000 5000
+ R10 4000 8000
+ R11 2000 8000
+
+[VERTICES]
+;Link X-Coord Y-Coord
+
+[LABELS]
+;X-Coord Y-Coord Label & Anchor Node
+
+[BACKDROP]
+ DIMENSIONS 0.00 0.00 10000.00 10000.00
+ UNITS None
+ FILE
+ OFFSET 0.00 0.00
+
+[END]
diff --git a/develop_feature_pdd.inp/unitTest_for_epanet_pdd.m b/develop_feature_pdd.inp/unitTest_for_epanet_pdd.m
new file mode 100644
index 0000000..c38de88
--- /dev/null
+++ b/develop_feature_pdd.inp/unitTest_for_epanet_pdd.m
@@ -0,0 +1,37 @@
+classdef unitTest_for_epanet_pdd < matlab.unittest.TestCase
+ %unitTest_for_epanet_pdd: an Unit Test Class for Epanet_pdd-Matlab toolkit v1.0
+ % 此处显示详细说明
+ % How to run
+ % t = unitTest_for_epanet_pdd()
+ % t.run
+ properties
+ obj
+ end
+
+ methods(TestClassSetup)
+ function create_epanet_pdd(testCase)
+ testCase.obj = epanet_pdd('net03.inp');
+ end
+ end
+ methods(Test)
+ function test_lib(testCase)
+ test = libisloaded('epanet2');
+ testCase.verifyTrue(test);
+ end
+% function test_delete(testCase) % test pass
+% testCase.obj.delete
+% test = libisloaded('epanet2');
+% testCase.verifyFalse(test);
+% end
+ end
+ methods(TestClassTeardown)
+ function unload(testCase)
+ testCase.obj.delete
+ end
+ end
+ methods(TestMethodSetup)
+ end
+ methods(TestMethodTeardown)
+ end
+end
+