import math
#calculate alpha and semiaxes of elliptical contaact area and max contact pressure
E=210. ##GPa
v=0.3
r1=0.4 ##m radius
r2=0.3 ##m cross radius
P=90. ##kN compression load
m=4./((1./r1)+(1./r2))
print'%s %.2f %s'%("m",m,"")
A=(1/2.)*((1./r1)+(1./r2))
print'%s %.2f %s'%("A",A,"")
B=(1/2.)*((1./r1)-(1./r2))
print'%s %.2f %s'%("B",B,"")
coss=(((1./r1)-(1./r2))/((1./r1)+(1./r2)))
print'%s %.2f %s'%("cos aplha is= ",coss,"")
n=(4.*E*10**9.)/(3.*(1.-v**2.))
print'%s %.3e %s'%("n is ",n,"")
s=math.acos(coss)*57.3
print'%s %.2f %s'%(" s is alpha value = ",s,"") ## ans is 81.79degree but here since cosa is in negative we get ans as 98.21
ca=1.1040 ## from the interpolating table
cb=0.9112 ## from the interpolating table
a=ca*(90000.*m/n)**(0.33)
print'%s %.4f %s'%("semiaxes of the elliptical contact area in meter is= ",a,"")
b=cb*(90000*m/n)**(0.33)
print'%s %.4f %s'%("semiaxes of the elliptical contact area in meter is= ",b,"")
sigmac=1.5*(90000./(math.pi*a*b))
print'%s %.3e %s'%("max contact pressure in Pa is= ",sigmac,"") ## text book ans is wrong