##Mohr's circle
#calculate centre of circle and max and min stress and principal stress and maxi shearing stress
import numpy
from numpy.linalg import inv
import math
sigma=((40+80)/2.)
print'%s %.2f %s'%("center of the circle in MPa = ",sigma,"")
##solution a
x=((80-40)**2.);
y=30**2.;
sigma1=60.+math.sqrt((.25*x)+y)
print'%s %.2f %s'%("maxi pricipal stress in MPa = ",sigma1,"");## print'%s %.2f %s'%laying result
sigma2=60.-math.sqrt((.25*x)+y)
print'%s %.2f %s'%("mini pricipal stress in MPa = ",sigma2,"");## print'%s %.2f %s'%laying result
theta1=((math.atan((30./20.))/2)*57.3)
print'%s %.2f %s'%("pricipal stresses in degree",theta1,"");## print'%s %.2f %s'%laying result
theta2=(((math.atan(30/20.))+180.)/2.)*57.3
print'%s %.2f %s'%("pricipal stresses in degree",theta2,"");## print'%s %.2f %s'%laying result
##solution b
tau=math.sqrt((.25*x)+y)
print'%s %.2f %s'%("maxi shearing stress in MPa = ",tau,"");## print'%s %.2f %s'%laying result
theta3=theta1+45.
print'%s %.2f %s'%("stress in MPa = ",theta3,"");## print'%s %.2f %s'%laying result
theta4=theta2+45
print'%s %.2f %s'%("stress in MPa = ",theta4,"");## print'%s %.2f %s'%laying result
##final solution in matrix form
p=([80 ,30, 30 ,40])
print(p)
q=([sigma1, 0 ,0 ,sigma2])
print(q)
r=([sigma, -tau, -tau, sigma])
print(r)
##Mohr's circle
#calculate circle and radius of circle and oriention of the stresses in MPA
import math
radius=((14+28)/2.)
print'%s %.2f %s'%("radius of the circle in degree = ",radius,"")
sigma1=(7+radius *math.cos(60/57.3))
print'%s %.2f %s'%(" the circle in MPa = ",sigma1,"")
sigma2=(7-radius *math.cos(60/57.3))
print'%s %.2f %s'%(" the circle in MPa = ",sigma2,"")
tau1=radius*math.sin(60./57.3)
print'%s %.2f %s'%(" orientation of the stresses in MPa = ",tau1,"")