import math
##calculate hieght above sea level to which ballon will rise
d=1.5; ##m
m=1.2; ## kg
rate=0.0065; ## K/m
R=287.; ## J/(kg.K)
T_0=288.15; ## K
p_0=101*10**3; ## Pa
g=9.81; ## m/s^2
rho=m/(math.pi*d**3/6);
rho_0=p_0/R/T_0;
## log(rho/rho_0)=(g/R*rate - 1)*log((T_0-rate*z)/T_0)
z=1/rate*(T_0-T_0*math.exp(math.log(rho/rho_0)/(g/R/rate-1)));
print'%s %.f %s'%("The height above sea level to which the ballon will rise =",z,"m")
import math
#calculate total force and Distance of line of action of total force from top of cylinder
d=2.; ## m
a=1.; ## radius in m
rho=880.; ## density of oil in kg/m^3
g=9.81; ## m/s^2
rho_w=1000.; ## density of water in kg/m^3
C_0=4*a/3/math.pi; ## centroid of the upper semicircle
h1=a-C_0; ## distance of the centroid from the top
P1=rho*g*h1; ## Pressure of the oil at this point
F1=P1*math.pi*a**2/2; ## Force exerted by the oil on the upper half of the wall
cp1=a**4*(math.pi/8-8/(9*math.pi)); ## (AK^2)_C
cp2=cp1/(math.pi*a**2/2*h1); ## Centre of Pressure below the centroid
cp0=cp2+h1; ## Centre of Pressure below the top
P_w=(rho*g*a)+(rho_w*g*C_0);
F_w=P_w*math.pi*a**2/2;
h2=C_0+rho/rho_w;
cp2_w=cp1/(math.pi*a**2/2*h2);
cp0_w=a+C_0+cp2_w; ## below the top of cylinder
F_total=F1+F_w;
## F1*cp0 + F_w*cp0_w = F_total*x
x=(F1*cp0 + F_w*cp0_w)/F_total;
print'%s %.1f %s'%("Total force =",F_total,"N")
print'%s %.3f %s'%("Distance of line of action of total force from top of cylinder =",x,"m")
import math
rho=1000.; ## kg/m**3
g=9.81; ## m/s**2
r=4.; ## m
h=2.; ## m
l=5.; ## m
theta=math.pi/6.;
A=h*l;
F_h=rho*g*h*A; ## Horizontal force
C0=(2.**2./(12.*2.))+2.; ## distance of line of action below the free surface
AB=4.-4.*math.cos(theta);
F_v=rho*g*l*(AB*1.+math.pi*r**2.*theta/(2.*math.pi)-1./2.*h*r*math.cos(theta));
BC=0.237; ## m
F_net=math.sqrt(F_h**2.+F_v**2.);
phi=math.atan(F_v/F_h);
print'%s %.1f %s'%("Net force =",F_net,"N")
print'%s %.3f %s'%("Angle between net force and horizontal =",phi,"degrees")
import math
#GM and states that negative or positive give explanation
m=10.; ## kg
M=80.; ## kg
H=1.5; ## m
rho=1026.; ## kg/m**3
g=9.81; ## m/s**2
d=1.; ## m
## m*H + M*H/2 =(M+m)(OG)
OG=(m*H + M*H/2)/(M+m);
## For vertical equilibrium, buoyancy = weight
h=(M+m)/(rho*math.pi/4*d**2);
BM=(math.pi*d**4./64.)/(math.pi*d**2.*h/4.);
OB=h/2.;
GM=OB+BM-OG;
print'%s %.4f %s'%("GM =",GM,"m")
print("Since this is negative (i.e. M is below G) buoy is unstable.")
import math
#calculate Least vertical downward force and Depth of immersion
m=10.; ## kg
M=80.; ## kg
OG=0.8333; ## m
rho=1026.; ## kg/m^3
g=9.81; ## m/s^2
d=1.; ## m
W=(m+M)*g;
## W(OG) = (W + F)(OB + BM) = rho*g*%pi/4*d^2*h1*(h1/2+d^2/(16*h1))
h1=math.sqrt(2*(W*OG/(rho*g*math.pi/4.*d**2) - d**2/16.));
F=rho*g*math.pi/4*d**2*h1 - W;
print'%s %.f %s'%("Least vertical downward force =",F,"N")
print'%s %.3f %s'%("Depth of immersion =",h1,"m")
import math
#calculate Volume left in the tank and Pressure at the lowest corners of the tank
a=5.; ## m/s^2
s=0.5; ## m
phi=math.atan(1./4.); ## degrees
g=9.81; ## m/s^2
rho=880.; ## kg/m^3
a_x=a*math.cos(phi); ## Horizontal component of acceleration
a_z=a*math.sin(phi); ## Vertical component of acceleration
theta=math.atan(a_x/(a_z+g)); ## b=tan(theta)
d=(math.tan(phi)+math.tan(theta))/(1-math.tan(phi)*math.tan(theta));
c=s*d;
V=s*(s**2-s*c/2.);
Z=V*1000.
print'%s %.1f %s'%("Volume left in the tank =",Z,"L")
P=rho*g*s*math.cos(phi);
print'%s %.f %s'%("Pressure at the lowest corners of the tank =",P,"Pa")
#apporxmatilty it is correct which is 4190 is given in text book