Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Aug 2, 2024
2 parents 3640d30 + ee6e174 commit d647d48
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 11 deletions.
1 change: 1 addition & 0 deletions docs/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ What's New

Discover notable new features and improvements in each release

.. include:: whats_new/v0-7-6-001.rst
.. include:: whats_new/v0-7-6.rst
.. include:: whats_new/v0-7-5.rst
.. include:: whats_new/v0-7-4.rst
Expand Down
17 changes: 17 additions & 0 deletions docs/whats_new/v0-7-6-001.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
v0.7.6.post1 - Newton's Nature (August, 02, 2024)
+++++++++++++++++++++++++++++++++++++++++++++++++

This is a post release for version 0.7.6 to fix a bug in the postprocessing of
the :code:`HeatExchanger` classes.

Bug Fixes
#########
- An exception is catched in the heat exchanger post processing, in case the
heat exchanger effectiveness cannot be calculated when hot side or cold side
inlet temperature value are out of bounds of the fluid properties for the
other side respectively
(`PR #533 <https://github.com/oemof/tespy/pull/533>`__).

Contributors
############
- Francesco Witte (`@fwitte <https://github.com/fwitte>`__)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exclude = ["docs/_build"]

[project]
name = "tespy"
version = "0.7.6"
version = "0.7.6.post1"
description = "Thermal Engineering Systems in Python (TESPy)"
readme = "README.rst"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion src/tespy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

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

# tespy data and connections import
from . import connections # noqa: F401
Expand Down
36 changes: 27 additions & 9 deletions src/tespy/components/heat_exchangers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from tespy.components.component import Component
from tespy.components.component import component_registry
from tespy.tools import logger
from tespy.tools.data_containers import ComponentCharacteristics as dc_cc
from tespy.tools.data_containers import ComponentProperties as dc_cp
from tespy.tools.data_containers import GroupedComponentCharacteristics as dc_gcc
Expand Down Expand Up @@ -1057,15 +1058,32 @@ def calc_parameters(self):
self.kA.val = -self.Q.val / self.td_log.val

# heat exchanger efficiencies
self.eff_hot.val = (
(self.outl[0].h.val_SI - self.inl[0].h.val_SI)
/ self.calc_dh_max_hot()
)

self.eff_cold.val = (
(self.outl[1].h.val_SI - self.inl[1].h.val_SI)
/ self.calc_dh_max_cold()
)
try:
self.eff_hot.val = (
(self.outl[0].h.val_SI - self.inl[0].h.val_SI)
/ self.calc_dh_max_hot()
)
except ValueError:
self.eff_hot.val = np.nan
msg = (
"Cannot calculate heat exchanger hot side effectiveness "
"because cold side inlet temperature is out of bounds for hot "
"side fluid."
)
logger.warning(msg)
try:
self.eff_cold.val = (
(self.outl[1].h.val_SI - self.inl[1].h.val_SI)
/ self.calc_dh_max_cold()
)
except ValueError:
self.eff_cold.val = np.nan
msg = (
"Cannot calculate heat exchanger cold side effectiveness "
"because hot side inlet temperature is out of bounds for cold "
"side fluid."
)
logger.warning(msg)
self.eff_max.val = max(self.eff_hot.val, self.eff_cold.val)

def entropy_balance(self):
Expand Down
31 changes: 31 additions & 0 deletions tests/test_components/test_heat_exchangers.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,37 @@ def test_HeatExchanger(self, tmp_path):
)
assert round(self.c3.m.val, 2) == 7.96

def test_HeatExchanger_effectiveness_invalid(self):

instance = HeatExchanger('heat exchanger')
self.setup_HeatExchanger_network(instance)

# remove fluid specifications
self.c1.set_attr(fluid={f: None for f in self.c1.fluid.val})
self.c3.set_attr(fluid={f: None for f in self.c3.fluid.val})

# add new fluids
# temperature range > 300 °C
self.c1.set_attr(fluid={"INCOMP::NaK": 1}, m=10, T=400, p=1)
self.c2.set_attr(T=350, p=1)
# temperature range < 100 °C at 1 bar
self.c3.set_attr(fluid={"INCOMP::Water": 1}, T=25, p=1)
self.c4.set_attr(T=50, p=1)
instance.set_attr(eff_cold=None, eff_hot=None, pr1=None, pr2=None)

self.nw.solve("design")
self.nw._convergence_check()
msg = (
'Value of cold effectiveness must be nan but is '
f'{round(instance.eff_cold.val, 1)}.'
)
assert np.isnan(instance.eff_cold.val), msg
msg = (
'Value of hot effectiveness must be nan but is '
f'{round(instance.eff_hot.val, 1)}.'
)
assert np.isnan(instance.eff_hot.val), msg

def test_Condenser(self, tmp_path):
"""Test component properties of Condenser."""
instance = Condenser('condenser')
Expand Down

0 comments on commit d647d48

Please sign in to comment.