tespy icon indicating copy to clipboard operation
tespy copied to clipboard

[bug] T_mix_ph results depend strongly on T0 when water is involved

Open BenPortner opened this issue 2 years ago • 3 comments

Current behavior

The helper function T_mix_ph can return very different results depending on the starting value when H2O is part of the mixture (see example).

Expected behavior

The function always returns the same value.

Proposed solution

The Newton algorithm should probably return NaN or None if it didn't converge.

Example

from tespy.tools.fluid_properties import T_mix_ph

T_mix_ph([1, 1e5, 2e6, {"H2O":0.99, "O2":0.01}], T0=800)
>>> 273.26000000000005
T_mix_ph([1, 1e5, 2e6, {"H2O":0.99, "O2":0.01}], T0=80)
>>> 749.5470656784826

BenPortner avatar May 06 '22 15:05 BenPortner

Hi,

thank you for reporting this. Unfortunately, TESPy (dev version) currently only solves for pure gaseous mixtures or pure fluids in liquid, two-phase or gaseous phase. The only exception is condensation of water in a gasous stream. Since the enthalpy value in your example is is somewhere in the two-phase region of water, the newton algorithm does not find a solution.

The reason why the Newton algorithm implemented for the fluid property functions does not throw an error is: Within the solving process of a network (especially at the beginning), the enthalpy/pressure values for some streams end up in regions that do not make much sense physically. If the function threw an error, the solving process would stop even if the overall network would still be solved later.

There is already a warning message in place, maybe we can promote that from debug to info or warning. What do you think?

Also, regarding the specific combination of values, you might be interested in the work @nkawerau is currently contributing (see #327). He is working on an implementation letting you choose between CoolProp and thermosteam, which is able to solve for multiphase mixtures.

Have nice week!

fwitte avatar May 09 '22 18:05 fwitte

Hi Francesco,

I think it makes sense to keep the function quiet during normal usage of TesPy. It would still be handy to access the logger information though. Where are the logs currently stored?

Thanks. Ben

BenPortner avatar May 23 '22 09:05 BenPortner

In your home folder there should be a folder .tespy/log or something like that. You an also change logging, I‘ll update this later, when I am at my computer again.

fwitte avatar May 23 '22 14:05 fwitte