Академический Документы
Профессиональный Документы
Культура Документы
Q1)
We find that the optimum value for Ex = 35.99GPa at theta = 36 deg.
Code1:
import numpy as np
import pylab as py
import math as m
#initializing A
A=np.zeros((3,3))
#iteration for calculating A matrix
for j in range(3):
for k in range(3):
for i in range(4):
if i < 4:
A[j,k] = A[j,k] + (Q_bar[i,j,k]*(z[i+1]-z[i]))
i = i+1
Ex.append(E)
Theta.append(theta)
Gxy.append(G)
vxy.append(v)
ax1=ax.twinx()
L3=ax1.plot(Theta,vxy,'g',label='vxy')
ax1.set_ylabel('vxy')
ax.legend(loc=1)
ax1.legend(loc=7)
print(Eopt)
print(Theta_opt)
Output:
The max Ex value that can be obtained with the given constraint is: 35.9920822368 Gpa
The optium ply orientation for the said Ex is: 36 deg
Assignment Q2)
Code2: The code is inefficient in the fact that the it is predicting the integral stress values at which
each ply is already failed rather than the exact stress for failure.
import numpy as np
import math as m
z= [-.375,-.25,-.125,0,.125,.25,.375]
S=np.matrix('0.0071428,-.0021428,0;-.0021428,0.1,0;0,0,.2')
Q=S.getI()
Theta=[0,45,90,90,45,0]
C=np.matrix('1,0,0;0,1,0;0,0,2')
CinV=C.getI()
maxIndex= []
def lamina(Theta,Q):
Q2 = []
for i in range(6):
c=m.cos(Theta[i])
s=m.sin(Theta[i])
T=np.array([[c**2,s**2,2*c*s],[s**2,c**2,-2*c*s],[-c*s,c*s,c**2-s**2]])
T_i = np.linalg.inv(T)
Q2.append(np.linalg.multi_dot([T_i,Q,C,T,CinV]))
return Q2
Q1= lamina(Theta,Q)
Q_bar=np.reshape(Q1,(6,3,3))
A=np.zeros((3,3))
for j in range(3):
for k in range(3):
for i in range(6):
if i < 6:
A[j,k] = A[j,k] + (Q_bar[i,j,k]*(z[i+1]-z[i]))
i = i+1
for i in range(0,10000,1):
Nmax=0
N=np.array([[Nmax+i],[0],[0]])
ex = np.linalg.multi_dot([np.linalg.inv(A),N])
e=np.zeros((6,3,1))
sigma=np.zeros((6,3,1))
for i in range(6):
c=m.cos(np.multiply(Theta[i],m.pi/180))
s=m.sin(np.multiply(Theta[i],m.pi/180))
T = np.array([[c**2,s**2,2*c*s],[s**2,c**2,-2*c*s],[-c*s,c*s,c**2-s**2]])
e[i,] = e[i,] + np.linalg.multi_dot([T,ex])
for l in range(len(maxIndex)):
e[maxIndex[l],]=np.zeros((3,1))
sigma[i,] = Q*e[i,]
Sigma= np.reshape(sigma,(6,3))
Stress_Ratio= np.zeros((6,3))
for i in range(0,6,1):
if Sigma[i,0]<0:
Stress_Ratio[i,0]=Stress_Ratio[i,0]+abs(Sigma[i,0])/1200
else:
Stress_Ratio[i,0]=Stress_Ratio[i,0]+Sigma[i,0]/1500
if Sigma[i,1]<0:
Stress_Ratio[i,1]=Stress_Ratio[i,1]+abs(Sigma[i,1])/250
else:
Stress_Ratio[i,1]=Stress_Ratio[i,1] +Sigma[i,1]/50
Stress_Ratio[i,2]=abs(Sigma[i,2])/70
SRmax=np.amax(Stress_Ratio,axis=1)
if np.amax(SRmax) < 1:
continue
else:
Nmax = N
break
print('Failure Load=',Nmax[0])
max=[]
for i in range(len(SRmax)):
if SRmax[i] >= 1:
max.append(SRmax[i])
maxIndex.append(i)
Fail_PlyIndex = maxIndex+np.ones_like(maxIndex)
print('Failed Ply:',Fail_PlyIndex)
for l in range(len(maxIndex)):
Q_bar[maxIndex[l],]=np.zeros((3,3))
Output: