In [3]:

```
#Variable Declaration:
p1 = 10 #Pressure at which steam is entering(in MPa):
p2 = 0.05 #Pressure at which steam is coming out(in MPa):
T = 100 #Temperature of the steam(inC):
h2 = 2682.5 #Enthalpy of superheated steam at 0.05 MPa and 100 C(in kJ/kg): #From steam tables:
hf10 = 1407.56
hfg10 = 1317.1
#Calculation:
h1 = h2 #Due to throttling:
x1 = (h1-hf10)/hfg10 #Dryness fraction:
#Results:
print "Dryness fraction: ",round(x1,3)
```

In [4]:

```
#Variable Declaration:
p = 12 #Pressure(in MPa):
v = 0.017 #Specific volume(in m**3/kg):
h = 2848 #Enthaply(in kJ/kg):
#Calculation:
u = h-p*10**3*v #Internal energy(in kJ/kg):
#Results:
print "Internal energy: ",round(u),"KJ/Kg"
```

In [5]:

```
from math import log
#Variable Declaration:
m = 5 #Mass of steam(in kg):
p = 2 #Pressure(in MPa):
Tss = 300+273.15 #Temperature of superheated steam(in K):
Cps = 2.1 #Specific heat of super heated steam(in kJ/kg.K):
Cpw = 4.18 #Specific heat of water(in kJ/kg.K):
hfg = 1890.7 #From steam tables:
#Calculations:
Tsat = 212.42+273.15 #Saturation temperature(in K):
s = Cpw*log(Tsat/273.15)+hfg/Tsat+Cps*log(Tss/Tsat) #Entropy of unit mass of superheated steam with reference to absolute zero(in kJ/kg.K):
S = m*s #Entropy of 5 kg of steam(in kJ/K):
#Result:
print "Entropy of steam: ",round(S,2),"KJ/K"
```

In [6]:

```
#Variable Declaration:
Tb = 110 #Boiling point(inÂ°C):
p = 143.27 #Pressure at which it boils(in kPa): #From steam table:
Tsat = 108.866 #From steam table this temperature(in Â°C): #Boiling point at this depth = Tsat at 138.365
#Calculation:
p1 = p-9.81*0.50 #Pressure at 50 cm depth(in kPa):
#Result:
print "Boiling point :",round(Tsat,2),"°C"
```

In [7]:

```
#Variable Declaration:
T = 100 #Temperature of the water vapor mixture(in Â°C):
V = 0.5 #Volume of the rigid vessel(in m**3):
v2 = 0.003155 #Specific volume at state 2(in m**3/kg): #From steam tables:
vf = 0.001044
vg = 1.6729
#Calculations:
v1 = v2 #Specific volume at state 1(in m**3/kg):
x1 = (v1-vf)/vg #Dryness fraction:
m = V/v2 #Total mass of fluid(in kg):
v = m*vf #Volume of water(in m**3):
#Results:
print "Mass of water :",round(m,2),"Kg"
print "Volume of water :",round(v,4),"m**3"
```

In [8]:

```
#Variable Declaration:
p = 2 #Pressure(in MPa):
T = 500+273.15 #Temperature(in K):
#Calculation:
s = T #Slope of isobar:(dh/ds)at constant pressure = T:
#Result:
print "Slope :",s
```

In [9]:

```
#Variable Declaration:
x = 0.10 #Dryness fraction:
p = 0.15 #Pressure(in MPa):
hf = 467.11 #From steam tables:(at 0.15 MPa):
hg = 2693.6
vf = 0.001053
vg = 1.1593
sf = 1.4336
sg = 7.2233
#Calculations:
h = hf+x*(hg-hf) #Enthalpy(in kJ/kg):
v = vf+x*(vg-vf) #Specific volume(in m**3/kg):
s = sf+x*(sg-sf) #Entropy(in kJ/kg.K):
#Results:
print "Enthalpy :",h,"KJ/Kg"
print "Specific volume :",v,"m**3/kg"
print "Entropy :",s,"KJ/Kg.K"
```

In [10]:

```
#Variable Declaration:
#Initial State:
p1 = 1 #Pressure(in MPa):
V1 = 0.05 #Volume(in m**3):
x1 = 0.80 #Dryness fraction:
#Final state:
p2 = 1 #Pressure(in MPa):
V2 = 0.2 #Volume(in m**3):
#From steam table:(at state 1):
vf = 0.001127 #(m3/kg)
vg = 0.19444 #(m3/kg)
uf = 761.68 #(kJ/kg)
ufg = 1822 #(kJ/kg)
#Calculations:
W = p1*10**3*(V2-V1) #Work done(in kJ):
v1 = vf+x1*(vg-vf) #Specific volume at state 1(in m**3/kg):
m = V1/v1 #Mass of system(in kg):
v2 = V2/m #Specific volume at state 2(in m**3/kg):
Tf = 1077.61 #Temperature at final state(in C):
u2 = 4209.6 #Internal energy at final state(at 1077.61 C):
u1 = uf+x1*ufg #Internal energy at initial state(in kJ/kg):
Q = m*(u2-u1)+W #Heat added(in kJ):
#Results:
print "Heat added :",round(Q,2),"kJ"
```

In [11]:

```
#Variable Declaration:
p1 = 800 #Presure of the steam(in kPa):
T = 200 #Temperature(in °C)
Tsat = 170.43 #Saturation temp(in °C):
#From steam tables:
v1 = 0.2404 #Specific volume(in m**3/kg):
vgI = 0.2168
vgII = 0.2428
TI = 175
TII = 170
PI = 892
PII = 791.7
#Calculations:
T2 = TI - (TI-TII)*(v1-vgI)/(vgII-vgI) #Final temperature after interpolation (in °C):
p2 = PI - (PI-PII)*(v1-vgI)/(vgII-vgI) #Final pressure after interpolation (in kPa):
#Results:
print "Pressure :",round(p2,2),"kPa"
print "Temperature :",round(T2,2),"°C"
```

In [12]:

```
#Variable Declaration:
T = 30 #Temperature of water(in C):
p = 200 #Pressure(in kPa):
p1 = 4.25 #Corresponding pressure at 30 C(in kPa): #From steam tables:
v1 = 0.001004 #Specific volume(in m**3):
#Calculations:
dh = v1*(p-p1) #Enthalpy change(in kJ/kg):
#Result:
print "Enthalpy change :",dh,"KJ/Kg"
```

In [13]:

```
#Variable Declaration:
V1 = 3./5*2 #Volume occupied by water(in m**3):
V2 = 2./5*2 #Volume occupied by steam(in m**3):
#From steam table
vf = 0.001091 #(m**3/kg)
vg = 0.3928 #(m**3/kg)
#Calculations:
mf = V1/vf #Mass of water(in kg):
mg = V2/vg #Mass of steam(in kg):
mt = mf+mg #Total mass(in kg):
x = mg/mt #Dryness fraction:
#Results:
print "Mass :",round(mt,2),"kg"
print "Quality :",round(x,6)
```

In [14]:

```
#Variable Declaration:
p = 4 #Pressure of the steam(in MPa):
T1 = 300 #Temperature of steam entering(in °C):
T2 = 50 #Temperature of steam at turbine exit(in °C):
#From steam tables:
h1 = 2886.2 #kJ/kg
s1 = 6.2285 #kJ/kg.K
hf = 209.33 #kJ/kg
sf = 0.7038 #kJ/kg.K
hfg = 2382.7 #kJ/kg
sfg = 7.3725 #kJ/kg.K
#Calculation:
s2 = s1 #Assumed
x2 = round((s2-sf)/sfg,4) #Dryness fraction:
h2 = hf+x2*hfg #Enthalpy at state 2(in kJ/kg):
W = h1-h2 #Turbine work(in kJ/kg):
#Results:
print "Turbine output: ",round(W,2),"kJ/kg"
```

In [15]:

```
#Variable Declaration:
m1 = 100 #Mass of steam(in kg):
p1 = 100 #Initial pressure(in kPa):
p2 = 1000 #Final pressure(in kPa):
x1 = 0.5 #Dryness fraction:
p3 = 2000 #Pressure of dry saturated steam(in kPa):
#From steam tables:
hf100kPa = 417.46 #kJ/kg
uf100kPa = 417.36 #kJ/kg
vf100kPa = 0.001043 #m**3/kg
hfg100kPa = 2258 #kJ/kg
ufg100kPa = 2088.7 #kJ/kg
vg100kPa = 1.6940 #m**3/kg
vg2000kPa = 0.09963 #m**3/kg
ug2000kPa = 2600.3 #kJ/kg
hg2000kPa = 2799.5 #kJ/kg
hf1000kPa = 762.81 #kJ/kg,
hfg1000kPa = 2015.3 #kJ/kg
vf1000kPa = 0.001127 #m3/kg
vg1000kPa = 0.19444 #m3/kg
#Calculations:
v1 = vf100kPa+x1*(vg100kPa-vf100kPa) #Initial specific volume(in m**3/kg):
h1 = hf100kPa+x1*hfg100kPa #Enthalpy at 1(in kJ/kg):
V = m1*x1*v1 #Volume of vessel(in m**3):
v2 = vg2000kPa*v1/(vg2000kPa+v1) #Final specific volume(in m**3/kg):
x2 = (v2-vf1000kPa)/(vg1000kPa-vf1000kPa)#Final dryness fraction:
h2 = hf1000kPa+x2*hfg1000kPa #Final enthalpy(in kJ/kg):
m = m1*(h1-h2)/(h2-hg2000kPa) #Mass of dry steam at 2000kPa(in kg):
U1 = m*(uf100kPa+x1*ufg100kPa) #Internal energy in the beginning(in kJ):
#Results:
print "Mass of dry steam at 2000 kPa to be added: ",round(m,2),"kg"
print "Quality of final mixture: ",round(x2,3)
```

In [17]:

```
#Variable Declaration:
r = 71.5 #Recorded condenser vacuum(cm of Mercury)
br = 76.8 #Barometer reading(cm of Mercury)
Tc = 35 #Temperature of condensation(°C)
Thw = 27.6 #Temperature of hot well(°C)
mc = 1930 #Mass of condensate per hour()Kg
mcw = 62000 #Mass of cooling water per hour(Kg)
Ti = 8.51 #Inlet temperature (°C)
To = 26.24 #Outlet temperature(°C)
#From steam tables:
hf = 146.68 #kJ/kg
hfg = 2418.6 #kJ/kg
#Calculations:
pc = (br-r)/73.55*101.325 #Condensor pressure(in kPa):
ps = 5.628 #Partial pressure of steam corresponding to 35Â°C from steam table(in kPa):
x = (mcw*(To-Ti)*4.18-mc*hf+mc*4.18*To)/(mc*hfg) #Dryness fraction:
#Results:
print "Dryness fraction of the steam entering:",round(x,2)
```

In [19]:

```
from math import pi
#Variable Declaration:
D = 0.2 #Diameter of the vessel(in m):
d = 0.02 #Depth(in m):
T = 150 #Temperature(in °C):
F = 10 #Force applied(in kN):
Q = 600 #Heat supplied(in kJ):
#From steam tables:
hf = 612.1
hfg = 2128.7
vg = 0.4435
h2 = 1582.8
#Calculations:
p = F/(pi*D**2)*4+101.3 #Pressure at which process is taking place(in kPa):
V1 = pi*D**2*d/4 #Volume of water contained(in m**3):
m = V1*1000 #Mass of water(in kg):
x = (Q-hf*m+4.18*T*m)/(hfg*m) #Dryness fraction:
U1 = m*4.18*T-p*V1 #Internal energy of water initially(in kJ):
V2 = m*x*vg #Final volume(in m**3):
U2 = m*h2-p*V2 #Internal energy at state 2(in kJ):
dU = U2-U1 #Change in internal energy(in kJ):
W = p*(V2-V1) #Work done(in kJ):
#Results:
print "Dryness fraction of the steam produced: " ,round(x,3)
print "Change in internal energy: ",round(dU,2), "kJ"
print "Work done: ",round(W,2),"kJ"
```

In [20]:

```
#Variable Declaration:
ms = 40 #Mass of steam passed(in kg):
mw = 2.2 #Mass of water passed(in kg):
p1 = 1.47 #Initial pressure of steam(in MPa):
T = 120 #Temperature after throttling(in C):
p2 = 107.88 #Pressure after throttling(in kPa):
s = 2.09 #Specific heat of superheated steam(in kJ/kg.K):
hf = 840.513 #From steam tables:
hfg = 1951.02
h1 = 2673.95
#Calculations:
ds = T-101.8 #Degree of superheat(in C):
h2 = h1+ds*s #Enthalpy of superheated steam(in kJ/kg):
x2 = (h2-hf)/hfg #Dryness fraction after throttling:
x1 = (ms-mw)/ms #Dryness fraction before throttling:
x = x1*x2 #Overall dryness fraction:
#Results:
print "Dryness fraction ",round(x,4)
```

In [21]:

```
#Variable Declaration:
Va = 0.4 #Initial volume in part A(in m**3):
pa = 10 #Pressure(in bar):
V = 0.4 #Initial volume in part B(in m**3):
p1 = 10 #Pressure in part B(in bar):
p2 = 15 #Final pressure in part B(in bar):
#From steam tables:
hf = 762.83
hfg = 2015.3
h2 = 2792.2
#Calculations:
Q = V*(p2-p1)*10**2 #Heat added(in kJ):
x1 = (h2-Q-hf)/hfg #Dryness fraction:
#Results:
print "Heat added: ",round(Q),"kJ"
print "Initial quality: ",round(x1,3)
```

In [23]:

```
#Variable Declaration:
m = 3 #Mass of wet steam(in kg):
p1 = 1.4 #Initial pressure(in bar):
V1 = 2.25 #Initial volume(in m**3):
T = 400 #Final temperature of steam(in °C):
V2 = 4.65 #At 400 °C,volume of steam(in m**3):
#From steam tables:
vg = 1.2455
hf = 457.99
hfg = 2232.3
h2 = 3276.6
uf = 457.84
ufg = 2059.34
u2 = 2966.7
#Calculations:
v1 = V1/m #Specific volume of wer steam in cylinder(in m**3/kg):
x1 = v1/vg #Dryness fraction of initial steam:
h1 = hf+x1*hfg #Initial enthalpy of wet steam(in kJ/kg):
v2 = V2/m #At 400°C specific volume of steam(in m**3/kg):
p2 = 0.20 #Actual pressure(from steam table)(in MPa):
ds = T-120.23 #Finally the degree of superheat(in °C): #Saturation temp at this pressure = 120.23Â°C
Q = m*(h2-h1) #Heat added during the process(in kJ):
u1 = uf+x1*ufg #Internal energy of initial wet steam(in kJ/kg):
dU = m*(u2-u1) #Change in internal energy(in kJ):
W = Q-dU #Work done(in kJ):
#Results:
print "Heat transfer: ",round(Q,2),"kJ"
print "Work transfer : ",round(W,2),"kJ"
print "____Note: Please check the value of x1 calculated and used: (calculated is 0.602 and used is 0.607 hence there is a difference in answer)____"
```

In [24]:

```
#Variable Declaration:
p1 = 10 #Pressure of the steam(in bar):
T = 500 #Temperature(in °C):
p2 = 1 #Final pressure(in bar):
#From steam tables:
h10bar500 = 3478.5 #kJ/kg
s10bar500 = 7.7622 #kJ/kg.K
v10bar500 = 0.3541 #m**3/kg
h1bar400 = 3278.2 #kJ/kg
h1bar500 = 3488.1 #kJ/kg
v1bar500 = 3.565 #m**3/kg
v1bar400 = 3.103 #m**3/kg
s1bar500 = 8.8342 #kJ/kg.K
s1bar400 = 8.5435 #kJ/kg.K
h2 = h10bar500
#Calculations:
T2 = (h2-h1bar400)*(T-400)/(h1bar500-h1bar400)+400 #Final temperature(in °C):
s2 = s1bar400+(s1bar500-s1bar400)/(T-400)*(T2-400) #Final entropy(in kJ/kg.K):
ds = s2-s10bar500 #Change in entropy(in kJ/kg.K):
v2 = v1bar400+(v1bar500-v1bar400)/(T-400)*(T2-400) #Final specific volume(in m**3/kg):
p = v10bar500/v2*100 #Percentage volume occupied by steam:
#Results:
print "Final temperature: ",round(T2,2),"°C"
print "Change in entropy: ",round(ds,4),"kJ/Kg K"
print "Percentage of vessel volume initially occupied by steam: ",round(p,2),"%"
```

In [25]:

```
#Variable Declaration:
#Steam entering:
p1 = 2.5 #Pressure(in MPa):
T1 = 350 #Temperature(in °C):
#Steam rejected:
p2 = 20 #Pressure(in kPa):
x2 = 0.92 #Dryness fraction:
p3 = 30 #Pressure of one quater of intial steam(in kPa):
T0 = 30+273 #Temperature(in K):
m1 = 1
m2 = 0.25
m3 = 0.75
Q = -10 #Heat lost during expansion(in kJ):
#From steam tables:
h1 = 3126.3 #kJ/kg
s1 = 6.8403 #kJ/kg.K
h2 = 2878.6 #kJ/kg
s2 = 8.5309 #kJ/kg.K
h3 = 2421.04 #kJ/kg
s3 = 7.3425 #kJ/kg.K
hf = 251.40 #kJ/kg
hg = 2609.7 #kJ/kg
sf = 0.8320 #kJ/kg.K
sfg = 7.0766 #kJ/kg.K
h0 = 125.79
s0 = 0.4369
#Calculations:
A1 = (h1-h0)-T0*(s1-s0) #Availability of steam entering turbine(in kJ/kg):
A2 = (h2-h0)-T0*(s2-s0) #Availability of steam leaving turbine at state 2(in kJ/kg):
A3 = (h3-h0)-T0*(s3-s0) #Availability of steam leaving turbine at state 3(in kJ/kg):
Wmax = m1*A1-m2*A2-m3*A3 #Maximum work per kg of steam entering turbine(in kJ/kg):
I = T0*(m2*s2+m3*s3-m1*s1)-Q#Irreversibilty(in kJ/s):
#Results:
print "Maximum work",round(Wmax,2),"kJ/kg"
print "Irreversibility",round(I,2),"kJ/s"
```

In [26]:

```
#Variable Declaration:
p1 = 6 #Initial pressure(in MPa):
p2 = 5 #Final pressure(in MPa):
T1 = 400 #Initial temperature(in °C):
patm = 100 #Atmospheric pressure(in kPa):
Ta = 20+273 #Atmospheric temperature(in °K):
#From steam tables:
h1 = 3177.2 #kJ/kg
s1 = 6.5408 #kJ/kg.K
h2 = h1
T2 = 392.7 #°C(by interpolation)
s2 = 6.6172 #kJ/kg.K(#By interpolation Entropy)
h0 = 83.96 #kJ/kg
s0 = 0.2966 #kJ/kg
#Calculations:
A1 = (h1-h0)-Ta*(s1-s0) #Availability at state 1(in kJ/kg):
A2 = (h2-h0)-Ta*(s2-s0) #Availability at state 2(in kJ/kg):
dA = A2-A1 #Change in availibilty(in kJ/kg):
print "Change in availability: ",round(-dA,1),"kJ/kg decrease",
```

In [27]:

```
#Variable Declaration:
TH1 = 95 #Temperature of the hot water entering(in Â°C):
TH2 = 50 #Temperature of the hot water at exit(in Â°C):
mH = 0.8 #Mass flow rate(in kg/s):
TC1 = 15+273 #Temperature of cooling water entering(in Â°K):
TC2 = 45+273 #Temperature of cooling water at exit(in Â°K):
T0 = 25+273 #Temperature of dead state(in K):
#From steam tables:
h0 = 104.89 #kJ/kg
s0 = 0.3674 #kJ/kg.K
hH1 = 397.96 #kJ/kg
sH1 = 1.2500 #kJ/kg.K
hH2 = 209.33 #kJ/kg.K
sH2 = 0.7038 #kJ/kg.K
hC2 = 188.45 #kJ/kg.K
sC2 = 0.6387 #kJ/kg.K
hC1 = 62.99 #kJ/kg.K
sC1 = 0.2245 #kJ/kg.K
#Calculations:
mC = mH*(TH1-TH2)/(TC2-TC1) #Mass flow rate of cooling water(in kg/s):
AH1 = mH*((hH1-h0)-T0*(sH1-s0)) #Exergy entering through hot water stream(in kJ/s):
dAc = mC*((hC2-hC1)-T0*(sC2-sC1))#Rate of exergy increase in cold stream(in kJ/s):
n = dAc/AH1*100 #Second law efficiency:
dAh = mH*((hH1-hH2)-T0*(sH1-sH2))#Rate of exergy loss in hot stream(in kJ/s):
dA = dAh-dAc #Exergy destruction(in kJ/s):
#Results:
print "Second law efficincy: ",round(n,2),"%"
print "Exergy destruction: ",round(dA,2),"kJ/s"
```