import math
# Variables :
D = 30*10**-2; #in m
F = 9810.; #in N
# Calculations
A = math.pi*D**2/4; #in m**2
p = F/A; #in N/m**2 or Pa
p = p/1000; #kPa
# Results
print "Intensity of pressure at the bottom of container in kPa : %.2f"%p
# Variables :
h = 1.5; #in m
w_w = 9.81; #in kN/m**3
w_g = 1.26; #in kN/m**3
w_m = 13.6; #in kN/m**3
# Calculations and Results
f = h*w_w; #kN/m**2
print "Intensity of pressure exerted by water column in kN/m**2 : ",f
f = h*w_w*w_g; #kN/m**2
print "Intensity of pressure exerted by glycerine column in kN/m**2 : ",f
f = h*w_w*w_m; #kN/m**2
print "Intensity of pressure exerted by mercury column in kN/m**2 : ",f
# Variables :
p = 2; #in kN/m**2
w_w = 9.81; #in kN/m**3
w_alcohol = w_w*0.789; #in kN/m**3
w_m = 13.6; #in kN/m**3
# Calculations and Results
H = p/w_alcohol; #in m
print "Depth of alcohol in meter : %.3f"%H
P_head_w = p/w_w; #m
print "Pressure head in terms of water in meter : %.3f"%P_head_w
P_head_m = p/w_w/w_m; #m
print "Pressure head in terms of mercury in meter : %.3f"%P_head_m
# Variables :
Hwater = 6.; #m(Pressure head of water)
S_oil = 0.70; #(specific gravity of oil)
# Calculations and Results
H_oil = Hwater/S_oil; #in m(Pressure head in terms of oil)
print "Pressure head of water in terms of oil in meter : %.2f"%H_oil
S_oil = 0.825; #(specific gravity of oil)
S_mercury = 13.6; #(specific gravity of mercury)
Hmercury = 70./100; #m(Pressure head of mercury)
H_oil = S_mercury/S_oil*Hmercury; #in m(Pressure head in terms of oil)
print "Pressure head of mercury in terms of oil in meter : %.3f"%H_oil
# Variables :
w = 9.81; #in kN/m**3
l = 3.; #in m
b = 2.; #in m
h = 1.; #in m
# Calculations and Results
f_bottom = w*h; #in kN/m**2(Pressure intensity at bottom)
p_bottom = f_bottom*l*b; #kN
print "Total pressure on the bottom in kN : ",p_bottom
f_long_vertical = f_bottom/2; #kN
p_long_vertical = f_long_vertical*l*h; #kN
print "Total pressure on long vertical wall in kN : ",p_long_vertical
f_short_vertical = f_bottom/2; #kN
p_short_vertical = f_short_vertical*b*h; #kN
print "Total pressure on short vertical wall in kN : ",p_short_vertical
# Variables :
p_water = 1000.; #in kg/m**3
p_liquid = 800.; #in kg/m**3
g = 9.81; #gravity consmath.tant
h1 = 1.5; #m
# Calculations and Results
px1 = p_liquid*g*h1/1000; #kN/m**2
print "Pressure at a point 1.5 meter below free surface in kN/m**2 : ",px1
h2 = 2.; #m
px2 = p_liquid*g*h2/1000; #kN/m**2
print "Pressure at a point 2 meter below free surface in kN/m**2 : ",px2
h31 = 2.; #m(for liquid)
h32 = 0.5; #m(for water)
px1 = p_liquid*g*h31/1000; #kN/m**2
px2 = p_water*g*h32/1000; #kN/m**2
px3 = (px1+px2); #kN/m**2
print "Pressure at a point 2.5 meter below free surface in kN/m**2 : ",px3
h = 2.; #meter(water level)
b = 8.; #meter(width of wall)
p_bottom = px1+(p_water*g*h)/1000; #kN/m**2
p_avg1 = (px1+0)/2; #kN/m**2(top 2m liquid layer)
p_avg2 = (px1+p_bottom)/2; #kN/m**2(top 2m water layer)
F_per_meter = p_avg1*h*1+p_avg2*h*1; #kN
Fwall = F_per_meter*b; #kN
print "Force on the wall in kN : ",Fwall
# Variables :
b = 3.; #in meter
h = 3.; #in meter
S_oil = 0.8; #(specific gravity of oil)
# Calculations
A = 1./2*h*b; #in m**2
x_bar = 2./3*3; #in meter
SW_water = 9.81*1000; #in N/m**3
SW_oil = SW_water*S_oil; #in N/m**3
F_surface = SW_oil*A*x_bar; #in kN
IG = b*h**3/36; #in m**3
h_bar = IG/A/x_bar+x_bar; #in meter
# Results
print "Force shall act at depth of centre of pressure. This depth in meter is : ",h_bar
# Variables :
l = 3.; #in meter
b = 2.; #in meter
p = 2.*10**6; #in Pa
g = 9.81; #gravity consmath.tant
w = g*1000.; #in N/m**3
# Calculations and Results
h = p/w; #in meter
xbar = h-1.5; #in meter
A = l*b; #in m**2
p_gate = w*A*xbar/10**6; #in MN
print "Total pressure on the gate in MN : %.3f"%p_gate
IG = b*l**3/12; #in m**3
h_bar = IG/A/xbar+xbar; #in meter
print "Position of centre of pressure is ",round(h_bar-xbar,3)," meter below the centroid of gate."
# Variables :
g = 9.81; #gravity
GH = 4.; #meter
IJ = 4.; #meter
IC = 2.; #meter
GC = 3.; #meter
AG = (10.-4)/2; #meter
BH = (10.-4)/2; #meter
EI = AG*IC/GC; #meter
JF = AG*IC/GC; #meter
EF = EI+IJ+JF; #meter
A = (8.+4.)/2*2; #in m**2
a = 4.; #meter
b = 8.; #meter
d = 2.; #meter
# Calculations and Results
xbar = (2*a+b)/(a+b)*d/3; #in meter
w = g*1000; #in N/m**3
p_gate = w*A*xbar/10**3; #in kN
print "Total pressure in kN : ",p_gate
IG = (a**2+4*a*b+b**2)/(a+b)*d**3/36; #in m**3
h_bar = IG/A/xbar+xbar; #in meter
print "Depth of centre of pressure is ",h_bar," meter."
import math
# Variables :
g = 9.81; #gravity
xbar = 8.; #meter
D = 4.; #meter
# Calculations and Results
A = math.pi*D**2/4; #meter**2
w = g*1000; #in N/m**3
p = w*A*xbar/10**3; #in kN
print "Total pressure in kN : %.2f"%p
IG = math.pi*D**4/64; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
print "Depth of centre of pressure is ",(h_bar)," meter."
# note : Answer of total pressure is wrong in the book.
import math
# Variables :
g = 9.81; #gravity
D = 4.; #meter
xbar = (10.+7)/2; #meter
# Calculations and Results
A = math.pi*D**2/4; #meter**2
w = g*1000; #in N/m**3
p = w*A*xbar/10**6; #in MN
print "Total pressure in MN : %.3f"%p
BC = 3; #meter
AB = 4; #mete
math.sin_theta = BC/AB;
IG = math.pi*D**4/64; #in m**4
h_bar = IG/A/xbar*math.sin_theta**2+xbar; #in meter
print "Position of centre of pressure is ",(h_bar)," meter."
import math
# Variables :
a = 3.; #meter
b = 4.; #meter(altitude)
S = 1.2; #specific gravity
theta = 30.; #degree
d = 2.5; #meter
g = 9.81; #gravity
AG = b/3; #meter
# Calculations and Results
xbar = d+AG*math.sin(math.radians(theta)); #meter
A = 1./2*a*b; #meter**2
w = S*g*1000; #in N/m**3
p = w*A*xbar/10**3; #in kN
print "Total pressure in kN : ",p
IG = a*b**3/36; #in m**4
h_bar = IG/A/xbar*(math.sin(math.radians(theta)))**2+xbar; #in meter
print "Depth of centre of pressure is ",round(h_bar,3)," meter."
import math
# Variables :
a = 8.; #meter
b = 6.; #meter
h = 3.; #meter
CD = 2.; #meter
theta = 30.; #degree
# Calculations and Results
A = (a+b)/2*h; #meter**2
AB = (a+2*b)/(a+b)*h/3; #meter
x1bar = AB; #meter
BC = AB*math.sin(math.radians(theta)); #meter
BD = BC+CD; #meter
xbar = BD; #meter
g = 9.81; #gravity
w = g*1000; #in N/m**3
p = w*A*xbar/10**3; #in kN
print "Total pressure in kN : ",p
IG = (a**2+b**2+4*a*b)/(a+b)*h**3/36; #in m**4
h_bar = IG/A/xbar*(math.sin(math.radians(theta)))**2+xbar; #in meter
print "Depth of centre of pressure is ",round(h_bar,3)," meter."
# note : rounding off error
import math
# Variables :
l = 2.; #meter
b = 2.; #meter
p_i = 98.1; #kN/m**3(Pressure intensity)
w = 9.81; #kN/m**2
BC = 1.; #meter
AB = 2.; #meter
theta = 30.; #degree
B = p_i/w; #m
# Calculations
BD = BC*math.sin(math.radians(theta)); #m
xbar = 10+0.5; #meter
A = l*b; #m**2
p = w*A*xbar; #kN
IG = (2*l**3)/12; #in m**4
h_bar = IG/A/xbar*(math.sin(math.radians(theta)))**2+xbar; #in meter
DI = h_bar-xbar; #m
FC = DI/math.sin(math.radians(theta)); #m
FB = FC+BC; #meter
P = p*FB/AB; #kN
# Results
print "Force in kN : ",P
RB = p-P; #kN
print "Reaction at hinge B in kN : ",RB
#Answer in the book is slightly differ due to limited accuracy used in the book as compared to SCILAB.
import math
# Variables :
l = 4.; #meter
b = 2.; #meter
h = 1.8; #meter
w = 9.81; #kN/m**2
xbar = 6.-2 #meter
# Calculations
A = l*b; #m**2
P = w*A*xbar; #kN
IG = (2*l**3)/12; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
# As P acts at h_bar-xbar :
F = P*((h_bar-xbar)-(b-h))/h; #kN
# Results
print "Horizontal Force in kN : %.3f"%F
# Variables :
b = 2.; #meter
d = 3.; #meter
h = 2.; #meter
w = 9.81; #kN/m**2
xbar = 2+3./2; #meter
# Calculations and Results
A = b*d; #m**2
P = w*A*xbar; #kN
print "Total Pressure in kN : ",P
IG = (b*d**3)/12; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
print "Position of centre of pressure in meter : %.3f"%h_bar
# Variables :
b = 4.; #meter
d = 4.; #meter
h = 8.; #meter
w = 9.81; #kN/m**2
xbar = 8.; #meter
# Calculations and Results
A = b*d; #m**2
P = w*A*xbar; #kN
print "Total Pressure in kN : ",P
IG = (b*d**3)/12; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
print "Position of centre of pressure in meter : %.3f"%h_bar
import math
# Variables :
D = 1.5; #meter
BE = 2.; #meter
AD = 0.75; #meter
CE = AD; #meter
# Calculations and Results
BC = BE-AD; #meter
FG = CE+BC/2; #meter
xbar = FG; #meter
w = 9.81; #kN/m**2
A = math.pi*D**2/4; #m**2
AB = D; #meter
sin_theta = BC/AB;
P = w*A*xbar; #kN
print "Total Pressure in kN : %.3f"%P
IG = (math.pi/64*D**4); #in m**4
h_bar = IG/A/xbar*sin_theta**2+xbar; #in meter
print "Position of centre of pressure in meter : %.3f"%h_bar
# Variables :
b = 3.; #meter
a = 3.; #meter
S_oil = 0.8; #specific gravity of oil
w = 9.81*S_oil; #kN/m**2
xbar = 1./3*b; #meter
A = 1./2*a*b; #m**2
# Calculations and Results
P = w*A*xbar; #kN
print "Total Pressure in kN : ",P
IG = (a*b**3)/36; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
print "Centre of pressure in meter : ",h_bar
# Variables :
a = 2.; #meter
b = 1.; #meter
d = 2.; #meter
w = 9.81; #kN/m**2
xbar = 2+a/2; #meter
# Calculations and Results
A = a*b; #m**2
P = w*A*xbar; #kN
print "Total Pressure in kN : ",P
IG = (b*d**3)/12; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
print "Position of centre of pressure in meter : %.3f"%h_bar
import math
# Variables :
r = 2.; #meter
l = 4.; #meter
A = r*l; #m**2
xbar = 2+r/2; #meter
w = 9.81; #kN/m**2
# Calculations and Results
PH = w*A*xbar; #kN
print "Horizontal component of resulting Pressure in kN : ",PH
PV = 2*r*l*w+math.pi*r**2/4*l*w; #kN
print "Verticalal component of resulting Pressure in kN : %.3f"%PV
IG = (l*r**3)/12; #in m**4
h_bar = IG/A/xbar+xbar; #in meter
print "Position of centre of horizontal component of pressure in meter : %.3f"%h_bar
x = (2*r+math.pi*r**2/4*(4*r/3/math.pi))/(2*r+math.pi*r**2/4); #meter
P = math.sqrt(PH**2+PV**2); #kN
print "Resultant pressure in kN : %.3f"%P
theta = math.degrees(math.atan(PV/PH)); #degree
print "Direction of resultant pressure in degree : %.2f"%theta
# note : rounding off error
import math
# Variables :
A = 2.*1; #m**2
xbar = 2+2./2; #meter
w = 9.81; #kN/m**2
# Calculations and Results
PH = w*A*xbar; #kN
print "Horizontal component of resultant Pressure in kN : ",PH
PV = w*(2*2+2*2-math.pi*2**2/4)*1; #kN
print "Verticalal component of resultant Pressure in kN : %.3f"%PV
P = math.sqrt(PH**2+PV**2); #kN
print "resultant pressure in kN : %.3f"%P
theta = math.degrees(math.atan(PV/PH)); #degree
print "Direction of resultant pressure in degree : %.2f"%theta
# note : rounding ogg error
import math
# Variables :
ABbar = math.sqrt(2)*4; #meter
xbar = ABbar/2; #meter
# Calculations and Results
A = ABbar*1; #m**2
w = 9.81; #kN/m**2
PH = w*A*xbar; #kN
print "Horizontal component of resultant Pressure in kN : ",PH
hbar = 2./3*ABbar; #meter
print "Position of horizontal component of pressure is ",round(hbar,3)," meter below free water surface."
PV = w*(math.pi*4**2/4-4*4./2)*1; #kN
print "Verticalal component of resultant Pressure in kN : %.3f"%PV
# Variables :
h = 24.; #meter
b = 15.; #meter
g = 9.81; #gravity consmath.tant
Wm = 2000.*g; #N/m**3
W = b*h/2*Wm; #N
w = 9.81; #kN/m**2
# Calculations and Results
PH = w*20**2/2.*1000; #N
y = PH/W*20/3+5; #meter
e = y-b/2; #meter
MaxStress = W/b*(1+6*e/b); #N/m**2
print "Maximum stress in N/m**2 : ",MaxStress
MinStress = W/b*(1-6*e/b); #N/m**2
print "Minimum stress in N/m**2 : ",MinStress
#Answer in the book is slightly differ due to limited accuracy used in the book as compared to PYTHON.