Skip to content

Commit d647d48

Browse files
committed
Merge branch 'dev'
2 parents 3640d30 + ee6e174 commit d647d48

File tree

6 files changed

+78
-11
lines changed

6 files changed

+78
-11
lines changed

docs/whats_new.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ What's New
33

44
Discover notable new features and improvements in each release
55

6+
.. include:: whats_new/v0-7-6-001.rst
67
.. include:: whats_new/v0-7-6.rst
78
.. include:: whats_new/v0-7-5.rst
89
.. include:: whats_new/v0-7-4.rst

docs/whats_new/v0-7-6-001.rst

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
v0.7.6.post1 - Newton's Nature (August, 02, 2024)
2+
+++++++++++++++++++++++++++++++++++++++++++++++++
3+
4+
This is a post release for version 0.7.6 to fix a bug in the postprocessing of
5+
the :code:`HeatExchanger` classes.
6+
7+
Bug Fixes
8+
#########
9+
- An exception is catched in the heat exchanger post processing, in case the
10+
heat exchanger effectiveness cannot be calculated when hot side or cold side
11+
inlet temperature value are out of bounds of the fluid properties for the
12+
other side respectively
13+
(`PR #533 <https://github.com/oemof/tespy/pull/533>`__).
14+
15+
Contributors
16+
############
17+
- Francesco Witte (`@fwitte <https://github.com/fwitte>`__)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ exclude = ["docs/_build"]
2424

2525
[project]
2626
name = "tespy"
27-
version = "0.7.6"
27+
version = "0.7.6.post1"
2828
description = "Thermal Engineering Systems in Python (TESPy)"
2929
readme = "README.rst"
3030
authors = [

src/tespy/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44

55
__datapath__ = os.path.join(importlib.resources.files("tespy"), "data")
6-
__version__ = '0.7.6 - Newton\'s Nature'
6+
__version__ = '0.7.6.post1 - Newton\'s Nature'
77

88
# tespy data and connections import
99
from . import connections # noqa: F401

src/tespy/components/heat_exchangers/base.py

+27-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from tespy.components.component import Component
1818
from tespy.components.component import component_registry
19+
from tespy.tools import logger
1920
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
2021
from tespy.tools.data_containers import ComponentProperties as dc_cp
2122
from tespy.tools.data_containers import GroupedComponentCharacteristics as dc_gcc
@@ -1057,15 +1058,32 @@ def calc_parameters(self):
10571058
self.kA.val = -self.Q.val / self.td_log.val
10581059

10591060
# heat exchanger efficiencies
1060-
self.eff_hot.val = (
1061-
(self.outl[0].h.val_SI - self.inl[0].h.val_SI)
1062-
/ self.calc_dh_max_hot()
1063-
)
1064-
1065-
self.eff_cold.val = (
1066-
(self.outl[1].h.val_SI - self.inl[1].h.val_SI)
1067-
/ self.calc_dh_max_cold()
1068-
)
1061+
try:
1062+
self.eff_hot.val = (
1063+
(self.outl[0].h.val_SI - self.inl[0].h.val_SI)
1064+
/ self.calc_dh_max_hot()
1065+
)
1066+
except ValueError:
1067+
self.eff_hot.val = np.nan
1068+
msg = (
1069+
"Cannot calculate heat exchanger hot side effectiveness "
1070+
"because cold side inlet temperature is out of bounds for hot "
1071+
"side fluid."
1072+
)
1073+
logger.warning(msg)
1074+
try:
1075+
self.eff_cold.val = (
1076+
(self.outl[1].h.val_SI - self.inl[1].h.val_SI)
1077+
/ self.calc_dh_max_cold()
1078+
)
1079+
except ValueError:
1080+
self.eff_cold.val = np.nan
1081+
msg = (
1082+
"Cannot calculate heat exchanger cold side effectiveness "
1083+
"because hot side inlet temperature is out of bounds for cold "
1084+
"side fluid."
1085+
)
1086+
logger.warning(msg)
10691087
self.eff_max.val = max(self.eff_hot.val, self.eff_cold.val)
10701088

10711089
def entropy_balance(self):

tests/test_components/test_heat_exchangers.py

+31
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,37 @@ def test_HeatExchanger(self, tmp_path):
476476
)
477477
assert round(self.c3.m.val, 2) == 7.96
478478

479+
def test_HeatExchanger_effectiveness_invalid(self):
480+
481+
instance = HeatExchanger('heat exchanger')
482+
self.setup_HeatExchanger_network(instance)
483+
484+
# remove fluid specifications
485+
self.c1.set_attr(fluid={f: None for f in self.c1.fluid.val})
486+
self.c3.set_attr(fluid={f: None for f in self.c3.fluid.val})
487+
488+
# add new fluids
489+
# temperature range > 300 °C
490+
self.c1.set_attr(fluid={"INCOMP::NaK": 1}, m=10, T=400, p=1)
491+
self.c2.set_attr(T=350, p=1)
492+
# temperature range < 100 °C at 1 bar
493+
self.c3.set_attr(fluid={"INCOMP::Water": 1}, T=25, p=1)
494+
self.c4.set_attr(T=50, p=1)
495+
instance.set_attr(eff_cold=None, eff_hot=None, pr1=None, pr2=None)
496+
497+
self.nw.solve("design")
498+
self.nw._convergence_check()
499+
msg = (
500+
'Value of cold effectiveness must be nan but is '
501+
f'{round(instance.eff_cold.val, 1)}.'
502+
)
503+
assert np.isnan(instance.eff_cold.val), msg
504+
msg = (
505+
'Value of hot effectiveness must be nan but is '
506+
f'{round(instance.eff_hot.val, 1)}.'
507+
)
508+
assert np.isnan(instance.eff_hot.val), msg
509+
479510
def test_Condenser(self, tmp_path):
480511
"""Test component properties of Condenser."""
481512
instance = Condenser('condenser')

0 commit comments

Comments
 (0)