forked from OpenWaterAnalytics/epanet-matlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0165d06
commit 98953e0
Showing
114 changed files
with
6,318 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
|
||
# Doxygen output | ||
doxygen_out/ | ||
|
||
# Mac Stuff | ||
.DS_Store | ||
*.swp | ||
*~.nib | ||
*.build/ | ||
DerivedData/ | ||
Debug/ | ||
|
||
*.xcodeproj/ | ||
!*.xcodeproj/project.pbxproj | ||
|
||
*.mode1v3 | ||
*.mode2v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
EPANET-Toolkit Functions by Task | ||
For reference see: EPANET programmer's toolkit Windows help file. | ||
Report bugs, inconsistencies, or errors to Feng Shang or Jim Uber | ||
|
||
Initialization | ||
ENMatlabSetup - Opens the EPANET DLL library and sets global variables required by the Matlab Epanet Toolkit | ||
ENMatlabCleanup - Closes the EPANET DLL library | ||
|
||
Opening and closing the EPANET Toolkit system | ||
ENopen - Opens the Toolkit to analyze a particular distribution system. | ||
ENclose - Closes down the Toolkit system (including all files being processed). | ||
|
||
|
||
Retrieving information about network nodes | ||
ENgetnodeindex - Retrieves the index of a node with a specified ID. | ||
ENgetnodeid - Retrieves the ID label of a node with a specified index. | ||
ENgetnodetype - Retrieves the node-type code for a specific node. | ||
ENgetnodevalue - Retrieves the value of a specific link parameter. | ||
|
||
|
||
Retrieving information about network links | ||
ENgetlinkindex - Retrieves the ID label of a link with a specified index. | ||
ENgetlinkid - Retrieves the ID label of a link with a specified index. | ||
ENgetlinktype - Retrieves the link-type code for a specific link. | ||
ENgetlinknodes - Retrieves the indexes of the end nodes of a specified link. | ||
ENgetlinkvalue - Retrieves the value of a specific link parameter. | ||
|
||
|
||
Retrieving information about time patterns | ||
ENgetpatternid - Retrieves the ID label of a particular time pattern. | ||
ENgetpatternindex - Retrieves the index of a particular time pattern. | ||
ENgetpatternlen - Retrieves the number of time periods in a specific time pattern. | ||
ENgetpatternvalue - Retrieves the multiplier factor for a specific time period in a time pattern. | ||
|
||
|
||
Retrieving other network information | ||
ENgetcontrol - Retrieves the parameters of a simple control statement. | ||
The index of the control is specified in cindex and the remaining arguments return the control's | ||
parameters. | ||
ENgetqualtype - Retrieves the type of water quality analysis called for. | ||
ENgetoption - Retrieves the value of a particular analysis option. | ||
|
||
|
||
|
||
Setting new values for network parameters | ||
ENsetcontrol - Sets the parameters of a simple control statement. | ||
ENsetnodevalue - Sets the value of a parameter for a specific node. | ||
ENsetlinkvalue - Sets the value of a parameter for a specific link. | ||
ENaddpattern - Adds a new time pattern to the network. | ||
ENsetpattern - Sets all of the multiplier factors for a specific time pattern. | ||
ENsetpatternvalue - Sets the multiplier factor for a specific period within a time pattern. | ||
ENsetqualtype - Sets the type of water quality analysis called for. | ||
ENsettimeparam - Sets the value of a time parameter. | ||
ENsetoption - Sets the value of a particular analysis option. | ||
|
||
|
||
Saving and using hydraulic analysis results files | ||
ENsavehydfile - Saves the current contents of the binary hydraulics file to a file. | ||
ENusehydfile - Uses the contents of the specified file as the current binary hydraulics file. | ||
|
||
|
||
|
||
Running a hydraulic analysis | ||
ENsolveH - Runs a complete hydraulic simulation with results | ||
for all time periods written to the binary Hydraulics file. | ||
ENopenH - Opens the hydraulics analysis system. | ||
ENinitH - Initializes storage tank levels, link status and settings, and | ||
the simulation clock time prior to running a hydraulic analysis. | ||
ENrunH - Runs a single period hydraulic analysis, retrieving the current simulation clock time t. | ||
ENnextH - Determines the length of time until the next hydraulic event | ||
occurs in an extended period simulation. | ||
ENcloseH - Closes the hydraulic analysis system, freeing all allocated memory. | ||
|
||
|
||
Running a water quality analysis | ||
ENsolveQ - Runs a complete water quality simulation with results at uniform | ||
reporting intervals written to EPANET's binary Output file. | ||
ENopenQ - Opens the water quality analysis system. | ||
ENinitQ - Initializes water quality and the simulation clock time prior to | ||
running a water quality analysis. | ||
ENrunQ - Makes available the hydraulic and water quality results that | ||
occur at the start of the next time period of a water quality analysis, where the start of the | ||
period is returned in t. | ||
ENnextQ - Advances the water quality simulation to the start of the next hydraulic time period. | ||
ENstepQ - Advances the water quality simulation one water quality time step. | ||
The time remaining in the overall simulation is returned in tleft. | ||
ENcloseQ - Closes the water quality analysis system, freeing all allocated memory. | ||
|
||
|
||
Generating an output report | ||
ENsaveH - Transfers results of a hydraulic simulation from the binary | ||
Hydraulics file to the binary Output file, where results are only reported at uniform reporting | ||
intervals. | ||
ENsaveinpfile - Writes all current network input data to a file using the format of an EPANET input file. | ||
ENreport - Writes a formatted text report on simulation results to the Report file. | ||
ENresetreport - Clears any report formatting commands that either appeared in the | ||
[REPORT] section of the EPANET Input file or were issued with the ENsetreport function. | ||
ENsetreport - Issues a report formatting command. Formatting commands are the | ||
same as used in the [REPORT] section of the EPANET Input file. | ||
ENsetstatusreport - Sets the level of hydraulic status reporting. | ||
ENgeterror - Retrieves the text of the message associated with a particular error or warning code. | ||
ENwriteline - Writes a line of text to the EPANET report file. | ||
|
||
|
||
General functions | ||
ENerror - Prints out the error message string associated with error number errcode | ||
ENgetflowunits - Retrieves a code number indicating the units used to express all flow rates. | ||
ENgetcount - Retrieves the number of network components of a specified type. | ||
|
||
|
||
Matlab specific functions | ||
ENgetalllinknodes - Gets the node indices associated with all network links | ||
ENgetnetsize - Retreive number of network components | ||
ENgetversion - Retrieves the EPANET code version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function ENMatlabCleanup(DLLname) | ||
% Declaration: | ||
% ENMatlabCleanup(DLLname) | ||
% | ||
% Description: | ||
% Unloads EPANET DLL library | ||
% | ||
% Arguments: | ||
% DLLname Name of the Epanet DLL file (w/o the *.dll extension) | ||
% | ||
% | ||
% Globals: | ||
% | ||
% Notes: | ||
% ENMatlabCleanup must be called at the end of a toolkit application. | ||
% must be called when all processing has been completed, | ||
% even if an error condition was encountered. | ||
|
||
|
||
global ENDLLNAME; | ||
%errcode = 0; | ||
if nargin == 1 | ||
ENDLLNAME=DLLname; | ||
end; | ||
% Load library | ||
if libisloaded(ENDLLNAME) | ||
unloadlibrary(ENDLLNAME); | ||
else | ||
errstring =['Library ', ENDLLNAME, '.dll was not loaded']; | ||
disp(errstring); | ||
end; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
function [errcode] = ENMatlabSetup(DLLname,Hname) | ||
% Declaration: | ||
% [errcode] = ENMatlabSetup(DLLname,Hname) | ||
% | ||
% Description: | ||
% Opens the EPANET DLL library and sets global variables required by the | ||
% Matlab Epanet Toolkit | ||
% | ||
% EPANET Programmer's Toolkit Version: | ||
% This version is consistent with the API defined for EPANET v2.00.12. | ||
% If you are using another version of the EPANET programmer's toolkit DLL | ||
% and header file, an error will be issued. | ||
% | ||
% Arguments: | ||
% DLLname Name of the Epanet DLL file (w/o the *.dll extension) | ||
% Hname Name of the Epanet header file defining the exported symbols in | ||
% DLLname.dll (with the *.h extension). | ||
% | ||
% Returns: | ||
% Returns an error code (zero is normal termination). | ||
% | ||
% Globals: | ||
% EN_CONSTANT is a global structure containing all integer codes defined | ||
% for use of the Epanet programmer's toolkit (as defined in epanet2.h). | ||
% This structure can then be used for convenient access to these codes, | ||
% by declaring 'global EN_CONSTANT' in the code module. | ||
% | ||
% Notes: | ||
% ENMatlabSetup must be called before any of the other toolkit functions. | ||
|
||
global ENDLLNAME; | ||
global EN_CONSTANT; | ||
|
||
currentversion = 20012; | ||
%errcode = 0; | ||
|
||
% Load library | ||
ENDLLNAME=DLLname; | ||
ENHNAME=Hname; | ||
if ~libisloaded(ENDLLNAME) | ||
loadlibrary(ENDLLNAME,ENHNAME); | ||
end | ||
|
||
% Check version of EPANET DLL | ||
[errcode, version] = ENgetversion(); | ||
if version ~= currentversion | ||
errcode = 1; | ||
errstring = ['Current version ',num2str(version),' of EPANET is not supported. Update to version ',num2str(currentversion)]; | ||
disp(errstring); | ||
return | ||
end | ||
|
||
EN_CONSTANT = struct(... | ||
'EN_ELEVATION', int32(0),... % Node parameters | ||
'EN_BASEDEMAND', int32(1),... | ||
'EN_PATTERN', int32(2),... | ||
'EN_EMITTER', int32(3),... | ||
'EN_INITQUAL', int32(4),... | ||
'EN_SOURCEQUAL', int32(5),... | ||
'EN_SOURCEPAT', int32(6),... | ||
'EN_SOURCETYPE', int32(7),... | ||
'EN_TANKLEVEL', int32(8),... | ||
'EN_DEMAND', int32(9),... | ||
'EN_HEAD', int32(10),... | ||
'EN_PRESSURE', int32(11),... | ||
'EN_QUALITY', int32(12),... | ||
'EN_SOURCEMASS', int32(13),... | ||
'EN_INITVOLUME', int32(14),... | ||
'EN_MIXMODEL', int32(15),... | ||
'EN_MIXZONEVOL', int32(16),... | ||
'EN_TANKDIAM', int32(17),... | ||
'EN_MINVOLUME', int32(18),... | ||
'EN_VOLCURVE', int32(19),... | ||
'EN_MINLEVEL', int32(20),... | ||
'EN_MAXLEVEL', int32(21),... | ||
'EN_MIXFRACTION', int32(22),... | ||
'EN_TANK_KBULK', int32(23),... | ||
'EN_DIAMETER', int32(0),... % Link parameters | ||
'EN_LENGTH', int32(1),... | ||
'EN_ROUGHNESS', int32(2),... | ||
'EN_MINORLOSS', int32(3),... | ||
'EN_INITSTATUS', int32(4),... | ||
'EN_INITSETTING', int32(5),... | ||
'EN_KBULK', int32(6),... | ||
'EN_KWALL', int32(7),... | ||
'EN_FLOW', int32(8),... | ||
'EN_VELOCITY', int32(9),... | ||
'EN_HEADLOSS', int32(10),... | ||
'EN_STATUS', int32(11),... | ||
'EN_SETTING', int32(12),... | ||
'EN_ENERGY', int32(13),... | ||
'EN_DURATION', int32(0),... % Time parameters | ||
'EN_HYDSTEP', int32(1),... | ||
'EN_QUALSTEP', int32(2),... | ||
'EN_PATTERNSTEP', int32(3),... | ||
'EN_PATTERNSTART', int32(4),... | ||
'EN_REPORTSTEP', int32(5),... | ||
'EN_REPORTSTART', int32(6),... | ||
'EN_RULESTEP', int32(7),... | ||
'EN_STATISTIC', int32(8),... | ||
'EN_PERIODS', int32(9),... | ||
'EN_NODECOUNT', int32(0),... % Component counts | ||
'EN_TANKCOUNT', int32(1),... | ||
'EN_LINKCOUNT', int32(2),... | ||
'EN_PATCOUNT', int32(3),... | ||
'EN_CURVECOUNT', int32(4),... | ||
'EN_CONTROLCOUNT', int32(5),... | ||
'EN_JUNCTION', int32(0),... % Node types | ||
'EN_RESERVOIR', int32(1),... | ||
'EN_TANK', int32(2),... | ||
'EN_CVPIPE', int32(0),... % Link types | ||
'EN_PIPE', int32(1),... | ||
'EN_PUMP', int32(2),... | ||
'EN_PRV', int32(3),... | ||
'EN_PSV', int32(4),... | ||
'EN_PBV', int32(5),... | ||
'EN_FCV', int32(6),... | ||
'EN_TCV', int32(7),... | ||
'EN_GPV', int32(8),... | ||
'EN_NONE', int32(0),... % Quality analysis types | ||
'EN_CHEM', int32(1),... | ||
'EN_AGE', int32(2),... | ||
'EN_TRACE', int32(3),... | ||
'EN_CONCEN', int32(0),... % Source quality types | ||
'EN_MASS', int32(1),... | ||
'EN_SETPOINT', int32(2),... | ||
'EN_FLOWPACED', int32(3),... | ||
'EN_CFS', int32(0),... % Flow units types | ||
'EN_GPM', int32(1),... | ||
'EN_MGD', int32(2),... | ||
'EN_IMGD', int32(3),... | ||
'EN_AFD', int32(4),... | ||
'EN_LPS', int32(5),... | ||
'EN_LPM', int32(6),... | ||
'EN_MLD', int32(7),... | ||
'EN_CMH', int32(8),... | ||
'EN_CMD', int32(9),... | ||
'EN_TRIALS', int32(0),... % Misc. options | ||
'EN_ACCURACY', int32(1),... | ||
'EN_TOLERANCE', int32(2),... | ||
'EN_EMITEXPON', int32(3),... | ||
'EN_DEMANDMULT', int32(4),... | ||
'EN_LOWLEVEL', int32(0),... % Control types | ||
'EN_HILEVEL', int32(1),... | ||
'EN_TIMER', int32(2),... | ||
'EN_TIMEOFDAY', int32(3),... | ||
'EN_AVERAGE', int32(1),... % Time statistic types. | ||
'EN_MINIMUM', int32(2),... | ||
'EN_MAXIMUM', int32(3),... | ||
'EN_RANGE', int32(4),... | ||
'EN_MIX1', int32(0),... % Tank mixing models | ||
'EN_MIX2', int32(1),... | ||
'EN_FIFO', int32(2),... | ||
'EN_LIFO', int32(3),... | ||
'EN_NOSAVE', int32(0),... % Save-results-to-file flag | ||
'EN_SAVE', int32(1),... | ||
'EN_INITFLOW', int32(10)); % Re-initialize flow flag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function [errcode] = ENaddpattern(patid) | ||
% Declaration: | ||
% int ENaddpattern( char* id ) | ||
% Description: | ||
% Adds a new time pattern to the network. | ||
% Arguments: | ||
% id: | ||
% ID label of pattern | ||
% Returns: | ||
% Returns an error code. | ||
% Notes: | ||
% The ID label should contain no more than 31 characters. | ||
% The new pattern will contain a single time period whose multiplier factor is 1. | ||
% Use the ENsetpattern function to populate the pattern with a specific set of multipliers after first retrieving its index with the ENgetpatternindex function. | ||
% Example: | ||
% char patId[] = "NewPattern"; | ||
% float patFactors[] = {0.8, 1.1, 1.4, 1.1, 0.8, 0.7}; | ||
% int patIndex; | ||
% ENaddpattern(patId); | ||
% ENgetpatternindex(patId, patIndex); | ||
% ENsetpattern(patIndex, patFactors, 6); | ||
|
||
global ENDLLNAME; | ||
|
||
errcode=calllib(ENDLLNAME,'ENaddpattern',patid); | ||
if errcode ENerror(errcode); end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
function [errcode] = ENclose() | ||
% Declaration: | ||
% [errcode]=ENclose() | ||
% | ||
% Description: | ||
% Closes down the Toolkit system (including all files being processed). | ||
% | ||
% Returns: | ||
% Returns an error code. | ||
% | ||
% Notes: | ||
% ENclose must be called when all processing has been completed, | ||
% even if an error condition was encountered. | ||
% | ||
% See Also: | ||
% ENopen | ||
% | ||
global ENDLLNAME; | ||
|
||
|
||
[errcode]=calllib(ENDLLNAME,'ENclose'); | ||
if errcode ENerror(errcode); end | ||
|
Oops, something went wrong.