In [4]:

```
#Ques 1
#To determine the efficiency of Rankine cycle
#1-Inlet state of pump
#2-Exit state of pump
P2=2000;#Exit pressure in kPa
P1=10;#Inlet pressure in kPa
v=0.00101;#specific weight of water in m^3/kg
wp=v*(P2-P1);#work done in pipe in kJ/kg
h1=191.8;#Enthalpy in kJ/kg from table
h2=h1+wp;#enthalpy in kJ/kg
#2-Inlet state for boiler
#3-Exit state for boiler
h3=2799.5;#Enthalpy in kJ/kg
#3-Inlet state for turbine
#4-Exit state for turbine
#s3=s4(Entropy remain same)
s4=6.3409;#kJ/kg
sf=0.6493;#Entropy at liquid state in kJ/kg
sfg=7.5009;#Entropy difference for vapor and liquid state in kJ/kg
x4=(s4-sf)/sfg;#x-factor
hfg=2392.8;#Enthalpy difference in kJ/kg for turbine
h4=h1+x4*hfg;#Enthalpy in kJ/kg
nth=((h3-h2)-(h4-h1))/(h3-h2);
print" Percentage efficiency =",round(nth*100,1)
```

In [41]:

```
#Ques 2
#To determine the efficiency of Rankine cycle
#1-Inlet state of pump
#2-Exit state of pump
P2=4000;#Exit pressure in kPa
P1=10;#Inlet pressure in kPa
v=0.00101;#specific weight of water in m^3/kg
wp=v*(P2-P1);#work done in pipe in kJ/kg
h1=191.8;#Enthalpy in kJ/kg from table
h2=h1+wp;#enthalpy in kJ/kg
#2-Inlet state for boiler
#3-Exit state for boiler
h3=3213.6;#Enthalpy in kJ/kg from table
#3-Inlet state for turbine
#4-Exit state for turbine
#s3=s4(Entropy remain same)
s4=6.7690;#Entropy in kJ/kg from table
sf=0.6493;#Entropy at liquid state in kJ/kg from table
sfg=7.5009;#Entropy difference for vapor and liquid state in kJ/kg from table
x4=(s4-sf)/sfg;#x-factor
hfg=2392.8;#Enthalpy difference in kJ/kg for turbine
h4=h1+x4*hfg;#Enthalpy in kJ/kg
nth=((h3-h2)-(h4-h1))/(h3-h2);
print"Percentage efficiency =",round(nth*100,1),"%"
```

In [42]:

```
#Ques 2
#To determine the efficiency of Rankine cycle
#1-Inlet state of pump
#2-Exit state of pump
P2=600.0 ;#Exit pressure in lbf/in^2
P1=1.0;#Inlet pressure in lbf/in^2
v=0.01614;#specific weight of water in ft^3/lbm
wp=v*(P2-P1)*(144.0/778.0);#work done in pipe in Btu/lbm
h1=69.70;#Enthalpy in Btu/lbm from table
h2=h1+wp;#enthalpy in Btu/lbm
#2-Inlet state for boiler
#3-Exit state for boiler
h3=1407.6;#Enthalpy in Btu/lbm from table
#3-Inlet state for turbine
#4-Exit state for turbine
#s3=s4(Entropy remain same)
s4=1.6343;#Entropy in Btu/lbm from table
sf=1.9779;#Entropy at liquid state in Btu/lbm from table
sfg=1.8453;#Entropy difference for vapor and liquid state in Btu/lbm from table
x4=-(s4-sf)/sfg;#x-factor
hfg=1036.0;#Enthalpy difference in Btu/lbm for turbine
h4=1105.8-x4*hfg;#Enthalpy in Btu/lbm
wt=(h3-h4) #work done in turbine in Btu/lbm
nth=((h3-h4)-wp)/(h3-h2);
print"Percentage efficiency =",round(nth*100,1),"%"
```

In [43]:

```
#Ques 3
#To determine the efficiency of a cycle
#1-Inlet state of pump
#2-Exit state of pump
P2=4000;#Exit pressure in kPa
P1=10;#Inlet pressure in kPa
v=0.00101;#specific weight of water in m^3/kg
wp=v*(P2-P1);#work done in pipe in kJ/kg
h1=191.8;#Enthalpy in kJ/kg from table
h2=h1+wp;#enthalpy in kJ/kg
#2-Inlet state for boiler
#3-Exit state for Boiler
h3=3213.6;#Enthalpy in kJ/kg from table
#3-Inlet state for high pressure turbine
#4-Exit state for high pressure turbine
#s3=s4(Entropy remain same)
s4=6.7690;#Entropy in kJ/kg from table
sf=1.7766;#Entropy at liquid state in kJ/kg from table
sfg=5.1193;#Entropy difference for vapor and liquid state in kJ/kg from table
x4=(s4-sf)/sfg;#x-factor
hf=604.7#Enthalpy of liquid state in kJ/kg
hfg=2133.8;#Enthalpy difference in kJ/kg for turbine
h4=hf+x4*hfg;#Enthalpy in kJ/kg
#5-Inlet state for low pressure turbine
#6-Exit pressure for low pressure turbine
sf=0.6493;#Entropy in liquid state in kJ/kg for turbine
h5=3273.4;#enthalpy in kJ/kg
s5=7.8985;#Entropy in kJ/kg
sfg=7.5009;#entropy diff in kJ/kg
x6=(s5-sf)/sfg;#x-factor
hfg=2392.8;#enthalpy difference for low pressure turbine in kj/kg
h6=h1+x6*hfg;#entropy in kg/kg
wt=(h3-h4)+(h5-h6);#work output in kJ/kg
qh=(h3-h2)+(h5-h4);
nth=(wt-wp)/qh;
print" Percentage efficiency =",round(nth*100,1),"%"
```

In [44]:

```
#ques4
#Efficiency of Refrigeration cycle
#from previous examples
h1=191.8;#kJ/kg
h5=3213.6;#kg/kg
h6=2685.7;#kJ/kg
h7=2144.1;#kJ/kg
h3=604.7;#kJ/kg
#1-Inlet state of pump
#2-Exit state of pump
P2=400;#Exit pressure in kPa
P1=10; #Inlet pressure in kPa
v=0.00101;#specific weight of water in m^3/kg
wp1=v*(P2-P1);#work done for low pressure pump in kJ/kg
h1=191.8;#Enthalpy in kJ/kg from table
h2=h1+wp1;#enthalpy in kJ/kg
#5-Inlet state for turbine
#6,7-Exit state for turbine
y=(h3-h2)/(h6-h2);#extraction fraction
wt=(h5-h6)+(1-y)*(h6-h7);#turbine work in kJ/kg
#3-Inlet for high pressure pump
#4-Exit for high pressure pump
P3=400;#kPa
P4=4000;#kPa
v=0.001084;#specific heat for 3-4 process in m^3/kg
wp2=v*(P4-P3);#work done for high pressure pump
h4=h3+wp2;#Enthalpy in kJ/kg
wnet=wt-(1-y)*wp1-wp2;
qh=h5-h4;#Heat output in kJ/kg
nth=wnet/qh;
print" Refrigerator Efficiency =",round(nth*100,1),"%"
```

In [45]:

```
#ques5
#To determine thermal efficiency of cycle
#5-Inlet state for turbine
#6-Exit state for turbine
#h-Enthalpy at a state
#s-Entropy at a state
#from steam table
h5=3169.1;#kJ/kg
s5=6.7235;#kJ/kg
s6s=s5;
sf=0.6493;#Entropy for liquid state in kJ/kg
sfg=7.5009;#Entropy difference in kJ/kg
hf=191.8;#kJ/kg
hfg=2392.8;#Enthalpy difference in kJ/kg
x6s=(s6s-sf)/sfg;#x-factor
h6s=hf+x6s*hfg;#kJ/Kg at state 6s
nt=0.86;#turbine efficiency given
wt=nt*(h5-h6s);
#1-Inlet state for pump
#2-Exit state for pump
np=0.80;#pump efficiency given
v=0.001009;#specific heat in m^3/kg
P2=5000;#kPa
P1=10;#kPa
wp=v*(P2-P1)/np;#Work done in pump in kJ/kg
wnet=wt-wp;#net work in kJ/kg
#3-Inlet state for boiler
#4-Exit state for boiler
h3=171.8;#in kJ/kg from table
h4=3213.6;#kJ/kg from table
qh=h4-h3;
nth=wnet/qh;
print "Cycle Efficiency =",round(nth*100,1),"%"
```

In [60]:

```
#ques5
#To determine thermal efficiency of cycle
#5-Inlet state for turbine
#6-Exit state for turbine
#h-Enthalpy at a state
#s-Entropy at a state
#from steam table
h5=1386.8;#Btu/lbm
s5=1.6248;#Btu/lbm
s6s=s5;
sf=1.9779;#Entropy for liquid state in Btu/lbm
sfg=1.8453;#Entropy difference in Btu/lbm
hf=1105.8;# Btu/lbm
hfg=1036.0;#Enthalpy difference in Btu/lbm
x6s=(s6s-sf)/sfg;#x-factor
h6s=hf+x6s*hfg;#Btu/lbm at state 6s
nt=0.86;#turbine efficiency given
wt=nt*(h5-h6s);
#1-Inlet state for pump
#2-Exit state for pump
np=0.80;#pump efficiency given
v=0.016;#specific heat in ft^3/lbm
P2=800.0;# lbf/in^2
P1=1.0;# lbf/in^2
wp=(v*(P2-P1)*144.0)/(np*778.0);#Work done in pump in Btu/lbm
wnet=wt-wp;#net work in Btu/lbm
#3-Inlet state for boiler
#4-Exit state for boiler
h3=65.1;#in Btu/lbm from table
h4=1407.6;# Btu/lbm from table
qh=h4-h3;
nth=wnet/qh;
print "Cycle Efficiency =",round(nth*100,2),"%"
```

In [16]:

```
#ques6
#to determine the rate of refrigeration
# refer to fig 11.21 in book
mdot=0.03 # mass flow rate in Kg/s
T1=-20 # temperature in evaporator in celsius
T3=40 #temperature in evaporator in Celsius
P2=1017 # saturation pressure in KPa
# from table of R-134a refrigerant
h1=386.1 # enthalpy at state 1 in kJ/kg,
S1=1.7395 # entropy at state 1 in kJ/kg.K
S2=S1 # isentropic process
T2=47.7# corresponding value to S2 in table of R-134a in degree celsius
h2=428.4 # corresponding value to S2 in table of R-134a in kJ/kg
wc=h2-h1 # work done in compressor in kJ/kg
h4=h3=256.5 #enthalpy at state 4 and 3 in kJ/kg
qL=h1-h4 #Heat rejected in kJ/kg
B=qL/wc # COP
print" the COP of the plant is",round(B,2)
print" the refrigeration rate is",round(mdot*qL,2)
```

In [20]:

```
#ques7
#to determine the COP of cycle
P1=125 # pressure at state 1 in kPa
P2=1.2 # pressure at state 2 in MPa
P3=1.19 # pressure at state 3 in MPa,
P4=1.16 # pressure at state 4 in MPa,
P5=1.15 # pressure at state 5 in MPa,
P6=P7=140 # pressure at state 6 and 7 in kPa,
P8=130 # pressure at state 8 in kPa,
T1=-10 #temperaure at state 1 in ◦C
T2=100 #temperaure at state 2 in ◦C
T3=80 #temperaure at state 3 in ◦C
T4=45 #temperaure at state 4 in ◦C
T5=40 #temperaure at state 5 in ◦C
T8=-20 #temperaure at state 8 in ◦C
q=-4 # heat transfer in kJ/Kg
#x6=x7 quality condition given in question
# the following values are taken from table for refrigerant R-134a
h1=394.9 # enthalpy at state 1 in kJ/kg
h2=480.9 # enthalpy at state 2 in kJ/kg
h8=386.6 # enthalpy at state 8 in kJ/kg
wc=h2-h1-q # from first law
h5=h6=h7=256.4 # as x6=x7 and from table at state 5 in Kj/Kg
qL=h8-h7 # from first law
B=qL/wc # COP
print" the COP of the plant is",round(B,3)
```