# Chapter 2: Stress and Strain Relationships for Elastic Behavior¶

### Example 2.1, State of Stress in two dimensions, Page No. 25¶

In [14]:
from math import sin
from math import cos
from numpy.linalg import inv
import numpy as np

#variable declaration
sigma_x=25;
sigma_y=5;
theta=45;
sigma_x_=50;
T_x_y_=5;

#calculation
A=[[(sigma_x+sigma_y)/2+(sigma_x-sigma_y)/2*cos(2*theta),sin(2*theta)],[(sigma_y-sigma_x)/2*sin(2*theta),cos(2*theta)]];
B=[[sigma_x_],[T_x_y_]];
X=np.dot(inv(A),B);
p=X[0];
T_xy=X[1];
sigma_x1=sigma_x*p;
sigma_y1=sigma_y*p;
sigma_y_=sigma_x1+sigma_y1-sigma_x_;

#result
print ('\nsigma_x= %g MPa\nsigma_y= %g MPa\nT_xy= %g MPa\nsigma_y= %g MPa') %(sigma_x1,sigma_y1,T_xy,sigma_y_);

sigma_x= -12.5 MPa
sigma_y= -2.5 MPa
T_xy= 57.5 MPa
sigma_y= -65 MPa


### Example 2.2, State of Stress in three dimensions, Page No. 29¶

In [22]:
import numpy as np

#variable declaration
A=[[0,-240,0],[-240,200,0],[0,0,-280]];

#calcualtion
p=[1, -(A[0][0]+A[1][1]+A[2][2]), (A[0][0]*A[1][1]+A[1][1]*A[2][2]+A[0][0]*A[2][2]-A[1][0]**2-A[2][1]**2-A[2][0]**2), -(A[0][0]*A[1][1]*A[2][2]+2*A[1][0]*A[2][1]*A[2][0]-A[0][0]*A[2][1]**2-A[1][1]*A[2][0]**2-A[2][2]*A[1][0]**2)];
X=np.roots(p);

#result
for i in range (0,3):
print('\nsigma%i = %g MPa')%(i,X[i]);

sigma0 = 360 MPa

sigma1 = -280 MPa

sigma2 = -160 MPa


### Example 2.3, Calculation of Stresses from elastic strains, Page No. 52¶

In [15]:
#variable declaration
E=200;
nu=0.33;
e1=0.004;
e2=0.001;

#calculation
sigma1=E*(e1+nu*e2)/(1-nu**2);
sigma2=E*(e2+nu*e1)/(1-nu**2);
sigma1=sigma1*1000;        #conversion to MPa
sigma2=sigma2*1000;        #conversion to MPa

#result
print('\nsigma1 = %g MPa\nsigma2 = %g MPa\n')%(sigma1,sigma2);
print('\nNote: Slight calculation errors in Book')

sigma1 = 971.833 MPa
sigma2 = 520.705 MPa

Note: Slight calculation errors in Book


### Example 2.4, Elastic Anisotropy, Page No. 60¶

In [16]:
#variable declaration
from math import sqrt
S11_Fe=0.8;
S12_Fe=-0.28;
S44_Fe=0.86;
S11_W=0.26;
S12_W=-0.07;
S44_W=0.66;
D_100_l=1;
D_100_m=0;
D_100_n=0;
D_110_l=1/sqrt(2);
D_110_m=1/sqrt(2);
D_110_n=0;
D_111_l=1/sqrt(3);
D_111_m=1/sqrt(3);
D_111_n=1/sqrt(3);

#calculation
Fe_E_111=1/(S11_Fe-2*((S11_Fe-S12_Fe)-S44_Fe/2)*(D_111_l**2*D_111_m**2+D_111_n**2*D_111_m**2+D_111_l**2*D_111_n**2));
Fe_E_100=1/(S11_Fe-2*((S11_Fe-S12_Fe)-S44_Fe/2)*(D_100_l**2*D_100_m**2+D_100_n**2*D_100_m**2+D_100_l**2*D_100_n**2));
W_E_111=1/(S11_W-2*((S11_W-S12_W)-S44_W/2)*(D_111_l**2*D_111_m**2+D_111_n**2*D_111_m**2+D_111_l**2*D_111_n**2));
W_E_100=1/(S11_W-2*((S11_W-S12_W)-S44_W/2)*(D_100_l**2*D_100_m**2+D_100_n**2*D_100_m**2+D_100_l**2*D_100_n**2));

#result
print '\nFor Iron:\n\n'
print 'E_111 = %g x 10^11 Pa\nE_100 = %g x 10^11 Pa\n' %(Fe_E_111,Fe_E_100)
print '\n\n\nFor Tungten:\n\n'
print 'E_111 = %g x 10^11 Pa\nE_100 = %g x 10^11 Pa\n\nTherefore tungsten is elastically isotropic while iron is elasitcally anisotropic' %(W_E_111,W_E_100)

For Iron:

E_111 = 2.72727 x 10^11 Pa
E_100 = 1.25 x 10^11 Pa

For Tungten:

E_111 = 3.84615 x 10^11 Pa
E_100 = 3.84615 x 10^11 Pa

Therefore tungsten is elastically isotropic while iron is elasitcally anisotropic