from __future__ import division
print "Example 10.1 pagr no. 98\n\n"
# in a column of liquid
h=2.493#height of the liquid (mercury) column
rho=848.7#density of mercury
P_at=2116#atmospheric pressure
print "\n height of mercury h=%0.3f ft\n density of mercury rho=%0.3f lb/ft**3\n atmospheric pressure P_at=%0.3f psf "%(h,rho,P_at)#
#refer to equation 10.5
g=9.8
g_c=9.8
P=rho*(g/g_c)*h#gauge pressure
P_ab=round(P+P_at)#absolute pressure
print "gauge pressure P=%0.3f psf\n absolute pressure P_ab=%0.3f psf"%(P,P_ab)#
from __future__ import division
print "Example 10.2 page no 99\n\n"
#determining the depth of atlantic ocean
rho=1000#density of water
P1=10#pressure at which depth is to be determine
P2=1#pressure at the ocean surface z1
z1=0#ocean surface
g=9.807#gravitational constant
print "\n density rho=%0.3f kg/m**3\n pressure P1=%0.3f atm\n pressure P2=%0.3f atm\n height at ocean surface z1=%0.3f m"%(rho,P1,P2,z1)#
z2=z1-(P1-P2)*101325/(rho*g)#depth at pressure P2
print " \n depth z2=%0.3f m"%(z2)#
from __future__ import division
from math import pi
from sympy.mpmath import quad
print "Example 10.3 page no 99 fig 10.1\n\n\n"
#a cylindrical tank contain water and immiscible oil ,tank isvopen to the atmosphere
rho=1000#density of water
SG=0.89#special gravity of oil
rho_oil=rho*SG#density of oil
print "\n density of water rho=%0.3f kg/m**3\n density of oil rho_oil=%0.3f kg/m**3"%(rho,rho_oil)#
#applying bernoulli equationbetween point 1 and 2 to calculate the gauge pressure at water oil interface
z1=0#depth at surface
P1=1#pressure at point 1
z2=-10.98#depth at point 2
print "\n depth at point 1, z1=%0.3f m\n pressure P1=%0.3f atm\n depth at point 2,z2=%0.3f m"%(z1,P1,z2)#
g=9.807#gravitational constant
P2_gu=rho_oil*g*(z1-z2)#gauge pressure at point 2
print "\n gauge pressure P2_gu=%0.3f Pag"%(P2_gu)#
#gauge preesure at bottom z3
z3=-13.72
P3=P2_gu+rho*g*(z2-z3)
print "\n depth z3=%0.3f m\n pressure at bottom P3=%0.3f Pag"%(z3,P3)#
d=6.1#diameter of tank
s=pi*d**2/4#surface area of tank
print "\n diameter of tank d=%0.3f m\n surface area of tank s=%0.3f m**2"%(d,s)#
P3_ab=P3+101325#absolute pressure
F=P3_ab*s#pressure force at the bottom of tank
print "\n absolute pressure P3_ab=%0.3f Pag\n pressure force at bottom F=%0.2e N"%(P3_ab,F)#
#the force on the side of the tank ,within water layer
F_s=(pi*d)*quad(lambda z:-11910-9807*z,[-13.72,-10.98])#
print "\n force on the side of the tank F_s=%0.2e N"%(F_s)#
from __future__ import division
print " Example 10.4 page n0 102 \n\n"
W_a=200#weight of material in air
W_w=120#weight of material in water
gamma_w=62.4#specific weight of water
print "\n weight of air W_a=%0.3f lbf\n weight of water W_w=%0.3f lbf\n sp.weight of water gamma_w=%0.3f lbf/ft**3"%(W_a,W_w,gamma_w)#
F_b=W_a-W_w#buoyant force\
print "\nbuoyant force F_b=%0.3f lbf"%(F_b)#
V_dis=F_b/gamma_w#volume displaced
print "\n volume displaced V_dis=%0.3f ft**3"%(V_dis)#
rho_b=W_a/V_dis#density of block
print "\n density of block rho_b=%0.3f lb/ft**3"%(rho_b)##printing mistake in book
#assumption of rho_b>rho_w is justified
from __future__ import division
from math import pi
print "\n Example 10.5 page no 103\n\n"
#a hydrometer is a liquid specific gravity indicator with the value being indicated by the level at which the surface of the liquid intersects the sten when floating in avliquid
F=0.13#the total hydrometer weight, N
SG=1.3#sp. gravity of liquid
D=.008#stem diameter of hydrometer,m
rho_w=1000#density of water ,kg/m**3
g=9.807
pi=22/7
print "\n force F=%0.3f N\n sp.gravity SG=%0.3f \n stem diameter D=%0.3f m\n density rho_w=%0.3f kg/m**3\n g=ravitational acc. g=%0.3f m/s**2"%(F,SG,D,rho_w,g)#
h=(4*F/(pi*D**2*rho_w*g))*(1-1/SG)#height where it will float
print "\n height h=%0.3f m"%(h)#
from __future__ import division
print "\n Example 10.6 page no 105 fig. 10.3\n\n\n"
# since the density of air is effectively zero,the contribution of air to the 3 ft. manometer can be neglected
#the contribution due to the carbon tetrachloride can be found by using the hydrostatic equation
rho=62.3#density of water
SG=1.4#/specific gravity of ccl4
h=3#height in manometer
P=rho*SG*h/144#factor 144 for psf to psi
print " \n pressure P=%0.3f psi"%(P)#
P_r=14.7#the right leg of manometer is open to atmosphere,atmospheric pressure at this point
#contribution to the prssure due to the height of water above pressure gauge
P_w=rho*h/144
print "\n pressure at right leg P_r=%0.3f psia\n pressure due to water height P_w=%0.3f psi"%(P_r,P_w)#
P_a=P_r-P+P_w#absolute pressure
P_g=P_a-14.7#gauge pressure
print "\n absolute pressure P_a=%0.3f psia\n gauge pressure P_g=%0.3f psig"%(P_a,P_g)#
P_af=P_a*144
P_gf=round(P_g*144)
print "\npressure in psfa P_af=%0.f psfa\n pressure in psfg P_gf=%0.f psfg"%(P_af,P_gf)#