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

EPyT 1.0.9-beta.4 #39

Merged
merged 46 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f9077ba
updated msx libraries for linux and mac & paths
ichrys03 Mar 21, 2024
2b8d425
updated paths
ichrys03 Mar 21, 2024
baba413
+3 functions updated readme and epanet
ichrys03 Mar 21, 2024
b261a84
update unload function.
Mariosmsk Mar 23, 2024
10fc192
Create test_unit_MSX.py
Mariosmsk Mar 23, 2024
cbba18a
Update build_tests.yml
Mariosmsk Mar 23, 2024
f606720
Update epanet.py
Mariosmsk Mar 23, 2024
b35eaeb
Merge pull request #38 from ichrys03/msxdev
Mariosmsk Mar 23, 2024
29dc893
some fixes.
Mariosmsk Mar 23, 2024
5858772
update lib folders
Mariosmsk Mar 23, 2024
ef40bbb
unsupported win 32bit
Mariosmsk Mar 23, 2024
bdd0ee4
.
Mariosmsk Mar 23, 2024
cbb1b1c
Update epanet.py
Mariosmsk Mar 23, 2024
532d1a3
Revert "Update epanet.py"
Mariosmsk Mar 23, 2024
05a2840
Create libepanet.so
Mariosmsk Mar 23, 2024
73f4556
Update build_tests.yml
Mariosmsk Mar 23, 2024
1cc5b30
Update epanet.py
Mariosmsk Mar 23, 2024
8609404
fix typo
Mariosmsk Mar 24, 2024
4d1a052
update safe delete function.
Mariosmsk Mar 24, 2024
7fdba9f
fix typo loadMSXFile
Mariosmsk Mar 24, 2024
1b3c498
cleanup.
Mariosmsk Mar 24, 2024
53862f4
changes in epanetmsxapi
Mariosmsk Mar 24, 2024
46e0f14
Update epanet.py
Mariosmsk Mar 24, 2024
bc501db
changes in epanet class - input arg msxfile.
Mariosmsk Mar 24, 2024
0e3e185
some fixes - tests
Mariosmsk Mar 24, 2024
d2e031a
fix bug in getpattern
Mariosmsk Mar 28, 2024
18f0479
some fixes n
Mariosmsk Mar 28, 2024
126883c
Update epanet.py
Mariosmsk Mar 28, 2024
3dea1aa
Update epanet.py
Mariosmsk Mar 28, 2024
1150d9f
cleanup
Mariosmsk Apr 5, 2024
37434cd
Update epanet.py
Mariosmsk Apr 16, 2024
e675c46
update in msx
Mariosmsk Apr 16, 2024
b078f5c
Update epanet.py
Mariosmsk Apr 16, 2024
3f877b8
some changes.
Mariosmsk Apr 16, 2024
da0d4ca
Update epanet.py
Mariosmsk Apr 16, 2024
427f4bf
Update test_unit_MSX.py
Mariosmsk Apr 16, 2024
f958eaf
Update test_unit_MSX.py
Mariosmsk Apr 16, 2024
ec12dd3
Delete test_unit_MSX.py
Mariosmsk Apr 16, 2024
7350da8
Update epanet.py
Mariosmsk Apr 16, 2024
84ae5dd
Merge branch 'dev' of https://github.com/OpenWaterAnalytics/EPyT into…
Mariosmsk Apr 16, 2024
601a521
using libraries to use epanetmsx v2.0
Mariosmsk Apr 16, 2024
a38c16a
Update test_unit_MSX.py
Mariosmsk Apr 16, 2024
1d392ce
Update net1_unit_test.py
Mariosmsk Apr 16, 2024
87221ab
update version to 1.0.9-beta.4
Mariosmsk Apr 16, 2024
266901b
Update build_tests.yml
Mariosmsk Apr 16, 2024
c9ecf49
Update epanet.py
Mariosmsk Apr 16, 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
2 changes: 1 addition & 1 deletion .github/workflows/build_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
pytest -v
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ If you want to contribute, please check out our [Code of Conduct](https://github
|<b> MSX Functions </b>
|loadMSXFile|Opens the EPANET-MSX toolkit system|
|unloadMSX|Closes the EPANET-MSX toolkit system|
|addMSXPattern|Adds a new, empty MSX source time pattern to the project|
|initializeMSXQualityAnalysis|Initializes the MSX system before solving for water quality results in step-wise fashion|
|stepMSXQualityAnalysisTimeLeft|Advances the water quality solution through a single water quality time step when performing a step-wise simulation|
|saveMSXFile|Saves the data associated with the current MSX project into a new MSX input file|
Expand Down Expand Up @@ -584,6 +585,8 @@ If you want to contribute, please check out our [Code of Conduct](https://github
|setMSXTimeStep|Sets time step|
|setMSXPatternValue|Assigns a new value to the multiplier for a specific time period in a given MSX source time pattern|
|setMSXPattern|Sets all of the multiplier factors for a specific time pattern|
|setMSXParametersPipesValue|Assigns a value to a particular reaction parameter for given pipes|
|setMSXParametersTanksValue|Assigns a value to a particular reaction parameter for given tanks|
|setMSXConstantsValue|Assigns a new value to a specific reaction constant|
|useMSXHydraulicFile|Uses a previously saved EPANET hydraulics file as the source of hydraulic information|

Expand Down
3 changes: 2 additions & 1 deletion epyt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
__author__ = """Marios S. Kyriakou"""
__email__ = "[email protected]"
__version__ = "1.0.9-beta.2"
__version__ = "1.0.9-beta.4"
__msxversion__ = "2.0.0"
__copyright__ = """Copyright 2022, KIOS Research and Innovation Center of Excellence (KIOS CoE),
University of Cyprus (www.kios.org.cy)."""
__license__ = "EUPL License, Version 1.2"
Expand Down
1,026 changes: 712 additions & 314 deletions epyt/epanet.py

Large diffs are not rendered by default.

Binary file removed epyt/libraries/glnx/epanetmsx
Binary file not shown.
Binary file modified epyt/libraries/glnx/epanetmsx.so
Binary file not shown.
Binary file added epyt/libraries/glnx/libepanet2.so
Binary file not shown.
Binary file removed epyt/libraries/glnx/libepanet2_2
Binary file not shown.
Binary file removed epyt/libraries/glnx/libepanet2_2.so
Binary file not shown.
Binary file added epyt/libraries/mac/epanetmsx.dylib
Binary file not shown.
Binary file added epyt/libraries/mac/libepanet2.dylib
Binary file not shown.
Binary file removed epyt/libraries/mac/libepanet2_2
Binary file not shown.
Binary file removed epyt/libraries/mac/libepanet2_2.dylib
Binary file not shown.
Binary file removed epyt/libraries/win/epanet2_2/32bit/epanet2.dll
Binary file not shown.
Binary file removed epyt/libraries/win/epanet2_2/32bit/epanet2.exe
Binary file not shown.
Binary file removed epyt/libraries/win/epanet2_2/64bit/epanetmsx.dll
Binary file not shown.
Binary file added epyt/libraries/win/epanetmsx.dll
Binary file not shown.
56 changes: 32 additions & 24 deletions epyt/tests/net1_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def testStepByStepAnalysis(self):
9.452347598503036e-07, 9.28221894076609e-07, 9.084721628771827e-07, 2.416368471024177,
2.4073945733540967,
2.3857323225219194])
np.testing.assert_array_almost_equal(velocity, v_desired, err_msg="Wrong Velocity output")
np.testing.assert_array_almost_equal(velocity, v_desired, decimal=3, err_msg="Wrong Velocity output")
h_desired = np.array(
[19.117018607743262, 18.784557106294415, 18.575821630530413, 18.350323106559813, 18.247536420722895,
18.125096976393024, 18.12282340051479, 18.099494697653654, 17.95951292501252, 17.843745116056084,
Expand All @@ -202,9 +202,9 @@ def testStepByStepAnalysis(self):
2.637534635141492e-11,
2.5352164811920375e-11, 20.08353269330769, 19.945617762391066,
19.61450487894149])
np.testing.assert_array_almost_equal(head_loss, h_desired, err_msg="Wrong HeadLoss output")
f_desired = [np.array(1866.17582999), np.array(1848.5811499), np.array(1837.46107838)]
np.testing.assert_array_almost_equal(flow[0:3], f_desired, err_msg="Wrong Flows output")
np.testing.assert_array_almost_equal(head_loss, h_desired, decimal=3, err_msg="Wrong HeadLoss output")
f_desired = [np.array(1866.17578125), np.array(1848.58117676), np.array(1837.46105957)]
np.testing.assert_array_almost_equal(flow[0:3], f_desired, decimal=3, err_msg="Wrong Flows output")

""" ------------------------------------------------------------------------- """

Expand Down Expand Up @@ -274,20 +274,21 @@ def testSetLinkRoughnessCoefficientIndex(self):

def testSetLinkMinorLossCoefficientAll(self):
self.epanetClass.setLinkMinorLossCoeff([1.2 for _ in self.epanetClass.getLinkMinorLossCoeff()])
assert all(self.epanetClass.getLinkMinorLossCoeff() == [1.2, 1.2000000000000002, 1.2000000000000002,
1.2000000000000002, 1.2, 1.2,
1.2, 1.2000000000000002, 1.2, 1.2, 1.2, 1.2,
0.0]), "Wrong set minor loss output"
expected_values = [1.2, 1.2000000000000002, 1.2000000000000002, 1.2000000000000002, 1.2, 1.2,
1.2, 1.2000000000000002, 1.2, 1.2, 1.2, 1.2, 0.0]
actual_values = self.epanetClass.getLinkMinorLossCoeff()
assert np.isclose(actual_values, expected_values).all(), "Wrong set minor loss output"

def testSetLinkMinorLossCoefficientIndices(self):
self.epanetClass.setLinkMinorLossCoeff([2, 3, 4], [1.01, 1.02, 1.01]) # index, value
assert all(self.epanetClass.getLinkMinorLossCoeff([2, 3, 4]) == [1.01, 1.02,
1.01]), "Wrong set minor loss output"
expected_values = [1.01, 1.02, 1.01]
self.epanetClass.setLinkMinorLossCoeff([2, 3, 4], expected_values) # index, value
actual_values = self.epanetClass.getLinkMinorLossCoeff([2, 3, 4])
for expected, actual in zip(expected_values, actual_values):
self.assertAlmostEqual(expected, actual, places=2, msg="Wrong set minor loss output")

def testSetLinkMinorLossCoefficientIndex(self):
self.epanetClass.setLinkMinorLossCoeff(2, 1.01) # index, value
assert self.epanetClass.getLinkMinorLossCoeff(2) == 1.01, "Wrong set minor loss output"

assert np.isclose(self.epanetClass.getLinkMinorLossCoeff(2), 1.01, atol=1e-6), "Wrong set minor loss output"
""" ------------------------------------------------------------------------- """

def testSetLinkInitialStatusAll(self):
Expand All @@ -306,28 +307,35 @@ def testSetLinkInitialStatusIndex(self):

def testSetLinkBulkReactionCoefficientAll(self):
self.epanetClass.setLinkBulkReactionCoeff([i - 0.055 for i in self.epanetClass.getLinkBulkReactionCoeff()])
assert all(
self.epanetClass.getLinkBulkReactionCoeff() == [-0.555, -0.555, -0.555, -0.555, -0.555, -0.555, -0.555,
-0.555, -0.555, -0.555, -0.555, -0.555,
0.0]), "Wrong set link bulk reaction output"

def assert_almost_equal(actual, expected, tolerance, message):
for a, e in zip(actual, expected):
assert abs(a - e) <= tolerance, message

expected_values = [-0.555, -0.555, -0.555, -0.555, -0.555, -0.555, -0.555,
-0.555, -0.555, -0.555, -0.555, -0.555, 0.0]
actual_values = self.epanetClass.getLinkBulkReactionCoeff()
assert_almost_equal(actual_values, expected_values, tolerance=1e-3, message="Wrong set link bulk reaction "
"output")

def testSetLinkBulkReactionCoefficientIndices(self):
self.epanetClass.setLinkBulkReactionCoeff([2, 3, 13], [0.1] * 3) # index, value
assert all(self.epanetClass.getLinkBulkReactionCoeff([2, 3, 13]) == [0.1, 0.1,
0.0]), "Wrong set link bulk reaction " \
"output"
expected_values = np.array([0.1, 0.1, 0.0])
actual_values = self.epanetClass.getLinkBulkReactionCoeff([2, 3, 13])
assert np.isclose(actual_values, expected_values).all(), "Wrong set link bulk reaction output"

def testSetLinkBulkReactionCoefficientIndex(self):
self.epanetClass.setLinkBulkReactionCoeff(1, 0.2) # index, value
assert self.epanetClass.getLinkBulkReactionCoeff(1) == 0.2, "Wrong set link bulk reaction output"
assert np.isclose(self.epanetClass.getLinkBulkReactionCoeff(1),
0.2).all(), "Wrong set link bulk reaction output"

""" ------------------------------------------------------------------------- """

def testSetLinkWallReactionCoefficientAll(self):
self.epanetClass.setLinkWallReactionCoeff([i * (-1.1) for i in self.epanetClass.getLinkWallReactionCoeff()])
assert all(self.epanetClass.getLinkWallReactionCoeff() == [1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1,
1.1, 1.1,
0.0]), "Wrong set link wall reaction output"
expected_values = [1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 1.1, 0.0]
actual_values = self.epanetClass.getLinkWallReactionCoeff()
assert np.isclose(actual_values, expected_values).all(), "Wrong set link wall reaction output"

def testSetLinkWallReactionCoefficientIndices(self):
self.epanetClass.setLinkWallReactionCoeff([2, 3, 13], [-2] * 3) # index, value
Expand Down
Loading