import math
#find the new stress tensor tau
import numpy
from numpy import linalg
## initialization of variables
tau=([[200, 100, 0],
[100, 0, 0],
[0 ,0, 500]]) ## some units
theta=60. ## degrees
##calculations
theta1=theta/57.3
a=([[math.cos(theta1), math.sin(theta1), 0],
[-math.sin(theta1), math.cos(theta1), 0],
[0, 0, 1]])
b=numpy.transpose(a)
tau_new=numpy.dot(a,tau)
tau_new1=numpy.dot(tau_new,b)
## Results
print('The new stress tensor is')
print tau_new1
find the octahedral at this point
## initialization of variables
import math
sigma_1=100. ##kg*f/cm^2
sigma_2=100. ##kg*f/cm^2
sigma_3=-200. ##kg*f/cm^2
## calculations
tau_oct=1/3.*math.sqrt((sigma_1-sigma_2)**2+(sigma_2-sigma_3)**2+(sigma_3-sigma_1)**2)
## Results
print'%s %.2f %s '%('Octahedra shear stress at the point is=',tau_oct,' kgf/cm^2')
import math
#check whether the invariants of stress sensor
import numpy
from numpy import linalg
## initialization of variable
tau=numpy.matrix([[200, 100, 0],
[100, 0, 0],
[0, 0, 500]]) ## some units
theta=60. ## degrees
##calculations
theta=theta*math.pi/180.
a=numpy.matrix([[math.cos(theta), math.sin(theta), 0],
[-math.sin(theta), math.cos(theta), 0],
[0, 0, 1]])
b=numpy.transpose(a)
tau_new=numpy.dot(a,tau)
tau_new1=numpy.dot(tau_new,b)
## stress invariants :old
I1=tau[0,0]+tau[1,1]+tau[2,2]
I2=tau[0,0]*tau[1,1]+tau[1,1]*tau[2,2]+tau[2,2]*tau[0,0]-(tau[0,1]**2+tau[1,2]**2+tau[2,0]**2)
I3=tau[0,0]*tau[1,1]*tau[2,2]+2*tau[0,1]*tau[1,2]*tau[2,0]-(tau[0,0]*tau[1,2]**2+tau[1,1]*tau[2,0]**2+tau[2,2]*tau[0,1]**2)
## stress invariants :new
I11=tau_new1[0,0]+tau_new1[0,0]+tau_new1[1,1]
I22=tau_new1[0,0]*tau_new1[1,1]+tau_new1[1,1]*tau_new1[2,2]+tau_new1[1,1]*tau_new1[0,0]-[tau_new1[0,1]**2+tau_new1[1,2]**2+tau_new1[1,0]**2]
I33=tau_new1[0,0]*tau_new1[1,1]*tau_new1[2,2]+2*tau_new1[0,1]*tau_new1[1,2]*tau_new1[2,0]-[tau_new1[0,0]*tau_new1[1,2]**2+tau_new1[1,1]*tau_new1[2,0]**2+tau_new1[2,2]*tau_new1[0,1]**2]
## Results
print'%s %.2f %s %.2f %s %.2f %s %.2f %s %.2f %s %.2f' %('The invariants of old stress tensor are I1=',I1,' I2=',I2,' I3=',I3,' \n and that of the new stress tensor are I1=',I11,' I2=',I22,' I3=',I33)
print('\n Hence the same stress tensor invariants')
import math
## initialization of variables
#find the value of sigma 1 and sigma2 at biaxial yeilding and unaxial
sigma_3=0. ## kgf/cm**2
tau_oct=1500. ## kgf/cm**2
n=2 ## given that sigma_1=n*sigma_2
## calculations
sigma_2=1500.*3./(math.sqrt(2*n**2-2*n+2)) ## ## kgf/cm**2
sigma_1=n*sigma_2 ## kgf/cm**2
sigma_0=4500./math.sqrt(2.) ## kgf/cm**2
## Results
print'%s %.2f %s %.2f %s %.2f %s '%('The necessary stresses sigma_1, sigma_2 for biaxial yielding are \n ',sigma_2,' kgf/cm^2' '',sigma_1,' kgf/cm^2' and 'for uniaxial yielding sigma_0 ',sigma_0,'kgf/cm^2.')
import math
##initialization of variables
#find the magnitude and direction of principal stress for the a b c
## part (a)
tau_xx=300 ## kgf/cm**2
tau_yy=0 ## kgf/cm**2
tau_xy=600 ## kgf/cm**2
##calculations
sigma_1=(tau_xx+tau_yy)/2.+math.sqrt((1./2.*(tau_xx-tau_yy))**2+tau_xy**2)
sigma_2=(tau_xx+tau_yy)/2-math.sqrt((1/2.*(tau_xx-tau_yy))**2+tau_xy**2)
Beta=math.atan(2*tau_xy/(tau_xx-tau_yy))
Beta=Beta*180/math.pi
##Results
print'%s %.2f%s %.2f %s %.2f %s'%('\n Part (a) \n The magnitude of principal stresses are',sigma_1,''and '',sigma_2,'kgf/cm^2' and' \n the direction is given by 2*beta=',Beta,'')
##part (b)
tau_xx=1000 ## kgf/cm**2
tau_yy=150 ## kgf/cm**2
tau_xy=450 ## kgf/cm**2
## calculations
sigma_1=(tau_xx+tau_yy)/2+math.sqrt((1/2*(tau_xx-tau_yy))**2+tau_xy**2)
sigma_2=(tau_xx+tau_yy)/2-math.sqrt((1/2*(tau_xx-tau_yy))**2+tau_xy**2)
Beta=math.atan(2*tau_xy/(tau_xx-tau_yy))
Beta1=Beta*180./math.pi
## Results
print'%s %.2f %s %.2f %s %.2f %s '%('\n Part (b) \n The magnitude of principal stresses are',sigma_1,''and '',sigma_2,'kgf/cm^2' and' \n the direction is given by 2*beta=',Beta1,'')
## part (c)
tau_xx=-850 ## kgf/cm**2
tau_yy=350 ## kgf/cm**2
tau_xy=700 ## kgf/cm**2
## calculations
sigma_1=(tau_xx+tau_yy)/2+math.sqrt((1/2*(tau_xx-tau_yy))**2+tau_xy**2)
sigma_2=(tau_xx+tau_yy)/2-math.sqrt((1/2*(tau_xx-tau_yy))**2+tau_xy**2)
Beta=math.atan(2*tau_xy/(tau_xx-tau_yy))
Beta=Beta*57.3
## Results
print'%s %.2f %s %.2f %s %.2f %s '%('\n Part (c) \n The magnitude of principal stresses are',sigma_1,''and '',sigma_2,'kgf/cm^2' and' \n the direction is given by 2*beta=',-Beta,'')
## wrong answers were given in textbook for part (b) (c)
import math
# initialization of variables
#find the intensity of diagonal tension
tau_xx= -1 # kgf/cm^2
tau_yy= 0 # kgf/cm^2
tau_xy= 7 # kgf/cm^2
# calculations
sigma_1=(tau_xx+tau_yy)/2.+math.sqrt((1/2.*(tau_xx-tau_yy))**2+tau_xy**2)
sigma_2=(tau_xx+tau_yy)/2.-math.sqrt((1/2.*(tau_xx-tau_yy))**2+tau_xy**2)
x=sigma_1 # positive one is tension
if(sigma_2>sigma_1):
x=sigma_2
# Results
print'%s %.2f %s'%('The diagonal tension is ',x,' kgf/cm^2')
import math
# initialization of variables
#find the state of stress at the joint
d=2 # m
l=10 # m
t=1 # cm
p=15 # kgf/cm^2
pitch= 2*math.pi #m
##calculations
w=2*math.pi*d/2. # m
theta=math.atan(w/(2*math.pi))
sigma_z=p*d*100./(4.*t)
sigma_th=p*d*100./(2.*t)
sigma_th_new=(sigma_th+sigma_z)/2.+(sigma_th-sigma_z)/2.*math.cos(2*theta)
tau_thz=(sigma_z-sigma_th)*math.sin(2.*theta)/2
# results
print'%s %.2f %s %.2f %s '%('At the junction, the normal and shear stresses are',sigma_th_new,'' and '',-tau_thz,' kgf/cm^2 \n respectively, and the rivets must be designed for this')