In [1]:

```
import math
sx = 16000 # Direct stress in x-direction in psi
sy = 6000 # Direct stress in y-direction ""
txy = 4000 # Shear stress in y-direction ""
tyx = txy # Shear stress in x-direction ""
t = 45 # Inclination pf plane in degree
#calculation
sx1 = (sx+sy)/2 + ((sx-sy)*(math.cos(math.radians(2*t))/2.0)) + txy*math.sin(math.radians(2*t)) # Direct stress in x1-direction in psi
sy1 = (sx+sy)/2 - ((sx-sy)*(math.cos(math.radians(2*t))/2.0)) - txy*math.sin(math.radians(2*t)) # Direct stress in y1-direction in psi
tx1y1 = - ((sx-sy)*(math.sin(math.radians(2*t))/2.0)) + txy*math.cos(math.radians(2*t)) # Shear stress in psi
print "The direct stress on the element in x1-direction is", sx1, "psi"
print "The direct stress on the element in y1-direction is", sy1, "psi"
print "The shear stress on the element", tx1y1, "psi"
```

In [2]:

```
import math
sx = -46e06 # Direct stress in x-direction in Pa
sy = 12e06 # Direct stress in y-direction ""
txy = -19e06 # Shear stress in y-direction ""
t = -15 # Inclination of plane in degree
#calculation
sx1 = (sx+sy)/2.0 + ((sx-sy)*(math.cos(math.radians(2*t))/2.0)) + txy*math.sin(math.radians(2*t)) # Direct stress in x1-direction in Pa
sy1 = (sx+sy)/2.0 - ((sx-sy)*(math.cos(math.radians(2*t))/2.0)) - txy*math.sin(math.radians(2*t)) # Direct stress in y1-direction in Pa
tx1y1 = -((sx-sy)*(math.sin(math.radians(2*t))/2.0)) + txy*math.cos(math.radians(2*t)) # Shear stress in Pa
print "The direct stress on the element in x1-direction is", sx1, "Pa"
print "The direct stress on the element in y1-direction is", sy1, "Pa"
print "The shear stress on the element", tx1y1, "Pa"
```

In [53]:

```
import math
ax = 12300.0
ay = -4200.0
txy = -4700.0
tan_2p = round((2*txy)/(ax-ay), 4)
theta_p1 = 150.3
theta_p2 = 330.3
stress1 = (ax+ay)/2.0
stress2 = (ax-ay)/2.0
a1 = stress1 + math.sqrt((stress2**2.0)+(txy**2.0))
a2 = stress1 - math.sqrt((stress2**2.0)+(txy**2.0))
#python calculations differ a bit. hence, differences in the answer
print "Principal stesses are ", round(a1), "psi and ", round(a2), " psi"
tmax = math.sqrt((stress2**2.0)+(txy**2.0))
print "Maximum shear stress is ", round(tmax), " psi"
a_aver = (ax+ay)/2.0
print "Normal stress acting at maximum shear stress = ", round(a_aver), "psi"
```

In [3]:

```
import math
#initialisation
sx = 90e06 # Direct stress in x-direction in Pa
sy = 20e06 # Direct stress in y-direction in Pa
t = 30 # Inclination of element in degree
#calculation
savg = (sx+sy)/2.0 # Average in-plane direct stress
txy = 0
R = math.sqrt(((sx-sy)/2)**2+(txy)**2) # Radius of mohr circle
# Point D at 2t = 60
sx1 = savg + R*math.cos(math.radians(2*t)) # Direct stress at point D
tx1y1 = -R*math.sin(math.radians(2*t)) # shear stress at point D
print "The direct stress at point D is", sx1, "Pa"
print "The shear stress at point D is", tx1y1, "Pa"
# Point D at 2t = 240
sx2 = savg + R*math.cos(math.radians(90 + t)) # Direct stress at point D
tx2y2 = R*math.sin(math.radians(90 + t)) # shear stress at point D
print "The direct stress at point D_desh is", sx2, "Pa"
print "The shear stress at point D_desh is", tx2y2, "Pa"
```

In [1]:

```
import math
import numpy
#initialisation
sx = 15000 # Direct stress in x-direction in psi
sy = 5000 # Direct stress in y-direction ""
txy = 4000 # Shear stress in y-direction ""
savg = (sx+sy)/2.0 # Average in-plane direct stress
sx1 = 15000 # Stress acting on face at theta = 0 degree
tx1y1 = 4000 # Stress acting on face at theta = 0 degree
sx1_ = 5000
tx1y1_ = -4000
#calculation
R = math.sqrt(((sx-sy)/2)**2+(txy)**2) # Radius of mohr circle
# Part (a)
t = 40 # Inclination of the plane in degree
f1 = numpy.degrees(numpy.arctan((4000.0/5000.0))) # Angle between line CD and x1-axis
f2 = 80 - f1 # Angle between line CA and x1-axis
# Point D
sx1 = savg + R*math.cos(math.radians(f2)) # Direct stress at point D
tx1y1 = -R*math.sin(math.radians(f2)) # shear stress at point D
print "The shear stress at point D", round(tx1y1), "psi"
# Point D'
sx2 = savg - R*math.cos(math.radians(f2)) # Direct stress at point D'
tx2y2 = R*math.sin(math.radians(f2)) # shear stress at point D'
print "The direct stres at point D_desh", round(sx2), "psi"
#Part (b)
sp1 = savg + R # Maximum direct stress in mohe circle (at point P1)
tp1 = f1/2 # Inclination of plane of maximum direct stress
print "with angle",round(tp1,2) , "degree The maximum direct stress at P1 is ",sp1 , "psi"
sp2 = savg - R # Minimum direct stress in mohe circle (at point P2)
tp2 = (f1+180)/2 # Inclination of plane of minimum direct stress
print "with angle", round(tp2,2), "degree The maximum direct stress at P2 is ",sp2 , "psi"
# Part (c)
tmax = R # Maximum shear stress in mohe circle
ts1 = -(90 - f1)/2.0 # Inclination of plane of maximum shear stress
print "with plane incilation of", tmax, "psi The Maximum shear stress is ", round(ts1,2), "deegree"
```

In [11]:

```
import math
import numpy
sx = -50e06 # Direct stress in x-direction in psi
sy = 10e06 # Direct stress in y-direction ""
txy = -40e06 # Shear stress in y-direction ""
savg = (sx+sy)/2 # Average in-plane direct stress
sx1 = -50e06
tx1y1 = -40e06 # Stress acting on face at theta = 0 degree
sx1_ = 10e06
tx1y1_ = 40e06 # Stress acting on face at theta = 0 degree
#calculation
R = math.sqrt(((sx-sy)/2)**2+(txy)**2) # Radius of mohr circle
# Part (a)
t = 45 # Inclination of the plane in degree
f1 = numpy.degrees(numpy.arctan((40e06/30e06))) # Angle between line CD and x1-axis
f2 = 90 - f1 # Angle between line CA and x1-axis
# Point D
sx1 = savg - R*math.cos(math.radians(f2)) # Direct stress at point D
tx1y1 = R*math.sin(math.radians(f2)) # shear stress at point D
print "The direct stres at point D", sx1, "Pa"
print "The shear stress at point D", tx1y1, "Pa"
# Point D'
sx2 = savg + R*math.cos(math.radians(f2)) # Direct stress at point D'
tx2y2 = -R*math.sin(math.radians(f2)) # shear stress at point D'
print "The direct stres at point D_desh", sx2, "Pa"
print "The shear stress at point D_desh", tx2y2, "Pa"
#Part (b)
sp1 = savg + R # Maximum direct stress in mohe circle (at point P1)
tp1 =(f1+180)/2 # Inclination of plane of maximum direct stress
print "with angle", round(tp1,2), "degree", "The maximum direct stress at P1 is ", sp1, "Pa"
sp2 = savg - R # Minimum direct stress in mohe circle (at point P2)
tp2 = f1/2 # Inclination of plane of minimum direct stress
print "with angle", round(tp2,2), "degree", "The maximum direct stress at P2 is ", sp2, "Pa"
# Part (c)
tmax = R # Maximum shear stress in mohe circle
ts1 = (90 + f1)/2 # Inclination of plane of maximum shear stress
print "with plane incilation of", round(ts1,2), "degree", "The Maximum shear stress is ", tmax, "Pa"
```

In [5]:

```
import math
import numpy
#initialisation
ex = 340e-06 # Strain in x-direction
ey = 110e-06 # Strain in y-direction
txy = 180e-06 # shear strain
# Part (a)
t = 30 # Inclination of the element in degree
ex1 = (ex+ey)/2.0 + ((ex-ey)/2.0)*math.cos(math.radians(2*t)) + (txy/2.0)*(math.sin(math.radians(2*t))) # Strain in x1 direction (located at 30 degree)
tx1y1 = 2*(-((ex-ey)/2.0)*math.sin(math.radians(2*t)) + (txy/2.0)*(math.cos(math.radians(2*t)))) # Shear starin
ey1 = ex+ey-ex1 # Strain in y1 direction (located at 30 degree)
print "Strain in x1 direction (located at 30 degree) is", round((ex1/1E-6),2),"* 10^-6"
print "shear strain is", round((tx1y1/1E-6),2),"* 10^-6"
print "Strain in y1 direction (located at 30 degree) is", ey1
# Part (b)
e1 = (ex+ey)/2.0 + math.sqrt(((ex-ey)/2.0)**2 + (txy/2.0)**2) # Principle stress
e2 = (ex+ey)/2.0 - math.sqrt(((ex-ey)/2.0)**2 + (txy/2.0)**2) # Principle stress
tp1 = (0.5)*numpy.degrees(numpy.arctan((txy/(ex-ey)))) # Angle to principle stress direction
tp2 = 90 + tp1 # Angle to principle stress direction
e1 = (ex+ey)/2.0 + ((ex-ey)/2.0)*math.cos(math.radians(2*tp1)) + (txy/2.0)*(math.sin(math.radians(2*tp1))) # Principle stress via another method
e2 = (ex+ey)/2.0 + ((ex-ey)/2.0)*math.cos(math.radians(2*tp2)) + (txy/2.0)*(math.sin(math.radians(2*tp2))) # Principle stress via another method
print "with angle", round(tp1,2), "degree","The Principle stress is ", round(e1,4)
print "with angle",round(tp2,2), "degree","The Principle stress is ",round(e2,4)
# Part (c)
tmax = 2*math.sqrt(((ex-ey)/2.0)**2 + (txy/2.0)**2) # Maxmum shear strain
ts = tp1 + 45 # Orientation of element having maximum shear stress
tx1y1_ = 2*( -((ex-ey)/2)*math.sin(math.radians(2*ts)) + (txy/2)*(math.cos(math.radians(2*ts)))) # Shear starin assosiated with ts direction
print "with angle",round(ts,2), "degree","The Maximum shear strain is ",round(tx1y1_,4)
eavg = (e1+e2)/2.0 # Average atrain
print "The average strain is", eavg
```