Chapter 2:THERMODYNAMIC CONCEPTS AND THE ZEROTH LAW

Example 2.1, Page No:33

In [1]:
#Variable declaration
patm = 14.5 ;                                   # atmospheric pressure in psia
pgauge = 2.5;                                   # gauge pressure in psia
A = 10;                                         # Area of the piston in in^2
g=9.80665;                                      # Acceleration due to gravity in m/s^2
#Calculation for (a)
p = patm + pgauge;                              #total pressure of gas
m=(p-patm)*A ;                                  # mass of the piston
#Result for (a)
print "In English units"
print "Mass of the piston =",m,"lbm"
#Calculation for (b)
p=(p*0.454*g)/(0.0254**2);                      # conversion of English unit to SI units
patm=(patm*0.454*g)/(0.0254**2);                # conversion of English unit to SI units
m = ((p-patm)*(A*2.54**2*10**-4))/g;            # Mass of the piston
#Result for (b)
print "\nIn SI units \n","Mass of the piston =",m,"kg"
In English units
Mass of the piston = 25.0 lbm

In SI units 
Mass of the piston = 11.35 kg

Example 2.2, Page No:34

In [2]:
import math
#Variable declaration
d_r = 13600;                                   # Density of manometric fluid (mercury) in kg/m^*3
g = 8.92;                                      # Gravitational acceleration in m/s^2
#Variable declaration
z1=0.589*math.sin(math.radians(60));           # vertical height of fluid at section 1
z2=2*math.sin(math.radians(30));               # vertical height of fluid at section 2
z=z2-z1;                                       # Difference in vertical heights of fluid
patm = 14.7;                                   # Atmospheric pressure in lbf/in^2
patm=(patm*4.44822*144/0.3048**2);             # conversion of lbf/in^2 unit to N/m^2 unit
p=patm + (d_r*g*(z2-z1));                      # Balance of force at A
#Result
print "Difference in vertical heights of fluid = ",round(z,2),"m"
print "\nThe pressure of fluid in the vessel = ",round(p/1000,0),"kPa" 
Difference in vertical heights of fluid =  0.49 m

The pressure of fluid in the vessel =  161.0 kPa