from math import sqrt,pi
#A material has strength in tension, compression and shear as 30N/mm2, 90 N/mm2 and 25 N/mm2, respectively. If a specimen of diameter 25 mm is tested in tension and compression identity the failure surfaces and loads.
#variable declaration
#In tension: Let axial direction be x direction. Since it is uniaxial loading, py = 0, q = 0 and only px exists.when the material is subjected to full tensile stress, px = 30 N/mm^2.
pt=float(30)
pc=float(90)
ps=float(25)
d=float(25)
px=float(30) #N/mm^2
py=0
q=0
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
qmax=(px-py)/2
#Hence failure criteria is normal stress p1
A=pi*pow(d,2)/4
#Corresponding load P is obtained by
p=p1
P=p1*A
print "(a) P=",round(P,2),"N"
#In case of compression test,
px=-pc
py=q=0
P=-px*A
print "(b) P=",round((-P),2),"N compressive"
#at this stage
qmax=sqrt((pow((px-py)/2,2))+pow(q,2))
print "Material fails because of maximum shear and not by axial compression."
qmax=25
px=2*qmax
P=px*A
print"P=",round(P),"N"
print "The plane of qmax is at 45° to the plane of px. "
#The direct stresses at a point in the strained material are 120 N/mm2 compressive and 80 N/mm2 tensile. There is no shear stress.
from math import sqrt,cos,sin,atan,pi
#variable declaration
#The plane AC makes 30° (anticlockwise) to the plane of px (y-axis). Hence theta= 30°. px = 80 N/mm^2 py = – 120 N/mm^2 ,q = 0
px=float(80)
py=float(-120)
q=float(0)
theta=30
pn=((px+py)/2)+((px-py)/2)*cos(2*theta*pi/180)+q*sin(2*theta*pi/180)
print"pn=",round(pn),"N/mm^2"
pt=((px-py)/2)*sin(2*theta*pi/180)-q*cos(2*theta*pi/180)
print"pt=",round(pt,1),"N/mm^2"
p=sqrt(pow(pn,2)+pow(pt,2))
print"p=",round(p,2),"N/mm^2"
alpha=atan(pn/pt)*180/pi
print "alpha=", round(alpha,1),"°"
from math import sqrt,cos,sin,atan,pi
#variable declaration
#Let the principal plane make anticlockwise angle theta with the plane of px with y-axis. Then
px=float(200) #N/mm^2
py=float(150) #N/mm^2
q=float(100) #N/mm^2
theta1=(atan((2*q)/(px-py))*180)/(pi*2)
theta2=90+theta1
print"theta=",round(theta1,2),"°" " and ",round(theta2,2),"°"
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p1=",round(p1,2),"N/mm^2"
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p2=",round(p2,2),"N/mm^2"
qmax=sqrt((pow((px-py)/2,2))+pow(q,2))
print"qmax=",round(qmax,2),"N/mm^2"
from math import sqrt,cos,sin,atan,pi
#variable declaration
#Let the principal plane make anticlockwise angle theta with the plane of px with y-axis. Then
px=float(80) #N/mm^2
py=float(-60) #N/mm^2
q=float(20) #N/mm^2
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p1=",round(p1,2),"N/mm^2"
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p2=",round(p2,2),"N/mm^2"
qmax=sqrt((pow((px-py)/2,2))+pow(q,2))
print"qmax=",round(qmax,2),"N/mm^2"
#let theta be the inclination of principal stress to the plane of px.
theta1=(atan((2*q)/(px-py))*180)/(pi*2)
theta2=90+theta1
print"theta=",round(theta1,2),"°" " and ",round(theta2,2),"°"
#Planes of maximum shear make 45° to the above planes.
theta11=45-theta1
theta22=theta2-45
print"theta'=",round(theta11,2),"°","and=",round(theta22,2),"°"
print"answer in book is wrong"
from math import sqrt,cos,sin,atan,pi
#variable declaration
#Let the principal plane make anticlockwise angle theta with the plane of px with y-axis. Then
px=float(-100) #N/mm^2
py=float(-75) #N/mm^2
q=float(-50) #N/mm^2
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p1=",round(p1,2),"N/mm^2"
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p2=",round(p2,2),"N/mm^2"
qmax=sqrt((pow((px-py)/2,2))+pow(q,2))
print"qmax=",round(qmax,2),"N/mm^2"
#let theta be the inclination of principal stress to the plane of px.
theta1=(atan((2*q)/(px-py))*180)/(pi*2)
theta2=90+theta1
print"theta=",round(theta1,2),"°" " and ",round(theta2,2),"°"
from math import sqrt,cos,sin,atan,pi
#variable declaration
#Let the principal plane make anticlockwise angle theta with the plane of px with y-axis. Then
px=float(-50) #N/mm^2
py=float(100) #N/mm^2
q=float(75) #N/mm^2
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
print "(i) p1=",round(p1,2),"N/mm^2"
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
print "p2=",round(p2,2),"N/mm^2"
qmax=sqrt((pow((px-py)/2,2))+pow(q,2))
print"(ii) qmax=",round(qmax,2),"N/mm^2"
#let theta be the inclination of principal stress to the plane of px.
theta1=(atan((2*q)/(px-py))*180)/(pi*2)
print"theta=",round(theta1,2),"°" " clockwise"
#Plane of maximum shear makes 45° to it
theta2=theta1+45
print"theta2=",round(theta2,2),"°"
#Normal stress on this plane is given by
pn=((px+py)/2)+((px-py)/2)*cos(2*theta2*pi/180)+q*sin(2*theta2*pi/180)
pt=qmax
#Resultant stress
p=sqrt(pow(pn,2)+pow(pt,2))
print "p=",round(p,2),"N/mm^2"
#Let ‘p’ make angle phi to tangential stress (maximum shear stress plane).
phi=atan(pn/pt)*180/pi
print "phi=",round(phi,1),"°"
#there is mistake in book
print"mitake in book answer is wrong"
from math import sqrt
#variable declaration
w=float(100) #wide of rectangular beam,mm
h=float(200) #height or rectangular beam dude,mm
I=w*pow(h,3)/12
#At point A, which is at 30 mm below top fibre
y=100-30
M=float(80*1000000) #sagging moment,KN-m
fx=M*y/I
px=-fx
F=float(100*1000 ) #shear force,N
b=float(100)
A=b*30
y1=100-15
q=(F*(A*y1))/(b*I) #shearing stress,N/mm^2
py=0
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
print " p1=",round(p1,2),"N/mm^2"
print " p2=",round(p2,2),"N/mm^2"
from math import sqrt,atan
P1=float(20) #vertical loading from A at distance of 1m,KN.
P2=float(20) #vertical loading from A at distance of 2m,KN.
P3=float(20) #vertical loading from A at distance of 3m,KN.
Ra=(P1+P2+P3)/2 #Due to symmetry
Rb=Ra
#At section 1.5 m from A
F=(Ra-P1)*1000
M=float((Ra*1.5-P1*0.5)*1000000)
b=float(100)
h=float(180)
I=float((b*pow(h,3))/12)
# Bending stress
#f=M*y/I
y11=0
f1=(-1)*M*y11/I
y22=45
f2=(-1)*M*y22/I
y33=90
f3=(-1)*M*y33/I
#Shearing stress at a fibre ‘y’ above N–A is
#q=(F/(b*I))*(A*y1)
#at y=0,
y1=45
A1=b*90
q1=(F/(b*I))*(A1*y1)
#at y=45
y2=float(90-45/2)
A2=b*45
q2=(F/(b*I))*(A2*y2)
#at y=90
q3=0
#(a) At neutral axis (y = 0) : The element is under pure shear
py=0
p1=(f1+py)/2+sqrt(pow(((f1-py)/2),2)+pow(q1,2))
p2=(f1+py)/2-sqrt(pow(((f1-py)/2),2)+pow(q1,2))
print "(i) p1=",round(p1,4),"N/mm^2"
print " p2=",round(p2,4),"N/mm^2"
theta1=45
theta2=theta1+90
print"theta=",round(theta1),"°"," and ",round(theta2),"°"
#(b) At (y = 45)
py=0
p1=(f2+py)/2+sqrt(pow(((f2-py)/2),2)+pow(q2,2))
p2=(f2+py)/2-sqrt(pow(((f2-py)/2),2)+pow(q2,2))
print "(ii) p1=",round(p1,4),"N/mm^2"
print " p2=",round(p2,4),"N/mm^2"
thetab1=(atan((2*q2)/(f2-py))*180)/(pi*2)
thetab2=thetab1+90
print"theta=",round(thetab1),"°"," and ",round(thetab2),"°"
#mistake in book
print"mistake in book"
#(c) At Y=90
py=0
p1=(f3+py)/2+sqrt(pow(((f3-py)/2),2)+pow(q3,2))
p2=(f3+py)/2-sqrt(pow(((f3-py)/2),2)+pow(q3,2))
print "(iii) p1=",round(p1,4),"N/mm^2"
print " p2=",round(p2,4),"N/mm^2"
thetac1=(atan((2*q3)/(f3-py))*180)/(pi*2)
thetac2=thetac1+90
print"theta=",round(thetac1),"°"," and ",round(thetac2),"°"
from math import sqrt
#variable declaration
L=float(6) #m
w=float(60) #uniformly distributed load,KN/m
Rs=L*w/2 #Reaction at support,KN
#Moment at 1.5 m from support
M =float( Rs*1.5-(w*pow(1.5,2)/2))
#Shear force at 1.5 m from support
F=Rs-1.5*w
B=float(200) #width of I-beam,mm
H=float(400) #height or I-beam,mm
b=float(190)
h=float(380)
I= (B*pow(H,3)/12)-(b*pow(h,3)/12)
#Bending stress at 100 mm above N–A
y=100
f=M*1000000*y/I
#Thus the state of stress on an element at y = 100 mm, as px = f,py=0
px=-f
py=0
A=200*10*195+10*90*145
q=(F*1000*(A))/(10*I) #shearing stress,N/mm^2
p1=(px+py)/2+sqrt(pow(((px-py)/2),2)+pow(q,2))
p2=(px+py)/2-sqrt(pow(((px-py)/2),2)+pow(q,2))
print " p1=",round(p1,2),"N/mm^2"
print " p2=",round(p2,2),"N/mm^2"
qmax=sqrt((pow((px-py)/2,2))+pow(q,2))
print"qmax=",round(qmax,2),"N/mm^2"