Skip to content

Commit

Permalink
fix: consider ambient pressure in calc. of compression work (#543)
Browse files Browse the repository at this point in the history
* fix: consider ambient pressure in calc. of compression work

* fix: consider rel. pressure when getting compressibility values

* fix: calculation of kappa instead of 1.4 assumption

* proper pandapower Version handling in GHA (reg.Python 3.7)

* Update pump_component.py

* pump std type from_list now returns the std type

* Update run_tests_develop.yml

* fix: calculation of compression power, add test

* fix np.bool error

* install correct pandapower version for tutorial test in Python 3.7

* fix GHA script for Master

* replaced references to python-igraph as recommended in #547 (#548)

* add example nets of the version

* increase version number


---------

Co-authored-by: dlohmeier <daniel.lohmeier@retoflow.de>
  • Loading branch information
jkisse and dlohmeier authored Jul 26, 2023
1 parent fa4d506 commit c320051
Show file tree
Hide file tree
Showing 15 changed files with 971 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest python-igraph pytest-split numba
python -m pip install pytest igraph pytest-split numba
- name: Install pandapipes from TestPyPI
if: ${{ inputs.upload_server == 'testpypi'}}
run: |
Expand Down
12 changes: 10 additions & 2 deletions .github/workflows/run_tests_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest python-igraph pytest-split numba
python -m pip install pytest igraph pytest-split numba
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if ${{ matrix.python-version == '3.7' }};
then pip install pandapower==2.11.1;
else
python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower
fi
pip install .
- name: List all installed packages
run: |
Expand Down Expand Up @@ -96,9 +100,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest nbmake pytest-xdist pytest-split python-igraph numba
python -m pip install pytest nbmake pytest-xdist pytest-split igraph numba
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if ${{ matrix.python-version == '3.7' }};
then pip install pandapower==2.11.1;
else
python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower
fi
pip install .
- name: List all installed packages
run: |
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/run_tests_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest python-igraph pytest-split numba
python -m pip install pytest igraph pytest-split numba
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower
if ${{ matrix.python-version == '3.7' }};
then pip install pandapower==2.11.1;
else
python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower;
fi
pip install .
- name: List all installed packages
run: |
Expand Down Expand Up @@ -64,9 +68,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest nbmake pytest-xdist pytest-split python-igraph numba
python -m pip install pytest nbmake pytest-xdist pytest-split igraph numba
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if ${{ matrix.python-version == '3.7' }};
then pip install pandapower==2.11.1;
else
python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower
fi
pip install .
- name: List all installed packages
run: |
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log
=============

[0.8.5] - 2023-06-19
-------------------------------
- [FIXED] consider ambient pressure in calculation of compression power for pumps/compressors
- [FIXED] np.bool error in pipeflow calculation due to deprecation of np.bool
- [FIXED] use igraph package instead of python-igraph (has been renamed)
- [ADDED] gas specific calculation of heat capacity ration kappa = cp/cv (for pumps/compressors)

[0.8.4] - 2023-02-02
-------------------------------
- [FIXED] added flow control to nxgraph
Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# The short X.Y version.
version = "0.8"
# The full version, including alpha/beta/rc tags.
release = "0.8.4"
release = "0.8.5"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pandapipes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# and Energy System Technology (IEE), Kassel, and University of Kassel. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

__version__ = '0.8.4'
__version__ = '0.8.5'
__format_version__ = '0.8.0'

import pandas as pd
Expand Down
12 changes: 7 additions & 5 deletions pandapipes/component_models/pump_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ def extract_results(cls, net, options, branch_results, nodes_connected, branches

if calc_compr_pow:
f, t = get_lookup(net, "branch", "from_to")[cls.table_name()]
from_nodes = branch_results["from_nodes"][f:t]

res_table = net["res_" + cls.table_name()]
if net.fluid.is_gas:
p_from = branch_results["p_from"][f:t]
p_to = branch_results["p_to"][f:t]
from_nodes = branch_results["from_nodes"][f:t]
p_from = branch_results["p_abs_from"][f:t]
p_to = branch_results["p_abs_to"][f:t]
t0 = net["_pit"]["node"][from_nodes, TINIT_NODE]
mf_sum_int = branch_results["mf_from"][f:t]
# calculate ideal compression power
Expand All @@ -165,8 +166,9 @@ def extract_results(cls, net, options, branch_results, nodes_connected, branches
' defined')
else:
r_spec = 1e3 * R_UNIVERSAL / molar_mass # [J/(kg * K)]
# 'kappa' heat capacity ratio:
k = 1.4 # TODO: implement proper calculation of kappa
cp = net.fluid.get_heat_capacity(t0)
cv = cp - r_spec
k = cp/cv # 'kappa' heat capacity ratio
w_real_isentr = (k / (k - 1)) * r_spec * compr * t0 * \
(np.divide(p_to, p_from) ** ((k - 1) / k) - 1)
res_table['compr_power_mw'].values[:] = \
Expand Down
4 changes: 2 additions & 2 deletions pandapipes/pipeflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def pipeflow(net, sol_vec=None, **kwargs):
nodes_connected, branches_connected = check_connectivity(
net, branch_pit, node_pit, check_heat=calculate_heat)
else:
nodes_connected = node_pit[:, ACTIVE_ND].astype(np.bool)
branches_connected = branch_pit[:, ACTIVE_BR].astype(np.bool)
nodes_connected = node_pit[:, ACTIVE_ND].astype(np.bool_)
branches_connected = branch_pit[:, ACTIVE_BR].astype(np.bool_)

reduce_pit(net, node_pit, branch_pit, nodes_connected, branches_connected)

Expand Down
6 changes: 3 additions & 3 deletions pandapipes/plotting/generic_geodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def build_igraph_from_ppipes(net, junctions=None):
try:
import igraph as ig
except (DeprecationWarning, ImportError):
raise ImportError("Please install python-igraph with "
"`pip install python-igraph` or "
"`conda install python-igraph` "
raise ImportError("Please install igraph with "

Check warning on line 42 in pandapipes/plotting/generic_geodata.py

View check run for this annotation

Codecov / codecov/patch

pandapipes/plotting/generic_geodata.py#L42

Added line #L42 was not covered by tests
"`pip install igraph` or "
"`conda install igraph` "
"or from https://www.lfd.uci.edu/~gohlke/pythonlibs")
g = ig.Graph(directed=True)
junction_index = net.junction.index if junctions is None else np.array(junctions)
Expand Down
5 changes: 3 additions & 2 deletions pandapipes/std_types/std_type_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ def from_path(cls, name, path):
@classmethod
def from_list(cls, name, x_values, y_values, degree):
reg_par, x_values, y_values, degree = cls._from_list(x_values, y_values, degree)
reg_st = cls(name, reg_par)
cls.init_std_type(reg_st, x_values, y_values, degree)
pump_st = cls(name, reg_par)
cls.init_std_type(pump_st, x_values, y_values, degree)
return pump_st

Check warning on line 222 in pandapipes/std_types/std_type_class.py

View check run for this annotation

Codecov / codecov/patch

pandapipes/std_types/std_type_class.py#L220-L222

Added lines #L220 - L222 were not covered by tests

@classmethod
def load_data(cls, path):
Expand Down
412 changes: 412 additions & 0 deletions pandapipes/test/api/old_versions/example_0.8.5_gas.json

Large diffs are not rendered by default.

Loading

0 comments on commit c320051

Please sign in to comment.