In [1]:

```
#Variable declaration
V=0.01; # Volume of water in a rigid vessel in m^3
m=4.5; # Mass of water+ steam in a rigid vessel in kg
T=35; # Temperature of water in a rigid vessel in degree celcius
#Calculation
# (a)
v=V/m; # specific volume of water
# From steam table
vf=0.001006; vg=25.22; # specific volume in m^3/kg
x=(v-vf)/(vg-vf); # Quality of steam
x1=1-x; # Quality of water
mg=x*m; # Mass of steam
mf=x1*m; # Mass of water
#Result for (a)
print "(a).\n","Quality of steam in a rigid vessel = ",x,"\nQuality of water in a rigid vessel = ",x1
print "Mass of steam in a rigid vessel = ",round(mg,8),"kg\n","Mass of water in a rigid vessel = ",round(mf,9),"kg\n"
# (b)
#Result for (b)
vc=0.003155; # Crictical volume for water in m^3/kg
print "(b).\n","The level of liquid water will rise in the vessel. Since v < vc and refer figure 3.21\n"
# (c)
#Result for (c)
print "(c)\n","The final temperature after heating is 370.04 oC. Because it is constant volume process and refer figure 3.21\n"
# (d)
#Calculation for (d)
m1=0.45; # Mass of water in kg
v1=V/m; # specific volume of water
#Result for (d)
print"(d).\n", "Level of liquid drops to bottom (v1 > vc). Temperature on reaching saturation state is 298.5 oC and refer figure 3.21"
```

In [2]:

```
#Variable declaration for (a)
# (a) Ammonia 26 oC and 0.074 m^3/kg
# From saturation table of ammonia at 26 oC
v=0.074; # specific volume of ammonia in m^3/kg
vf=0.001663; vg=0.1245; # specific volume of ammonia in m^3/kg
#Calculation for (a)
x=(v-vf)/(vg-vf); # Quality of vapour since v<vg
#Result for (a)
print "(a) Ammonia 26 oC and 0.074 m^3/kg\n","The Quality of ammonia = ",round(x,3)
#Variable declaration for (b)
# (b).Ammonia 550kPa and 0.31m^3/kg
# From saturation table of ammonia at 550 kPa
v=0.31; # specific volume of ammonia in m^3/kg
vg=0.23; # specific volume of ammonia in m^3/kg
#Calculation for (b)
# v > vg . Since from superheated table by interpolation for 550kPa and v
T=82.1; # Temperature of ammonia in degree celcius
#Result for (b)
print "\n(b).Ammonia 550kPa and 0.31m^3/kg\n","Temperature of ammonia = ",T,"oC\n"
#Variable declaration for (c)
# (c).Freon 12, 0.35MPa and 0.036 m^3/kg
# From saturation table of Freon 12 at 0.35MPa
v=0.036; # specific volume of Freon 12 in m^3/kg
vf=0.000722; vg=0.049329; # specific volume of Freon 12 in m^3/kg
#Calculation for (c)
x=(v-vf)/(vg-vf); # Quality of vapour since v<vg
#Result for (c)
print "(c).Freon 12, 0.35MPa and 0.036 m^3/kg\n","The Quality of Freon 12 = ",round(x,2)
#Variable declaration for (d)
# (d).Methane 0.5MPa and 1.0 m^3/kmol
v=1; # specific volume of Methane in m^3/kmol
# From table at 0.5 MPa molar values are
vf=0.04153; vg=2.007; # specific volume of Methane in m^3/kmol
#Calculation for (d)
x=(v-vf)/(vg-vf); # Quality of vapour since v<vg
#Result for (d)
print "\n(d).Methane 0.5MPa and 1.0 m^3/kmol","\nThe Quality of Methane = ",round(x,4)
```

In [3]:

```
#Variable declaration
V=300; # Volume of air in the room in m^3
p=1; # Atmospheric pressure in bar
T=25; # Temperature of air in Degree Celcius
R=287; # Characteristic constant of Air in J/kg k
#Calculation
m=(p*10**5*V)/(R*(T+273)); # Ideal gas equation
#Result
print "Mass of air in room = ",round(m,2),"kg"
```

In [4]:

```
#Variable declaration
D=20; # Diameter of the sphere in cm
m=2.54; # Mass of gas filled in sphere in gram
p=10; # Pressure of gas in bar
T=25; # Temperature of gas in Degree Celcius
R=8.3144*10**3; # Universal gas constant in J/kmol K
#Calculation
V=(3.14*(D*10**-2)**3)/16; # Volume of das in sphere in m^3
M=(m*10**-3*R*(T+273))/(p*10**5*V); # Molecular weight of the gas
#Result
print "Molecular weight of the gas = ",round(M,3),"\nTherefore gas in sphere is Helium (unless mixture of two or more gases)"
```

In [5]:

```
#Variable declaration
p2=2.5; # Pressure of air in the cylinder in bar
T1=430; # Temperature of air in cylinder in Degree Celcius
V1=1.2; # Volume of cylinder in m^3
V2=0.6; # Volume of cylinder upto end stops in m^3
#Calculation for (a)
# (a) Temperature of air when the piston reaches the stops
T2=(T1+273)*(V2/V1); # constant pressure process
#Result for (a)
print "(a).Temperature of air when the piston reaches the stops = ",round(T2,1),"K"
#Calculation for (b)
# (b) The pressure of air when its temperature equals to 25 oC
T3=25; #Room temperature in Degree Celcius
p3=p2*((T3+273)/T2); # constant volume process
#Result for (b)
print "\n(b).The pressure of air when its temperature equals to 25 oC = ",round(p3,2),"bar"
```

In [6]:

```
import math
from __future__ import division
#Variable declaration
p=6000; # Pressure of nitrogen gas in kPa
T=150; # Temperature of nitrogen gas in kelvin
V=250; # Volume of tank in litres
R_1=8.3143; # Universal gas constant in kJ/kmol K
M=28.1013; # Molecular mass
#Calculation for (a)
# (a).Beattie - Bridgeman equation of state
# Constants for nitrogen gas
c=4.2*10**4; Ao=136.2315; a=0.02617; Bo=0.05046; b=-0.00691;
# By substituting these values in the following equation
# p=(R_1*T/v^2)*(1-(c/(vT^3)))*(v+Bo*(1-(b/v)))-(Ao/v^2*(1-(a/v)))
# By trial and error we get
v=0.1222; # specific volume in m^3/kmol
m=(M*V/1000)/v; # Mass of nitrogen gas
#Result for (a)
print "(a).Beattie - Bridgeman equation of state","\nMass of nitrogen gas = ",round(m,2),"kg"
print "specific volume of nitrogen gas = ",round(v,4),"m^3/kmol"
#Calculation for (b)
# (b).Nitrogen tables
# From property table of nitrogen fas
v=0.004413; # specific volume in m^3/kg
m=(V/1000)/v; # Mass of nitrogen gas
#Result for (b)
print "\n\n(b).Nitrogen tables","\nMass of nitrogen gas = ",round(m,2),"kg","\nspecific volume of nitrogen gas = ",round(v,6),"m^3/kg"
#Calculation for (c)
# (c).Ideal gas equation of state
m=(p*V/1000)/(R_1*T/M); #Mass of nitrogen gas
#Result for (c)
print "\n\n(c).Ideal gas equation of state","\nMass of nitrogen gas = ",round(m,2),"kg"
#Calculation for (d)
# (d).Generalized compressibility chart
# The crictical properties for nitrogen gas
Tc=126.2; # Temperature in kelvin
Pc=3.349; # Pressure in MPa
# Reduced properties are
Pr=p/Pc; Tr=T/Tc;
z=0.6; # From chart
m=(p*V/1000)/(z*R_1*T/M); #Mass of nitrogen gas
#Result for (d)
print "\n\n(d).Generalized compressibility chart","\nMass of nitrogen gas = ",round(m,2),"kg"
#Result for (e)
#(e).Arrangement the methods in order of percentage error
print " \n\n(e).Arrangement the methods in order of percentage error : "
print "Nitrogen tables","\nBeattie - Bridgeman equation of state","\nGeneralized compressibility chart","\nIdeal gas equation of state"
```

In [7]:

```
#Variable declaration
T=-58.7; #Normal boling point of CF3Br in Degree Celcius
Tc=340.9; # Crictical temperature of CF3Br in K
pc=4.05; # Crictical pressure of CF3Br in MPa
M=148.9; # Moleclar mass of CF3Br
p=1.01325*10**5; # Atmospheric pressure in N/m^2
R1=8314.4; # Universal gas constant in J/kmol K
R=R1/M; # Gas constant of CF3Br
#Calculation
a=(0.42748*R**2*Tc**2.5)/(pc*10**6); # Constant of Redlich-Kwong equation of state
b=(0.08664*R*Tc)/(pc*10**6); # Constant of Redlich-Kwong equation of state
vi=(R*(T+273))/p; # Ideal gas volume for assigning initial value
# By substituting these values in the Redlich-Kwong equation of state
vi_1=(R*(T+273)/p)+b-((a/(p*(273+T)**0.5*vi))*((vi-b)/(vi+b))); #and solving it by trial and error method we get
#Result
print "Saturated vapour volume = ",round(vi_1,5),"m^3/kg (roundoff error)"
```