In [1]:

```
#cal of maximum possible work
#intiation of all variables
# Chapter 7
print"Example 7.1, Page:218 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 1")
C2=150;#leave velocity of steam in m/s
m=2.5;#steam mass flow rate in kg/s
print("let us neglect the potential energy change during the flow.")
print("applying S.F.E.E,neglecting inlet velocity and change in potential energy,")
print("W_max=(h1-To*s1)-(h2+C2^2/2-To*s2)")
print("W_max=(h1-h2)-To*(s1-s2)-C2^2/2")
print("from steam tables,")
print("h1=h_1.6Mpa_300=3034.8 KJ/kg,s1=s_1.6Mpa_300=6.8844 KJ/kg,h2=h_0.1Mpa_150=2776.4 KJ/kg,s2=s_150Mpa_150=7.6134 KJ/kg")
h1=3034.8;
s1=6.8844;
h2=2776.4;
s2=7.6134;
print("given To=288 K")
To=288;
W_max=(h1-h2)-To*(s1-s2)-(C2**2/2*10**-3)
print("so W_max in KJ/kg="),round(W_max,2)
W_max=m*W_max
print("maximum possible work(W_max) in KW="),round(W_max,2)
```

In [2]:

```
#cal of availability of air in tank A,B
#intiation of all variables
# Chapter 7
import math
print"Example 7.2, Page:219 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 2")
m=1.;#mass of air in kg
Po=1.*10**5;#atmospheric pressure in pa
To=(15.+273.);#temperature of atmosphere in K
Cv=0.717;#specific heat at constant volume in KJ/kg K
R=0.287;#gas constant in KJ/kg K
Cp=1.004;#specific heat at constant pressure in KJ/kg K
T=(50.+273.);#temperature of tanks A and B in K
print("In these tanks the air stored is at same temperature of 50 degree celcius.Therefore,for air behaving as perfect gas the internal energy of air in tanks shall be same as it depends upon temperature alone.But the availability shall be different.")
print("BOTH THE TANKS HAVE SAME INTERNAL ENERGY")
print("availability of air in tank,A")
print("A=(E-Uo)+Po*(V-Vo)-To*(S-So)")
print("=m*{(e-uo)+Po(v-vo)-To(s-so)}")
print("m*{Cv*(T-To)+Po*(R*T/P-R*To/Po)-To(Cp*log(T/To)-R*log(P/Po))}")
print("so A=m*{Cv*(T-To)+R*(Po*T/P-To)-To*Cp*log(T/To)+To*R*log(P/Po)}")
P=1.*10**5;#pressure in tank A in pa
availability_A=m*(Cv*(T-To)+R*(Po*T/P-To)-To*Cp*math.log(T/To)+To*R*math.log(P/Po))
print("for tank A,P in pa,so availability_A in KJ="),round(availability_A,2)
P=3.*10**5;#pressure in tank B in pa
availability_B=m*(Cv*(T-To)+R*(Po*T/P-To)-To*Cp*math.log(T/To)+To*R*math.log(P/Po))
print("for tank B,P=3*10^5 pa,so availability_B in KJ="),round(availability_B,2)
print("so availability of air in tank B is more than that of tank A")
print("availability of air in tank A=1.98 KJ")
print("availability of air in tank B=30.98 KJ")
```

In [3]:

```
#cal of maximum power output and that could be obtained from exhaust steam
#intiation of all variables
# Chapter 7
print"Example 7.3, Page:221 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 3")
m=15;#steam flow rate in kg/s
V2=160;#exit velocity of steam in m/s
To=(15+273);#pond water temperature in K
print("inlet conditions,")
print("from steam tables,,h1=3051.2 KJ/kg,s1=7.1229 KJ/kg K")
h1=3051.2;
s1=7.1229;
print("outlet conditions,at 0.05 bar and 0.95 dryness fraction")
print("from steam tables,sf=0.4764 KJ/kg K,s_fg=7.9187 KJ/kg K,x=0.95,hf=137.82 KJ/kg,h_fg=2423.7 KJ/kg")
sf=0.4764;
s_fg=7.9187;
x=0.95;
hf=137.82;
h_fg=2423.7;
s2=sf+x*s_fg
print("so s2= in KJ/kg K="),round(s2,2)
h2=hf+x*h_fg
print("and h2= in KJ/kg="),round(h2,2)
print("neglecting the change in potential energy and velocity at inlet to turbine,the steady flow energy equation may be written as to give work output.")
w=(h1-h2)-V2**2*10**-3/2
print("w in KJ/kg="),round(w,2)
print("power output in KW="),round(m*w,2)
print("maximum work for given end states,")
w_max=(h1-To*s1)-(h2+V2**2*10**-3/2-To*s2)
print("w_max=(h1-To*s1)-(h2+V2^2*10^-3/2-To*s2) in KJ/kg"),round(w_max,2)
w_max=850.38;#approx.
w_max=m*w_max
print("w_max in KW"),round(w_max,2)
print("so maximum power output=12755.7 KW")
print("maximum power that could be obtained from exhaust steam shall depend upon availability with exhaust steam and the dead state.stream availability of exhaust steam,")
print("A_exhaust=(h2+V^2/2-To*s2)-(ho-To*so)")
print("=(h2-ho)+V2^2/2-To(s2-so)")
print("approximately the enthalpy of water at dead state of 1 bar,15 degree celcius can be approximated to saturated liquid at 15 degree celcius")
print("from steam tables,at 15 degree celcius,ho=62.99 KJ/kg,so=0.2245 KJ/kg K")
ho=62.99;
so=0.2245;
print("maximum work available from exhaust steam,A_exhaust in KJ/kg")
A_exhaust=(h2-ho)+V2**2*10**-3/2-To*(s2-so)
A_exhaust=151.1;#approx.
print("A_exhaust=(h2-ho)+V2^2*10^-3/2-To*(s2-so)"),round(A_exhaust,2)
print("maximum power that could be obtained from exhaust steam in KW="),round(m*A_exhaust,2)
print("so maximum power from exhaust steam=2266.5 KW")
```

In [4]:

```
#cal of availability at initial,final state and also change
#intiation of all variables
# Chapter 7
print"Example 7.4, Page:222 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 4")
m=5;#mass of steam in kg
z1=10;#initial elevation in m
V1=25;#initial velocity of steam in m/s
z2=2;#final elevation in m
V2=10;#final velocity of steam in m/s
Po=100;#environmental pressure in Kpa
To=(25+273);#environmental temperature in K
g=9.81;#acceleration due to gravity in m/s^2
print("for dead state of water,")
print("from steam tables,uo=104.86 KJ/kg,vo=1.0029*10^-3 m^3/kg,so=0.3673 KJ/kg K")
uo=104.86;
vo=1.0029*10**-3;
so=0.3673;
print("for initial state of water,")
print("from steam tables,u1=2550 KJ/kg,v1=0.5089 m^3/kg,s1=6.93 KJ/kg K")
u1=2550;
v1=0.5089;
s1=6.93;
print("for final state of water,")
print("from steam tables,u2=83.94 KJ/kg,v2=1.0018*10^-3 m^3/kg,s2=0.2966 KJ/kg K")
u2=83.94;
v2=1.0018*10**-3;
s2=0.2966;
print("availability at any state can be given by")
print("A=m*((u-uo)+Po*(v-vo)-To*(s-so)+V^2/2+g*z)")
A1=m*((u1-uo)+Po*(v1-vo)-To*(s1-so)+V1**2*10**-3/2+g*z1*10**-3)
print("so availability at initial state,A1 in KJ")
print("A1="),round(A1,2)
A2=m*((u2-uo)+Po*(v2-vo)-To*(s2-so)+V2**2*10**-3/2+g*z2*10**-3)
print("and availability at final state,A2 in KJ")
print("A2="),round(A2,2)
A2-A1
print("change in availability,A2-A1 in KJ="),round(A2-A1,2)
print("hence availability decreases by 2702.188 KJ")
print("NOTE=>In this question,due to large calculations,answers are approximately correct.")
```

In [5]:

```
#intiation of all variables
# Chapter 7
print"Example 7.5, Page:223 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 5")
print("In question no. 5 expression I=To*S_gen is derived which cannot be solve using python software.")
```

In [6]:

```
#cal of available energy and ratio of lost available exhaust gas energy to engine work
#intiation of all variables
# Chapter 7
print"Example 7.6, Page:223 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 6")
To=(30.+273.);#temperature of surrounding in K
W=1050.;#work done in engine in KJ/kg
Cp=1.1;#specific heat at constant pressure in KJ/kg K
T=(800.+273.);#temperature of exhaust gas in K
print("loss of available energy=irreversibility=To*deltaSc")
print("deltaSc=deltaSs+deltaSe")
deltaSs=W/T
print("change in enropy of system(deltaSs)=W/T in KJ/kg K"),round(deltaSs,2)
deltaSe=-Cp*(T-To)/To
print("change in entropy of surrounding(deltaSe)=-Cp*(T-To)/To in KJ/kg K"),round(deltaSe,2)
E=To*(deltaSs+deltaSe)
print("loss of available energy(E) in KJ/kg="),round(E,2)
E=-E
print("loss of available energy(E)="),round(-E,2)
print("ratio of lost available exhaust gas energy to engine work=E/W="),round(E/W,3)
```

In [7]:

```
#cal of initial,final and change in availability
#intiation of all variables
# Chapter 7
print"Example 7.7, Page:224 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 7")
m=10;#mass of water in kg
C1=25;#initial velocity in m/s
C2=10;#final velocity in m/s
Po=0.1*1000;#environmental pressure in Kpa
To=(25+273.15);#environmental temperature in K
g=9.8;#acceleration due to gravity in m/s^2
z1=10;#initial elevation in m
z2=3;#final elevation in m
print("let us consider velocities and elevations to be given in reference to environment.Availability is given by")
print("A=m*((u-uo)+Po*(v-vo)-To(s-so)+C^2/2+g*z)")
print("dead state of water,from steam tables,uo=104.88 KJ/kg,vo=1.003*10^-3 m^3/kg,so=0.3674 KJ/kg K")
uo=104.88;
vo=1.003*10**-3;
so=0.3674;
print("for initial state of saturated vapour at 150 degree celcius")
print("from steam tables,u1=2559.5 KJ/kg,v1=0.3928 m^3/kg,s1=6.8379 KJ/kg K")
u1=2559.5;
v1=0.3928;
s1=6.8379;
print("for final state of saturated liquid at 20 degree celcius")
print("from steam tables,u2=83.95 KJ/kg,v2=0.001002 m^3/kg,s2=0.2966 KJ/kg K")
u2=83.95;
v2=0.001002;
s2=0.2966;
print("substituting in the expression for availability")
A1=m*((u1-uo)+Po*(v1-vo)-To*(s1-so)+C1**2*10**-3/2+g*z1*10**-3)
print("initial state availability,A1 in KJ")
print("A1="),round(A1,2)
A2=m*((u2-uo)+Po*(v2-vo)-To*(s2-so)+C2**2*10**-3/2+g*z2*10**-3)
print("final state availability,A2 in KJ")
print("A2="),round(A2,2)
deltaA=A2-A1
print("change in availability,deltaA in KJ="),round(deltaA,2)
print("so initial availability =5650.28 KJ")
print("final availability=2.58 KJ ")
print("change in availability=decrease by 5647.70 KJ ")
```

In [8]:

```
#cal of availability of steam at inlet,turbine output,maximum possible turbine output,irreversibility
#intiation of all variables
# Chapter 7
print"Example 7.8, Page:225 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 8")
m=5.;#steam flow rate in kg/s
p1=5.*1000.;#initial pressure of steam in Kpa
T1=(500.+273.15);#initial temperature of steam in K
p2=0.2*1000.;#final pressure of steam in Kpa
T1=(140.+273.15);#final temperature of steam in K
po=101.3;#pressure of steam at dead state in Kpa
To=(25.+273.15);#temperature of steam at dead state in K
Q=600.;#heat loss through turbine in KJ/s
print("let inlet and exit states of turbine be denoted as 1 and 2")
print("at inlet to turbine,")
print("from steam tables,h1=3433.8 KJ/kg,s1=6.9759 KJ/kg K")
h1=3433.8;
s1=6.9759;
print("at exit from turbine,")
print("from steam tables,h2=2748 KJ/kg,s2=7.228 KJ/kg K")
h2=2748;
s2=7.228;
print("at dead state,")
print("from steam tables,ho=104.96 KJ/kg,so=0.3673 KJ/kg K")
ho=104.96;
so=0.3673;
A1=m*((h1-ho)-To*(s1-so))
print("availability of steam at inlet,A1 in KJ="),round(A1,2)
print("so availability of steam at inlet=6792.43 KJ")
print("applying first law of thermodynamics,")
print("Q+m*h1=m*h2+W")
W=m*(h1-h2)-Q
print("so W in KJ/s="),round(W,2)
print("so turbine output=2829 KW")
print("maximum possible turbine output will be available when irreversibility is zero.")
print("W_rev=W_max=A1-A2")
W_max=m*((h1-h2)-To*(s1-s2))
print("W_max in KJ/s="),round(W_max,2)
print("so maximum output=3804.81 KW")
print("irreversibility can be estimated by the difference between the maximum output and turbine output.")
I=W_max-W
print("I= in KW="),round(I,2)
print("so irreversibility=975.81807 KW")
print("NOTE=>In book,W_max is calculated wrong,so irreversibility also comes wrong,which are corrected above.")
```

In [9]:

```
#intiation of all variables
# Chapter 7
print"Example 7.9, Page:226 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 9")
print("In question no.9 comparision between sublimation and vaporisation line is made which cannot be solve using python software.")
```

In [10]:

```
#intiation of all variables
# Chapter 7
print"Example 7.10, Page:227 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 10")
print("In question no. 10 expression for change in internal energy of gas is derive which cannot be solve using python software.")
```

In [11]:

```
#cal of loss of available energy
#intiation of all variables
# Chapter 7
print"Example 7.11, Page:227 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 11")
To=280.;#surrounding temperature in K
Q=500.;#heat removed in KJ
T1=835.;#temperature of reservoir in K
T2=720.;#temperature of system in K
A_HR=To*Q/T1
print("availability for heat reservoir(A_HR) in KJ/kg K"),round(A_HR,2)
A_system=To*Q/T2
print("now availability for system(A_system) in KJ/kg K"),round(A_system,2)
A=A_HR-A_system
print("net loss of available energy(A) in KJ/kg K="),round(A,2)
print("so loss of available energy=26.77 KJ/kg K")
```

In [2]:

```
#cal of actual,maximum possible work
#intiation of all variables
# Chapter 7
print"Example 7.12, Page:228 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 12")
h1=4142;#enthalpy at entrance in KJ/kg
h2=2585;#enthalpy at exit in KJ/kg
W1=1787;#availability of steam at entrance in KJ/kg
W2=140;#availability of steam at exit in KJ/kg
print("here dead state is given as 300 K and maximum possible work for given change of state of steam can be estimated by the difference of flow availability as given under:")
W_max=W1-W2
print("W_max=W1-W2 in KJ/kg"),round(W_max,2)
W_actual=h1-h2
print("actual work from turbine,W_actual=h1-h2 in KJ/kg"),round(W_actual,2)
print("so actual work=1557 KJ/kg")
print("maximum possible work=1647 KJ/kg")
```

In [13]:

```
#cal of second law efficiency
#intiation of all variables
# Chapter 7
print"Example 7.13, Page:228 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 13")
T_min=(20.+273.);#minimum temperature reservoir temperature in K
T_max=(500.+273.);#maximum temperature reservoir temperature in K
n=0.25;#efficiency of heat engine
n_rev=1-(T_min/T_max)
print("reversible engine efficiency,n_rev=1-(T_min/T_max)"),round(n_rev,4)
n/n_rev
print("second law efficiency=n/n_rev"),round(n/n_rev,4)
print("in %"),round(n*100/n_rev,2)
```

In [14]:

```
#cal of loss of available energy
#intiation of all variables
# Chapter 7
import math
print"Example 7.14, Page:228 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 14")
V_A=6.;#volume of compartment A in m^3
V_B=4.;#volume of compartment B in m^3
To=300.;#temperature of atmosphere in K
Po=1.*10**5;#atmospheric pressure in pa
P1=6.*10**5;#initial pressure in pa
T1=600.;#initial temperature in K
V1=V_A;#initial volume in m^3
V2=(V_A+V_B);#final volume in m^3
y=1.4;#expansion constant
R=287.;#gas constant in J/kg K
Cv=0.718;#specific heat at constant volume in KJ/kg K
print("expansion occurs in adiabatic conditions.")
print("temperature after expansion can be obtained by considering adiabatic expansion")
T2=T1*(V1/V2)**(y-1)
print("T2/T1=(V1/V2)^(y-1)")
print("so T2= in K="),round(T2,2)
T2=489.12;#approx.
m=(P1*V1)/(R*T1)
print("mass of air,m in kg="),round(m,2)
m=20.91;#approx.
deltaSs=m*Cv*math.log(T2/T1)+m*R*10**-3*math.log(V2/V1)
print("change in entropy of control system,deltaSs=(S2-S1) in KJ/K="),round(deltaSs,2)
print("here,there is no change in entropy of environment,deltaSe=0")
deltaSe=0;
deltaSc=deltaSs+deltaSe
print("total entropy change of combined system=deltaSc in KJ/K="),round(deltaSc,2)
E=To*deltaSc
print("loss of available energy(E)=irreversibility in KJ="),round(E,3)
print("so loss of available energy,E=0.603 KJ")
```

In [15]:

```
#cal of maximum possible work
#intiation of all variables
# Chapter 7
print"Example 7.15, Page:229 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 15")
print("In question no. 15 prove for ideal gas satisfies the cyclic relation is done which cannot be solve using python software.")
```

In [16]:

```
#cal of availability,rate of irreversibility and second law efficiency
#intiation of all variables
# Chapter 7
print"Example 7.16, Page:230 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 16")
To=(17.+273.);#temperature of surrounding in K
T1=(700.+273.);#temperature of high temperature reservoir in K
T2=(30.+273.);#temperature of low temperature reservoir in K
Q1=2.*10**4;#rate of heat receive in KJ/min
W_useful=0.13*10**3;#output of engine in KW
n_rev=(1-T2/T1);
W_rev=n_rev*Q1
W_rev=W_rev/60.;#W_rev in KJ/s
print("availability or reversible work,W_rev=n_rev*Q1 in KJ/min"),round(W_rev,2)
I=W_rev-W_useful
print("rate of irreversibility,I=W_rev-W_useful in KJ/sec"),round(I,2)
W_useful/W_rev
print("second law efficiency=W_useful/W_rev"),round(W_useful/W_rev,2)
W_useful*100/W_rev
print("in percentage"),round(W_useful*100/W_rev,2)
print("so availability=1.38*10^4 KJ/min")
print("and rate of irreversibility=100 KW,second law efficiency=56.63 %")
print("NOTE=>In this question,wrong values are put in expression for W_rev in book,however answer is calculated correctly.")
```

In [17]:

```
#cal of loss of available energy
#intiation of all variables
# Chapter 7
import math
print"Example 7.17, Page:230 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 17")
To=(27+273);#temperature of surrounding in K
T1=(60+273);#initial temperature of air in K
P1=1.5*10**5;#initial pressure of air in pa
P2=2.5*10**5;#final pressure of air in pa
T_reservoir=(400+273);#temperature of reservoir in K
Cp=1.005;#specific heat at constant pressure in KJ/kg K
print("loss of available energy=irreversibility=To*deltaSc")
print("deltaSc=deltaSs+deltaSe")
print("change in entropy of system=deltaSs")
print("change in entropy of environment/surroundings=deltaSe")
print("here heat addition process causing rise in pressure from 1.5 bar to 2.5 bar occurs isochorically.let initial and final states be given by subscript 1 and 2")
print("P1/T1=P2/T2")
T2=P2*T1/P1
print("so T2 in K="),round(T2,2)
print("heat addition to air in tank")
deltaT=T2-T1;
Q=Cp*deltaT
print("Q in KJ/kg="),round(Q,2)
deltaSs=Q/T1
print("deltaSs in KJ/kg K="),round(deltaSs,2)
deltaSe=-Q/T_reservoir
print("deltaSe in KJ/kg K="),round(deltaSe,2)
deltaSc=deltaSs+deltaSe
print("and deltaSc in KJ/kg K="),round(deltaSc,2)
E=To*deltaSc
print("so loss of available energy(E)in KJ/kg="),round(E,2)
```

In [18]:

```
#intiation of all variables
# Chapter 7
print"Example 7.18, Page:231 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 18")
print("In question no. 18,relation for T*ds using maxwell relation is derived which cannot be solve using python software.")
```

In [19]:

```
#cal of enthalpy of vaporisation
#intiation of all variables
# Chapter 7
import math
print"Example 7.19, Page:232 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 19")
T=(200+273);#temperature of water in K
print("clapeyron equation says,h_fg=T*v_fg*(dp/dT)_sat")
print("from steam tables,vg=0.12736 m^3/kg,vf=0.001157 m^3/kg")
vg=0.12736;
vf=0.001157;
v_fg=(vg-vf)
print("v_fg in m^3/kg="),round(v_fg)
print("let us approximate,")
print("(dp/dT)_sat_200oc=(deltaP/deltaT)_200oc=(P_205oc-P_195oc)/(205-195) in Mpa/oc")
print("here from steam tables,P_205oc=1.7230 Mpa,P_195oc=1.3978 Mpa")
P_205oc=1.7230;#pressure at 205 degree celcius in Mpa
P_195oc=1.3978;#pressure at 195 degree celcius in Mpa
(P_205oc-P_195oc)/(205-195)
print("substituting in clapeyron equation,")
h_fg=T*v_fg*(P_205oc-P_195oc)*1000/(205-195)
print("h_fg in KJ/kg"),round(h_fg,2)
print("so calculated enthalpy of vaporisation=1941.25 KJ/kg")
print("and enthalpy of vaporisation from steam table=1940.7 KJ/kg")
```

In [20]:

```
#cal of loss of available energy
#intiation of all variables
# Chapter 7
import math
print"Example 7.20, Page:232 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 20")
P2=260.96;#saturation pressure at -5 degree celcius
P1=182.60;#saturation pressure at -15 degree celcius
vg=0.07665;#specific volume of gas at -10 degree celcius in m^3/kg
vf=0.00070#specific volume at -10 degree celcius in m^3/kg
R=0.06876;#gas constant in KJ/kg K
h_fg=156.3;#enthalpy in KJ/kg K
T2=(-5.+273.);#temperature in K
T1=(-15.+273.);#temperature in K
print("by clapeyron equation")
print("h_fg=T2*v_fg*(do/dT)_sat ")
print("h_fg=T2*(vg-vf)*(deltaP/deltaT)in KJ/kg")
h_fg=T2*(vg-vf)*(P1-P2)/(T1-T2)
print("by clapeyron-clausius equation,")
print("log(P2/P1)_sat=(h_fg/R)*((1/T1)-(1/T2))_sat")
print("log(P2/P1)=(h_fg/R)*((1/T1)-(1/T2))")
print("so h_fg=log(P2/P1)*R/((1/T1)-(1/T2))in KJ/kg")
h_fg=math.log(P2/P1)*R/((1/T1)-(1/T2))
print("% deviation from clapeyron equation in %"),round((169.76-159.49)*100/159.49,2)
print("h_fg by clapeyron equation=159.49 KJ/kg")
print("h_fg by clapeyron-clausius equation=169.76 KJ/kg")
print("% deviation in h_fg value by clapeyron-clausius equation from the value from clapeyron equation=6.44%")
```

In [2]:

```
#cal of volume expansivity and isothermal compressibility
#intiation of all variables
# Chapter 7
import math
print"Example 7.21, Page:233 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 21")
print("volume expansion=(1/v)*(dv/dT)_P")
print("isothermal compressibility=-(1/v)*(dv/dp)_T")
print("let us write dv/dT=deltav/deltaT and dv/dP=deltav/deltaP.The difference may be taken for small pressure and temperature changes.")
print("volume expansivity in K^-1,")
print("=(1/v)*(dv/dT)_300Kpa")
print("=(1/v_300Kpa_300oc)*((v_350oc-v_250oc)/(350-250))_300Kpa")
print("from steam tables,v_300Kpa_300oc=0.8753 in m^3/kg,v_350oc=0.9534 in m^3/kg,v_250oc=0.7964 in m^3/kg")
v_300Kpa_300oc=0.8753;#specific volume at 300Kpa and 300 degree celcius
v_350oc=0.9534;#specific volume 350 degree celcius
v_250oc=0.7964;#specific volume 250 degree celcius
(1/v_300Kpa_300oc)*(v_350oc-v_250oc)/(350-250)
print("volume expansivity=1.7937*10^-3 K^-1")
print("isothermal compressibility=k in Kpa^-1")
v_350Kpa=0.76505;#specific volume 350 Kpa
v_250Kpa=1.09575;#specific volume 250 Kpa
k=(-1./v_300Kpa_300oc)*(v_350Kpa-v_250Kpa)/(350.-250.)
print("k="),round((-1./v_300Kpa_300oc)*(v_350Kpa-v_250Kpa)/(350.-250.),3)
print("from steam tables,v_300Kpa_300oc=0.8753 in m^3/kg,v_350Kpa=0.76505 in m^3/kg,v_250Kpa=1.09575 in m^3/kg")
print("so isothermal compressibility=3.778*10^-3 Kpa^-1")
```

In [22]:

```
#cal of inside final temperature,change in entropy and irreversibility
#intiation of all variables
# Chapter 7
import math
print"Example 7.22, Page:234 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 22")
Cp=1.005;#specific heat at constant pressure in KJ/kg K
Cv=0.718;#specific heat at constant volume in KJ/kg K
Ti=(25+273.15);#atmospheric temperature in K
print("filling of the tank is a transient flow(unsteady)process.for the transient filling process,considering subscripts i and f for initial and final states,")
print("hi=uf")
print("Cp*Ti=Cv*Tf")
Tf=Cp*Ti/Cv
print("so Tf=Cp*Ti/Cv in K"),round(Tf,2)
print("inside final temperature,Tf=417.33 K")
deltaS_gen=Cp*math.log(Tf/Ti)
print("change in entropy,deltaS_gen=(Sf-Si)+deltaS_surr in KJ/kg K="),round(deltaS_gen,4)
print("Cp*log(Tf/Ti)+0")
print("change in entropy,deltaS_gen=0.3379 KJ/kg K")
To=Ti;
I=To*deltaS_gen
print("irreversibility,I in KJ/kg="),round(I,2)
print("irreversibility,I=100.74 KJ/kg")
```

In [23]:

```
#cal of maximum work
#intiation of all variables
# Chapter 7
import math
print"Example 7.23, Page:234 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 23")
m=75.;#mass of hot water in kg
T1=(400.+273.);#temperature of hot water in K
T2=(27.+273.);#temperature of environment in K
Cp=4.18;#specific heat of water in KJ/kg K
print("here the combined closed system consists of hot water and heat engine.here there is no thermal reservoir in the system under consideration.for the maximum work output,irreversibility=0")
print("therefore,d(E-To-S)/dt=W_max")
print("or W_max=(E-To-S)1-(E-To-S)2")
print("here E1=U1=m*Cp*T1,E2=U2=m*Cp*T2")
print("therefore,W_max=m*Cp*(T1-T2)-To*m*Cp*log(T1/T2)in KJ")
To=T2;
W_max=m*Cp*(T1-T2)-To*m*Cp*math.log(T1/T2)
print("so maximum work in KJ="),round(W_max,1)
```

In [24]:

```
#cal of inlet stream availability,exit stream availability and irreversibility
#intiation of all variables
# Chapter 7
import math
print"Example 7.24, Page:235 \n \n"
print("Engineering Thermodynamics by Onkar Singh Chapter 7 Example 24")
C1=150;#steam entering velocity in m/s
C2=50;#steam leaving velocity in m/s
To=(15+273);#dead state temperature in K
W=1000;#expansion work in KJ/kg
print("from steam tables,h1=h_50bar_600oc=3666.5 KJ/kg,s1=s_50bar_600oc=7.2589 KJ/kg K,h2=hg=2584.7 KJ/kg,s2=sg=8.1502 KJ/kg K")
h1=3666.5;
s1=7.2589;
h2=2584.7;
s2=8.1502;
(h1+C1**2*10**-3/2)-To*s1
print("inlet stream availability in KJ/kg="),round((h1+C1**2*10**-3/2)-To*s1,2)
(h2+C2**2*10**-3/2)-To*s2
print("input stream availability is equal to the input absolute availability.")
print("exit stream availaability in KJ/kg"),round((h2+C2**2*10**-3/2)-To*s2,2)
print("exit stream availability is equal to the exit absolute availability.")
print("W_rev in KJ/kg")
W_rev=1587.18-238.69
W_rev-W
print("irreversibility=W_rev-W in KJ/kg"),round(W_rev-W,2)
print("this irreversibility is in fact the availability loss.")
print("inlet stream availability=1587.18 KJ/kg")
print("exit stream availability=238.69 KJ/kg")
print("irreversibility=348.49 KJ/kg")
print("NOTE=>In book this question is solve using dead state temperature 25 degree celcius which is wrong as we have to take dead state temperature 15 degree celcius,now this question is correctly solve above taking dead state temperature 15 degree celcius as mentioned in question. ")
```