Hello. I wanted a python module by which I could access thermodynamic properties of steam. On googling I came across this module called thermopy
http://packages.python.org/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 .
I needed an online data – book which I could scrape steam data . My friend Tejas helped me out , when I had almost lost hope. http://www.ohio.edu/mechanical/thermo/property_tables/H2O/H2O_PresSat1.html , 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 = re.search(line , raw_string) if a: print a.group(1)
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 = shelve.open('a.dat') raw_string = 'ALIGN=RIGHT>(.*)<' for line in file.readlines(): b = re.search(line , raw_string) if b: a['pressure'] = b.group(1) a.close()
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() 0.7183539797807206 print a.GetEnthalpy() 2354.0
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.