import math
#Initialization of variables
z = 20000. #ft
rate = -0.00356 #F/ft
T = 59. #F
P = 14.7 #psia
gamma = 0.076 #lb/ft**3
#calculations
P2 = P*144 - gamma*(z)
P2f = P2/144
P3 = P*math.exp(-gamma*z/(P*144))
P4 = ((P*144)**0.285 -0.285*gamma*z*(P*144)**(-0.715))**(1/0.285)
P4f = P4/144.
P5 = P*((460+T)/(460+T+rate*z))**(gamma*(T+460)/(P*144*rate))
#Results
print ' Constant density'
print ' Final pressure = %.2f psia'%(P2f)
print ' \nIsothermal'
print ' Final pressure = %.2f psia'%(P3)
print ' \nIsentropic'
print ' Final pressure = %.1f psia'%(P4f)
print ' \nLinear decrease'
print ' Final pressure = %.1f psia'%(P5)
import math
#Initialization of variables
wA = 53.5 #weight of A - lb/ft**3
wA2 = 8.4 #kN/m**3
wB = 78.8 #weight of B - lb/ft**3
wB2 = 12.3 #kN/m**3
PB = 30. #pressure at B - psi
PB2 = 200. #kN/m**2
AB = 1.3 #ft
AB2 = 40./100 #m
BC = 6.5 #ft
BC2 = 2. #m
CD = 10. #ft
CD2 = 3. #m
#calculations
PAbyGB = PB*144/wB - AB*13.55*62.4/wB - (BC+CD) + (AB+BC)*wA/wB
PA = PAbyGB*wB/144.
PAbyGB2 = PB2/wB2 - AB2*13.55*9.81/wB2 - (BC2+CD2) + (AB2+BC2)*wA2/wB2
PA2 = PAbyGB2*wB2
#Results
print ' English units'
print " Final pressure = %.1f psi"%(PA)
print ' \n SI Units'
print " Final pressure = %d kPa"%(PA2+1)
import math
from numpy import *
#Initialization of variables
W = 500. #weight of gate - lb
width = 2. #ft
len1 = 4. #ft
CGx = 1.2 #ft
CGy = 0.9 #ft
theta = 30. #degrees
gam = 62.4 #lb/ft**3
#calculations
Fv = width*len1 #multiply by gam*x
F = width/(2*math.cos(math.radians(theta))) #multiply by gam*x*x
vector = roots([F*gam*0.770/2,0, - Fv*gam*width,W*CGx])
#Result
print 'The gate will remain closed between %.2f ft and %.2f ft'%(vector[2],vector[1])
import math
#Initialization of variables
z1 = 1. #in
z2 = 2. #in
z3 = 2. #in
sOil = 0.8
sWater = 1.
Pa = 3. #psi
#calculations
Pd = (Pa) + (z2+z1)*sOil*62.4/144 + 62.4*z3/144
Fa = Pa*144*math.pi*z3**2
Fb = sOil*62.4*(z2+z1-(z2+z3)*z2/((z2+z1)*math.pi))*(math.pi*z3**2 /2)
Fc = sOil*62.4*(z2+z1)*(math.pi*z3**2 /2)
Fd = 62.4*(z2+z3)*z2/((z2+z1)*math.pi)*(math.pi*z3**2 /2)
F = Fa+Fb+Fc+Fd
yPa = z2+z1
yCb = z2+z1-(z2+z3)*z2/((z2+z1)*math.pi)
ICb = math.pi*(z2+z3)**4 /128 -0.5*math.pi*z2**2 *((z2+z3)*z2/((z2+z1)*math.pi))**2
yPb = yCb+ICb/(yCb*0.5*math.pi*z2**2)
yPc = z2+z1+ (z2+z3)*z2/((z2+z1)*math.pi)
ICd = ICb
yPd = z2+z1 + (z2+z3)*z2/((z2+z1)*math.pi) + ICb/((z2+z3)*z2/((z2+z1)*math.pi)*0.5*math.pi*z3**2 )
yP = (Fa*yPa+Fb*yPb+Fc*yPc+Fd*yPd)/F
#Results
print ' case 1'
print ' Pressure at the bottom = %.1f psi'%(Pd)
print ' \n case 2'
print ' Net force = %d lb'%( F+3)
print ' Location of net force = %.2f ft'%( yP)
import math
#Initialization of variables
dia = 4. #m
P = 35. #kN/m**2
theta = 30. #degrees
#calculations
Fx = P*(dia-dia*(1-math.cos(math.radians(theta)))/2.)
Fz = P*dia*math.sin(math.radians(theta))/2
dist = (dia-dia*(1-math.cos(math.radians(theta)))/2.)
Fxb = 9.81*dist*dist/2
Fzb = 9.81*((180+theta)*math.pi*(dia/2)**2/360 + math.sqrt(3) /2 + dia/2)
#Results
print ' part a'
print ' Horizontal force = %.1f kN/m to the right'%( Fx)
print ' Vertical force = %.1f kN/m upward' %( Fz)
print ' \n part b'
print ' force by the fluid = %.1f kN/m to the right'%(Fxb)
print ' weight of the cross-hatched volume of liquid = %.1f kN/m Upward'%(Fzb )
import math
from numpy.linalg import solve
from numpy import *
#Initialization of variables
d1 = 4. #diameter - in
h1 = 3.75 #in
w1 = 0.85 #weight of cylinder - lb
gamma = 52. #lb/ft**3
d2 = 5. #in
depth = 3. #in
#calculations
A = array([[(d1/2)*(d1/2), -(d2/2)*(d2/2)+(d1/2)*(d1/2)],[ 1,1]])
b = array([[0],[w1*12*(12*2/d1)**2 /(gamma*math.pi)]])
C = solve(A,b)
x = C[0]
y = C[1]
height = depth-x
#Results
print 'Bottom of the cylinder will be %.2f in above the bottom of hollow cylinder'%(height)
import math
#Initialization of variables
v = 180. #velocity - m/s
angle = 40. #degrees
a = 4. #m/s**2
r = 2600. #radius - m
g = 9.81 #m/s**2
#calculations
#Assume outward and right as positive
an = round(-v*v/r,1)
at = -a
ax = at*math.cos(math.radians(angle)) +an*math.sin(math.radians(angle))
az = at*math.sin(math.radians(angle)) -an*math.cos(math.radians(angle))
tangent = ax/(az+g)
theta = math.degrees(math.atan(tangent))
#Results
print 'Angle made by the free liquid = %.1f degrees'%(-theta)