jjgomera/iapws

why we need confirm the boundary before use fundamental equations?

Closed this issue · 2 comments

function _Region1(T, P) and _Region2(T, P) have the same Var, why we need run iapws97._Bound_TP first?
https://images2018.cnblogs.com/blog/1285395/201804/1285395-20180404221857518-2043536130.png
In the steam-water property curve, one T and one P to one point.

def t_ps(self, p, s):
"""temperature as a function of pressure and entropy"""
p = self.unitConverter.toSIunit_p(p)
s = self.unitConverter.toSIunit_s(s)
region = RegionSelection.region_ps(p, s)
if region == 1:
return self.unitConverter.fromSIunit_T(Region1.T1_ps(p, s))
elif region == 2:
return self.unitConverter.fromSIunit_T(Region2.T2_ps(p, s))
elif region == 3:
return self.unitConverter.fromSIunit_T(Region3.T3_ps(p, s))
elif region == 4:
return self.unitConverter.fromSIunit_T(Region4.T4_p(p))
elif region == 5:
return self.unitConverter.fromSIunit_T(Region5.T5_ps(p, s))
else:
self.logger.warning("Region switch t_ps returned unknown value: {:d}".format(region))
return float("NaN")

why not select the Region automatic?

Hi,

In first post, how do you know in advance the region of a point with known T and P? So, what region fundamental equation we must use for a input pair T-P..., a example:

In [1]: from iapws.iapws97 import _Bound_TP, _Region1, _Region2

In [2]: _Bound_TP(400, 0.25)
Out[2]: 1

In [3]: _Region1(400, 0.25)
Out[3]: 
{'P': 0.25,
 'T': 400,
 'alfav': 0.0008950992641466376,
 'cp': 4.258735446068072,
 'cv': 3.6347956857246033,
 'h': 532.9494783465037,
 'kt': 0.0005478918651168938,
 'region': 1,
 's': 1.6012208895258233,
 'v': 0.00106668238306045,
 'w': 1510.3251848919394,
 'x': 0}

In [4]: _Region2(400, 0.25)
Out[4]: 
{'P': 0.25,
 'T': 400,
 'alfav': 0.002881661628961307,
 'cp': 2.2246293455593698,
 'cv': 1.6472320828749782,
 'h': 2715.2477890373757,
 'kt': 4.127743696869426,
 'region': 2,
 's': 7.049276864297086,
 'v': 0.7175323481142449,
 'w': 484.5245821714653,
 'x': 1}

In [5]: _Region1(400, 0.25)["cp"], _Region2(400, 0.25)["cp"]
Out[5]: (4.258735446068072, 2.2246293455593698)

So, what's the correct value of cp for water a 400K and 0.25MPa?

Obviously, if you know the region you can bypass the region checking using the internal method of iapws.

About the second post, I don't understand the question, by the way, is that code yours?