THERMODYNAMICS AND STEAM TABLE USE IN PYTHON

 STEAM TABLE USE IN PYTHON

IAPWS = The International Association for the Properties of Water and Steam

make sure that you first install this library in your pc 

pip install iapws 

Some standard

here T = temperature (K) #all temperature are used herein Kelvin so you have to manually convert them as per your requirement

P = pressure (MPa) #all pressure units are available in this library are in Mega Pascal

h = enthalpy (kj/kg) #all enthalpy units are available in kj/kg

x = dryness fraction (unitless)

s = entropy kj/kgK

from iapws import IAPWS97 #1

T1 = 100+273  #2      100°C  converting into Kelving

a = IAPWS97(T =T1,x=.5) #3

P1 =  a.P #4

h = a.h #5

s1 = a.s #6

print('pressue',P1,'enthalpy',h,'entropy ',s1) #7

output : pressue 0.10087630072581115 enthalpy 1546.900746838229 entropy 4.3305976268584105

let's try to understand what is going on in the code

#1 basically we as are calling iapws and using iapws97 steam standard

#2  we are defining two points and with the help of this we will find out the other properties

make sure you use correct syntax here i have given temperature in K (kelvin) and x (dryness fraction)

so basically what i told to library that i have steam that is temperature 373K and at dryness fraction of 0.5

#4 to 7 now i simply  use a (where i store the two coordinates ) to find pressure ,enthalpy and entropy


what if you want to know specific volume of fluid and  specific volume of vapour ?

we know that at specific volume of fluid[vf] (x = 0) and at specific volume of vapour[vg] (x =1) for supersatured (x>1)

just put the value of x in the above parameter in code 

and type a.v


what is i don't put x = 0 and 1 .but put the value in between it

if you do that then specific volume that is given by this formla v = vf + x(vg - vf)

 

Now let's make it more complex

from iapws import IAPWS97

import numpy as np

from matplotlib.pyplot import*


figure()

clf()

T = np.linspace(300, 372+273, 200) # range of temperatures

for P in [0.1, 1, 2, 5, 10, 20]:

    steam = [IAPWS97(T=t, P=P) for t in T]

    S = [s.s for s in steam]

    plot(S, T, 'k-')#MPa



# saturated vapor and liquid entropy lines

svap = [s.s for s in [IAPWS97(T=t, x=1) for t in T]]

sliq = [s.s for s in [IAPWS97(T=t, x=0) for t in T]]


plot(svap, T, 'r-')

plot(sliq, T, 'b-')


xlabel('Entropy (kJ/(kg K)')

ylabel('Temperature (K)')

show()



here we basically matplotlib.pyplot to use graph and various kind of loop

from code comment eveything is clear if you still have any doubts and query just comment i will try to help 


check out my video for more information



Post a Comment

0 Comments