Skip to content

Commit

Permalink
Adding Pipe Leakage Model
Browse files Browse the repository at this point in the history
  • Loading branch information
LRossman committed Jun 25, 2024
1 parent cc9105f commit f68fcbf
Show file tree
Hide file tree
Showing 22 changed files with 1,191 additions and 221 deletions.
11 changes: 10 additions & 1 deletion include/epanet2.bas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Attribute VB_Name = "Module1"
'Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
'(EPANET2.DLL)

'Last updated on 09/28/2023
'Last updated on 06/23/2024

' These are codes used by the DLL functions
Public Const EN_ELEVATION = 0 ' Node parameters
Expand Down Expand Up @@ -38,6 +38,9 @@ Public Const EN_CANOVERFLOW = 26
Public Const EN_DEMANDDEFICIT = 27
Public Const EN_NODE_INCONTROL = 28
Public Const EN_EMITTERFLOW = 29
Public Const EN_LEAKAGEFLOW = 30
Public Const EN_DEMANDFLOW = 31
Public Const EN_FULLDEMAND = 32

Public Const EN_DIAMETER = 0 ' Link parameters
Public Const EN_LENGTH = 1
Expand Down Expand Up @@ -65,6 +68,9 @@ Public Const EN_PUMP_EPAT = 22
Public Const EN_LINK_INCONTROL = 23
Public Const EN_GPV_CURVE = 24
Public Const EN_PCV_CURVE = 25
Public Const EN_LEAK_AREA = 26
Public Const EN_LEAK_EXPAN = 27
Public Const EN_LINK_LEAKAGE = 28

Public Const EN_DURATION = 0 ' Time parameters
Public Const EN_HYDSTEP = 1
Expand All @@ -90,6 +96,7 @@ Public Const EN_MAXFLOWCHANGE = 3
Public Const EN_MASSBALANCE = 4
Public Const EN_DEFICIENTNODES = 5
Public Const EN_DEMANDREDUCTION = 6
Public Const EN_LEAKAGELOSS = 7

Public Const EN_NODE = 0 ' Component types
Public Const EN_LINK = 1
Expand Down Expand Up @@ -350,6 +357,7 @@ Public Const EN_TRUE = 1 ' boolean true
Declare Function ENsettankdata Lib "epanet2.dll" (ByVal index As Long, ByVal elev As Single, ByVal initlvl As Single, ByVal minlvl As Single, ByVal maxlvl As Single, ByVal diam As Single, ByVal minvol As Single, ByVal volcurve As String) As Long
Declare Function ENgetcoord Lib "epanet2.dll" (ByVal index As Long, x As Double, y As Double) As Long
Declare Function ENsetcoord Lib "epanet2.dll" (ByVal index As Long, ByVal x As Double, ByVal y As Double) As Long
Declare Function ENgetnodevalues Lib "epanet2.dll" (ByVal property as Long, values as Any) As Long

'Nodal Demand Functions
Declare Function ENgetdemandmodel Lib "epanet2.dll" (type_ As Long, pmin As Single, preq As Single, pexp As Single) As Long
Expand Down Expand Up @@ -382,6 +390,7 @@ Public Const EN_TRUE = 1 ' boolean true
Declare Function ENgetvertex Lib "epanet2.dll" (ByVal index As Long, ByVal vertex As Long, x As Double, y As Double) As Long
Declare Function ENsetvertex Lib "epanet2.dll" (ByVal index As Long, ByVal vertex As Long, ByVal x As Double, ByVal y As Double) As Long
Declare Function ENsetvertices Lib "epanet2.dll" (ByVal index As Long, xCoords As Any, yCoords As Any, ByVal count As Long) As Long
Declare Function ENgetlinkvalues Lib "epanet2.dll" (ByVal property as Long, values as Any) As Long

'Pump Functions
Declare Function ENgetheadcurveindex Lib "epanet2.dll" (ByVal linkIndex As Long, curveIndex As Long) As Long
Expand Down
25 changes: 20 additions & 5 deletions include/epanet2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.InteropServices;

//epanet2.cs[By Oscar Vegas]
//Last updated on 09/28/2023
//Last updated on 06/23/2024

//Declarations of functions in the EPANET PROGRAMMERs TOOLKIT
//(EPANET2.DLL) for use with C#
Expand Down Expand Up @@ -50,6 +50,9 @@ public static class Epanet
public const int EN_DEMANDDEFICIT = 27;
public const int EN_NODE_INCONTROL = 28;
public const int EN_EMITTERFLOW = 29;
public const int EN_LEAKAGEFLOW = 30;
public const int EN_DEMANDFLOW = 31;
public const int EN_FULLDEMAND = 32;

public const int EN_DIAMETER = 0; //Link parameters
public const int EN_LENGTH = 1;
Expand Down Expand Up @@ -78,6 +81,9 @@ public static class Epanet
public const int EN_LINK_INCONTROL = 23;
public const int EN_GPV_CURVE = 24;
public const int EN_PCV_CURVE = 25;
public const int EN_LEAK_AREA = 26;
public const int EN_LEAK_EXPAN = 27;
public const int EN_LINK_LEAKAGE = 28;

public const int EN_DURATION = 0; //Time parameters
public const int EN_HYDSTEP = 1;
Expand All @@ -102,6 +108,7 @@ public static class Epanet
public const int EN_MASSBALANCE = 4;
public const int EN_DEFICIENTNODES = 5;
public const int EN_DEMANDREDUCTION = 6;
public const int EN_LEAKAGELOSS = 7;

public const int EN_NODE = 0; //Component types
public const int EN_LINK = 1;
Expand Down Expand Up @@ -390,6 +397,9 @@ public static class Epanet
[DllImport(EPANETDLL, EntryPoint = "ENgetresultindex")]
public static extern int ENgetresultindex(int type, int index, ref int value);

[DllImport(EPANETDLL, EntryPoint = "ENtimetonextevent")]
public static extern int ENtimetonextevent(ref int eventType, ref long duration, ref int elementIndex);


//Analysis Options Functions
[DllImport(EPANETDLL, EntryPoint = "ENgetoption")]
Expand Down Expand Up @@ -440,10 +450,10 @@ public static class Epanet
public static extern int ENgetnodetype(int index, ref int nodeType);

[DllImport(EPANETDLL, EntryPoint = "ENgetnodevalue")]
public static extern int ENgetnodevalue(int index, int paramcode, ref float value);
public static extern int ENgetnodevalue(int index, int param, ref float value);

[DllImport(EPANETDLL, EntryPoint = "ENsetnodevalue")]
public static extern int ENsetnodevalue(int index, int code, float value);
public static extern int ENsetnodevalue(int index, int param, float value);

[DllImport(EPANETDLL, EntryPoint = "ENsetjuncdata")]
public static extern int ENsetjuncdata(int index, float elev, float dmnd, string dmndpat);
Expand All @@ -457,6 +467,8 @@ public static class Epanet
[DllImport(EPANETDLL, EntryPoint = "ENsetcoord")]
public static extern int ENsetcoord(int index, double x, double y);

[DllImport(EPANETDLL, EntryPoint = "ENgetnodevalues")]
public static extern int ENgetnodevalues(int param, ref float values);

//Nodal Demand Functions
[DllImport(EPANETDLL, EntryPoint = "ENgetdemandmodel")]
Expand Down Expand Up @@ -525,10 +537,10 @@ public static class Epanet
public static extern int ENsetlinknodes(int index, int node1, int node2);

[DllImport(EPANETDLL, EntryPoint = "ENgetlinkvalue")]
public static extern int ENgetlinkvalue(int index, int code, ref float value);
public static extern int ENgetlinkvalue(int index, int param, ref float value);

[DllImport(EPANETDLL, EntryPoint = "ENsetlinkvalue")]
public static extern int ENsetlinkvalue(int index, int code, float value);
public static extern int ENsetlinkvalue(int index, int param, float value);

[DllImport(EPANETDLL, EntryPoint = "ENsetpipedata")]
public static extern int ENsetpipedata(int index, float length, float diam, float rough, float mloss);
Expand All @@ -542,6 +554,9 @@ public static class Epanet
[DllImport(EPANETDLL, EntryPoint = "ENsetvertices")]
public static extern int ENsetvertices(int index, ref double[] x, ref double[] y, int count);

[DllImport(EPANETDLL, EntryPoint = "ENgetlinkvalues")]
public static extern int ENgetlinkvalues(int param, ref float values);


//Pump Functions
[DllImport(EPANETDLL, EntryPoint = "ENgetheadcurveindex")]
Expand Down
17 changes: 9 additions & 8 deletions include/epanet2.def
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ EXPORTS
ENgetbasedemand = _ENgetbasedemand@12
ENgetcomment = _ENgetcomment@12
ENgetcontrol = _ENgetcontrol@24
ENgetcontrolenabled = _ENgetcontrolenabled@8
ENgetcoord = _ENgetcoord@12
ENgetcount = _ENgetcount@8
ENgetcurve = _ENgetcurve@20
Expand All @@ -44,13 +45,14 @@ EXPORTS
ENgetlinkid = _ENgetlinkid@8
ENgetlinkindex = _ENgetlinkindex@8
ENgetlinknodes = _ENgetlinknodes@12
ENsetlinknodes = _ENsetlinknodes@12
ENgetlinktype = _ENgetlinktype@8
ENgetlinkvalue = _ENgetlinkvalue@12
ENgetlinkvalues = _ENgetlinkvalues@8
ENgetnodeid = _ENgetnodeid@8
ENgetnodeindex = _ENgetnodeindex@8
ENgetnodetype = _ENgetnodetype@8
ENgetnodevalue = _ENgetnodevalue@12
ENgetnodevalue = _ENgetnodevalue@12
ENgetnodevalues = _ENgetnodevalues@8
ENgetnumdemands = _ENgetnumdemands@8
ENgetoption = _ENgetoption@8
ENgetpatternid = _ENgetpatternid@8
Expand All @@ -63,6 +65,7 @@ EXPORTS
ENgetqualtype = _ENgetqualtype@8
ENgetresultindex = _ENgetresultindex@12
ENgetrule = _ENgetrule@20
ENgetruleenabled = _ENgetruleenabled@8
ENgetruleID = _ENgetruleID@8
ENgetstatistic = _ENgetstatistic@8
ENgetthenaction = _ENgetthenaction@20
Expand All @@ -79,6 +82,7 @@ EXPORTS
ENopen = _ENopen@12
ENopenH = _ENopenH@0
ENopenQ = _ENopenQ@0
ENopenX = _ENopenX@12
ENreport = _ENreport@0
ENresetreport = _ENresetreport@0
ENrunH = _ENrunH@4
Expand All @@ -89,6 +93,7 @@ EXPORTS
ENsetbasedemand = _ENsetbasedemand@12
ENsetcomment = _ENsetcomment@12
ENsetcontrol = _ENsetcontrol@24
ENsetcontrolenabled = _ENsetcontrolenabled@8
ENsetcoord = _ENsetcoord@20
ENsetcurve = _ENsetcurve@16
ENsetcurveid = _ENsetcurveid@8
Expand Down Expand Up @@ -118,6 +123,7 @@ EXPORTS
ENsetpremisevalue = _ENsetpremisevalue@12
ENsetqualtype = _ENsetqualtype@16
ENsetreport = _ENsetreport@4
ENsetruleenabled = _ENsetruleenabled@8
ENsetrulepriority = _ENsetrulepriority@8
ENsetstatusreport = _ENsetstatusreport@4
ENsettankdata = _ENsettankdata@32
Expand All @@ -129,11 +135,6 @@ EXPORTS
ENsolveH = _ENsolveH@0
ENsolveQ = _ENsolveQ@0
ENstepQ = _ENstepQ@4
ENtimetonextevent = _ENtimetonextevent@12
ENusehydfile = _ENusehydfile@4
ENwriteline = _ENwriteline@4
ENtimetonextevent = _ENtimetonextevent@12
ENopenX = _ENopenX@12
ENgetcontrolenabled = _ENgetcontrolenabled@8
ENsetcontrolenabled = _ENsetcontrolenabled@8
ENgetruleenabled = _ENgetruleenabled@8
ENsetruleenabled = _ENsetruleenabled@8
Loading

0 comments on commit f68fcbf

Please sign in to comment.