# Function to calculate temperature from steamtable look up in Julia

**URL:** <https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [February 7, 2022, 8:38pm UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974 "2022-02-07T20:38:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curio\_math](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curio_math/32/32981_2.png) [@Curio\_math](https://discourse.julialang.org/u/Curio_math)\
**Post date:** [February 7, 2022, 8:38pm UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974/1 "2022-02-07T20:38:10Z")

</div>

I have been using a dynamic mathematical model, where I assume to replace some nonlinear functions corresponding to finding temperature (as a function of pressure and enthalpy) by substituting them with functions inbuild in Julia for this purpose, that is by looking up Julia implementation of steamtable.

I refered **SteamTables.jl** Package, for such a function but could not find any, such that it would render temperature as output, for given pressure and enthalpy as inputs.

Is there any function for the same ? Or any other package recommendations?  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 7, 2022, 10:02pm UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974/2 "2022-02-07T22:02:03Z")

</div>

> [@Curio\_math](#):
>
> I refered **SteamTables.jl** Package, for such a function but could not find any, such that it would render temperature as output, for given pressure and enthalpy as inputs.

It seems to have a function `Tsat(P)`, is that what you want?

Or do you want to invert the function `SpecificH(P, T)` to get a function `T(P, H)`? Assuming it’s invertible, presumably you can do build up the desired inverse function by interpolation (just do root-finding at a sequence of H values and then interpolate).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 7, 2022, 10:16pm UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974/3 "2022-02-07T22:16:06Z")

</div>

> [@stevengj](#):
>
> Assuming it’s invertible …

It’s not obvious to me that this is the case, because there is a discontinuity in enthalpy SpecificH(P, T) across the phase transition…?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [February 7, 2022, 10:23pm UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974/4 "2022-02-07T22:23:14Z")

</div>

See also [https://github.com/braamvandyk/SteamTables.jl/issues/13](https://github.com/braamvandyk/SteamTables.jl/issues/13)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 7, 2022, 11:53pm UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974/5 "2022-02-07T23:53:59Z")

</div>

In the [IAPWS-IF97 reference](http://www.iapws.org/relguide/IF97-Rev.pdf), five regions are defined:

 ![IAPWS-IF97_five_regions](https://global.discourse-cdn.com/julialang/original/3X/a/a/aa1edb94ab6200c7ba920db7a44ec2d47da5e2f1.png)

and backward equations are provided in the forms of T(p,h) and T(p,s) for regions 1 and 2, and Ts(p) for region 4.

---

<div class="post-metadata">

**Author:** ![Curio\_math](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/curio_math/32/32981_2.png) [@Curio\_math](https://discourse.julialang.org/u/Curio_math)\
**Post date:** [February 8, 2022, 5:50am UTC](https://discourse.julialang.org/t/function-to-calculate-temperature-from-steamtable-look-up-in-julia/75974/6 "2022-02-08T05:50:30Z")

</div>

What I need is exactly the second case you suggested, to get a function T(P,H). Have to check if building inverse function using interpolation would help. Thanks for your reply…
