In [2]:

```
#example 1
#determinig the phase of water
print"from the table,we find that at 120C,saturation pressure of water is 198.5 kPa.But here we have pressure of 500 kPa.hence,water exists as a compressed liquid here."
print"also at 120C,vf=0.00106 kg/m^3 and vg=0.89186 kg/m^3.given v=0.5 m^3/kg i.e. vf<v<vg,so we have two phase mixture of liquid and vapor."
```

In [3]:

```
#example 2
#determinig the phase
print"from the table,we find that at 30C,saturation pressure of ammonia is 1167 kPa.But here we have pressure of 1000 kPa.hence,ammonia exists in superheated vapor state."
print"for R-22 at 200 kPa,vg=0.1119 kg/m^3.given v=0.15 m^3/kg i.e. v>vg,so the state is superheated vapor"
```

In [13]:

```
#example 3
#determining the quality and specific volume
v1=0.5 #given specific volume in m^3/kg
vf=0.001073 #specific volume when only liquid phase is present in m^3/kg
vfg=0.60475 #in m^3/kg
x=(v1-vf)/vfg #quality
print"For water at a pressure of 300 kPa,the state at which v1 is 0.5 m^3/kg is seen to be in the liquid-vapor two-phase region,at which T=133.6 C and the quality is",round(x,3)
v2=1 #given specific volume in m^3/kg
# using the method of interplotation
T=((400-300)*(1.0-0.8753))/(1.0315-0.8753)+300 #temperature of the water
print"For water at a pressure of 300 kPa,the state at which v2 is 1 m^3/kg is seen to be in the liquid-vapor two-phase region,the temperature is",round(T,1)
```

In [7]:

```
#example 4
#percentage of vapor
vliq=0.1 #volume of saturated liquid in m^3
vf=0.000843 #in m^3/kg
vvap=0.9 #volume of saturated vapor R-134a in equilbrium
vg=0.02671 #in m^3/kg
mliq=vliq/vf #mass of liquid in kg
mvap=vvap/vg #mass of vapor in kg
m=mliq+mvap #total mass in kg
x=mvap*100/m #percentage of vapor on mass basis
print"hence,% vapor on mass basis is",round(x,1),"%"
```

In [1]:

```
#example 5
#percentage of vapor
vliq=0.1 #volume of saturated liquid in ft^3
vf=0.0136 #in ft^3/lbm
vvap=0.9 #volume of saturated vapor R-134a in equilbrium
vg=0.4009 #in ft^3/lbm
mliq=vliq/vf #mass of liquid in lbm
mvap=vvap/vg #mass of vapor in lbm
m=mliq+mvap #total mass in lbm
x=mvap*100/m #percentage of vapor on mass basis
print"hence,% vapor on mass basis is",round(x,1),"%"
```

In [7]:

```
#example 5
#calculating pressure after heat addition
v1=0.14922 #specific volume of sautrated ammonia in m^3/kg
print"Since the volume does not change during the process,the specific volume remains constant.therefore"
v2=v1 #in m^3/kg
print"Since vg at 40C is less than v2,it is evident that in the final state the Ammonia is superheated vapor.By interplotation,we find that"
P2=945 #final pressure in kPa
print"hence,the final pressure is 945 kPa"
```

In [8]:

```
#example 5
#calculating pressure after heat addition
v1=2.311 #specific volume of sautrated ammonia in ft^3/lbm
print"Since the volume does not change during the process,the specific volume remains constant.therefore"
v2=v1 #in ft^3/lbm
print"Since vg at 120f is less than v2,it is evident that in the final state the Ammonia is superheated vapor.By interplotation,we find that"
P2=145 #final pressure in lbf/in^2
print"hence,the final pressure is 145 lbf/in^2"
```

In [19]:

```
#example 6
#Determinig the missing property
T1=273-53.2 #given temperature in K
P1=600 #given pressure in kPa
print"This temperature is higher than the critical temperature (critical temp. at P=600 kPa) is 96.37 K.Hence,v=0.10788 m^3/kg"
T2=100 #given temp. in K
v2=0.008 #given specific volume in m^3/kg
vf=0.001452 #in m^3/kg
vg=0.0312 #in m^3/kg
Psat=779.2 #saturation pressure in kPa
vfg=vg-vf #in m^3/kg
x=(v2-vf)/vfg #quality
print"\n hence, the pressure is",round(Psat,1),"kPa"
print"\n and quality is",round(x,4),"%"
```

In [21]:

```
#example 7
#determining the pressure of water
vg=0.12736 #specific volume in m^3/kg for water at 200C
v=0.4 #specific volume in m^3/kg
P1=500 #in kPa
v1=0.42492 #specific volume at P1 in m^3/kg
P2=600 #in kPa
v2=0.35202 #specific volume at P2 in m^3/kg
P=P1+(P2-P1)*(v-v1)/(v2-v1) #calculating pressure by interplotation
print "hence,the pressure of water is",round(P,1)," kPa"
```

In [27]:

```
#example 8
#calculating mass of air
P=100 #pressure in kPa
V=6*10*4 #volume of room in m^3
R=0.287 #in kN-m/kg-K
T=25 #temperature in Celsius
m=P*V/(R*(T+273.1)) #mass of air contained in room
print"\n hence, mass of air contained in room is",round(m,1),"kg"
```

In [30]:

```
#example 9
#calculating pressure inside tank
V=0.5 #volumr of tank in m^3
m=10 #mass of ideal gas in kg
T=25 #temperature of tank in Celsius
M=24 #molecular mass of gas in kg/kmol
Ru=8.3145 #universal gas constant in kN-m/kmol-K
R=Ru/M #gas constant for given ideal gas in kN-m/kg-K
P=m*R*(T+273.2)/V #pressure inside tank
print"\n hence,pressure inside tank is",round(P),"kpa"
```

In [40]:

```
#example 10
#mass flow rate
dt=185 #time period in seconds over which there is incrrease in volume
dV=0.75 #increase in volume in 0.75 in m^3
V=dV/dt #volume flow rate in m^3/s
P=105 #pressure inside gas bell kPa
T=21 #temperature in celsius
R=0.1889 #ideal gas constant in kJ/kg-K
m=P*V/(R*(T+273.15)) #mass flow rate of the flow in kg/s
print"\n hence,mass flow rate is",round(m,5),"kg/s"
print"\n and volume flow rate is",round(V,5),"m^3/s"
#The answer of volume flow rate in the book is wrong.
```

In [51]:

```
#example 12
#determining specific using diffenet laws
T=100.0 #given temp.in 100 celsius
P=3.0 #given pressure in MPa
v1=0.0065 #specific volume in m^3/kg using table
print"\n hence,the specific volume for R-134a using R-134a tables is",round(v1,3),"m^3/kg"
M=102.3 #molecular mass in kg
R=8.3145 #in kJ/K
Ru=R/M #in kJ/K-kg
v2=Ru*(T+273)/(P*1000) #specific volume assuming R-134a to be ideal gas in m^3/kg
print"\n hence,the specific volume for R-134a using R-134a the ideal gas laws is",round(v2,5),"m^3/kg"
Tr=373.2/374.2 #reduced temperature using generalized chart
Pr=3.0/4.06 #reduced pressure using generalized chart
Z=0.67 #compressibility factor
v3=Z*v2 # specific volume using generalized chart in m^3/kg
print"\n hence,the specific volume for R-134a using the generalized chart is",round(v3,5),"m^3/kg"
```

In [44]:

```
#example 13
#calculating mass of gas
Pc=4250 #critical pressure of propane in kPa
Tc=369.8 #critical temperature in K
T=15 #temperature of propane in celsius
Tr=T/Tc #reduced temperature
Prsat=0.2 # reduced pressure
P=Prsat*Pc #pressure in kPa
x=0.1 #given quality
Zf=0.035 #from graph
Zg=0.83 #from graph
Z=(1-x)*Zf+x*Zg #overall compressibility factor
V=0.1 #volume of steel bottle in m^3
R=0.1887 #in kPa-m^3/kg-K
m=P*V/(Z*R*(T+273)) #total propane mass in kg
print"\n hence,the total propane mass is",round(m,2),"kg"
print"\n and pressure is",round(P,2),"kPa"
```