In [1]:

```
from __future__ import division
#Variable Declaration:
p1 = 7 #Lower pressure limit(in kPa):
p2 = 7 #Higher pressure limit(in MPa):
h2 = 2772.1 #Enthalpy at state 2(in kJ/kg):
s2 = 5.8133 #Entropy at state 2(in kJ/kg.K):
h3 = 1267 #Enthalpy at state 3(in kJ/kg):
s3 = 3.1211 #Entropy at state 3(in kJ/kg.K):
sf1 = 0.5564 #Value of sf at 7 kPa(in kJ/kg.K):
sfg1 = 7.7237 #Value of sfg at 7 kPa(in kJ/kg.K):
hf1 = 162.60 #Value of hf at 7 kPa(in kJ/kg):
hfg1 = 2409.54 #Value of hfg at 7 kPa(in kJ/kg):
s1 = s2 #Entropy at state 1(in kJ/kg.K):
#Calculations:
x1 = (s1-sf1)/sfg1 #Dryness fraction at state 1:
h1 = hf1+x1*hfg1 #Enthalpy at state 1(in kJ/kg):
s4 = s3 #Entropy at state 4(in kJ/kg.K):
x4 = (s4-sf1)/sfg1 #Dryness fraction for state 4:
h4 = hf1+x4*hfg1 #Enthalpy at state 4(in kJ/kg):
W1 = h2-h1 #Expansion work per kg(in kJ/kg):
W2 = h3-h4 #Compression work per kg(in kJ/kg):
H = h2-h3 #Heat added per kg(in kJ/kg):
W = W1-W2 #Net work done(in kJ/kg):
n = W/H #Thermal efficiency:
#Results:
print "Thermal Efficiency: ",round(n*100,2),"%"
print "Turbine work: ",round(W1,2),"KJ/Kg"
print "Compression work: ",round(W2,2),"KJ/Kg"
```

In [4]:

```
from __future__ import division
#Variable Declaration:
p1 = 5 #Lower pressure limit(in kPa):
p2 = 5000 #Higher pressure limit(in kPa):
#From gas tables:
hf5M = 1154.23 #Value of hf at 5 MPa(in kJ/kg):
sf5M = 2.92 #Value of sf at 5 MPa(in kJ/kg.K):
hg5M = 2794.3 #Value of hg at 5 MPa(in kJ/kg):
sg5M = 5.97 #Value of sg at 5 MPa(in kJ/kg.K):
hf5k = 137.82 #Value of hf at 5 kPa(in kJ/kg):
sf5k = 0.4764 #Value of sf at 5 kPa(in kJ/kg.K):
hg5k = 2561.5 #Value of hg at 5 kPa(in kJ/kg):
sg5k = 8.3961 #Value of sg at 5 kPa(in kJ/kg.K):
vf5k = 0.001005 #/Value of vf at 5 kPa(in m**3/kg):
#Calculation:
sfg5k = sg5k-sf5k #Value of sfg at 5 kPa(in kJ/kg.K):
hfg5k = hg5k-hf5k #Value of hfg at 5 kPa(in kJ/kg.K):
s2 = sg5M #Entropy at point 2(in kJ/kg.K):
s3 = s2 #As process 2-3 is isentropic:
x3 = (s3-sf5k)/sfg5k #Dryness fraction at point 3:
h3 = hf5k+x3*hfg5k #Enthalpy at point 3(in kJ/kg):
h2 = hg5M #Enthalpy at point 2(in kJ/kg):
s1 = sf5M #Entropy at point 1(in kJ/kg.K):
s4 = s1 #Process 1-4 is isentropic:
x4 = (s4-sf5k)/sfg5k #Dryness fraction at point 4:
h4 = hf5k+x4*hfg5k #Enthalpy at point 4(in kJ/kg):
h1 = hf5M #Enthalpy at point 1(in kJ/kg):
n = ((h2-h3)-(h1-h4))/(h2-h1) #Carnot efficiency:
Pw = vf5k*(p2-p1) #Pump work:
h5 = hf5k #Enthalpy at point 5(in kJ/kg):
h6 = h5+Pw #Enthalpy at point 6(in kJ/kg):
Nw = (h2-h3)-(h6-h5) #Net work in the cycle:
Ha = h2-h6 #Heat added:
nr = Nw/Ha #Rankine efficiency:
#Results:
print "Carnot cycle efficiency: ",round(n*100,2)
print "Rankine cycle efficiency: ",round(nr*100,2)
```

In [7]:

```
from __future__ import division
#Variable Declaration:
p1 = 40 #Pressure of steam entering(in bar):
T1 = 350+273 #Temperature(in K):
p4 = 0.05 #Pressure of steam leaving(in bar):
#From steam tables:
h2 = 3092.5 #kJ/kg
s2 = 6.5821 #kJ/kg.K
h4 = 137.82 #kJ/kg
s4 = 0.4764 #kJ/kg.K
v4 = 0.001005 #m**3/kg
sf = 0.4764 #kJ/kg.K
sfg = 7.9187 #kJ/kg.K
hf = 137.82 #kJ/kg
hfg = 2423.7 #kJ/kg
#Calculations:
s3 = s2 #Entropy at state 3:
x3 = (s3-sf)/sfg #Dryness fraction at state 3:
h3 = hf+x3*hfg #Enthalpy at state 3(in kJ/kg):
h1 = h4+v4*(p1-p4)*10**2 #Enthalpy at state 1(in kJ/kg):
Wp = h1-h4 #Pump work(in kJ/kg):
Wnet = h2-h3-Wp #Net work(in kJ/kg):
Q = h2-h1 #Heat added(in kJ/kg):
n = Wnet/Q*100 #Cycle efficiency(in kJ/kg):
#Results:
print "Net work per kg of steam: ",round(Wnet,2),"kJ/kg"
print "Cycle efficiency: ",round(n,2),"%"
print "Pump work per kg of steam: ",round(Wp,2),"kJ/kg"
```

In [11]:

```
from __future__ import division
#Variable Declaration:
p1 = 20 #Pressure of the steam entering(in MPa):
T1 = 500+273 #Temperature(in K):
x = 0.90 #Dryness fraction of the steam leaving:
p6 = 0.005 #Condensor pressure(in MPa):
#From steam tables:
h2 = 3238.2 #kJ/kg
s2 = 6.1401 #kJ/kg.K
s3 = s2
hf = 137.82 #kJ/kg
hfg = 2423.7 #kJ/kg.K
sf = 0.4764 #kJ/kg.K
sfg = 7.9187 #kJ/kg.K
h6 = 137.82 #kJ/kg
h4 = 3474.1 #kJ/kg
sf1 = 2.2842 #kJ/kg.K
sfg1 = 4.1850 #kJ/kg.K
hf1 = 830.3 #kJ/kg
hfg1 = 1959.7 #kJ/kg
v6 = 0.001005 #m**3/kg
#Calculations:
h5 = hf+x*hfg #Enthalpy at state 5(in kJ/kg):
s5 = sf+x*sfg
p4 = 1.4 #By interpolation, pressure at state 4(in bar):
x3 = (s3-sf1)/sfg1 #Dryness fraction at state 3:
h3 = hf1+x3*hfg1 #Enthalpy at state 3(in kJ/kg):
h1 = h6+v6*(p1-p6)*10**3 #Enthalpy at state 1(in kJ/kg):
Wnet = (h2-h3)+(h4-h5)-(h1-h6) #Net work per kg of steam(in kJ/kg):
Q = h2-h1 #Heat added per kg of steam(in kJ/kg):
n = Wnet/Q*100 #Thermal efficiency:
#Results:
print "Pressure of steam leaving HP turbine: ",round(p4,2),"MPa"
print "Thermal efficiency: ",round(n,2),"%"
```

In [14]:

```
from __future__ import division
#Variable Declaration:
p1 = 10 #Pressure of steam leaving the boiler(in MPa):
T1 = 700+273 #Temperature(in K):
p4 = 0.005 #Pressure of steam leaving the turbine(in MPa):
W = 50 #Output of the plant(in MW):
Twin = 15+273 #Temperature of the cooling water entering and leaving the condensor(in K):
Twout = 30+273
#From steam tables:
h2 = 3870.5 #kJ/kg
s2 = 7.1687 #kJ/kg.K
sf = 0.4764 #kJ/kg.K
sfg = 7.9187 #kJ/kg.K
hf = 137.82 #kJ/kg
hfg = 2423.7 #kJ/kg
v4 = 0.001005 #m**3/kg
Cp = 4.18 #Specific heat of water(in kJ/kg.K):
#Calculations:
s3 = s2
h4 = hf
x3 = (s3-sf)/sfg #Dryness fraction at state 3:
h3 = hf+x3*hfg #Enthalpy at state 3(in kJ/kg):
h1 = h4+v4*(p1-p4) #Enthalpy at state 1(in kJ/kg):
Wnet = (h2-h3)-(h1-h4) #Net output per kg of steam(in kJ/kg):
ms = W*10**3/Wnet #Mass flow rate of steam(in kg/s):
mw = (h3-h4)*ms/(Cp*(Twout-Twin))#Mass flow rate of water(in kg/s):
Q = h2-h1 #Heat added per kg of steam(in kJ/kg):
n = Wnet/Q #Thermal efficiency:
r = (h2-h1)/(h3-h4) #Ratio of heat supplied:
print "Mass flow rate of steam: ",round(ms,2),"kg/s"
print "Mass flow rate of condensor cooling water: ",round(mw,2),"kg/s"
print "Thermal efficiency: ",round(n*100,2),"%"
print "Ratio of heat supplied and rejected: ",round(r,3)
```

In [15]:

```
from __future__ import division
#Variable Declaration:
p1 = 200 #Pressure of steam leaving the boiler(in MPa):
T1 = 650+273 #Temperature(in K):
p4 = 0.05 #Pressure of steam leaving the turbine(in MPa):
#From steam tables:
h2 = 3675.3 #kJ/kg
s2 = 6.6582 #kJ/kg.K
h4 = 137.82 #kJ/kg
v4 = 0.001005 #m**3/kg
sf = 0.4764 #kJ/kg.K
sfg = 7.9187 #kJ/kg.K
hf = 137.82 #kJ/kg
hfg = 2423.7 #kJ/kg
hf8 = 721.11 #kJ/kg
hfg8 = 2048 #kJ/kg
vf8 = 0.001115 #m**3/kg
sf8 = 2.0462 #kJ/kg.K
sfg8 = 4.6166 #kJ/kg.K
T10 = 370.36+273 #K(by interpolation)
h10 = 3141.81 #kJ/kg
sf4 = 1.7766 #kJ/kg.K
sfg4 = 5.1193 #kJ/kg.K
hf4 = 604.74 #kJ/kg
hfg4 = 2133.8 #kJ/kg
s3 = s2
s6 = s2 #For case b:
s10 = s2 #For case c:
s9 = s2
h11 = hf4
h13 = 1087.31 #kJ/kg
v11 = 0.001084 #m**3/kg
v13 = 0.001252 #m**3/kg
p10 = 40 #bar
p9 = 4 #bar
#Calculations:
#Case a:
x3 = (s3-sf)/sfg #Dryness farction at state 3:
h3 = hf+x3*hfg #Enthalpy at state 3(in kJ/kg):
h1 = h4+v4*(p1-p4) #Enthalpy at state 1(in kJ/kg):
Wnet = (h2-h3)-(h1-h4) #Net output per kg of steam(in kJ/kg):
Q = h2-h1 #Heat added(in kJ/kg):
na = Wnet/Q*100 #Thermal efficiency:
#Case b:
x6 = (s6-sf8)/sfg8 #Dryness fraction at state 6(in kJ/kg.K):
h6 = hf8+x6*hfg8 #Enthalpy at state 6(in kJ/kg):
h7 = hf8 #Enthalpy at state 7(in kJ/kg):
h5 = h4+v4*(p1-p4)*10**2 #Enthalpy at state 5(in kJ/kg):
m = (h7-h5)/(h6-h5) #Mass of steam(in kg):
h1 = h7+vf8*(p1-p4)*10**2 #Enthalpy at state 1(in kJ/kg):
nb = ((h2-h6)+(1-m)*(h6-h3)-((1-m)*(h5-h4)+(h1-h7)))/(h2-h1)*100 #Thermal efficiency:
#Case c:
x9 = (s9-sf4)/sfg4 #Dryness fraction at state 9:
h9 = hf4+x9*hfg4 #Enthalpy at state 9(in kJ/kg):
h8 = h4+v4*(p9-p4)*10**2 #Enthalpy at state 8(in kJ/kg):
h12 = h11+v11*(p10-p9)*10**2#Enthalpy at state 12(in kJ/kg):
h1a = h13+v13*(p1-p10)*10**2#Enthalpy at state 1'(in kJ/kg):
m1 = (h13-h12)/(h10-h12) #Mass of steam flowing through first heater:
m2 = ((1-m1)*h11-(1-m1)*h8)/(h9-h8)#Mass of steam flowing through second heater:
Wcep = (1-m1-m2)*(h8-h4) #Work done by Condensate extraction pump(in kJ/kg):
WFP1 = h1a-h13 #Work done by feed pump 1(in kJ/kg):
WFP2 = (1-m1)*(h12-h11) #Work done by feed pump 2(in kJ/kg):
nc = ((h2-h10)+(1-m1)*(h10-h9)+(1-m1-m2)*(h9-h3)-(Wcep+WFP1+WFP2))/(h2-h1a)*100 #Thermal efficiency:
#Results:
print "Thermal efficiency in case a: ",round(na,2),"%"
print "Thermal efficiency in case b: ",round(nb,2),"%"
print "Thermal efficiency in case c: ",round(nc,2),"%"
```

In [18]:

```
from __future__ import division
#Variable Declaration:
p1 = 50 #Pressure at which steam is generated(in bar):
T1 = 500+273 #Temperature of the steam(in K):
p3 = 5 #Pressure upto which steam is expanded(in bar):
T3 = 400+273 #Temperature(in K):
p5 = 0.05 #Final pressure(in bar):
#From steam tables:
h2 = 3433.8 #kJ/kg
s2 = 6.9759 #kJ/kg.K
s3 = s2
T3 = 183.14+273 #K(by interpolation)
h3 = 2818.03 #kJ/kg
h4 = 3271.9 #kJ/kg
s4 = 7.7938 #kJ/kg.K
s5 = s4
sf = 0.4764 #kJ/kg.K
sfg = 7.9187 #kJ/kg.K
hf = 137.82 #kJ/kg
hfg = 2423.7 #kJ/kg
h6 = hf
v6 = 0.001005 #m**3/kg
#Calculations:
x5 = (s5-sf)/sfg #Dryness fraction at state 5:
h5 = hf+x5*hfg #Enthalpy at state 5(in kJ/kg):
h1 = h6+v6*(p1-p5)*10**2#Enthalpy at state 1(in kJ/kg):
Wt = (h2-h3)+(h4-h5) #Turbine work(in kJ/kg):
Wp = h1-h6 #Pump work(in kJ/kg):
Wnet = Wt-Wp #Net output per kg of steam(in kJ/kg):
Q = h2-h1 #Heat added per kg of steam(in kJ/kg):
n = Wnet/Q #Cycle efficiency:
ssc = 0.7457*3600/Wnet #Specific steam consumption(in kg/hp.hr):
r = Wnet/Wt #Work ratio:
#Results:
print "Cycle efficiency: ",round(n*100,2),"%"
print "Specific steam consumption: ",round(ssc,2),"kg/hp.hr"
print "Work ratio: ",round(r,4)
```

In [20]:

```
from __future__ import division
#Variable Declaration:
m = 0.144 #Mass of steam entering the feed pump(in kg):
p1 = 60 #Pressure of steam fed in HP turbine(in bar):
T1 = 450+273 #Temperature of the steam(in K):
p3 = 3 #Pressure of steam entering LP turbine(in bar):
p4 = 0.05 #Pressure of steam leaving the LP turbine(in bar):
T3 = 115 #Condensate temperature(in C):
W = 30 #Alternator output(in MW):
nb = 0.90 #Boiler efficiency:
na = 0.98 #Alternator efficiency:
#From steam tables:
h2 = 3301.8 #kJ/kg
s2 = 6.7198 #kJ/kg.K
hf = 137.82 #kJ/kg
hfg = 2423.7 #kJ/kg
vf = 0.001005 #m**3/kg
h8 = 561.47 #kJ/kg
sf3 = 1.6718 #kJ/kg.K
sfg3 = 5.3201 #kJ/kg.K
hf3 = 561.47 #kJ/kg
hfg3 = 2163.8 #kJ/kg
sf = 0.4764 #kJ/kg.K
sfg = 7.9187 #kJ/kg.K
#Calculations:
h5 = hf
v5 = vf
s3 = s2
s4 = s2
h9 = h8
v6 = v5
x3 = (s3-sf3)/sfg3 #Dryness fraction at state 3:
x4 = (s4-sf)/sfg #Dryness fraction at state 4:
h3 = hf3+x3*hfg3 #Enthalpy at state 3(in kJ/kg):
h4 = hf+x4*hfg #Enthalpy at state 4(in kJ/kg):
h1 = 4.18*T3 #Enthalpy at state 1(in kJ/kg):
Wp = v5*(p1-p4)*10**2 #Pumping work(in kJ/kg) also equal to h7-h6:
Wnet = (h2-h3)+(1-m)*(h3-h4)-(1-m)*Wp#Net output(in kJ/kg):
ms = W*10**3/(na*Wnet) #Mass of steam required to be generated(in kg/hr):
Q = (h2-h1)/nb #Heat added(in kJ/kg):
no = Wnet/Q*100 #Overall thermal efficiency:
#Results:
print "Steam bled for feed heating: ",round(m,3),"kg"
print "Capacity of boiler: ",round(ms,2)*3600,"kg/hr"
print "Overall thermal efficiency: ",round(no,2),"%"
```

In [22]:

```
from __future__ import division
#Variable Declaration:
p1 = 30 #Pressure of steam entering(in bar):
T1 = 300 #Temperature(in C):
p3 = 6 #Pressure of steam leaving the first stage(in bar):
p4 = 1 #Steam leaving second stage at pressure(in bar):
p5 = 0.075 #Pressure of steam leaving the third stage(in bar):
T = 38 #Condenstate temperature(in C):
T8 = 150 #Temperature of water after leaving first and second heater(in C):
T13 = 95
n = 0.8 #Efficiency of turbine:
W = 15 #Turbine output(in MW):
#From steam tables:
h2 = 3230.9 #kJ/kg
s2 = 6.9212 #kJ/kg.K
T3 = 190.97 #K(by interpolation)
h3 = 2829.63 #kJ/kg
s3a = 7.1075 #kJ/kg.K
sf1 = 1.3026 #kJ/kg.K
sfg1 = 6.0568 #kJ/kg.K
hf1 = 417.46 #kJ/kg
hfg1 = 2258 #kJ/kg
h5 = 234.64 #kJ/kg
hf6 = 670.56 #kJ/kg
#Calculations:
s3 = s2
s4 = s3a
h11 = hf6
h3a = round(h2-n*(h2-h3),2) #Actual enthalpy at state 3(in kJ/kg):
x4 = round((s4-sf1)/sfg1,3) #Dryness fraaction at state 4:
h4 = hf1+x4*hfg1 #Enthalpy at state 4(in kJ/kg):
h4a = round(h3a-n*(h3a-h4),2) #Actual enthaly at state 4(in kJ/kg):
x4a = (h4a-hf1)/hfg1 #Actual dryness fraction at state 4:
s4a = sf1+x4a*sfg1 #Actual entropy at state 4(in kJ/kg.K):
s5 = s4a #Entropy at state 5(in kJ/kg.K):
x5 = 0.8735 #Dryness fraction:
h5 = 2270.43 #Enthalpy at state 5(in kJ/kg):
h5a = h4a-n*(h4a-h5) #Actual enthalpy at state 5(in kJ/kg):
m1 = 0.1293
m2 = 0.1059
Wt = (h2-h3a)+(1-m1)*(h3a-h4a)+(1-m1-m2)*(h4a-h5a) #Turbine output(in kJ/kg):
r = W*10**3/Wt*3600 #Rate of steam generation required(in kg/hr):
c = (m1+m2)*r #Capacity of drain pump(in kg/hr):
#Results:
print "Capacity of drain pump: ",round(c,2),"kg/hr"
```

In [24]:

```
from __future__ import division
#Variable Declaration:
p1 = 70 #Pressure of the steam entering(in bar):
T1 = 450 #Temperature of the steam entering the HP turbine(in C):
p3 = 30 #Pressure at which steam is extracted(in bar):
T4 = 400 #Temperature at which it is reheated(in C):
p6 = 0.075 #Pressure of steam after expanding(in bar):
T = 140 #Temperature at which steam is bled(in C):
nh = 0.80 #Efficiency of HP turbine:
nl = 0.85 #Efficiency of LP turbine:
#From steam tables:
h2 = 3287.1 #kJ/kg
s2 = 6.6327 #kJ/kg.K
h3 = 3049.48 #kJ/kg
h4 = 3230.9 #kJ/kg
s4 = 6.9212 #kJ/kg.K
h6 = 2158.55 #kJ/kg
p5 = 3.61 #bar
h5 = 2712.38 #kJ/kg
h9 = 1008.42 #kJ/kg
v7 = 0.001008 #m**3/kg
h7 = 168.79 #kJ/kg
h8 = 169.15 #kJ/kg
v9 = 0.00108 #m**3/kg
#Calculations:
s6 = s4
s5 = s4
h3a = h2-nh*(h2-h3) #Actual enthalpy at state 3(in kJ/kg):
h6a = h4-nl*(h4-h6) #Actual enthaly at state 6(in kJ/kg):
h5a = h4-nl*(h4-h5) #Actual enthaly at state 5(in kJ/kg):
h8 = h7+v7*(p5-p6)*10**2 #Enthalpy at state 8(in kJ/kg):
m = (h9-h8)/(h5a-h8) #Mass of bled steam per kg of steam generated(in kg/kg steam generated):
h1 = h9+v9*(p1-p5)*10**2 #Enthalpy at state 1(in kJ/kg):
Wnet = (h2-h3a)+(h4-h5a)+(1-m)*(h5a-h6a)-((1-m)*(h8-h7)+(h1-h9))#Net work per kg of steam generated(in kJ/kg):
Q = (h2-h1)+(h4-h3a) #Heat added per kg of steam generated(in kJ/kg):
n = Wnet/Q*100 #Thermal efficiency:
#Result:
print "Thermal efficiency: ",round(n,2),"%"
print "___There is a calculation mistake in calculating h2-h1 in book hence difference in answer_____"
```

In [26]:

```
from __future__ import division
#Variable Declaration:
p1 = 150 #Pressure of the steam entering the boiler(in bar):
T1 = 450 #Temperature of the steam entering the turbine(in C):
p6 = 0.05 #Condensor pressure(in bar):
p3 = 10 #Pressure of steam bled out between 1st & 2nd stage and 2nd & 3rd(in bar):
p4 = 1.5
T11 = 150 #Temperature of feed water leaving closed water heater(in C):
m = 300 #Mass flow rate(in kg/s):
#From steam tables:
h2 = 3308.6 #kJ/kg
s2 = 6.3443 #kJ/kg.K
h3 = 2667.26 #kJ/kg
h4 = 2355.18 #kJ/kg
h5 = 1928.93 #kJ/kg
h6 = 137.82 #kJ/kg
v6 = 0.001005 #m**3/kg
h8 = 467.11 #kJ/kg
v8 = 0.001053 #m**3/kg
h10 = 1610.5 #kJ/kg
v10 = 0.001658 #m**3/kg
#Calculations:
s3 = s2
s4 = s2
s5 = s2
h7 = h6+v6*(p4-p6)*10**2 #Enthalpy at state 7(in kJ/kg):
h9 = round(h8+v8*(p1-p4)*10**2,2) #Enthalpy at state 9(in kJ/kg):
h12 = round(h10+v10*(p1-p3)*10**2,2) #Enthalpy at state 12(in kJ/kg):
m1 = round((4.18*T11-h9)/(h3-h9+4.18*T11-h10),2)#Mass of steam bled out in closed feed water heater(in kg/kg of steam generated):
m2 = round(((1-m1)*(h8-h7))/(h4-h7),2)
h1 = (4.18*T11)*(1-m1)+m1*h12 #Enthalpy at state 1(in kJ/kg):
Wnet = (h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-((1-m1-m2)*(h7-h6)+(1-m1)*(h9-h8)+m1*(h12-h10)) #Net work output per kg of steam generated(in kJ/kg):
Q = h2-h1 #Heat added(in kJ/kg):
n = Wnet/Q*100 #Cycle thermal efficiency:
P = Wnet*m #Net power developed(KW)
#Results:
print "Cycle thermal efficiency: ",round(n,1),"%"
print "Net power developed: ",round(P),"kW"
```

In [28]:

```
from __future__ import division
#Variable Declaration:
p1 = 100 #Pressure of the steam entering the boiler(in bar):
T1 = 500 #Temperature of the steam entering the turbine(in ºC):
p6 = 0.075 #Condensor pressure(in bar):
p3 = 20 #Pressure at which steam is extracted at exit of HPT(in bar):
p4 = 4 #Pressure at which steam is extracted at exit of IPT(in bar):
T = 200 #Temperature at which feed water leaves closed feed warere heater(in C):
W = 100 #Net power output(in MW):
#From steam tables:
h2 = 3373.7 #kJ/kg
s2 = 6.5966 #kJ/kg.K
T3 = 261.6 #C(by interpolation)
h3 = 2930.57 #kJ/kg
h4 = 2612.65 #kJ/kg
h5 = 2055.09 #kJ/kg
h10 = 908.79 #kJ/kg
h8 = 604.74 #kJ/kg
v6 = 0.001008 #m**3/kg
h6 = 168.79 #kJ/kg
h8 = 604.74 #kJ/kg
v8 = 0.001084 #m**3/kg
#For modified part:
h3a = 3247.6 #kJ/kg
s3a = 7.1271 #kJ/kg.K
T4 = 190.96 #C(by interpolation)
h4a = 2841.2 #kJ/kg
h5a = 2221.11 #kJ/kg
#Calculations:
s3 = s2
s4 = s2
s5 = s2
h1 = 4.18*T
h11 = h10
s4a = s3a
s5a = s3a
h7 = h6+v6*(p4-p6)*10**2 #Enthalpy at state 7(in kJ/kg):
h9 = h8+v8*(p3-p4)*10**2 #Enthalpy at state 9(in kJ/kg):
m1 = (h1-h9)/(h3-h10) #Mass of steam bled out in closed feed water heater(in kg/kg of steam generated):
m2 = ((h8-h7)-m1*(h11-h7))/(h4-h7)
Wnet = (h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-((1-m1-m2)*(h7-h6)+(h9-h8)) #Net work per steam generated(in kJ/kg):
Q = h2-h1 #Heat added(in kJ/kg):
n = Wnet/Q*100 #Thermal efficiency:
sgc = W*10**3/Wnet #Steam genration rate(in kg/s):
m2a = ((h8-h7)-m1*(h11-h7))/(h4a-h7)#Mass of steam bled out in closed feed water heater(in kg/kg of steam generated): #For modified part:
Wneta = (h2-h3)+(1-m1)*(h3a-h4a)+(1-m1-m2a)*(h4a-h5a)-((1-m1-m2a)*(h7-h6)+(h9-h8)) #Net work per steam generated(in kJ/kg):
Qa = h2-h1+(1-m1)*(h3a-h3) #Heat added(in kJ/kg):
na = Wneta/Qa*100 #Thermal efficiency:
I = (na-n)/n*100 #% Increase in thermal efficiency due to reheating:
#Results:
print "Thermal efficiency: ",round(n,2),"%"
print "Steam generation rate: ",round(sgc,2),"kg/s"
print "Thermal efficiency: ",round(na,2),"%"
print "Percentage increase in efficiency due to reheating: ",round(I,2),"%"
```

In [30]:

```
from __future__ import division
#Variable Declaration:
hd = 349 #Enthalpy of dry saturated vapour at 8.45 bar(KJ/Kg)
hi = 234.5 #Enthalpy after isentropic expansion to 0.07 bar(KJ/Kg)
hs = 35 #Enthalpy of saturated liquid at 0.07 bar (KJ/Kg)
n1 = 0.85 #Capability:
Cpw = 4.18 #Specific heat of water:
#From steam tables:
h1 = 2767.13 #kJ/kg
h2 = 3330.3 #kJ/kg
s2 = 6.9363 #kJ/kg.K
h3 = 2899.23 #kJ/kg
x4 = 0.93
h4 = 2517.4 #kJ/kg
x5 = 0.828
h5 = 2160.958 #kJ/kg
h6 = 168.79 #kJ/kg
v6 = 0.001008 #m**3/kg
h7 = 168.88 #kJ/kg
h9 = 417.46 #kJ/kg
h13 = 721.11 #kJ/kg
v13 = 0.001252 #m**3/kg
T1 = 150 #ºC
h10 = 418.19 #kJ/kg
m1 = 0.102
m2 = 0.073
#Calculations:
s3 = s2
s4 = s2
s5 = s2
qd = hd-hi #For mercury cycle,Isentropic heat drop:
qda = n1*qd#Actual heat drop:
qre = hd-qda-hs #Heat rejected in condenser(in kJ/kg):
qa = hd-hs #Heat added in the boiler(in kJ/kg):
qam = h1-Cpw*T1 #Heat added in the condenser of mercury cycle(in kJ/kg):
m = qam/qre #Mercury per steam required per kg of steam:
Wp = v13*(40-8)*10**2 #Pump work(in kJ/kg):
qt = m*qa+h2-h1 #Total heat supplied(in kJ/kg steam):
Wm = m*qda #Work done in mercury cycle(in kJ/kg):
Ws = (h2-h3)+(1-m1)*(h3-h4)+(1-m1-m2)*(h4-h5)-(1-m1-m2)*(h7-h6)-m2*(h10-h9)-m1*Wp#Work done in steam cycle(in kJ/hr):
Wt = Wm+Ws #Total work done(in kJ/kg):
n = Wt/qt*100 #Thermal efficiency:
#Results:
print "Thermal efficiency: ",round(n,2),"%"
```

In [2]:

```
from __future__ import division
from sympy import symbols,solve
#Variable Declaration:
h1 = 3023.5 #KJ/Kg
s1 = 6.7664 #KJ/Kg.K
n = 0.8 #Efficiency ratio of HP and LP
W = 0.1 #Steam consumption at no load
P = 2500 #Pressure turbine output
mHP,cHP,mLP,cLP = symbols('mHp cHP mLP cLP') #Symbolic expressions for mHP,cHP,mLP,cLP respectively
LPavail = 1.5 #LP steam available(Kg/s) for getting 1000hp
DhLP = 387.49 #Actual enthalpy drop in LP(KJ/Kg)
#From Table 3
sf = 0.5764
sfg = 7.6752
hf = 168.79
hfg = 2406.0
#Calculations:
s2 = s1
x3 = round((s2 - sf)/sfg,3)
h3HP = hf + x3*hfg
DhHP = n*(h1-h3HP) #Actual enthalpy drop in HP(KJ/Kg)
x3a = (7.1271-sf)/sfg
h3LP = hf+ x3a*hfg #Enthalpy at exit(KJ/Kg)
HPfull = P*0.7457/DhHP #HP steam consumption at full load(Kg/s)
HPNL = W*HPfull #HP steam consumption at no load(Kg/s)
LPfull = P*0.7457/DhLP #LP steam consumption at full load(Kg/s)
LPNL = W*LPfull ##LP steam consumption at no load(Kg/s)
HP = solve([mHP*P+cHP-HPfull,mHP*0+cHP-HPNL],[mHP,cHP])
LP = solve([mLP*P+cLP-LPfull,mLP*0+cLP-LPNL],[mLP,cLP])
xLP = (LPavail-LP[cLP])/LP[mLP]
xHP = 1000-xLP
yHP = HP[mHP]*xHP + HP[cHP]
#Results:
print 'HP steam required:',round(yHP,2),'Kg/s'
```

In [35]:

```
from __future__ import division
#Variable Declaration:
Cpw = 4.18 #Specific heat of water:
#From steam tables:
h2 = 2960.7 #kJ/kg
s2 = 6.3615 #kJ/kg
x3 = 0.863
h3 = 2404.94 #kJ/kg
h7 = 358.59 #kJ/kg
x10 = 0.754
h10 = 1982.91 #kJ/kg
#Calculation:
s3 = s2
s10 = s3
m1 = (1-x3)*0.5 #Mass pf moisture in separator(in kg):
m2 = 0.5-m1 #Mass of steam entering LPT(in kg):
m3 = 0.5+m1 #Mass of water entering the hot well(in kg):
T = (m3*90+m2*40) #Temperature of water leaving hotwell(in C):
Q = 0.5*(h3-h7) #Heat transferred per kg steam generated:
Wnet = (h2-h3)*1+m2*(h3-h10) #Net work output(in kJ/kg):
Qa = h2-Cpw*T #Heat added(in kJ/kg):
n = Wnet/Qa*100 #Thermal efficiency:
#Results:
print "Temperature of water leaving hotwell: ",round(T,3),"°C"
print "Heat transferred per kg steam generated: ",round(Q,3),"kJ/kg steam"
print "Thermal efficiency: ",round(n,2),"%"
```

In [37]:

```
from __future__ import division
#Variable Declaration:
m = 35 #Steam flow rate(in kg/s):
#From steam tables:
h1 = 3530.9 #kJ/kg
s1 = 6.9486 #kJ/kg.K
x2 = 0.864
h2 = 2288.97 #kJ/kg
v3 = 0.001017 #m**3/kg
h3 = 251.40 #kJ/kg
#Calculations:
s2 = s1
Wp = v3*(70-0.20)*10**2 #Pump work(in kJ/kg):
Wt = h1-h2 #Turbine work(in kJ/kg):
Wnet = Wt-Wp #Net work(in kJ/kg):
P = m*Wnet/10**3 #Power produced(in MW):
h4 = h3+Wp #Enthalpy at state 4(in kJ/kg):
Q = m*(h1-h4) #Total heat supplied to the boiler(in kJ/s):
n = Wnet*m/Q*100 #Thermal efficiency:
#results:
print "Net power: ",round(P,2),"MW"
print "Thermal efficiency: ",round(n,2),"%"
```

In [39]:

```
from __future__ import division
#Variable Declaration:
P = 10 #Output(in MW):
#From steam tables:
h1 = 3625.3 #kJ/kg
s1 = 6.9029 #kJ/kg.K
h2 = 3105.08 #kJ/kg
x3 = 0.834
h3 = 2187.43 #kJ/kg
h6 = 908.79 #kJ/kg
h5 = 191.83 #kJ/kg
#Calculations:
s2 = s1
s3 = s2
h4 = h5
h7 = h6
mb = (h6-h5)/(h2-h5) #Steam bled per kg of steam passing through HP stage:
m = round(P*10**3/((h1-h2)+(1-mb)*(h2-h3)),2) #Mass of steam leaving boiler(in kg/s):
Q = m*(h1-h7) #Heat supplied to the boiler(in kJ/s):
#Results:
print "Steam bled per kg of steam passing through HP stage: ",round(mb,3),"kg"
print "Heat added: ",round(Q,2),"kJ/s"
```

In [41]:

```
from __future__ import division
#Variable Declaration:
P = 50 #Net output(in MW):
#From steam tables:
h1 = 3373.7 #kJ/kg
s1 = 6.5966 #kJ/kg.K
s3 = 7.7622 #kJ/kg.K
h6 = 2930.572 #kJ/kg
h3 = 3478.5 #kJ/kg
T2 = 181.8 #C
h2 = 2782.8 #kJ/kg
T8 = 358.98 #C
h8 = 3188.7 #kJ/kg
x4 = 0.95
h4 = 2462.99 #kJ/kg
h11 = 856.8 #kJ/kg
h9 = 604.74 #kJ/kg
h7 = 908.79 #kJ/kg
h4a = 191.83 #kJ/kg
v4a = 0.001010 #m**3/kg
v9 = 0.001084 #m**3/kg
#Calculations:
s6 = s1
s2 = s1
s8 = s3
s4 = s3
h7a = h7
h5 = h4a+v4a*(4-0.1)*10**2 #Enthalpy at state 5(in kJ/kg):
h10 = h9+v9*(100-4)*10**2 #Enthalpy at state 10(in kJ/kg):
m6 = (h11-h10)/(h6-h7) #Mass per kg of steam from boiler(in kg):
m8 = (h9-(1-m6)*h5-m6*h7a)/(h8-h5)
m6 = 0.135
m8 = 0.105
Whpt = (h1-h6)+(1-m6)*(h6-h2) #Work in turbines(in kJ/kg):
Wlpt = (1-m6)*(h3-h8)+(1-m6-m8)*(h8-h4)
Wcep = (1-m6-m8)*(h5-h4a) #Pump works(in kJ/kg)
Wfp = h10-h9
m = P*10**3/(Whpt+Wlpt-Wcep-Wfp)#Mass of steam entering first stage of turbine(in kg/s):
Q = m*(h1-h11) #Heat supplied in the boiler(in kJ/s):
n = P*10**3/Q*100 #Thermal efficiency:
#Results:
print "Mass of steam bled at 20 bar: ",round(m6,3)," kg per kg of steam entering first stage"
print "Mass of steam bled at 4 bar: ",round(m8,3)," kg per kg of steam entering first stage"
print "Mass of steam entering first stage: ",round(m,2)," kg/s"
print "Thermal efficiency: ",round(n,2),"%"
```

In [43]:

```
from __future__ import division
#Variable Declaration:
nt = 0.85 #Turbine efficiency:
ng = 0.90 #Generator efficiency:
nm = 0.95 #Mechanical efficiency:
Cpw = 4.18 #Specific heat of water:
#From steam tables:
h1 = 3450.02 #kJ/kg
s1 = 6.6923 #kJ/kg.K
h3 = 3576.99 #kJ/kg
s3 = 7.52411 #kJ/kg.K
h2 = 3010 #kJ/kg
h9 = 3175 #kJ/kg
h4 = 2300 #kJ/kg
h5 = 137.82 #kJ/kg
v5 = 0.001005 #m**3/kg
h8 = 962.11 #kJ/kg
h12 = 1407.56 #kJ/kg
h10 = 670.56 #kJ/kg
v10 = 0.001101 #m**3/kg
PO = 120 #Plant output(MW)
#Calculations:
h2a = h1-(h1-h2)*nt #Enthalpy at state 2'(in kJ/kg):
h9a = h3-(h3-h9)*nt #Enthalpy at state 9'(in kJ/kg):
h4a = h3-(h3-h4)*nt #Enthalpy at state 4'(in kJ/kg):
h6 = h5+v5*(6-0.05)*10**2 #Enthalpy at state 6(in kJ/kg):
h6a = h5+(h6-h5)/ng #Enthalpy at state 6'(in kJ/kg):
h11 = h10+v10*(100-6)*10**2 #Enthalpy at state 11(in kJ/kg):
h11a = h10+(h11-h10)/ng #Enthalpy at state 11'(in kJ/kg):
m1 = round((h11a-h12)/(h8-h2a),3) #Mass flow rate(in kg/kg steam):
m2 = round((h10-m1*h8-(1-m1)*h6a)/(h9-h6a),3)
Whp = h1-h2a #Work from HP turbine(in kJ/kg):
Wlp = (1-m1)*(h3-h9a)+(1-m1-m2)*(h9a-h4a)#Work from LP turbine(in kJ/kg):
Wp = (1-m1-m2)*(h6a-h5)+(h11a-h10) #Pump work:
Wnet = Whp+Wlp-Wp #Net work(in kJ/kg):
ssc = 3600/(Wnet*ng*nm) #Specific steam consumption(in kg/kw.h):
ssc = 3.93
no = Wnet*nm*ng/((h1-h12)+(1-m1)*(h3-h2a))*100 #Overall thermal efficiency:
m = ssc*PO*10**3 #Mass of steam required(in kg/hr):
#Results:
print "Specific steam consumption: ",round(ssc,2),"kg/kw.h"
print "Overall efficiency: ",round(no,2),"%"
print "Mass of steam held from HP turbine: ",round(m1*m,1),"kg/hr"
print "Mass of steam held from LP turbine: ",round(m2*m,1),"kg/hr"
print m1, m2
```

In [45]:

```
from __future__ import division
#Variable Declaration:
P = 14000 #Power required(in kW):
r = 0.75 #Efficiency ratio of turbine:
#From steam tables:
h1 = 3137 #kJ/kg
s1 = 6.9563 #kJ/kg.K
x2 = 0.765
h2 = 2170.38 #kJ/kg
hf = 467.11 #kJ/kg
#Calculations:
s2 = s1
h2a = h1-(h1-h2)*r #Enthalpy at state 2'(in kJ/kg):
m = P/(h2a-hf) #Mass of steam required(in kg/s):
P1 = m*(h1-h2a) #Power available to the generator(in kW):
#Results:
print "Power available to the generator: ",round(P1,2),"kW"
```

In [48]:

```
from __future__ import division
#Variable Declaration:
nt = 0.80 #Turbine efficiency:
nb = 0.80 #Boiler efficiency:
P = 9000 #Power required(in kW):
h1 = 3137 #kJ/kg #From steam tables:
s1 = 6.9563 #kJ/kg.K
s2 = s1
x2 = 0.960
h2 = 2638.34 #kJ/kg
hf = 503.71 #kJ/kg
#Calculations:
h2a = h1-(h1-h2)*nt #Enthalpy at state 2'(in kJ/kg):
ms = P/(h2a-hf) #Mass flow rate(in kg/s):
P1 = ms*(h1-h2a) #Power developed(in kW):
pt = (h1-hf)*ms #Total heat consumption in the bolier(in kW):
pa = pt/nb #Actual heat consumption(in kJ/s):
#Results:
print "Power developed: ",round(P1,2),"kW"
print "Actual heat consumption: ",round(pa,2),"kJ/s"
```

In [51]:

```
#Variable Declaration:
P = 4500 #Total power required(in kW):
Q = 15000 #Heat load(in kW):
n = 0.80 #Efficiency of turbines:
m = 10 #Steam consumption rate(in kg/s):
#From steam tables:
h1 = 3137 #kJ/kg
s1 = 6.9563 #kJ/kg.K
T2 = 179.18 #C
h2 = 2813.41 #kJ/kg
hf = 640.23 #kJ/kg
#For case 1:
T2a = 213.34 #C
s2a = 7.125 #kJ/kg.K
x3 = 0.853
h3 = 2221.11 #kJ/kg
#For case 2:
h2a = 2878.13 #kJ/kg
T3aa = 210.04 #C
s3aa = 7.138 #kJ/kg.K
x4 = 0.855
h4 = 2225.92 #kJ/kg
#Calculations:
s3 = s2a
h3aa = h2a
s4 = s3aa
h2a = h1-(h1-h2)*n #Enthalpy at state 2'(in kJ/kg):
q = h2a-hf #Heat available for process heating(in kJ/kg):
msh = Q/q #Mass flow rate(in kg/s):
h3a = h2-(h2a-h3)*n #Enthalpy at state 3'(in kJ/kg):
mshp = (P+msh*(h2a-h3a))/((h1-h2a)+(h2a-h3a)) #Mass of steam produced:
#For case 2:
mshpn = 10
mshn = 6.7
Pn = mshpn*(h1-h2a) #Power produced by HP turbine(in kW):
M3aa = mshpn-mshn
h4a = h3aa-(h3aa-h4)*n #Enthalpy at state 4'(in kJ/kg):
Pn1 = M3aa*(h3aa-h4a) #Power produced by LP turbine(in kW):
Pt = Pn+Pn1 #Total power produced(in kW):
#Results:
print "Total power produced: ",round(Pt,2),"kW"
```

In [54]:

```
from __future__ import division
#Variable Declaration:
na = 0.975 #Alternator efficiency:
nt = 0.80 #Turbine efficiency:
L = 50 #Turbine's losses(in kW):
p = 8 #Electric power developed(in mW):
m = 8 #Condenser discharge(in kg/s):
#From steam tables:
h1 = 3137 #kJ/kg
s1 = 6.9563 #kJ/kg.K
s1a = 7 #kJ/kg.K
h2 = 2830 #kJ/kg
h4 = 2210 #kJ/kg
hf = 376.92 #kJ/kg
#Calculations:
h1a = h1
s2 = s1a
h2a = h1a-(h1a-h2)*nt #Enthalpy at state 2'(in kJ/kg):
h3 = h2a
h4a = h3-(h3-h4)*nt #Enthalpy at state 4'(in kJ/kg):
P = m/na #Power available to the alternator(in MW):
Pt = P*10**3+L #Total power produced(in kW):
plp = m*(h3-h4) #Power produced by LP turbine(in kW):
php = Pt-plp #Power produced by LP turbine(in kW):
m1 = round(php/(h1a-h2a),2) #Mass flow rate through HP turbine(in kg/s):
ph = (m1-m)*(h2-hf) #Heat available for process heating(in kW):
#Results:
print "Heat available for process heating: ",round(ph,2),"kW"
```

In [56]:

```
from __future__ import division
#Variable Declaration:
nt = 0.80 #Turbine efficiency:
nm = 0.90 #Mechanical efficiency:
p = 720 #Power delivered by turbine(in kW):
#From steam tables:
h1 = 3045.8 #kJ/kg
s1 = 7.0317 #kJ/kg.K
x4 = 0.841
h4 = 2192.24 #kJ/kg.K
h2 = 2706.7 #kJ/kg
s2 = 7.1271 #kJ/kg.K
x3 = 0.854
h3 = 2223.51 #kJ/kg
#Calculation:
s4 = s1
s3 = s2
h4a = h1-(h1-h4)*nt #Enthalpy at state 4'(in kJ/kg):
h3a = h2-(h2-h3)*nt #Enthalpy at state 3'(in kJ/kg):
P = p/nm #Power developed in the turbine(in kW):
m1 = 3600/(h1-h4a) #HP steam consumption(in kg/kW.h):
m2 = 3600/(h2-h3a) #LP steam consumption(in kg/kW.h):
#Results:
print "HP steam consumption: ",round(m1,2),"kg/kW.h"
print "LP steam consumption: ",round(m2,2),"kg/kW.h"
```

In [60]:

```
from __future__ import division
#Variable Declaration:
mhp = 2 #Mass flow rate(in kg/s):
mlp = 1.5
n = 0.90 #Expansion efficiency:
P = 3000 #Power developed by the turbine(in kW):
#From steam tables:
h1 = 3034.8 #kJ/kg
s1 = 6.8844 #kJ/kg.K
x3 = 0.9566
h3 = 2611.04 #kJ/kg
h2 = 2706.7 #kJ/kg
xout = 0.8535
hout = 2222.31 #kJ/kg
h4 = 2676.25 #kJ/kg
h5 = 2290 #kJ/kg
#Calculations:
s3 = s1
hin = h2
h3a = h1-(h1-h3)*n #Enthalpy at state 3'(in kJ/kg):
houta = hin-(hin-hout)*n #Enthalpy of steam going out(in kJ/kg):
ms = P/(hin-hout) #Mass flow rate of steam(in kg/s):
h5a = h4-(h4-h5)*n #Enthalpy at state 5'(in kJ/kg):
p = mhp*(h1-h3a)+(mhp+mlp)*(h4-h5a)#Power output from mixed pressure turbine(in kW):
#Results:
print "Power: ",round(p,2),"KW"
```