#example 1
#work done by steam
hi=3051.2 #initial specific heat of enthalpy of steam in kJ/kg
si=7.1228 #initial specific entropy of steam in kJ/kg-K
Pe=0.15 #final pressure in MPa
se=si #specific entropy in final state in kJ/kg-K
sf=1.4335 #in kJ/kg-K
sfg=5.7897 #in kJ/kg-K
vi=50.0 #velocity with which steam enters turbine in m/s
ve=200.0 #velocity with which steam leaves the turbine in m/s
xe=(se-sf)/sfg #quality of steam in final state
hf=467.1 #in kJ/kg
hfg=2226.5 #in kJ/kg
he=hf+xe*hfg #final specific heat of enthalpy of steam in kJ/kg
w=hi+vi**2/(2*1000)-he-ve**2/(2*1000) #work of steam for isentropic process in kJ/kg
print"\n hence, work per kilogram of steam for this isentropic process is",round(w,1),"KJ/kg"
#example 2
#exit velocity of steam from nozzle
hi=3051.2 #initial specific heat of enthalpy in kJ/kg
si=7.1228 #initial specific entropy in kJ/kg-K
se=si #final specific entropy
Pe=0.3 #final pressure in MPa
print"from steam table,various properties at final state are"
he=2780.2 #final specific heat of enthalpy in kJ/kg-K
Te=159.1 #final temperature in celsius
vi=30.0 #velocity with which steam enters the nozzle in m/s
ve=((2*(hi-he)+(vi**2/1000))*1000)**0.5 #final velocity of steam with which it exits in m/s
print"\n hence,exit velocity of the steam from the nozzle is",round(ve),"m/s"
#example 2E
#exit velocity of steam from nozzle
hi=1279.1 #initial specific heat of enthalpy in Btu/lbm
si=1.7085 #initial specific entropy in Btu/lbm R
se=si #final specific entropy
Pe=40 #final pressure in lbf/in^2
he=1193.9 #final specific heat of enthalpy in Btu/lbm
Te=314.2 #final temperature in F
vi=100.0 #velocity with which steam enters the nozzle in ft/s
ve=((2*((hi-he)+(vi**2/(32.17*778)))*(32.17*778)))**0.5 #final velocity of steam with which it exits in ft/s
print"\n hence,exit velocity of the steam from the nozzle is",round(ve),"ft/s"
#example 3
#violation of second law
print"from R-134a tables"
se=1.7148 #specific entropy in final state in kJ/kg-K
si=1.7395 #initial specific entropy in kJ/kg-K
print"therefore,se<si,whereas for this process the second law requires that se>=si.The process described involves a violation of the second law and thus would be impossible."
#example 4
#calculating required specific work
Cp=1.004 #specific heat of air at constant pressure in kJ/kg-K
Ti=290 #initial temperature in kelvins
Pi=100 #initial pressure in kPa
Pe=1000 #final pressure in kPa
k=1.4
Te=Ti*(Pe/Pi)**((k-1)/k) #final temperature in kelvins
we=Cp*(Ti-Te) #required specific work in kJ/kg
print"\n hence,specific work required is",round(we),"kJ/kg"
#example 4E
#calculating required specific work
Cp=0.24 #specific heat of air at constant pressure in Btu/lbm R
Ti=520 #initial temperature in R
Pi=14.7 #initial pressure in lbf/in^2
Pe=147 #final pressure in lbf/in^2
k=1.4
Te=Ti*(Pe/Pi)**((k-1)/k) #final temperature in R
we=Cp*(Ti-Te) #required specific work in Btu/lbm
print"\n hence,specific work required is",round(we,2),"Btu/lbm"
#example 5
#entropy generation
h1=2865.54 #specific heat of enthalpy at state 1 in kJ/kg
h2=83.94 #specific heat of enthalpy at state 2 in kJ/kg
h3=2725.3 #specific heat of enthalpy at state 3 in kJ?kg
s1=7.3115 #specific entropy at state 1 in kJ/kg-K
s2=0.2966 #specific entropy at state 2 in kJ/kg-K
s3=6.9918 #specific entropy at state 3in kJ/kg-K
m1=2 #mass flow rate at state 1 in kg/s
m2=m1*(h1-h3)/(h3-h2) #mass flow rate at state 2 in kg/s
m3=m1+m2 #mass flow rate at state 3 in kg/s
Sgen=m3*s3-m1*s1-m2*s2 #entropy generation in the process
print"\n hence,entropy generated in this process is ",round(Sgen,3),"kW/K"
#example 6
#work required to fill the tank
import math
T1=17+273 #initial temperature of tank in Kelvins
sT1=6.83521 #specific entropy in kJ/kg-K
R=0.287 #gas constant in kJ/kg-K
P1=100 #initial pressure in kPa
P2=1000 #final pressure in kPa
sT2=sT1+R*math.log(P2/P1) #specific entropy at temperature T2 in kJ/kg-K
T2=555.7 #from interplotation
V1=0.04 #volume of tank in m^3
V2=V1 #final volume is equal to initial volume
m1=P1*V1/(R*T1) #initial mass of air in tank in kg
m2=P2*V2/(R*T2) #final mass of air in tank in kg
Min=m2-m1 #in kg
u1=207.19 #initial specific heat of enthalpy in kJ/kg
u2=401.49 #final specific heat of enthalpy in kJ/kg
hin=290.43 #in kJ/kg
W12=Min*hin+m1*u1-m2*u2 #work required to fill the tank in kJ
print"\n hence,the total amount of work required to fill the tank is",round(W12,1),"kJ"
#example 7
#work required to pump water isentropically
P1=100 #initial pressure in kPa
P2=5000 #final pressure in kPa
v=0.001004 #specific volume in m^3/kg
w=v*(P2-P1) #work required to pump water isentropically
print"\n hence,work required to pump water isentropically is ",round(w,2),"kJ/kg"
#example 8
#Velocity in exit flow
print"From Steam Tables, for liquid water at 20 C"
vf=0.001002 #in m^3/kg
v=vf
Pi=300 #Line pressure in kPa
Po=100 #in kPa
Ve=(2*v*(Pi-Po)*1000)**0.5 #velocity in the exit flow
print" \n Hence, an ideal nozzle can generate upto ",round(Ve),"m/s"
#example 9
#Rate of Entropy Generation
print"From R-410a tables,we get"
hi=280.6 #in kJ/kg
he=307.8 #in kJ/kg
si=1.0272 #in kJ/kg
se=1.0140 #in kJ/kg
m=0.08 #flow rate of refrigerant in kg/s
P=3 #electrical power input in kW
Qcv=m*(he-hi)-P #in kW
To=30 #in Celsius
Sgen=m*(se-si)-Qcv/(To+273.2) #rate of entropy generation
print"\n Hence,the rate of entropy generation for this process is",round(Sgen,5),"kW/K"
#example 10
#turbine efficiency
hi=3051.2 #initial specific heat of enthalpy in kJ/kg
si=7.1228 #initial specific entropy in kJ/kg-K
sf=0.7548 #in kJ/kg-K
sfg=7.2536 #in kJ/kg-K
ses=si #final specific entropy is same as the initial
xes=(si-sf)/sfg #quality of steam when it leaves the turbine
hf=225.9 #in kJ/kg
hfg=2373.1 #in kJ/kg
hes=hf+xes*hfg #final specific heat of enthalpy in kJ/kg
ws=hi-hes #work output of turbine calculated ideally in kJ/kg
wa=600 #actual work output of turbine in kJ/kg
nturbine=wa/ws #efiiciency of turbine
print"\n hence,efficiency of the turbine is",round(nturbine*100,1),"%"
#example 11
#turbine inlet pressure
import math
hi=1757.3 #initial specific heat of enthalpy of air in kJ/kg
si=8.6905 #initial specifc entropy of airin kJ/kg-K
he=855.3 #final specific heat of enthalpy of air in kJ/kg
w=hi-he #actual work done by turbine in kJ/kg
n=0.85 #efficiency of turbine
ws=w/n #ideal work done by turbine in kJ/kg
hes=hi-ws #from first law of isentropic process
Tes=683.7 #final temperature in kelvins from air tables
ses=7.7148 #in kJ/kg-K
R=0.287 #gas constant in kJ/kg-K
Pi=100/math.e**((si-ses)/-R) #turbine inlet pressure in kPa
print"\n hence,turbine inlet pressure is",round(Pi),"kPa"
#example 12
#required work input
Pe=150.0 #final pressure of air in kPa
Pi=100.0 #initial presure of air in kPa
k=1.4
Ti=300.0 #initial temperature of air in kelvis
Tes=Ti*(Pe/Pi)**((k-1)/k) #from second law
ws=1.004*(Ti-Tes) #from first law of isentropic process
n=0.7 #efficiency of automotive supercharger
w=ws/n #real work input in kJ/kg
Te=Ti-w/1.004 #temperature at supercharger exit in K
print"\n hence,required work input is ",round(w),"kJ/kg"
print"\n and exit temperature is ",round(Te,1),"K"