jjgomera/iapws

Is it possible to extract thermodynamic data for metastable liquid/gas phases?

Closed this issue · 3 comments

Thank you for this package. I have a question, not a bug. I am using the package to teach a course on thermodynamics, where I demonstrate things based on “real” data. I am not too familiar with the IAPWS formulas, since I only use this for a course. When I calculate, e.g., an isobar with

p = 0.1
T = np.linspace(253.15, 773.15, 100)
G = [iapws.iapws95.IAPWS95_PT(p, T_i).g for T_i in T]

there is obviously a discontinuity in G when the water evaporates (and a corresponding jump in S etc). For didactic reasons, I would like to plot G, S, cp, … in the metastable regions, too. The functions looks like they must be piecewise defined (for liquid and gas), but I cannot find how to access the individual functions. For ice (iapws._iapws._Ice), I can get the free energies over the whole range. I appreciate that these might be unreliable extrapolations, but I just want to demonstrate things like ΔG in undercooling etc. Can this be done with this package?

Hi,
you can do easily using iapws97, using directly the different region correlations

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

In [2]: _Region1(400, 0.1)   # water liquid  at metastable conditions above boiling point
Out[2]: 
{'T': 400,
 'P': 0.1,
 'v': 0.001066770077006482,
 'h': 532.8467717759336,
 's': 1.601364145433787,
 'cp': 4.259137661887794,
 'cv': 3.6349635158871316,
 'w': 1509.9697825944884,
 'alfav': 0.0008954997036707562,
 'kt': 0.0005482213360900553,
 'region': 1,
 'x': 0}

In [3]: _Region2(360, 0.1)    # vapor below its condesnation temperature
Out[3]: 
{'T': 360,
 'P': 0.1,
 'v': 1.6306206277775008,
 'h': 2647.9037232659953,
 's': 7.284968650485413,
 'cp': 2.186403602666266,
 'cv': 1.6362893769523013,
 'w': 461.97557061124303,
 'alfav': 0.0030930809673336878,
 'kt': 10.209045379140832,
 'region': 2,
 'x': 1}

For region3 there is a little more unusable because need density and temperature as input parameter
For region 2 exist a special correlation for metastable states dont implemented in this library, working of that...

Done, now you can use the special correlation for vapor in metastable state:

In [1]: from iapws.iapws97 import _Region2_meta

In [2]: _Region2_meta(360, 0.101325)
Out[2]: 
{'T': 360,
 'P': 0.101325,
 'v': 1.6087447325890363,
 'h': 2647.655107910522,
 's': 7.278320647817223,
 'cp': 2.1680156708391864,
 'cv': 1.619240492418992,
 'w': 462.3206487379948,
 'alfav': 0.0030901404516094693,
 'kt': 10.077472402997257,
 'region': 2,
 'x': 1}

Wow, thanks for the quick response and implementation. That appears to be exactly what I need, works well in my testing.