import math
#Initialization of variables
h1 = 1.5 #m
h2 = 2. #m
g1 = 800. #kg/m**3
g2 = 1000. #kg/m**3
g = 9.81
#calculations
P = h1*g*g1 + h2*g*g2
#results
print "Pressure at the bottom of the vessel = %.2f kN/m**2"%(P/1000)
import math
#Initialization of variables
depth = 8000. #m
sw = 10.06 #kN/m**3
BM = 2.05*10**9 #N/m**2
#calculations
g = sw*10**3 /(1- sw*10**3 *depth/BM)
Ph = 2.3*BM*math.log10(BM/(BM-depth*9.81*1025))
#results
print "Specific weight = %.2f kN/m**2"%(g/1000)
print " Pressure at depth h = %.2f MN/m**2"%(Ph/10**6)
# note : rounding off error.
import math
#Initialization of variables
Patm = 101.3/9.81 #m of water
x1 = 0.45 #m
x2 = 0.3 #m
s1 = 920. #Kg/m**3
s2 = 13.6 #Kg/m**3
g = 9.81 #m/s**2
#calculations
Pa = (s1*x1*g + s2*x2*g)/1000
Pa2 = Pa*10**3/(1000*g)
Pa3 = Pa/(s2)
#results
print "Pressure at A = %.1f kPa"%Pa
print " Pressure at A = %.3f m of water"%(Pa2)
print " Pressure at A = %.3f m of mercury"%(Pa3)
print " Pressure at A = %.1f m of water absolute"%(Pa/1000 +101.3)
print " Pressure at A = %.3f m of mercury"%(Pa2+10.3)
import math
#Initialization of variables
sg = 1.25 # gravity
d = 0.5 #m
d2 = 13.5*10**-2 #m
sw = 9.81 #specific weight of water - kN/m**2
#calculations
sl = sg*sw #specific weight of liquid
sm = 13.6*sw #specfic weight of mercury
Pa = sl*d - sm*d2
#results
print "Pressure at A = %.2f kN/m**2 vacuum "%(-Pa)
import math
#Initialization of variables
#Following values are ontained from the figure 2.17
s1 = 0.85
s2 = 13.6
z1 = 30
z2 = 15
z3 = 20
z4 = 35
z5 = 60
#calculations
dHa = s1*(z1+z5+z3-z4) +s2*z4 -z3+s2*z2-s1*(z1+z2) #Ha-Hb
Pd = 1000*9.81*dHa/100 #Pa-Pb
#results
print "Pressure difference = %.2f kN/m**2"%(Pd/1000)
import math
#Initialization of variables
P = 450 #pressure - kN/m**2
alt = 2000 #altitude - m
r = 610 #atmospheric pressure - mm of mercury
#calculations
Pat = 760-r
Pat2 = Pat*13.6*9.81*10**-3
Pg = Pat2+P
#results
print "Gauge reading = %.2f kN/m**2"%(Pg)
import math
#Initialization of variables
g = 9.81 #kN/m**2
hc = 16.25 #m
w = 1.5 #width - m
b = 2.5 #depth - m
f = 0.3 #coefficient of friction
Pi = 50. #weight of gate - kN
#calculations
P = g*hc*w*b
Preq = Pi+f*P
#results
print "Force required to lift the gate = %.2f kN"%(Preq)
import math
#Initialization of variables
a = 6. #m
b = 8. #m
#calculations
Ixy = 9./32 *b**4 /4
xp = Ixy/(2./3 *b *1./2 *a*b)
ICG = 1./36 *a*b**3
yp = 2./3*b + ICG/(2./3 *b* 1./2 *a*b )
#results
print "The coordinates of centre of pressure are %.2f,%d"%(xp,yp)
import math
#Initialization of variables
z = 1.2 #m
y = 1. #m
#calculations
hp = 0.6 + 1./12 *y*z**3 /(0.6*y*z)
#results
print "Position of hinge = %.1f m"%(hp)
import math
from sympy import *
#Initialization of variables
r = 0.75 #radius of plane - m
gam = 8. #specific weight of fluid - kN/m**3
#calculations
P = gam*2./3 *r**3
hp = Symbol('hp')
hp = 4*r/(3*math.pi) + (math.pi/gam - gam/(9*math.pi)) * r**4/(4*r/(3*math.pi) * 1./2*math.pi*r**3)
#results
print " Total pressure = %.2f kN"%(P)
print "Total pressure location = %.3f m"%(hp)
# note : answer is slightly different because of rounding off error. please check.
import math
#Initialization of variables
B = 3. #m
b = 2. #m
h1 = 0.75 #m
h2 = 1. #m
sg = 0.9 #specific gravity
#calculations
IP = sg*9.81*h2
F1 = 0.5*IP*h2
F2 = IP*h1
F3 = 0.5*(9.81*h1)*h1
F = B*(F1+F2+F3)
ybar = (F1*(h1+ 1./3) + F2* h1/2 + F3* h1/3)/(F1+F2+F3)
#results
print "Total force = %.2f kN"%(F)
print "Location = %.3f m from the base"%(ybar)
# note : rounding off error.
import math
from scipy.integrate import quad
#Initialization of variables
g = 1000*9.81 #kg/m**3
hc = 20. #m
Ax = 40.*1 #m**2
y1 = 0. #m
y2 = 40. #m
#calculations
Fx = g*hc*Ax
def fy(y):
return (12*y)**(1./3)
Fy = quad(fy,y1,y2)
Fy = g*Fy[0]
F = math.sqrt(Fx**2 +Fy**2)
#results
print "Net force = %d kN"%(F/1000)
#The answer is a bit different due to rounding off error in the textbook
import math
#Initialization of variables
g = 9.81 #kN/m**2
hc = 1. #m
l = 3. #m
b = 0.5 #m
#calculations
Ax = l*b #m**2
Fx = g*hc*Ax
Fz = g*(0.5* math.pi/4 *b**2)*l
F = math.sqrt(Fx**2 + Fz**2)
theta = math.degrees(math.atan(Fz/Fx))
#results
print "Magintude of resultant force = %.3f kN"%(F)
print " Direction of the resultant force = %.1f deg"%(theta)
import math
#Initialization of variables
r1 = 920. #density of ice - kg/m**3
r2 = 1030. #density of sea water - kg/m**3
#calculations
VtbyV2 = r2/r1
V1byV2 = VtbyV2-1
V1byVt = 1./(1+1/V1byV2)
#results
print "fraction = %.3f "%(V1byVt)
import math
#Initialization of variables
d = 3. #diameter of balloon - m
rh1 = 1.19 #density of air - kg/m**3
rh2 = 0.17 #density of helium - kg/m**3
g = 9.81 #m/s**2
#calculations
pay = (rh1-rh2)*g*math.pi/6 *d**3
#results
print " Pay load = %.2f N"%(pay)
from numpy import roots
#calculations
y = [6,-6,1]
z = roots(y)
#results
print "For stability, s must be greater than %.2f and less than %.2f and must be less than 1"%(z[0],z[1])
import math
#Initialization of variables
ax = 1.5 #m/s**2
g = 9.81 #m/s**2
#calculations
alpha = math.degrees(math.atan(ax/g))
#results
print "The interface is inclined at %.f degrees with the horizontal"%(alpha)
import math
#Initialization of variables
d = 10. #diameter - cm
h = 25. #height - cm
hw = 15. #cm
g = 9.81 #m/s**2
#calculations
z = d**2 *d*2/d**2
w = math.sqrt(z*2*g/(d/2)**2 *100)
N = w/(2*math.pi) *60
#results
print "Speed of rotation = %d rpm"%(N)
import math
from scipy.integrate import quad
#Initialization of variables
dia = 1. #diameter - m
h = 3. #height - m
rho = 1000. #kg/m**3
N = 80. #rpm
g = 9.81 #m/s**2
#calculation
w = 2*math.pi*N/60
def fun(r):
return 0.5*rho*w**2 *r**3 *2*math.pi
vec = quad(fun,0,dia/2)
Pt = vec[0] + math.pi/4 *dia**2 *(h-dia)*rho*g
#results
print "Total pressure on base = %.2f kN"%(Pt/1000)