Closed fwitte closed 3 years ago
Hi! Thanks for proposing this enhancement. Please use the indomain
method to make sure that the temperature/pressure is within the domain of the model.
For example:
import thermosteam as tmo
import numpy as np
for fluid in ['Water', 'Ethanol', 'Methane', 'CO2', 'R134a']:
fluid_data = tmo.Chemical(fluid)
print('#' * 50)
print('Properties of ' + fluid)
print('#' * 50)
for sometemperature in np.linspace(50, 1000, 20):
print('*' * 25)
print('Evaluation at T=' + str(sometemperature) + ' K')
print('*' * 25)
print('Saturation pressure')
print('*' * 25)
for model in fluid_data.Psat:
if not model.indomain(sometemperature): continue # This should do the trick!
try:
print('Methematical model:', model.name)
print('Temperature limits (min, max):', model.Tmin, model.Tmax)
print('Saturation pressure at T=' + str(sometemperature) + ' K:', model(T=sometemperature))
if sometemperature < model.Tmin:
print('There is no warning for minimum temperature!')
elif sometemperature > model.Tmax:
print('There is no warning for maximum temperature!')
except (ValueError, FloatingPointError, OverflowError) as e:
print('ERROR: ' + str(e))
print('*' * 25)
print('Sufrace tension')
print('*' * 25)
for model in fluid_data.sigma:
if not model.indomain(sometemperature): continue # This should do the trick!
try:
print('Methematical model:', model.name)
print('Temperature limits (min, max):', model.Tmin, model.Tmax)
print('Surface tension at T=' + str(sometemperature) + ' K:', model(T=sometemperature))
if sometemperature < model.Tmin:
print('There is no warning for minimum temperature!')
elif sometemperature > model.Tmax:
print('There is no warning for maximum temperature!')
except (ValueError, FloatingPointError, OverflowError) as e:
print('ERROR: ' + str(e))
Although a warning in the models themselves might be nice in some cases, it would mean that either ModelHandles would be double checking the domain to not raise a warning (computationally expensive), or the code would need to be more complex with hidden, no-checking counterparts for the call method and the integrate_by_T, integrate_by_T_over_T objects... So such an enhancement won't be worked on in the near future.
Thanks!
Closing this then, thanks for your explanation.
Hi @yoelcortes, there are warning messages when the user calls
Psat
orsigma
method with a temperature value out of bounds. But I do not get a warning or an error, if my input value is out of bounds for a specific model:While it may not make any sense to call saturation pressure of e.g. water at -100 °C or at T>Tcritical, there is always the chance for a typo to happen. So I feel, that it would be very beneficial for the user to get a warning message, that his input is out of bounds for this specific method, too. In some cases a different error is thrown (for T>Tmax), but there is no hint towards the upper temperature limit. Best regards Francesco
OS: Ubuntu 18.04 LTS Python: 3.8.0 thermosteam: 0.21.1