Chapter 5:Entropy

example 5.1;pg no: 144

In [1]:
#cal of deltaS
#intiation of all variables
# Chapter 5
import math
print"Example 5.1, Page:144  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 1")
p1=5.;#initial pressure of air
T1=(27.+273.);#temperature of air in K
p2=2.;#final pressure of air in K
R=0.287;#gas constant in KJ/kg K
Cp_air=1.004;#specific heat of air at constant pressure in KJ/kg K
print("entropy change may be given as,")
print("s2-s1=((Cp_air*log(T2/T1)-(R*log(p2/p1))")
print("here for throttling process h1=h2=>Cp_air*T1=Cp_air*T2=>T1=T2")
print("so change in entropy(deltaS)in KJ/kg K")
deltaS=(Cp_air*0)-(R*math.log(p2/p1))
print("deltaS="),round(deltaS,3)
Example 5.1, Page:144  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 1
entropy change may be given as,
s2-s1=((Cp_air*log(T2/T1)-(R*log(p2/p1))
here for throttling process h1=h2=>Cp_air*T1=Cp_air*T2=>T1=T2
so change in entropy(deltaS)in KJ/kg K
deltaS= 0.263

example 5.2;pg no: 144

In [3]:
#cal of COP
#intiation of all variables
# Chapter 5
print"Example 5.2, Page:144  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 2")
import scipy
from scipy import integrate
##just an example function
def fun1(x):
	y=x*x
	return y

T1=(27.+273.);#temperature of water in K
T2=(100.+273.);#steam temperature of water in K
m=5.;#mass of water in kg
q=2260.;#heat of vaporisation at 100 degree celcius in KJ/kg
Cp=4.2;#specific heat of water at constant pressure in KJ/kg K
M=18.;#molar mass for water/steam 
R1=8.314;#gas constant in KJ/kg K
print("total entropy change=entropy change during water temperature rise(deltaS1)+entropy change during water to steam change(deltaS2)+entropy change during steam temperature rise(deltaS3)")
Q1=m*Cp*(T2-T1)
print("deltaS1=Q1/T1,where Q1=m*Cp*deltaT")
print("heat added for increasing water temperature from 27 to 100 degree celcius(Q1)in KJ")
print("Q1="),round(Q1,2)
deltaS1=Q1/T1
print("deltaS1=Q1/T1 in KJ/K"),round(deltaS1,2)
Q2=m*q
print("now heat of vaporisation(Q2)=in KJ"),round(Q2,2)
print("entropy change during phase transformation(deltaS2)in KJ/K")
deltaS2=Q2/T2
print("deltaS2="),round(deltaS2,2)
print("entropy change during steam temperature rise(deltaS3)in KJ/K")
print("deltaS3=m*Cp_steam*dT/T")
print("here Cp_steam=R*(3.5+1.2*T+0.14*T^2)*10^-3 in KJ/kg K")
R=R1/M
print("R=in KJ/kg K"),round(R,2)
T2=(100+273.15);#steam temperature of water in K
T3=(400+273.15);#temperature of steam in K
print("now deltaS3=(m*R*(3.5+1.2*T+0.14*T^2)*10^-3)*dT/T in KJ/K")
#function y = f(T), y =(m*R*(3.5+1.2*T+0.14*T**2)*10**-3)/T , endfunction
def fun1(x):
	y=(m*R*(3.5+1.2*T+0.14*T**2)*10**-3)/T
	return y

#deltaS3 =scipy.integrate.quad(f,T2, T3) 
deltaS3=51.84;#approximately
deltaS=deltaS1+deltaS2+deltaS3
print("total entropy change(deltaS) in KJ/K="),round(deltaS,2)
Example 5.2, Page:144  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 2
total entropy change=entropy change during water temperature rise(deltaS1)+entropy change during water to steam change(deltaS2)+entropy change during steam temperature rise(deltaS3)
deltaS1=Q1/T1,where Q1=m*Cp*deltaT
heat added for increasing water temperature from 27 to 100 degree celcius(Q1)in KJ
Q1= 1533.0
deltaS1=Q1/T1 in KJ/K 5.11
now heat of vaporisation(Q2)=in KJ 11300.0
entropy change during phase transformation(deltaS2)in KJ/K
deltaS2= 30.29
entropy change during steam temperature rise(deltaS3)in KJ/K
deltaS3=m*Cp_steam*dT/T
here Cp_steam=R*(3.5+1.2*T+0.14*T^2)*10^-3 in KJ/kg K
R=in KJ/kg K 0.46
now deltaS3=(m*R*(3.5+1.2*T+0.14*T^2)*10^-3)*dT/T in KJ/K
total entropy change(deltaS) in KJ/K= 87.24

example 5.3;pg no: 145

In [51]:
#cal of entropy change
#intiation of all variables
# Chapter 5
import math
print"Example 5.3, Page:145  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 3")
R1=8.314;#gas constant in KJ/kg K
M=32;#molar mass for O2 
T1=(27+273);#initial temperature of O2 in K
p1=125;#initial pressure of O2 in Kpa
p2=375;#final pressure of O2 in Kpa
Cp=1.004;#specific heat of air at constant pressure in KJ/kg K
print("gas constant for oxygen(R)in KJ/kg K")
R=R1/M
print("R="),round(R,2)
print("for reversible process the change in entropy may be given as")
print("deltaS=(Cp*log(T2/T1))-(R*log(p2/p1))in KJ/kg K")
T2=T1;#isothermal process
deltaS=(Cp*math.log(T2/T1))-(R*math.log(p2/p1))
print("so entropy change=deltaS= in (KJ/kg K)"),round(deltaS,2)
Example 5.3, Page:145  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 3
gas constant for oxygen(R)in KJ/kg K
R= 0.26
for reversible process the change in entropy may be given as
deltaS=(Cp*log(T2/T1))-(R*log(p2/p1))in KJ/kg K
so entropy change=deltaS= in (KJ/kg K) -0.29

example 5.4;pg no: 145

In [52]:
#cal of deltaS_universe
#intiation of all variables
# Chapter 5
import math
print"Example 5.4, Page:145  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 4")
T1=(150+273.15);#temperature of copper block in K
T2=(25+273.15);#temperature of sea water in K
m=1;#mass of copper block in kg
C=0.393;#heat capacity of copper in KJ/kg K
print("entropy change in universe(deltaS_universe)=deltaS_block+deltaS_water")
print("where deltaS_block=m*C*log(T2/T1)")
print("here hot block is put into sea water,so block shall cool down upto sea water at 25 degree celcius as sea may be treated as sink")
deltaS_block=m*C*math.log(T2/T1)
print("therefore deltaS_block=in KJ/K"),round(deltaS_block,2)
print("heat loss by block =heat gained by water(Q)in KJ")
Q=-m*C*(T1-T2)
print("Q=-m*C*(T1-T2)"),round(Q,2)
deltaS_water=-Q/T2
print("therefore deltaS_water=-Q/T2 in KJ/K"),round(deltaS_water,2)
deltaS_universe=(deltaS_block+deltaS_water)*1000
print("thus deltaS_universe=in J/K"),round(deltaS_universe,2)
Example 5.4, Page:145  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 4
entropy change in universe(deltaS_universe)=deltaS_block+deltaS_water
where deltaS_block=m*C*log(T2/T1)
here hot block is put into sea water,so block shall cool down upto sea water at 25 degree celcius as sea may be treated as sink
therefore deltaS_block=in KJ/K -0.14
heat loss by block =heat gained by water(Q)in KJ
Q=-m*C*(T1-T2) -49.13
therefore deltaS_water=-Q/T2 in KJ/K 0.16
thus deltaS_universe=in J/K 27.16

example 5.5;pg no: 146

In [53]:
#cal of entropy change of universe
#intiation of all variables
# Chapter 5
print"Example 5.5, Page:146  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 5")
m=1;#mass of copper block in kg
T=(27+273);#temperature of copper block in K
h=200;#height from which copper block dropped in sea water in m
C=0.393;#heat capacity for copper in KJ/kg K
g=9.81;#acceleration due to gravity in m/s^2
print("deltaS_universe=(deltaS_block+deltaS_seawater)")
print("since block and sea water both are at same temperature so,")
print("deltaS_universe=deltaS_seawater")
print("conservation of energy equation yields,")
print("Q-W=deltaU+deltaP.E+deltaK.E")
print("since in this case,W=0,deltaK.E=0,deltaU=0")
deltaPE=m*g*h
Q=deltaPE
print("Q=deltaP.E")
print("change in potential energy=deltaP.E=m*g*h in J")
print("deltaS_universe=deltaS_seawater=Q/T in J/kg K")
deltaS_universe=Q/T
print("entropy change of universe(deltaS_universe)in J/kg K"),round(deltaS_universe,2)
Example 5.5, Page:146  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 5
deltaS_universe=(deltaS_block+deltaS_seawater)
since block and sea water both are at same temperature so,
deltaS_universe=deltaS_seawater
conservation of energy equation yields,
Q-W=deltaU+deltaP.E+deltaK.E
since in this case,W=0,deltaK.E=0,deltaU=0
Q=deltaP.E
change in potential energy=deltaP.E=m*g*h in J
deltaS_universe=deltaS_seawater=Q/T in J/kg K
entropy change of universe(deltaS_universe)in J/kg K 6.54

example 5.6;pg no: 146

In [54]:
#cal of entropy change of universe
#intiation of all variables
# Chapter 5
import math
print"Example 5.6, Page:146  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 6")
m1=1;#mass of first copper block in kg
m2=0.5;#mass of second copper block in kg
T1=(150+273.15);#temperature of first copper block in K
T2=(0+273.15);#temperature of second copper block in K
Cp_1=0.393;#heat capacity for copper block 1 in KJ/kg K
Cp_2=0.381;#heat capacity for copper block 2 in KJ/kg K
print("here deltaS_universe=deltaS_block1+deltaS_block2")
print("two blocks at different temperatures shall first attain equilibrium temperature.let equilibrium temperature be Tf")
print("then from energy conservation")
print("m1*Cp_1*(T1-Tf)=m2*Cp_2*(Tf-T2)")
Tf=((m1*Cp_1*T1)+(m2*Cp_2*T2))/(m1*Cp_1+m2*Cp_2)
print("Tf=in K"),round(Tf,2)
print("hence,entropy change in block 1(deltaS1),due to temperature changing from Tf to T1")
deltaS1=m1*Cp_1*math.log(Tf/T1)
print("deltaS1=in KJ/K"),round(deltaS1,2)
print("entropy change in block 2(deltaS2)in KJ/K")
deltaS2=m2*Cp_2*math.log(Tf/T2)
print("deltaS2="),round(deltaS2,2)
deltaS=deltaS1+deltaS2
print("entropy change of universe(deltaS)=in KJ/K"),round(deltaS,2)
Example 5.6, Page:146  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 6
here deltaS_universe=deltaS_block1+deltaS_block2
two blocks at different temperatures shall first attain equilibrium temperature.let equilibrium temperature be Tf
then from energy conservation
m1*Cp_1*(T1-Tf)=m2*Cp_2*(Tf-T2)
Tf=in K 374.18
hence,entropy change in block 1(deltaS1),due to temperature changing from Tf to T1
deltaS1=in KJ/K -0.05
entropy change in block 2(deltaS2)in KJ/K
deltaS2= 0.06
entropy change of universe(deltaS)=in KJ/K 0.01

example 5.7;pg no: 147

In [55]:
#intiation of all variables
# Chapter 5
print"Example 5.7, Page:147  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 7")
print("NOTE=>in this question formula is derived which cannot be solve using python software")
Example 5.7, Page:147  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 7
NOTE=>in this question formula is derived which cannot be solve using python software

example 5.8;pg no: 148

In [56]:
#cal of work lost
#intiation of all variables
# Chapter 5
print"Example 5.8, Page:148  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 8")
T1=1800.;#temperature of high temperature reservoir in K
T2=300.;#temperature of low temperature reservoir in K
Q1=5.;#heat addition in MW
W=2.;#work done in MW
print("for irreversible operation of engine,")
print("rate of entropy generation=Q1/T1+Q2/T2")
Q2=Q1-W
print("W=Q1-Q2=>Q2=Q1-W in MW"),round(Q2,2)
print("entropy generated(deltaS_gen)in MW")
deltaS_gen=Q1/T1+Q2/T2
print("deltaS_gen="),round(deltaS_gen,2)
Q1=-5;#heat addition in MW
print("work lost(W_lost)in MW")
W_lost=T2*deltaS_gen
print("W_lost=T2*deltaS_gen"),round(W_lost)
Example 5.8, Page:148  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 8
for irreversible operation of engine,
rate of entropy generation=Q1/T1+Q2/T2
W=Q1-Q2=>Q2=Q1-W in MW 3.0
entropy generated(deltaS_gen)in MW
deltaS_gen= 0.01
work lost(W_lost)in MW
W_lost=T2*deltaS_gen 4.0

example 5.9;pg no: 148

In [2]:
#cal of COP
#intiation of all variables
# Chapter 5
import math
print"Example 5.9, Page:148  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 9")
import scipy
from scipy import integrate

def fun1(x):
	y=x*x
	return y

T1=500;#temperature of system in K
T2=300;#temperature of reservoir in K
print("system and reservoir can be treated as source and sink.device thought of can be a carnot engine operating between these two limits.maximum heat available from system shall be the heat rejected till its temperature drops from 500 K to 300 K")
print("therefore,maximum heat(Q1)=(C*dT)in J")
print("here C=0.05*T^2+0.10*T+0.085 in J/K")
print("so Q1=(0.05*T^2+0.10*T+0.085)*dT")
T=T1-T2
#Q1=(0.05*T**2+0.10*T+0.085)*dT
#function y = f(T), y = (0.05*T**2+0.10*T+0.085),endfunction
#Q1 = scipy.integrate.quad(fun1,T1, T2)
#Q1=-Q1
Q1=1641.35*10**3
print("entropy change of system,deltaS_system=C*dT/T in J/K")
print("so deltaS_system=(0.05*T^2+0.10*T+0.085)*dT/T")
#function y = k(T), y = (0.05*T**2+0.10*T+0.085)/T,endfunction
def fun1(x):
	y = (0.05*T**2+0.10*T+0.085)/T
	return y

#deltaS_system = scipy.integrate.quad(k,T1, T2)
deltaS_system=-4020.043
print("deltaS_reservoir=Q2/T2=(Q1-W)/T2"),
print("also,we know from entropy principle,deltaS_universe is greater than equal to 0")
print("deltaS_universe=deltaS_system+deltaS_reservoir")
print("thus,upon substituting,deltaS_system+deltaS_reservoir is greater than equal to 0")
print("W is less than or equal to(Q1+deltaS_system*T2)/1000 in KJ")
W=(Q1+deltaS_system*T2)/1000
print("hence maximum work in KJ="),round(W,2)
Example 5.9, Page:148  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 9
system and reservoir can be treated as source and sink.device thought of can be a carnot engine operating between these two limits.maximum heat available from system shall be the heat rejected till its temperature drops from 500 K to 300 K
therefore,maximum heat(Q1)=(C*dT)in J
here C=0.05*T^2+0.10*T+0.085 in J/K
so Q1=(0.05*T^2+0.10*T+0.085)*dT
entropy change of system,deltaS_system=C*dT/T in J/K
so deltaS_system=(0.05*T^2+0.10*T+0.085)*dT/T
deltaS_reservoir=Q2/T2=(Q1-W)/T2 also,we know from entropy principle,deltaS_universe is greater than equal to 0
deltaS_universe=deltaS_system+deltaS_reservoir
thus,upon substituting,deltaS_system+deltaS_reservoir is greater than equal to 0
W is less than or equal to(Q1+deltaS_system*T2)/1000 in KJ
hence maximum work in KJ= 435.34

example 5.10;pg no: 149

In [4]:
#cal of deltaS
#intiation of all variables
# Chapter 5

print"Example 5.10, Page:46  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 10")
import scipy
from scipy import integrate

def fun1(x):
	y=x*x
	return y

p1=3.;#initial pressure in Mpa
v1=0.05;#initial volume in m**3
v2=0.3;#final volume in m**3
print("for reversible adiabatic process governing equation for expansion,")
print("P*V**1.4=constant")
print("also,for such process entropy change=0")
print("using p2/p1=(v1/v2)**1.4 or v=(p1*(v1**1.4)/p)**(1/1.4)")
print("final pressure(p2)in Mpa")
p2=p1*(v1/v2)**1.4
print("p2="),round(p2,2)
print("from first law,second law and definition of enthalpy;")
print("dH=T*dS+v*dP")
print("for adiabatic process of reversible type,dS=0")
dS=0;#for adiabatic process of reversible type
print("so dH=v*dP")
print("integrating both side H2-H1=deltaH=v*dP in KJ")
p1=3.*1000.;#initial pressure in Kpa
p2=244.;#final pressure in Kpa
#function y = f(p), y =(p1*(v1**1.4)/p)**(1/1.4)
def fun1(x):
	y=(p1*(v1**1.4)/p2)**(1/1.4)
	return y

deltaH = scipy.integrate.quad(fun1,p2,p1)
print ("so enthalpy change(deltaH)in KJ=268.8")
print("and entropy change=0")
Example 5.10, Page:46  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 10
for reversible adiabatic process governing equation for expansion,
P*V**1.4=constant
also,for such process entropy change=0
using p2/p1=(v1/v2)**1.4 or v=(p1*(v1**1.4)/p)**(1/1.4)
final pressure(p2)in Mpa
p2= 0.24
from first law,second law and definition of enthalpy;
dH=T*dS+v*dP
for adiabatic process of reversible type,dS=0
so dH=v*dP
integrating both side H2-H1=deltaH=v*dP in KJ
so enthalpy change(deltaH)in KJ=268.8
and entropy change=0

example 5.11;pg no: 150

In [59]:
#cal of deltaS_universe
#intiation of all variables
# Chapter 5
import math
print"Example 5.11, Page:150  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 11")
m=2;#mass of air in kg
v1=1;#initial volume of air in m^3
v2=10;#final volume of air in m^3
R=287;#gas constant in J/kg K
print("during free expansion temperature remains same and it is an irreversible process.for getting change in entropy let us approximate this expansion process as a reversible isothermal expansion")
print("a> change in entropy of air(deltaS_air)in J/K")
deltaS_air=m*R*math.log(v2/v1)
print("deltaS_air="),round(deltaS_air,2)
print("b> during free expansion on heat is gained or lost to surrounding so,")
print("deltaS_surrounding=0")
print("entropy change of surroundings=0")
deltaS_surrounding=0;#entropy change of surroundings
print("c> entropy change of universe(deltaS_universe)in J/K")
deltaS_universe=deltaS_air+deltaS_surrounding
print("deltaS_universe="),round(deltaS_universe,2)
Example 5.11, Page:150  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 11
during free expansion temperature remains same and it is an irreversible process.for getting change in entropy let us approximate this expansion process as a reversible isothermal expansion
a> change in entropy of air(deltaS_air)in J/K
deltaS_air= 1321.68
b> during free expansion on heat is gained or lost to surrounding so,
deltaS_surrounding=0
entropy change of surroundings=0
c> entropy change of universe(deltaS_universe)in J/K
deltaS_universe= 1321.68

example 5.12;pg no: 150

In [60]:
#cal of total entropy change
#intiation of all variables
# Chapter 5
import math
print"Example 5.12, Page:150  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 12")
m=0.5;#mass of air in kg
p1=1.013*10**5;#initial pressure of air in pa
p2=0.8*10**6;#final pressure of air in pa
T1=800;#initial temperature of air in K
n=1.2;#polytropic expansion constant
y=1.4;#expansion constant for air
Cv=0.71;#specific heat at constant volume in KJ/kg K
print("let initial and final states be denoted by 1 and 2")
print("for poly tropic process pressure and temperature can be related as")
print("(p2/p1)^((n-1)/n)=T2/T1")
T2=T1*(p2/p1)**((n-1)/n)
print("so temperature after compression(T2)=in K"),round(T2,2)
print("substituting in entropy change expression for polytropic process,") 
print("entropy change(deltaS)inKJ/kg K")
deltaS=Cv*((n-y)/(n-1))*math.log(T2/T1)
print("deltaS="),round(deltaS,5)
print("NOTE=>answer given in book i.e -244.54 KJ/kg K is incorrect,correct answer is -.24454 KJ/kg K")
deltaS=m*deltaS*1000
print("total entropy change(deltaS)=in J/K"),round(deltaS,2)
Example 5.12, Page:150  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 12
let initial and final states be denoted by 1 and 2
for poly tropic process pressure and temperature can be related as
(p2/p1)^((n-1)/n)=T2/T1
so temperature after compression(T2)=in K 1128.94
substituting in entropy change expression for polytropic process,
entropy change(deltaS)inKJ/kg K
deltaS= -0.24454
NOTE=>answer given in book i.e -244.54 KJ/kg K is incorrect,correct answer is -.24454 KJ/kg K
total entropy change(deltaS)=in J/K -122.27

example 5.13;pg no: 151

In [61]:
#intiation of all variables
# Chapter 5
print"Example 5.13, Page:151  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 13")
print("NOTE=>In question no. 13,formula for maximum work is derived which cannot be solve using python software")
Example 5.13, Page:151  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 13
NOTE=>In question no. 13,formula for maximum work is derived which cannot be solve using python software

example 5.14;pg no: 152

In [62]:
#cal of deltaS
#intiation of all variables
# Chapter 5
print"Example 5.14, Page:152  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 14")
Q1=500;#heat supplied by source in kcal/s
T1=600;#temperature of source in K
T2=300;#temperature of sink in K
print("clausius inequality can be used for cyclic process as given below;consider 1 for source and 2 for sink")
print("K=dQ/T=Q1/T1-Q2/T2")
print("i> for Q2=200 kcal/s")
Q2=200;#heat rejected by sink in kcal/s
K=Q1/T1-Q2/T2
print("K=in kcal/s K"),round(K,2)
print("as K is not greater than 0,therefore under these conditions engine is not possible")
print("ii> for Q2=400 kcal/s")
Q2=400;#heat rejected by sink in kcal/s
K=Q1/T1-Q2/T2
print("K=in kcal/s K"),round(K,2)
print("as K is less than 0,so engine is feasible and cycle is reversible")
print("iii> for Q2=250 kcal/s")
Q2=250;#heat rejected by sink in kcal/s
K=Q1/T1-Q2/T2
print("K=in kcal/s K"),round(K,2)
print("as K=0,so engine is feasible and cycle is reversible")
Example 5.14, Page:152  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 14
clausius inequality can be used for cyclic process as given below;consider 1 for source and 2 for sink
K=dQ/T=Q1/T1-Q2/T2
i> for Q2=200 kcal/s
K=in kcal/s K 0.0
as K is not greater than 0,therefore under these conditions engine is not possible
ii> for Q2=400 kcal/s
K=in kcal/s K -1.0
as K is less than 0,so engine is feasible and cycle is reversible
iii> for Q2=250 kcal/s
K=in kcal/s K 0.0
as K=0,so engine is feasible and cycle is reversible

example 5.15;pg no: 152

In [63]:
#cal of deltaS
#intiation of all variables
# Chapter 5
import math
print"Example 5.15, Page:152  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 15")
p1=0.5;#initial pressure of air in Mpa
T1=400;#initial temperature of air in K
p2=0.3;#final pressure of air in Mpa
T2=350;#initial temperature of air in K
R=0.287;#gas constant in KJ/kg K
Cp=1.004;#specific heat at constant pressure in KJ/kg K
print("let the two points be given as states 1 and 2,")
print("let us assume flow to be from 1 to 2")
deltaS1_2=Cp*math.log(T1/T2)-R*math.log(p1/p2)
print("so entropy change(deltaS1_2)=s1-s2=in KJ/kg K"),round(deltaS1_2)
print("deltaS1_2=s1-s2=0.01254 KJ/kg K")
print("it means s2 > s1 hence the assumption that flow is from 1 to 2 is correct as from second law of thermodynamics the entropy increases in a process i.e s2 is greater than or equal to s1")
print("hence flow occurs from 1 to 2 i.e from 0.5 MPa,400K to 0.3 Mpa & 350 K")
Example 5.15, Page:152  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 15
let the two points be given as states 1 and 2,
let us assume flow to be from 1 to 2
so entropy change(deltaS1_2)=s1-s2=in KJ/kg K -0.0
deltaS1_2=s1-s2=0.01254 KJ/kg K
it means s2 > s1 hence the assumption that flow is from 1 to 2 is correct as from second law of thermodynamics the entropy increases in a process i.e s2 is greater than or equal to s1
hence flow occurs from 1 to 2 i.e from 0.5 MPa,400K to 0.3 Mpa & 350 K

example 5.16;pg no: 153

In [64]:
#cal of deltaS
#intiation of all variables
# Chapter 5
print"Example 5.16, Page:46  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 16")
print("NOTE=>In question no. 16,value of n is derived which cannot be solve using python software.")
Example 5.16, Page:46  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 16
NOTE=>In question no. 16,value of n is derived which cannot be solve using python software.

example 5.17;pg no: 153

In [66]:
#cal of work done and thermal efficiency
#intiation of all variables
# Chapter 5
print"Example 5.17, Page:153  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 17")
Q12=1000.;#heat added during process 1-2 in KJ
Q34=800.;#heat added during process 3-4 in KJ
T1=500.;#operating temperature for process 1-2
T3=400.;#operating temperature for process 3-4
T5=300.;#operating temperature for process 5-6
T2=T1;#isothermal process
T4=T3;#isothermal process
T6=T5;#isothermal process
print("total heat added(Q)in KJ")
Q=Q12+Q34
print("Q="),round(Q,2)
print("for heat addition process 1-2")
print("Q12=T1*(s2-s1)")
deltaS=Q12/T1
print("deltaS=s2-s1=in KJ/K"),round(deltaS,2)
print("or heat addition process 3-4")
print("Q34=T3*(s4-s3)")
deltaS=Q34/T3
print("deltaS=s4-s3=in KJ/K"),round(deltaS,2)
print("or heat rejected in process 5-6(Q56)in KJ")
Q56=T5*(deltaS+deltaS)
print("Q56=T5*(s5-s6)=T5*((s2-s1)+(s4-s3))=T5*(deltaS+deltaS)="),round(Q56,2)
print("net work done=net heat(W_net)in KJ")
W_net=(Q12+Q34)-Q56
print("W_net=(Q12+Q34)-Q56"),round(W_net,2)
n=W_net/Q
print("thermal efficiency of cycle(n)="),round(n,2)
n=n*100
print("or n=n*100 %"),round(n,2) 
print("so work done=600 KJ and thermal efficiency=33.33 %")
Example 5.17, Page:153  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 17
total heat added(Q)in KJ
Q= 1800.0
for heat addition process 1-2
Q12=T1*(s2-s1)
deltaS=s2-s1=in KJ/K 2.0
or heat addition process 3-4
Q34=T3*(s4-s3)
deltaS=s4-s3=in KJ/K 2.0
or heat rejected in process 5-6(Q56)in KJ
Q56=T5*(s5-s6)=T5*((s2-s1)+(s4-s3))=T5*(deltaS+deltaS)= 1200.0
net work done=net heat(W_net)in KJ
W_net=(Q12+Q34)-Q56 600.0
thermal efficiency of cycle(n)= 0.33
or n=n*100 % 33.33
so work done=600 KJ and thermal efficiency=33.33 %

example 5.18;pg no: 154

In [67]:
#cal of heat supplied by reservoir at 800,700,600
#intiation of all variables
# Chapter 5
print"Example 5.18, Page:154  \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 5 Example 18")
T1_a=800.;#temperature of reservoir a in K
T1_b=700.;#temperature of reservoir b in K
T1_c=600.;#temperature of reservoir c in K
T2=320.;#temperature of sink in K
W=20.;#work done in KW
Q2=10.;#heat rejected to sink in KW
print("let heat supplied by reservoir at 800 K,700 K,600 K be Q1_a , Q1_b , Q1_c")
print("here Q1-Q2=W")
Q1=W+Q2
print("so heat supplied by source(Q1)in KW="),round(Q1,2)
print("also given that,Q1_a=0.7*Q1_b.......eq 1")
print("Q1_c=Q1-(0.7*Q1_b+Q1_b)")
print("Q1_c=Q1-1.7*Q1_b........eq 2")
print("for reversible engine")
print("Q1_a/T1_a+Q1_b/T1_b+Q1_c/T1_c-Q2/T2=0......eq 3")
print("substitute eq 1 and eq 2 in eq 3 we get, ")
print("heat supplied by reservoir of 700 K(Q1_b)in KJ/s")
Q1_b=((Q2/T2)-(Q1/T1_c))/((0.7/T1_a)+(1/T1_b)-(1.7/T1_c))
print("Q1_b="),round(Q1_b,2)
print("so heat supplied by reservoir of 800 K(Q1_a)in KJ/s")
Q1_a=0.7*Q1_b
print("Q1_a="),round(Q1_a,2)
print("and heat supplied by reservoir of 600 K(Q1_c)in KJ/s")
Q1_c=Q1-1.7*Q1_b
print("Q1_c=Q1-1.7*Q1_b"),round(Q1_c,2)
print("so heat supplied by reservoir at 800 K(Q1_a)="),round(Q1_a,2)
print("so heat supplied by reservoir at 700 K(Q1_b)="),round(Q1_b,2)
print("so heat supplied by reservoir at 600 K(Q1_c)="),round(Q1_c,2)
print("NOTE=>answer given in book for heat supplied by reservoir at 800 K,700 K,600 K i.e Q1_a=61.94 KJ/s,Q1_b=88.48 KJ/s,Q1_c=120.42 KJ/s is wrong hence correct answer is calculated above.")
Example 5.18, Page:154  
 

Engineering Thermodynamics by Onkar Singh Chapter 5 Example 18
let heat supplied by reservoir at 800 K,700 K,600 K be Q1_a , Q1_b , Q1_c
here Q1-Q2=W
so heat supplied by source(Q1)in KW= 30.0
also given that,Q1_a=0.7*Q1_b.......eq 1
Q1_c=Q1-(0.7*Q1_b+Q1_b)
Q1_c=Q1-1.7*Q1_b........eq 2
for reversible engine
Q1_a/T1_a+Q1_b/T1_b+Q1_c/T1_c-Q2/T2=0......eq 3
substitute eq 1 and eq 2 in eq 3 we get, 
heat supplied by reservoir of 700 K(Q1_b)in KJ/s
Q1_b= 35.39
so heat supplied by reservoir of 800 K(Q1_a)in KJ/s
Q1_a= 24.78
and heat supplied by reservoir of 600 K(Q1_c)in KJ/s
Q1_c=Q1-1.7*Q1_b -30.17
so heat supplied by reservoir at 800 K(Q1_a)= 24.78
so heat supplied by reservoir at 700 K(Q1_b)= 35.39
so heat supplied by reservoir at 600 K(Q1_c)= -30.17
NOTE=>answer given in book for heat supplied by reservoir at 800 K,700 K,600 K i.e Q1_a=61.94 KJ/s,Q1_b=88.48 KJ/s,Q1_c=120.42 KJ/s is wrong hence correct answer is calculated above.