Skip to content

Commit

Permalink
Merge pull request #478 from oemof/fix/temperature-upper-limit-mixtures
Browse files Browse the repository at this point in the history
Increase upper limit for mixture temperature root finding
  • Loading branch information
fwitte authored Jan 21, 2024
2 parents be92091 + 88e4002 commit d115c98
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/tespy/connections/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
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_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
Expand Down Expand Up @@ -917,7 +918,15 @@ 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."
)
logger.warning(msg)
else:
try:
if not self.x.is_set:
Expand Down
2 changes: 2 additions & 0 deletions src/tespy/tools/fluid_properties/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion tests/test_components/test_combustion.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
SPDX-License-Identifier: MIT
"""

import shutil

import pytest

from tespy.components import CombustionChamber
from tespy.components import CombustionEngine
from tespy.components import DiabaticCombustionChamber
Expand Down Expand Up @@ -103,6 +104,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.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_networks/test_binary_incompressible.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def setup_method(self):
self.nw.solve("design")

def test_binaries(self):
self.nw._convergence_check()
self.nw._convergence_check()

0 comments on commit d115c98

Please sign in to comment.