Thermodynamics and Python

Hello. I wanted a python module by which I could access thermodynamic properties of steam. On googling I came across this module called thermopy  .  But the range of temperatures and pressure  which I could use was very limited.  Then I came across this library , called freesteam , which I couldn’t install , though I tried really hard. So I thought I would write my own mini- module to access the properties of steam .

Step 1:

I needed an online data – book which I could scrape steam data . My friend Tejas helped me out , when I had almost lost hope.  , this was the link I used . If one examines the html of the page , it isnt tough to scrape the required date. BeautifulSoup (Ive forgotten most of it , thats a different issue) , a simple regular expression would do.

import re
raw_string = 'ALIGN=RIGHT>(.*)<'
for line in file.readlines():
 a = , raw_string)
 if a:

Step 2:

After extracting the data storing it in a .dat file . This can be quite easily done with the help of the shelve module . For example in the previous code , if one replaces a couple of lines it would get stored in a .dat file as a dictionary.

import re
<pre>import shelve
a ='a.dat')
raw_string = 'ALIGN=RIGHT>(.*)<'
for line in file.readlines():
    b = , raw_string)
    if b:
        a['pressure'] =

Step 3:
Using the .dat files to use access various properties.This can be really confusing at times. Since there are multiple
lists. It took some time before I could finally implement it.

So here is the sourcecode.
Couldnt upload the .py file , ill put it on git soon. I will also improve the documentation and try to improvise it.

This is how the module should be used.

import thermo
a = thermo.State(T = 300 , h = 2354)
print a.GetQuality()
print a.GetEnthalpy()

P.S : You need not be an awesome coder like many people in my college to write simple apps like these , you just need to
spend a lot of time.



  1. I do not even understand how I ended up right here, but I believed this submit was good.

    I do not recognize who you might be but certainly you are going to a famous blogger in the event you aren’t already. Cheers!

  2. PRO!!!

  3. Marcos · · Reply


    1. What is cool?

  4. DC_energia · · Reply

    Simply: THANKS!

  5. bapossatto · · Reply

    you might be interested in CoolProp …

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: