From 23148e87136631b38be7f9a4ac57e2bd8293daa1 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Tue, 16 Jan 2024 16:30:10 +0100 Subject: [PATCH 1/4] Increase upper limit for mixture temperature root finding --- src/tespy/tools/fluid_properties/helpers.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tespy/tools/fluid_properties/helpers.py b/src/tespy/tools/fluid_properties/helpers.py index 27740208a..155c5cfa6 100644 --- a/src/tespy/tools/fluid_properties/helpers.py +++ b/src/tespy/tools/fluid_properties/helpers.py @@ -70,6 +70,8 @@ def inverse_temperature_mixture(p=None, target_value=None, fluid_data=None, T0=N if T0 is None: T0 = (valmin + valmax) / 2.0 + valmax *= 2 + function_kwargs = { "p": p, "fluid_data": fluid_data, "T": T0, "function": f, "parameter": "T" , "delta": 0.01 From 4b4ccf1220d5aaf199f46db6eca99036f08a853b Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Sun, 21 Jan 2024 12:27:42 +0100 Subject: [PATCH 2/4] Add a warning message for out of bound mixture tempertures --- src/tespy/connections/connection.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tespy/connections/connection.py b/src/tespy/connections/connection.py index 3c58eeafe..47466b01e 100644 --- a/src/tespy/connections/connection.py +++ b/src/tespy/connections/connection.py @@ -37,6 +37,7 @@ from tespy.tools.fluid_properties.functions import dT_mix_ph_dfluid from tespy.tools.fluid_properties.functions import p_sat_T from tespy.tools.fluid_properties.helpers import get_number_of_fluids +from tespy.tools.fluid_properties.helpers import get_mixture_temperature_range from tespy.tools.global_vars import ERR from tespy.tools.global_vars import fluid_property_data as fpd from tespy.tools.helpers import TESPyConnectionError @@ -917,7 +918,14 @@ def calc_results(self): ) logger.error(msg) _converged = False - + else: + _, Tmax = get_mixture_temperature_range(self.fluid_data) + if self.T.val_SI > Tmax: + msg = ( + "The temperature value of the mixture is above the " + "upper temperature limit of a mixture component. " + "The resulting temperature might not be erroneous." + ) else: try: if not self.x.is_set: From c066179ff13e7409b83aceab5504d559a83c9d95 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Sun, 21 Jan 2024 12:37:22 +0100 Subject: [PATCH 3/4] Add a test with higher temperature combustion product that water fluid properties allow --- src/tespy/connections/connection.py | 1 + tests/test_components/test_combustion.py | 16 +++++++++++++++- .../test_networks/test_binary_incompressible.py | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/tespy/connections/connection.py b/src/tespy/connections/connection.py index 47466b01e..9bcc80260 100644 --- a/src/tespy/connections/connection.py +++ b/src/tespy/connections/connection.py @@ -926,6 +926,7 @@ def calc_results(self): "upper temperature limit of a mixture component. " "The resulting temperature might not be erroneous." ) + logger.warning(msg) else: try: if not self.x.is_set: diff --git a/tests/test_components/test_combustion.py b/tests/test_components/test_combustion.py index 7912781fb..298601099 100644 --- a/tests/test_components/test_combustion.py +++ b/tests/test_components/test_combustion.py @@ -9,7 +9,7 @@ SPDX-License-Identifier: MIT """ - +import pytest import shutil from tespy.components import CombustionChamber @@ -103,6 +103,20 @@ def test_CombustionChamber(self): str(round(self.c3.fluid.val['O2'], 4)) + '.') assert 0.0 == round(self.c3.fluid.val['O2'], 4), msg + def test_CombustionChamberHighTemperature(self): + instance = CombustionChamber('combustion chamber') + self.setup_CombustionChamber_network(instance) + + # connection parameter specification + air = {'N2': 0.8, 'O2': 0.2} + fuel = {'CH4': 1} + self.c1.set_attr(fluid=air, p=1, T=30, m=1) + self.c2.set_attr(fluid=fuel, T=30) + instance.set_attr(lamb=1) + self.nw.solve('design') + self.nw._convergence_check() + assert self.c3.T.val_SI == pytest.approx(2110, abs=0.1) + def test_DiabaticCombustionChamber(self): """ Test component properties of diabatic combustion chamber. diff --git a/tests/test_networks/test_binary_incompressible.py b/tests/test_networks/test_binary_incompressible.py index c5aa7be94..9683e71cd 100644 --- a/tests/test_networks/test_binary_incompressible.py +++ b/tests/test_networks/test_binary_incompressible.py @@ -51,4 +51,4 @@ def setup_method(self): self.nw.solve("design") def test_binaries(self): - self.nw._convergence_check() \ No newline at end of file + self.nw._convergence_check() From 88e4002c7cecd3292e91a2786ba66a17fbd2feb3 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Sun, 21 Jan 2024 12:46:14 +0100 Subject: [PATCH 4/4] Run isort --- src/tespy/connections/connection.py | 2 +- tests/test_components/test_combustion.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tespy/connections/connection.py b/src/tespy/connections/connection.py index 9bcc80260..7e1f8b09c 100644 --- a/src/tespy/connections/connection.py +++ b/src/tespy/connections/connection.py @@ -36,8 +36,8 @@ from tespy.tools.fluid_properties import viscosity_mix_ph from tespy.tools.fluid_properties.functions import dT_mix_ph_dfluid from tespy.tools.fluid_properties.functions import p_sat_T -from tespy.tools.fluid_properties.helpers import get_number_of_fluids from tespy.tools.fluid_properties.helpers import get_mixture_temperature_range +from tespy.tools.fluid_properties.helpers import get_number_of_fluids from tespy.tools.global_vars import ERR from tespy.tools.global_vars import fluid_property_data as fpd from tespy.tools.helpers import TESPyConnectionError diff --git a/tests/test_components/test_combustion.py b/tests/test_components/test_combustion.py index 298601099..b8290babd 100644 --- a/tests/test_components/test_combustion.py +++ b/tests/test_components/test_combustion.py @@ -9,9 +9,10 @@ SPDX-License-Identifier: MIT """ -import pytest import shutil +import pytest + from tespy.components import CombustionChamber from tespy.components import CombustionEngine from tespy.components import DiabaticCombustionChamber