#example 7.1
sigmao=48.0; # in KN/m^2
phi1=30*math.pi/180; # angle
phi2=36*math.pi/180; # angle
Ka1=(math.tan(math.pi/4.0-phi1/2))**2;
Ka2=(math.tan(math.pi/4.0-phi2/2))**2;
sigmaa1=Ka1*sigmao; # in KN/m^2
print round(sigmaa1,2),"top soil pressure in kN/m**2"
sigmaa2=Ka2*sigmao; # in KN/m^2
print round(sigmaa2,2),"bottom soil pressure in kN/m**2"
Po=1/2.0*3*16+3*12.48+1/3.0*3*(19.65-12.48)+1/2.0*3*29.43;
zbar=(24*(3+3/3.0)+37.44*(3/2.0)+10.76*3/3.0+44.1*3/3.0)/Po;
print round(zbar,2),"resultant force acting from the bottom in m"
# The answers in the book are different due to approximation while here calculations are precise
#example 7.2
import math
c=14.36;
Gamma=17.4; # in KN/m^3
H=6; # in m
phi=26*math.pi/180;
Ka=(math.tan(math.pi/4-phi/2))**2;
sigma0=Gamma*H*Ka-2*c*math.sqrt(Ka);
Pa=1/2.0*Gamma*H**2*Ka-2*c*H*math.sqrt(Ka);
print round(Pa,2),"active force before which tensile crack appeared in kN/m"
zbar=(244.32-323.1)/14.46;
print round(zbar,2),"the line of action on which net force is acting in m"
zc=2*c/Gamma/math.sqrt(Ka);
print round(zc,2),"distance where tensile crack appeared in m"
Pa=1/2.0*(H-zc)*(Gamma*H*Ka-2*c*math.sqrt(Ka));
print round(Pa,2),"Active force in tensile crack in kN/m"
zbar=(H-zc)/3;
print round(zbar,2),"the line of action on which net force is acting in m"
#example 7.3
import math
pi=math.pi
H=10.0; # in ft
Gamma=110.0; # in lb/ft^3
phi=35*math.pi/180.0; # angle
alpha=15*math.pi/180.0; # angle
theta=10*math.pi/180.0; # angle
zi=math.sin(math.sin(alpha)/math.sin(phi))-alpha+2*theta;
print round(zi*180.0/math.pi,2)," is zi in degrees"
Ka=math.cos(alpha-theta)*math.sqrt(1+(math.sin(phi))**2-2*math.sin(phi)*math.sin(zi))/((math.cos(theta))**2*(math.cos(alpha)+math.sqrt((math.sin(phi))**2+((math.sin(alpha))**2))));
Pa=1/2.0*Gamma*H**2*Ka;
print round(Pa,2)," is rankine earth pressure in lb/ft"
print "there is slight error in answer due to rounding off error"
Beta=math.tan(math.sin(phi)*math.sin(zi)/(1-math.sin(phi)*math.cos(zi)));
print round(Beta*180/pi,2)," is angle in degrees"
# The answers in the book are different due to approximation while here calculations are precise
#example 7.4
H=4.6; # in m
Gamma=16.5; # in KN/m^3
Ka=0.297;
Po=1/2.0*Gamma*H**2*Ka;
print round(Po,2),"coulomb active force per unit length in kN/m"
#example 7.5
#part(a)
Gamma=105; # in lb/ft^3
H=10; #in ft
Kae=0.474;
k1=0;
Pae=1/2.0*Gamma*H**2*Kae*(1-k1) # in lb/ft
print Pae,"active force in lb/ft"
#part(b)
Ka=0.246;
Pa=1/2.0*Gamma*H**2*Ka; # in lb/ft
print Pa,"active force in lb/ft"
DPae=Pae-Pa;#deltaPae
zbar=(0.6*H*DPae+H/3*(Pa))/Pae;
print round(zbar,2),"the distance of resultant force from bottom in ft"
#example 7.6
import math
import numpy
import matplotlib.pyplot as plt
z=[0, 4, 8, 12, 16];
Gamma=110; # in lb/ft^3
phi=36*math.pi/180;
H=16; # in ft
Sa1=numpy.zeros(5);#sigma(1)
Sa2=numpy.zeros(5);#sigma(2)
Sztr=numpy.zeros(5);#sigma(z)translation
print "z(ft)\t sigma(1)(lb/ft**2) \t sigma(2)(lb/ft**2) \t sigma(z)translation (lb/ft**2)\n"
for i in range(0,5):
Sa1[i]=Gamma*(math.tan(math.pi/4-phi*z[i]/2/H))**2*(z[i]-phi*z[i]**2/H/math.cos(phi*z[i]/H));
Sa2[i]=Gamma*z[i]*(math.cos(phi)/(1+math.sin(phi)))**2;
Sztr[i]=Sa1[i]/2.0+Sa2[i]/2.0;
print round(z[i],2),"\t ",round(Sa1[i],2),"\t\t\t ",round(Sa2[i],2),"\t\t\t ",round(Sztr[i],2),"\n"
plt.plot(Sztr,z);
plt.title("sigma(z)translation vs z")
plt.ylabel("z(ft)")
plt.xlabel("sigma(z)translation (lb/ft**2)")
plt.show()
#example 7.7
import math
Gammasat=18.86; # in KN/m^3
Gammaw=9.81; # in KN/m^3
phi1=math.pi/180*30; # angle 1
phi2=math.pi/180*26; # angle 2
Kp1=(math.tan(math.pi/4+phi1/2))**2;
Kp2=(math.tan(math.pi/4+phi2/2))**2;
#for top soil
c=0;
sigma0=31.44; # in KN/m^2
sigmap=sigma0*Kp1+2*c*math.sqrt(Kp1);
print round(sigmap,2),"passive pressure for top layer in kN/m**2"
#for z=2
c=10;
sigma0=31.44; # in KN/m^2
sigmap=sigma0*Kp2+2*c*math.sqrt(Kp2);
print round(sigmap,2),"passive pressure for z=2m in kN/m**2"
#for z=3
c=10;
sigma0=15.72*2+(Gammasat-Gammaw)*1; # in KN/m^2
sigmap=sigma0*Kp2+2*c*math.sqrt(Kp2); # in KN/m^2
print round(sigmap,2)," is passive pressure for z=3m in kN/m**2"