Skip to content

Commit 98953e0

Browse files
committed
first commit of files
1 parent 0165d06 commit 98953e0

File tree

114 files changed

+6318
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+6318
-1
lines changed

.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Compiled Object files
2+
*.slo
3+
*.lo
4+
*.o
5+
6+
# Compiled Dynamic libraries
7+
*.so
8+
9+
# Compiled Static libraries
10+
*.lai
11+
*.la
12+
*.a
13+
14+
# Doxygen output
15+
doxygen_out/
16+
17+
# Mac Stuff
18+
.DS_Store
19+
*.swp
20+
*~.nib
21+
*.build/
22+
DerivedData/
23+
Debug/
24+
25+
*.xcodeproj/
26+
!*.xcodeproj/project.pbxproj
27+
28+
*.mode1v3
29+
*.mode2v3

EPANET/Content.txt

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
EPANET-Toolkit Functions by Task
2+
For reference see: EPANET programmer's toolkit Windows help file.
3+
Report bugs, inconsistencies, or errors to Feng Shang or Jim Uber
4+
5+
Initialization
6+
ENMatlabSetup - Opens the EPANET DLL library and sets global variables required by the Matlab Epanet Toolkit
7+
ENMatlabCleanup - Closes the EPANET DLL library
8+
9+
Opening and closing the EPANET Toolkit system
10+
ENopen - Opens the Toolkit to analyze a particular distribution system.
11+
ENclose - Closes down the Toolkit system (including all files being processed).
12+
13+
14+
Retrieving information about network nodes
15+
ENgetnodeindex - Retrieves the index of a node with a specified ID.
16+
ENgetnodeid - Retrieves the ID label of a node with a specified index.
17+
ENgetnodetype - Retrieves the node-type code for a specific node.
18+
ENgetnodevalue - Retrieves the value of a specific link parameter.
19+
20+
21+
Retrieving information about network links
22+
ENgetlinkindex - Retrieves the ID label of a link with a specified index.
23+
ENgetlinkid - Retrieves the ID label of a link with a specified index.
24+
ENgetlinktype - Retrieves the link-type code for a specific link.
25+
ENgetlinknodes - Retrieves the indexes of the end nodes of a specified link.
26+
ENgetlinkvalue - Retrieves the value of a specific link parameter.
27+
28+
29+
Retrieving information about time patterns
30+
ENgetpatternid - Retrieves the ID label of a particular time pattern.
31+
ENgetpatternindex - Retrieves the index of a particular time pattern.
32+
ENgetpatternlen - Retrieves the number of time periods in a specific time pattern.
33+
ENgetpatternvalue - Retrieves the multiplier factor for a specific time period in a time pattern.
34+
35+
36+
Retrieving other network information
37+
ENgetcontrol - Retrieves the parameters of a simple control statement.
38+
The index of the control is specified in cindex and the remaining arguments return the control's
39+
parameters.
40+
ENgetqualtype - Retrieves the type of water quality analysis called for.
41+
ENgetoption - Retrieves the value of a particular analysis option.
42+
43+
44+
45+
Setting new values for network parameters
46+
ENsetcontrol - Sets the parameters of a simple control statement.
47+
ENsetnodevalue - Sets the value of a parameter for a specific node.
48+
ENsetlinkvalue - Sets the value of a parameter for a specific link.
49+
ENaddpattern - Adds a new time pattern to the network.
50+
ENsetpattern - Sets all of the multiplier factors for a specific time pattern.
51+
ENsetpatternvalue - Sets the multiplier factor for a specific period within a time pattern.
52+
ENsetqualtype - Sets the type of water quality analysis called for.
53+
ENsettimeparam - Sets the value of a time parameter.
54+
ENsetoption - Sets the value of a particular analysis option.
55+
56+
57+
Saving and using hydraulic analysis results files
58+
ENsavehydfile - Saves the current contents of the binary hydraulics file to a file.
59+
ENusehydfile - Uses the contents of the specified file as the current binary hydraulics file.
60+
61+
62+
63+
Running a hydraulic analysis
64+
ENsolveH - Runs a complete hydraulic simulation with results
65+
for all time periods written to the binary Hydraulics file.
66+
ENopenH - Opens the hydraulics analysis system.
67+
ENinitH - Initializes storage tank levels, link status and settings, and
68+
the simulation clock time prior to running a hydraulic analysis.
69+
ENrunH - Runs a single period hydraulic analysis, retrieving the current simulation clock time t.
70+
ENnextH - Determines the length of time until the next hydraulic event
71+
occurs in an extended period simulation.
72+
ENcloseH - Closes the hydraulic analysis system, freeing all allocated memory.
73+
74+
75+
Running a water quality analysis
76+
ENsolveQ - Runs a complete water quality simulation with results at uniform
77+
reporting intervals written to EPANET's binary Output file.
78+
ENopenQ - Opens the water quality analysis system.
79+
ENinitQ - Initializes water quality and the simulation clock time prior to
80+
running a water quality analysis.
81+
ENrunQ - Makes available the hydraulic and water quality results that
82+
occur at the start of the next time period of a water quality analysis, where the start of the
83+
period is returned in t.
84+
ENnextQ - Advances the water quality simulation to the start of the next hydraulic time period.
85+
ENstepQ - Advances the water quality simulation one water quality time step.
86+
The time remaining in the overall simulation is returned in tleft.
87+
ENcloseQ - Closes the water quality analysis system, freeing all allocated memory.
88+
89+
90+
Generating an output report
91+
ENsaveH - Transfers results of a hydraulic simulation from the binary
92+
Hydraulics file to the binary Output file, where results are only reported at uniform reporting
93+
intervals.
94+
ENsaveinpfile - Writes all current network input data to a file using the format of an EPANET input file.
95+
ENreport - Writes a formatted text report on simulation results to the Report file.
96+
ENresetreport - Clears any report formatting commands that either appeared in the
97+
[REPORT] section of the EPANET Input file or were issued with the ENsetreport function.
98+
ENsetreport - Issues a report formatting command. Formatting commands are the
99+
same as used in the [REPORT] section of the EPANET Input file.
100+
ENsetstatusreport - Sets the level of hydraulic status reporting.
101+
ENgeterror - Retrieves the text of the message associated with a particular error or warning code.
102+
ENwriteline - Writes a line of text to the EPANET report file.
103+
104+
105+
General functions
106+
ENerror - Prints out the error message string associated with error number errcode
107+
ENgetflowunits - Retrieves a code number indicating the units used to express all flow rates.
108+
ENgetcount - Retrieves the number of network components of a specified type.
109+
110+
111+
Matlab specific functions
112+
ENgetalllinknodes - Gets the node indices associated with all network links
113+
ENgetnetsize - Retreive number of network components
114+
ENgetversion - Retrieves the EPANET code version

EPANET/ENMatlabCleanup.m

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function ENMatlabCleanup(DLLname)
2+
% Declaration:
3+
% ENMatlabCleanup(DLLname)
4+
%
5+
% Description:
6+
% Unloads EPANET DLL library
7+
%
8+
% Arguments:
9+
% DLLname Name of the Epanet DLL file (w/o the *.dll extension)
10+
%
11+
%
12+
% Globals:
13+
%
14+
% Notes:
15+
% ENMatlabCleanup must be called at the end of a toolkit application.
16+
% must be called when all processing has been completed,
17+
% even if an error condition was encountered.
18+
19+
20+
global ENDLLNAME;
21+
%errcode = 0;
22+
if nargin == 1
23+
ENDLLNAME=DLLname;
24+
end;
25+
% Load library
26+
if libisloaded(ENDLLNAME)
27+
unloadlibrary(ENDLLNAME);
28+
else
29+
errstring =['Library ', ENDLLNAME, '.dll was not loaded'];
30+
disp(errstring);
31+
end;

EPANET/ENMatlabSetup.m

+157
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
function [errcode] = ENMatlabSetup(DLLname,Hname)
2+
% Declaration:
3+
% [errcode] = ENMatlabSetup(DLLname,Hname)
4+
%
5+
% Description:
6+
% Opens the EPANET DLL library and sets global variables required by the
7+
% Matlab Epanet Toolkit
8+
%
9+
% EPANET Programmer's Toolkit Version:
10+
% This version is consistent with the API defined for EPANET v2.00.12.
11+
% If you are using another version of the EPANET programmer's toolkit DLL
12+
% and header file, an error will be issued.
13+
%
14+
% Arguments:
15+
% DLLname Name of the Epanet DLL file (w/o the *.dll extension)
16+
% Hname Name of the Epanet header file defining the exported symbols in
17+
% DLLname.dll (with the *.h extension).
18+
%
19+
% Returns:
20+
% Returns an error code (zero is normal termination).
21+
%
22+
% Globals:
23+
% EN_CONSTANT is a global structure containing all integer codes defined
24+
% for use of the Epanet programmer's toolkit (as defined in epanet2.h).
25+
% This structure can then be used for convenient access to these codes,
26+
% by declaring 'global EN_CONSTANT' in the code module.
27+
%
28+
% Notes:
29+
% ENMatlabSetup must be called before any of the other toolkit functions.
30+
31+
global ENDLLNAME;
32+
global EN_CONSTANT;
33+
34+
currentversion = 20012;
35+
%errcode = 0;
36+
37+
% Load library
38+
ENDLLNAME=DLLname;
39+
ENHNAME=Hname;
40+
if ~libisloaded(ENDLLNAME)
41+
loadlibrary(ENDLLNAME,ENHNAME);
42+
end
43+
44+
% Check version of EPANET DLL
45+
[errcode, version] = ENgetversion();
46+
if version ~= currentversion
47+
errcode = 1;
48+
errstring = ['Current version ',num2str(version),' of EPANET is not supported. Update to version ',num2str(currentversion)];
49+
disp(errstring);
50+
return
51+
end
52+
53+
EN_CONSTANT = struct(...
54+
'EN_ELEVATION', int32(0),... % Node parameters
55+
'EN_BASEDEMAND', int32(1),...
56+
'EN_PATTERN', int32(2),...
57+
'EN_EMITTER', int32(3),...
58+
'EN_INITQUAL', int32(4),...
59+
'EN_SOURCEQUAL', int32(5),...
60+
'EN_SOURCEPAT', int32(6),...
61+
'EN_SOURCETYPE', int32(7),...
62+
'EN_TANKLEVEL', int32(8),...
63+
'EN_DEMAND', int32(9),...
64+
'EN_HEAD', int32(10),...
65+
'EN_PRESSURE', int32(11),...
66+
'EN_QUALITY', int32(12),...
67+
'EN_SOURCEMASS', int32(13),...
68+
'EN_INITVOLUME', int32(14),...
69+
'EN_MIXMODEL', int32(15),...
70+
'EN_MIXZONEVOL', int32(16),...
71+
'EN_TANKDIAM', int32(17),...
72+
'EN_MINVOLUME', int32(18),...
73+
'EN_VOLCURVE', int32(19),...
74+
'EN_MINLEVEL', int32(20),...
75+
'EN_MAXLEVEL', int32(21),...
76+
'EN_MIXFRACTION', int32(22),...
77+
'EN_TANK_KBULK', int32(23),...
78+
'EN_DIAMETER', int32(0),... % Link parameters
79+
'EN_LENGTH', int32(1),...
80+
'EN_ROUGHNESS', int32(2),...
81+
'EN_MINORLOSS', int32(3),...
82+
'EN_INITSTATUS', int32(4),...
83+
'EN_INITSETTING', int32(5),...
84+
'EN_KBULK', int32(6),...
85+
'EN_KWALL', int32(7),...
86+
'EN_FLOW', int32(8),...
87+
'EN_VELOCITY', int32(9),...
88+
'EN_HEADLOSS', int32(10),...
89+
'EN_STATUS', int32(11),...
90+
'EN_SETTING', int32(12),...
91+
'EN_ENERGY', int32(13),...
92+
'EN_DURATION', int32(0),... % Time parameters
93+
'EN_HYDSTEP', int32(1),...
94+
'EN_QUALSTEP', int32(2),...
95+
'EN_PATTERNSTEP', int32(3),...
96+
'EN_PATTERNSTART', int32(4),...
97+
'EN_REPORTSTEP', int32(5),...
98+
'EN_REPORTSTART', int32(6),...
99+
'EN_RULESTEP', int32(7),...
100+
'EN_STATISTIC', int32(8),...
101+
'EN_PERIODS', int32(9),...
102+
'EN_NODECOUNT', int32(0),... % Component counts
103+
'EN_TANKCOUNT', int32(1),...
104+
'EN_LINKCOUNT', int32(2),...
105+
'EN_PATCOUNT', int32(3),...
106+
'EN_CURVECOUNT', int32(4),...
107+
'EN_CONTROLCOUNT', int32(5),...
108+
'EN_JUNCTION', int32(0),... % Node types
109+
'EN_RESERVOIR', int32(1),...
110+
'EN_TANK', int32(2),...
111+
'EN_CVPIPE', int32(0),... % Link types
112+
'EN_PIPE', int32(1),...
113+
'EN_PUMP', int32(2),...
114+
'EN_PRV', int32(3),...
115+
'EN_PSV', int32(4),...
116+
'EN_PBV', int32(5),...
117+
'EN_FCV', int32(6),...
118+
'EN_TCV', int32(7),...
119+
'EN_GPV', int32(8),...
120+
'EN_NONE', int32(0),... % Quality analysis types
121+
'EN_CHEM', int32(1),...
122+
'EN_AGE', int32(2),...
123+
'EN_TRACE', int32(3),...
124+
'EN_CONCEN', int32(0),... % Source quality types
125+
'EN_MASS', int32(1),...
126+
'EN_SETPOINT', int32(2),...
127+
'EN_FLOWPACED', int32(3),...
128+
'EN_CFS', int32(0),... % Flow units types
129+
'EN_GPM', int32(1),...
130+
'EN_MGD', int32(2),...
131+
'EN_IMGD', int32(3),...
132+
'EN_AFD', int32(4),...
133+
'EN_LPS', int32(5),...
134+
'EN_LPM', int32(6),...
135+
'EN_MLD', int32(7),...
136+
'EN_CMH', int32(8),...
137+
'EN_CMD', int32(9),...
138+
'EN_TRIALS', int32(0),... % Misc. options
139+
'EN_ACCURACY', int32(1),...
140+
'EN_TOLERANCE', int32(2),...
141+
'EN_EMITEXPON', int32(3),...
142+
'EN_DEMANDMULT', int32(4),...
143+
'EN_LOWLEVEL', int32(0),... % Control types
144+
'EN_HILEVEL', int32(1),...
145+
'EN_TIMER', int32(2),...
146+
'EN_TIMEOFDAY', int32(3),...
147+
'EN_AVERAGE', int32(1),... % Time statistic types.
148+
'EN_MINIMUM', int32(2),...
149+
'EN_MAXIMUM', int32(3),...
150+
'EN_RANGE', int32(4),...
151+
'EN_MIX1', int32(0),... % Tank mixing models
152+
'EN_MIX2', int32(1),...
153+
'EN_FIFO', int32(2),...
154+
'EN_LIFO', int32(3),...
155+
'EN_NOSAVE', int32(0),... % Save-results-to-file flag
156+
'EN_SAVE', int32(1),...
157+
'EN_INITFLOW', int32(10)); % Re-initialize flow flag

EPANET/ENaddpattern.m

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function [errcode] = ENaddpattern(patid)
2+
% Declaration:
3+
% int ENaddpattern( char* id )
4+
% Description:
5+
% Adds a new time pattern to the network.
6+
% Arguments:
7+
% id:
8+
% ID label of pattern
9+
% Returns:
10+
% Returns an error code.
11+
% Notes:
12+
% The ID label should contain no more than 31 characters.
13+
% The new pattern will contain a single time period whose multiplier factor is 1.
14+
% Use the ENsetpattern function to populate the pattern with a specific set of multipliers after first retrieving its index with the ENgetpatternindex function.
15+
% Example:
16+
% char patId[] = "NewPattern";
17+
% float patFactors[] = {0.8, 1.1, 1.4, 1.1, 0.8, 0.7};
18+
% int patIndex;
19+
% ENaddpattern(patId);
20+
% ENgetpatternindex(patId, patIndex);
21+
% ENsetpattern(patIndex, patFactors, 6);
22+
23+
global ENDLLNAME;
24+
25+
errcode=calllib(ENDLLNAME,'ENaddpattern',patid);
26+
if errcode ENerror(errcode); end

EPANET/ENclose.m

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function [errcode] = ENclose()
2+
% Declaration:
3+
% [errcode]=ENclose()
4+
%
5+
% Description:
6+
% Closes down the Toolkit system (including all files being processed).
7+
%
8+
% Returns:
9+
% Returns an error code.
10+
%
11+
% Notes:
12+
% ENclose must be called when all processing has been completed,
13+
% even if an error condition was encountered.
14+
%
15+
% See Also:
16+
% ENopen
17+
%
18+
global ENDLLNAME;
19+
20+
21+
[errcode]=calllib(ENDLLNAME,'ENclose');
22+
if errcode ENerror(errcode); end
23+

0 commit comments

Comments
 (0)