Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epanet2.3 new updates #62

Open
wants to merge 148 commits into
base: dev2.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
40982c7
2.3 library update
ichrys03 Aug 8, 2024
cd6f469
Update 2.3 EN_setcurvetype (api)
ichrys03 Aug 8, 2024
5191749
update 2.3 def EN_setvertex api
ichrys03 Aug 8, 2024
a238034
update 2.3 EN_timetonextevent api
ichrys03 Aug 8, 2024
2890262
2.3 EN_getcontrolenabled api
ichrys03 Aug 8, 2024
9140058
2.3 EN_setcontrolenabled api
ichrys03 Aug 8, 2024
b469b2c
2.3 EN_getruleenabled api
ichrys03 Aug 8, 2024
203bd4e
2.3 EN_setruleenabled api
ichrys03 Aug 8, 2024
36ee4d8
2.3 EN_openX api
ichrys03 Aug 8, 2024
0b68449
2.3 EN_getlinksvalues api
ichrys03 Aug 8, 2024
e56468c
2.3 EN_loadpatternfile api
ichrys03 Aug 8, 2024
838847e
setCurvetype()
ichrys03 Aug 8, 2024
2908856
2.3 setvertex()
ichrys03 Aug 8, 2024
9bf105e
2.3 timetonexteven
ichrys03 Aug 8, 2024
e240a89
2.3 getcontrolenabled()
ichrys03 Aug 8, 2024
bb6e63c
2.3 setcontrolenabled()
ichrys03 Aug 8, 2024
2845ae6
2.3 getruleenabled()
ichrys03 Aug 8, 2024
d8bb7c4
2.3 setruleenabled()
ichrys03 Aug 8, 2024
a3bb023
2.3 openX()
ichrys03 Aug 9, 2024
7c7abb9
2.3 loadpatternfile()
ichrys03 Aug 9, 2024
1201e3a
2.3 getlinksvalues()
ichrys03 Aug 9, 2024
f7d95ca
function getlinkvalues() from update 2.3 tested
ichrys03 Aug 23, 2024
50a7d0f
setCurveType tested, now with comments + getLinkValues
ichrys03 Aug 26, 2024
4eed1f7
minor fix with setCurveType now shows errorcode + setVertex() now has…
ichrys03 Aug 26, 2024
41c3c56
Update epanet.py
ichrys03 Aug 26, 2024
3a992d5
minor fix
ichrys03 Aug 26, 2024
925c157
getControlEnabled() + setControlEnabled()
ichrys03 Aug 26, 2024
b91cb84
getRuleEnabled() + setRuleEnabled()
ichrys03 Aug 26, 2024
9c3f978
loadPatternfile()
ichrys03 Aug 26, 2024
2edaa97
openX()
ichrys03 Aug 26, 2024
a0f089a
error message added
ichrys03 Aug 26, 2024
2553102
Unit test update 2.3 setcurvetype()
ichrys03 Aug 28, 2024
0ed2780
Unit test update 2.3 set/get control enabled
ichrys03 Aug 28, 2024
0573879
unitest for getlinkvalues
ichrys03 Aug 28, 2024
f6fc1d2
major fix
ichrys03 Aug 29, 2024
3fd0919
typepump index 3 added 2.3 update
ichrys03 Sep 3, 2024
c35e368
Underscore typo functions 2.3
ichrys03 Sep 3, 2024
5a37717
setControlEnabled() function splitted into 2 functions setControlEnab…
ichrys03 Sep 3, 2024
90be47c
typo fix getControlRulesCount() -> getControlCount
ichrys03 Sep 3, 2024
839ef00
typo fixed with warning to users that already have been using the fun…
ichrys03 Sep 3, 2024
8807f93
getControlEnabled() now works without arguments to get all items upda…
ichrys03 Sep 3, 2024
cb0722b
getRulesEnabled() now works without arguments to get all items update…
ichrys03 Sep 3, 2024
a8b1755
getControlEnabled() renamed to getControlState() for users
ichrys03 Sep 7, 2024
801455f
setcontroldisabled and set ruleenabled removed , back with setcontrol…
ichrys03 Sep 7, 2024
3a3767e
new param added update 2.3 to create setStartTime()
ichrys03 Sep 10, 2024
76265d8
4 new option constants added for update 2.3
ichrys03 Sep 10, 2024
6219e51
setPressureUnit() for options (function) added. update 2.3
ichrys03 Sep 10, 2024
927b36b
getPressureUnit() function added update 2.3
ichrys03 Sep 10, 2024
02de18f
new constants for nodes update 2.3
ichrys03 Sep 10, 2024
1570813
get statusreport/nodeemitterflow() added update 2.3
ichrys03 Sep 10, 2024
c25114f
new constants added update 2.3
ichrys03 Sep 10, 2024
454a847
new link constants parameters added for update 2.3
ichrys03 Sep 10, 2024
6b2b790
set/get for GPVCurver and PVCCurve
ichrys03 Sep 10, 2024
be076b3
get/set DefaultTimePat update 2.3
ichrys03 Sep 10, 2024
6422925
Curve constants added 2.3 update
ichrys03 Sep 10, 2024
f405285
typepump comment
ichrys03 Sep 10, 2024
3afab22
Constant added update 2.3
ichrys03 Sep 10, 2024
8c1dee0
get/set LinkLeakArea & LinkExpansionProp
ichrys03 Sep 10, 2024
76fe5cf
getLinkLeakageRate() added 2.3 update
ichrys03 Sep 10, 2024
962b960
getNodeLeageDemand & getTotalLeageLoss added, update 2.3
ichrys03 Sep 10, 2024
68980d3
new functions from update 2.3
ichrys03 Sep 10, 2024
8414557
setCurveType() -> split into 5 types setCurveTypeVolume(),setCurveTyp…
ichrys03 Sep 12, 2024
0ecad3b
The method set /get GPVCurve has been renamed to set/get LinkValveCur…
ichrys03 Sep 12, 2024
8932fb6
+
ichrys03 Sep 12, 2024
1dfdce4
set/get timestarttime has been renamed to set/get TimeClockStartTime(…
ichrys03 Sep 12, 2024
aa6a3c1
Performance Example for new function getLinkValues() update 2.3
ichrys03 Sep 12, 2024
13d44bb
getPatternAverageDefaultValue() update 2.3 function
ichrys03 Sep 12, 2024
f999c99
set/get OptionsDemandPattern() update 2.3 update
ichrys03 Sep 12, 2024
a6cd366
Warning message if the network is not fully connected update 2.3 (now…
ichrys03 Sep 12, 2024
589facd
2 functions added update 2.3 (addLinkValvePCV + setLinkTypeValvePCV)
ichrys03 Sep 13, 2024
ce87433
new functions added set/get OptionsEmitterBackFlow() update 2.3
ichrys03 Sep 13, 2024
25673aa
Refactor : from ENgetLinkValues(code) - > __getLinkInfo(code,*argv)
ichrys03 Sep 13, 2024
fff4cec
update 2.3 EN_timetonextevent function fixed
ichrys03 Sep 13, 2024
dcca1e9
ENgettimetonextevent ->{getTimetoNextEventIndex, getTimeDurationtoNex…
ichrys03 Sep 17, 2024
43aa8bc
getoNodeEmitterFlow now accepts *argv as input
ichrys03 Sep 26, 2024
3f1bab8
getTimeToNextEvent function update 2.3
ichrys03 Sep 26, 2024
78bed9e
setoptionsemmiterbackflowAllowed and dissalowed update 2.3
ichrys03 Sep 26, 2024
0ed429b
new constants update 2.3
ichrys03 Sep 26, 2024
c2347ec
setOptionsStatusReport slit to 3 functions -> setOptionsStatusReportN…
ichrys03 Sep 26, 2024
9aa6c00
new constants update 2.3 for pressure unit type
ichrys03 Sep 26, 2024
56c8d79
setOptionsPressureUnits split to -> setOptionsPressureUnitsMeters, se…
ichrys03 Sep 26, 2024
e77f428
ENsetOption for status report now is called with constants from toolkit.
ichrys03 Sep 26, 2024
62d455f
getpressureunit to getOptionspressureunits()
ichrys03 Sep 26, 2024
8894a23
setOptionsCurveType now uses toolkitconstants
ichrys03 Sep 26, 2024
eb76cf8
new function setCurveTypeValveCurve() update 2.3
ichrys03 Sep 26, 2024
8826cd8
getOptionsPressureUnits() now returns string instead of integer
ichrys03 Sep 26, 2024
69153b3
new constants for demand driven analysis and pressure driven analysis
ichrys03 Sep 26, 2024
fe15d38
getNodeInControl / getLinkInControl new functions update 2.3
ichrys03 Sep 26, 2024
65bb907
getNodeLeakageDemand() typo fix
ichrys03 Sep 26, 2024
c212438
fix for new functions missing argument update 2.3
ichrys03 Sep 26, 2024
3dfd1db
typo link instead of node
ichrys03 Sep 28, 2024
358dd1b
removed duplicate functions
ichrys03 Oct 3, 2024
6620563
fixed for getnodeincontrol and getlinkincontrol where the output was …
ichrys03 Oct 3, 2024
194c044
getNodeInControl() and getLinkInControl() can be called by 4 differen…
ichrys03 Oct 3, 2024
7ee7cd1
Revert "getNodeInControl() and getLinkInControl() can be called by 4 …
ichrys03 Oct 3, 2024
8afb873
Revert "getNodeInControl() and getLinkInControl() can be called by 4 …
ichrys03 Oct 3, 2024
f1b8d4d
update 2.3 setFLowUnitsCMS() new function
ichrys03 Oct 3, 2024
96c8b09
getStatistic got another property .TotalLeakageLoss update 2.3
ichrys03 Oct 3, 2024
7f3a6e6
getstatistic splitted into 5 new functions
ichrys03 Oct 3, 2024
ab8ae46
after every function is called there is a check for errors. if an err…
ichrys03 Oct 3, 2024
1de5053
fix with program starting with errors
ichrys03 Oct 4, 2024
4577fa6
smooth error messages for users 1 line instead of 2-3 lines for each …
ichrys03 Oct 4, 2024
d65b822
Changed variables for easier understanding(item - > function_id) and …
ichrys03 Oct 4, 2024
ec5c73a
Updated comments for the family of functions using setFlowUnits.
ichrys03 Oct 4, 2024
135b8f8
Function that checks the current flow units and returns whether it's …
ichrys03 Oct 4, 2024
681bb9d
Function that checks if the change of metric is possible; if not, it …
ichrys03 Oct 4, 2024
dcc1ca2
Comments for set of functions -> setOptionsPressureUnits
ichrys03 Oct 4, 2024
f60aec4
comments for set of functions -> setOptionsStatusReport
ichrys03 Oct 4, 2024
5d8e22f
Comments for get/set LinkLeakArea
ichrys03 Oct 4, 2024
450b9f0
comments for get/set LinkExpansionProperties()
ichrys03 Oct 4, 2024
d8d4dcd
removed duplicate function getConsumerDemandDeficit -> getNodeDemandD…
ichrys03 Oct 4, 2024
a46d2e3
Comments for non user functions
ichrys03 Oct 4, 2024
c8157e9
Coments for getLinkInControl & getNodeInControl
ichrys03 Oct 4, 2024
2fa0984
fix on setVertex() from float to double and updated example
ichrys03 Oct 4, 2024
44c97a8
comments for set/get LinkValveCurveGPV/PCV
ichrys03 Oct 4, 2024
9759846
comments getTimeofNextEvent
ichrys03 Oct 4, 2024
565d3b6
comments for statistics functions
ichrys03 Oct 4, 2024
b312400
comments
ichrys03 Oct 4, 2024
f351184
updated readme and comments
ichrys03 Oct 6, 2024
2c46f6c
updated readme + comments + private functions
ichrys03 Oct 7, 2024
8cace5a
typo in readme
ichrys03 Oct 7, 2024
87b0576
private function
ichrys03 Oct 7, 2024
22ca820
Users will now be able to see the line of error in their code, along …
ichrys03 Oct 8, 2024
acf80da
fix :memory violation error with changeMSXOptions
ichrys03 Oct 8, 2024
e7bd168
typofix
ichrys03 Oct 8, 2024
e061497
Update epanet.py
ichrys03 Oct 8, 2024
ec38a6c
fix in genral unit test
ichrys03 Oct 8, 2024
73d1a41
unit_test update 2.3
ichrys03 Oct 8, 2024
2bcde51
unit test and example for new functions update 2.3
ichrys03 Oct 8, 2024
de3070c
library for linux update 2.3
ichrys03 Oct 8, 2024
8d361ff
test1
ichrys03 Oct 8, 2024
365f219
Update general_unit_test.py
ichrys03 Oct 8, 2024
d1602eb
mac libraries
ichrys03 Oct 9, 2024
7056b72
mac_libaries update
ichrys03 Oct 9, 2024
85c07e5
mac libraries
ichrys03 Oct 9, 2024
1a43916
Update epanet.py
ichrys03 Oct 9, 2024
8294396
maclibs
ichrys03 Oct 9, 2024
5d7b4c5
mac libs
ichrys03 Oct 9, 2024
6314958
Update epanetmsx.dylib
ichrys03 Oct 9, 2024
0a90a7d
Update general_unit_test.py
ichrys03 Oct 15, 2024
81f3cd0
Update epanet.py
ichrys03 Oct 15, 2024
07b98db
Revert "Update epanet.py"
ichrys03 Oct 15, 2024
7764345
Revert "Update general_unit_test.py"
ichrys03 Oct 15, 2024
f0d7115
general unit test fix?
ichrys03 Oct 22, 2024
267f49d
unit_test leakage from epanet 2.3 update + some set functions now ret…
ichrys03 Oct 22, 2024
0e9b9fb
test unit leakage with EN functions
ichrys03 Oct 24, 2024
83f2dc6
revert changes
ichrys03 Oct 24, 2024
e4cd12f
Users can now include an id column which contains the node or link ID…
ichrys03 Nov 12, 2024
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
1,324 changes: 721 additions & 603 deletions README.md

Large diffs are not rendered by default.

1,921 changes: 1,797 additions & 124 deletions epyt/epanet.py

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions epyt/examples/python/EX_NewFunctions_2_3_EPANET.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
from epyt import epanet

# inpfile = "Richmond_standard.inp"

# #Warning that a link is missing and the network is not fully connected
# inpfile = "BrokenNetwork.inp"
# d = epanet(inpfile)
# d.unload()

inpfile = "Net1.inp"
d = epanet(inpfile)

# d.getNodeNameID('dakjsdfhjksdfhsd')
# setcurvetype functions
d.setCurveTypePump(1)
d.printv(d.getCurveType(1))
d.setCurveTypeVolume(1)
d.printv(d.getCurveType())
d.setCurveTypeGeneral(1)
d.printv(d.getCurveType())
d.setCurveTypeHeadloss(1)
d.printv(d.getCurveType())
d.setCurveTypeEfficiency(1)
d.printv(d.getCurveType())
d.setCurveTypeValveCurve(1)
d.printv(d.getCurveType())

# Setvertex
linkID = '10'
x = [22, 24, 28]
y = [30, 68, 69]
d.setLinkVertices(linkID, x, y)
x = d.getLinkVertices()
d.setVertex(1, 1, 1, 1)
d.printv(d.getLinkVertices())

# set and get linkvalvecurvegpv
linkid = d.getLinkPipeNameID(1)
condition = 1
index = d.setLinkTypeValveGPV(linkid, condition)
d.setLinkValveCurveGPV(index, 1)
d.printv(d.getLinkValveCurveGPV())

# set and get linkvalvecurvepcv
linkid = d.getLinkPipeNameID(1)
condition = 1
index = d.setLinkTypeValvePCV(linkid, condition)
d.setLinkValveCurvePCV(index, 1)
d.printv(d.getLinkValveCurvePCV(index))

# setTimeClockStartTime & getTimeClockStartTime
d.printv(d.getTimeClockStartTime())
d.setTimeClockStartTime(3600)
d.printv(d.getTimeClockStartTime())

# getOptionsDemandPattern())
d.printv(d.getOptionsDemandPattern())
d.setOptionsDemandPattern(0)
d.printv(d.getOptionsDemandPattern())

# getLinkType / d.setLinkTypeValvePCV / d.addLinkValvePCV
d.getLinkType(1) # Retrieves the type of the 1st link
linkid = d.getLinkPipeNameID(1) # Retrieves the ID of the 1t pipe
index = d.setLinkTypeValvePCV(linkid) # Changes the 1st pipe to valve PCV given it's ID
print(d.getLinkType(index))

# addLinkValvePCV
# d.plot()
valveID = 'newValvePCV'
fromNode = '10'
toNode = '21'
valveIndex = d.addLinkValvePCV(valveID, fromNode, toNode)
# d.plot()

# getset OptionsEmiterBackFlow
d.printv(d.getOptionsEmitterBackFlow())
d.setOptionsEmitterBackFlowDisallowed()
d.printv(d.getOptionsEmitterBackFlow())
d.setOptionsEmitterBackFlowAllowed()
d.printv(d.getOptionsEmitterBackFlow())

# getNodeInControl & getLinkInControl
d.printv(d.getLinkInControl())
d.printv(d.getLinkInControl(10))
d.printv(d.getNodeInControl())
d.printv(d.getNodeInControl(11))

# setLinkFlowUnitsCMS
d.setFlowUnitsCMS() # kpa and meters
d.printv(d.getFlowUnits())

# example with change from kpa to psi without changing metric first
d.setOptionsPressureUnitsPSI()
d.printv(d.getOptionsPressureUnits())

# how to do it right
d.setFlowUnitsIMGD()
d.setOptionsPressureUnitsPSI()
d.printv(d.getOptionsPressureUnits())

# example with change from psi to KPA without changing the metric
d.setOptionsPressureUnitsKPA()
d.printv(d.getOptionsPressureUnits())

# reseting
d.setFlowUnitsGPM()
d.setOptionsPressureUnitsPSI()

# setNodeEmitterCoeff
d.setNodeEmitterCoeff([2, 3], [0.5, 0.6])
d.printv(d.getNodeEmitterCoeff())

# getset Optionsstatusreport
d.setOptionsStatusReportNo()
d.printv(d.getOptionsStatusReport())
d.setOptionsStatusReportNormal()
d.printv(d.getOptionsStatusReport())
d.setOptionsStatusReportFull()
d.printv(d.getOptionsStatusReport())

# Leakage section
d.solveCompleteHydraulics()

d.setLinkLeakArea(2, 10.5)
d.printv(d.getLinkLeakArea())

d.setLinkExpansionProperties(5, 2)
d.printv(d.getLinkExpansionProperties())

d.printv(d.getLinkLeakageRate())

d.printv(d.getConsumerDemandRequested(5))

d.printv(d.getConsumerDemandDelivered(5))

d.printv(d.getNodeEmitterFlow())

d.unload()
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
from epyt import epanet
import time

"""
Performance Example Summary:

Objective:

To compare the execution speed of two functions, getLinkFlows vs. getLinkValues.

Criteria:

The main criterion for comparison was speed.
Both functions were tested under the same simulation conditions.

Test Setup:

The simulation was designed to extract link flow values:
getLinkFlows: Extracts flows for all links - 1.
getLinkValues: Extracts the flow values for all links.

Results:

getLinkFlows: Extracted fewer values (flows set to -1).
getLinkValues: Extracted all actual flow values for each link,
processing more data than getLinkFlows.
Despite extracting more data, getLinkValues performed faster than getLinkFlows.

Conclusion:

The function getLinkValues was more efficient in terms of speed,
even though it processed and returned more values compared to getLinkFlows.
"""



inp= "Net1.inp"
d = epanet(inp)

d.setTimeSimulationDuration(1000*3600*24)
start_time = time.time()
d.openHydraulicAnalysis()
d.initializeHydraulicAnalysis()
numbers = [i for i in range(1, 13)]
tstep = 1
T_H, Ft, Fb = [], [], []
while tstep > 0:
t = d.runHydraulicAnalysis()
#flow test
Fb.append(d.getLinkFlows(numbers))
T_H.append(t)
tstep = d.nextHydraulicAnalysisStep()

d.closeHydraulicAnalysis()
print(Fb)
end_time = time.time()
timeforold = end_time - start_time
print(f"Time taken by old function: {timeforold} seconds")
d.unload()

d = epanet(inp)
start_time = time.time()

d.openHydraulicAnalysis()
d.initializeHydraulicAnalysis()

tstep = 1
T_H, Ft, Fb = [], [], []
while tstep > 0:
t = d.runHydraulicAnalysis()
#flow test
Ft.append(d.getLinkValues(d.ToolkitConstants.EN_FLOW))
T_H.append(t)
tstep = d.nextHydraulicAnalysisStep()

d.closeHydraulicAnalysis()
print(Ft)
end_time = time.time()
timefornew = end_time - start_time
print(f"Time taken by newfunction: {timefornew} seconds")
print(f"The new function is faster by {timeforold-timefornew} seconds")
Binary file modified epyt/libraries/glnx/libepanet2.so
Binary file not shown.
Binary file modified epyt/libraries/mac/epanetmsx.dylib
Binary file not shown.
Binary file modified epyt/libraries/mac/libepanet2.dylib
Binary file not shown.
Binary file added epyt/libraries/mac/libepanet2_2.dylib
Binary file not shown.
Binary file added epyt/libraries/win/2.2/epanet2.dll
Binary file not shown.
Binary file added epyt/libraries/win/2.2/epanet2.exe
Binary file not shown.
Binary file added epyt/libraries/win/2.2/epanetmsx.dll
Binary file not shown.
Binary file added epyt/libraries/win/2.2/epanetmsx.exe
Binary file not shown.
Binary file modified epyt/libraries/win/epanet2.dll
Binary file not shown.
48 changes: 23 additions & 25 deletions epyt/tests/general_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,16 @@ def test_getCurvesData(self):
""" ---getCurveType--- """
err_msg = 'Wrong curve type'
# Test 10
self.assertEqual(d.getCurveType(10), 'PUMP', err_msg)
self.assertEqual(d.getCurveType(10), 'GENERAL', err_msg)
# Test 11
self.assertEqual(d.getCurveType([2, 3]), ['PUMP', 'GENERAL'], err_msg)
self.assertEqual(d.getCurveType([2, 3]), ['GENERAL', 'GENERAL'], err_msg)

""" ---getCurveType--- """
err_msg = 'Wrong curve type index'
# Test 11
self.assertEqual(d.getCurveTypeIndex(10), 1, err_msg)
self.assertEqual(d.getCurveTypeIndex(10), 4, err_msg)
# Test 12
self.assertEqual(d.getCurveTypeIndex([2, 3]), [1, 4], err_msg)
self.assertEqual(d.getCurveTypeIndex([2, 3]), [4, 4], err_msg)

""" ---getCurveValue--- """
err_msg = 'Wrong curve value'
Expand Down Expand Up @@ -811,19 +811,19 @@ def test_getLinkPumpData(self):
""" ---getLinkPumpType--- """
err_msg = 'Wrong Pump Type'
# Test 12
self.assertEqual(d.getLinkPumpType(), ['CUSTOM', 'CUSTOM', 'CUSTOM', 'CUSTOM', 'CUSTOM', 'CUSTOM',
'CUSTOM', 'CONSTANT_HORSEPOWER'],
self.assertEqual(d.getLinkPumpType(), ['NO_CURVE', 'NO_CURVE', 'NO_CURVE', 'NO_CURVE', 'NO_CURVE', 'NO_CURVE',
'NO_CURVE', 'CONSTANT_HORSEPOWER'],
err_msg)

""" ---getLinkPumpTypeCode--- """
err_msg = 'Wrong Pump Type Code'
d.unload()
# Test 13
d = epanet('Richmond_skeleton.inp', ph=False)
self.assertEqual(d.getLinkPumpTypeCode(), [2, 2, 2, 2, 2, 2, 2], err_msg)
self.assertEqual(d.getLinkPumpTypeCode(), [3, 3, 3, 3, 3, 3, 3], err_msg)
self.epanetClass.unload()
self.epanetClass = epanet('Net1.inp', ph=False)
self.assertEqual(self.epanetClass.getLinkPumpTypeCode(), [1], err_msg)
self.assertEqual(self.epanetClass.getLinkPumpTypeCode(), [3], err_msg)

def test_getLinksInfo(self):
# Desired data
Expand Down Expand Up @@ -909,8 +909,6 @@ def test_getNodeInfo(self):
'Wrong Node Emitter output')
self.assertEqual(list(n_info.NodeInitialQuality), [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0],
'Wrong Node Initial Quality output')
self.assertEqual(list(n_info.NodePatternIndex), [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0],
'Wrong Node Pattern Index output')
self.assertEqual(list(n_info.NodeSourcePatternIndex), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
'Wrong Node Source Pattern Index output')
self.assertEqual(list(n_info.NodeSourceQuality), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
Expand Down Expand Up @@ -951,10 +949,10 @@ def testDemandsInfo(self):
# getComputedHydraulicTimeSeries.DemandDeficit works fine
self.epanetClass.setDemandModel('PDA', 0, 0.1, 0.5)
actual_def = self.epanetClass.getComputedHydraulicTimeSeries().DemandDeficit[0]
desired_dem_def = [0.0, -0.0012342832044413999, -0.0012111212332749546, -0.0012281893931302976,
-0.0012177492556971789,
-0.0012291126064630734, -0.0012496099800993576, -0.0011990998540248189,
-0.0011465764024330798, 0.0, 0.0]
desired_dem_def = [0.0, -0.00012342832044413999, -0.00012111212332749546, -0.00012281893931302976,
-0.00012177492556971789,
-0.00012291126064630734, -0.00012496099800993576, -0.00011990998540248189,
-0.00011465764024330798, 0.0, 0.0]
np.testing.assert_array_almost_equal(list(actual_def), desired_dem_def, decimal=5)

""" ---getNodeDemandPatternIndex--- """
Expand Down Expand Up @@ -1281,7 +1279,7 @@ def test_getTime(self):
self.assertEqual(self.epanetClass.getTimeRuleControlStep(), 360, 'Wrong Time Reporting Start Output')
self.assertEqual(self.epanetClass.getTimeStatisticsType(), 'NONE', 'Wrong Time Statistics Type Output')
self.assertEqual(self.epanetClass.getTimeReportingPeriods(), 25, 'Wrong Time Output')
self.assertEqual(self.epanetClass.getTimeStartTime(), 0, 'Wrong Reporting Periods Output')
self.assertEqual(self.epanetClass.getTimeClockStartTime(), 0, 'Wrong Reporting Periods Output')
self.assertEqual(self.epanetClass.getTimeHTime(), 86400, 'Wrong hydraulic solution Time Output')
self.assertEqual(self.epanetClass.getTimeQTime(), 86400, 'Wrong quality solution Time Output')
self.assertEqual(self.epanetClass.getTimeHaltFlag(), 0, 'Wrong Halt Flag Time Output')
Expand Down Expand Up @@ -2565,7 +2563,7 @@ def testStepByStepHydraulicQuality(self):
0.97022719, 1.00736078, 0.94322095, 0.80143815, 0.12152811,
0.14431463, 0.08355057, 0.0130776, 0.02278652, 0.01139326,
0.11465239, 0.01730443, 0.02278652, 0.00548209, 0.00759551])
np.testing.assert_array_almost_equal(velocity[5], desired_vel_5, err_msg=err_msg)
np.testing.assert_array_almost_equal(velocity[5], desired_vel_5, err_msg=err_msg, decimal=4)

desired_vel_25 = np.array([1.81227798, 1.49462949, 0.65854063, 0.56024584, 0.22403439,
1.69370013, 1.67809778, 0.04368657, 1.62192933, 0.03510528,
Expand All @@ -2575,7 +2573,7 @@ def testStepByStepHydraulicQuality(self):
0.96107627, 0.99540144, 0.93611252, 0.80505279, 0.11233691,
0.13340008, 0.07723162, 0.01208854, 0.02106317, 0.01053158,
0.11353814, 0.01599569, 0.02106317, 0.00506748, 0.00702106])
np.testing.assert_array_almost_equal(velocity[25], desired_vel_25, err_msg=err_msg)
np.testing.assert_array_almost_equal(velocity[25], desired_vel_25, err_msg=err_msg, decimal=4)

desired_vel_50 = np.array([1.81227798, 1.49714577, 0.65645338, 0.56441371, 0.22747538,
1.70124599, 1.68663652, 0.04090652, 1.63404243, 0.03287131,
Expand All @@ -2585,7 +2583,7 @@ def testStepByStepHydraulicQuality(self):
1.01524366, 1.04738449, 0.9918685, 0.86914894, 0.10518819,
0.12491098, 0.07231688, 0.01131927, 0.01972279, 0.00986139,
0.12084703, 0.01497778, 0.01972279, 0.004745, 0.00657426])
np.testing.assert_array_almost_equal(velocity[50], desired_vel_50, err_msg=err_msg)
np.testing.assert_array_almost_equal(velocity[50], desired_vel_50, err_msg=err_msg, decimal=4)

# Test Link Head Loss
err_msg = 'Error in Link Head Loss '
Expand All @@ -2599,7 +2597,7 @@ def testStepByStepHydraulicQuality(self):
7.93029468e-02, 7.23210341e-03, 1.06388168e-02, 3.86634775e-03,
2.18121485e-04, 8.71385305e-04, 9.65523106e-05, 8.68436388e-03,
2.61714521e-04, 8.71385306e-04, 4.35930363e-05, 3.41745593e-05])
np.testing.assert_array_almost_equal(head_loss[5], desired_hl_5, err_msg=err_msg)
np.testing.assert_array_almost_equal(head_loss[5], desired_hl_5, err_msg=err_msg, decimal=4)

desired_hl_23 = np.array([0.00000000e+00, 2.12312025e-03, 6.07622722e-03, 5.55697659e-03,
2.64237088e-03, 1.77728998e-02, 5.02764696e-02, 1.49966988e-03,
Expand All @@ -2611,7 +2609,7 @@ def testStepByStepHydraulicQuality(self):
1.55718379e-01, 8.03966410e-03, 1.18267824e-02, 4.29807698e-03,
2.42477654e-04, 9.68687084e-04, 1.07333662e-04, 5.50837145e-04,
2.90938434e-04, 9.68687084e-04, 4.84607797e-05, 3.79906041e-05])
np.testing.assert_array_almost_equal(head_loss[23], desired_hl_23, err_msg=err_msg)
np.testing.assert_array_almost_equal(head_loss[23], desired_hl_23, err_msg=err_msg, decimal=4)

desired_hl_51 = np.array([4.31256504e+00, 1.01913328e+00, 5.61048713e-01, 4.16152148e-01,
4.19324206e-02, 1.96783554e+00, 4.37316956e+00, 6.61642927e-04,
Expand All @@ -2623,15 +2621,15 @@ def testStepByStepHydraulicQuality(self):
1.35577363e-01, 3.54703856e-03, 5.21788629e-03, 1.89627882e-03,
1.06979294e-04, 4.27377362e-04, 4.73547942e-05, 1.26416617e-02,
1.28359821e-04, 4.27377362e-04, 2.13805269e-05, 1.67611652e-05])
np.testing.assert_array_almost_equal(head_loss[51], desired_hl_51, err_msg=err_msg)
np.testing.assert_array_almost_equal(head_loss[51], desired_hl_51, err_msg=err_msg, decimal=4)

# Test Link Settings
err_msg = 'Error in Link Settings'
desired_sett_0 = np.array([100., 100., 100., 100., 100., 100., 100., 140., 100., 140., 100.,
100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100.,
100., 100., 100., 100., 100., 100., 100., 100., 100., 100., 100.,
100., 100., 100., 100., 100., 100., 100.])
np.testing.assert_array_almost_equal(settings[0], desired_sett_0, err_msg=err_msg)
np.testing.assert_array_almost_equal(settings[0], desired_sett_0, err_msg=err_msg, decimal=4)

# Test Link Energy
err_msg = 'Error in Link Energy'
Expand All @@ -2645,7 +2643,7 @@ def testStepByStepHydraulicQuality(self):
4.22318706e-03, 5.84012767e-05, 4.53421535e-05, 9.54000958e-06,
8.42412685e-08, 5.86390195e-07, 3.24869652e-08, 2.94048909e-05,
1.33746844e-07, 5.86390195e-07, 7.05767837e-09, 7.66581151e-09])
np.testing.assert_array_almost_equal(energy[5], desired_energy_5, err_msg=err_msg)
np.testing.assert_array_almost_equal(energy[5], desired_energy_5, err_msg=err_msg, decimal=4)

desired_energy_23 = np.array([0.00000000e+00, 7.57281174e-06, 1.01274099e-05, 9.21563204e-06,
9.40276051e-06, 1.60406707e-04, 5.13468317e-04, 4.98657667e-06,
Expand All @@ -2657,7 +2655,7 @@ def testStepByStepHydraulicQuality(self):
1.19378331e-02, 6.87415312e-05, 5.33702213e-05, 1.12291187e-05,
9.91566299e-08, 6.90213677e-07, 3.82389540e-08, 4.20717423e-07,
1.57427429e-07, 6.90213677e-07, 8.30727765e-09, 9.02308390e-09])
np.testing.assert_array_almost_equal(energy[23], desired_energy_23, err_msg=err_msg)
np.testing.assert_array_almost_equal(energy[23], desired_energy_23, err_msg=err_msg, decimal=4)

desired_energy_51 = np.array([5.19327654e-01, 1.01923935e-01, 1.07665857e-02, 7.09644859e-03,
6.63834774e-04, 2.25553307e-01, 4.97914128e-01, 1.41431120e-06,
Expand All @@ -2669,7 +2667,7 @@ def testStepByStepHydraulicQuality(self):
9.64479399e-03, 1.94967257e-05, 1.51370583e-05, 3.18484390e-06,
2.81231677e-08, 1.95760939e-07, 1.08454726e-08, 5.24245111e-05,
4.46501460e-08, 1.95760939e-07, 2.35614062e-09, 2.55916022e-09])
np.testing.assert_array_almost_equal(energy[51], desired_energy_51, err_msg=err_msg)
np.testing.assert_array_almost_equal(energy[51], desired_energy_51, err_msg=err_msg, decimal=4)

# Test Node Actual Demand Sensing Nodes
err_msg = 'Error in Node Actual Demand Sensing Nodes'
Expand Down
Loading