In [4]:

```
import math
#Variable Decleration
#Axial Forces in lb in member AB, BC and CD
P_AB=2000
P_BC=2000
P_CD=4000
#Other Variables
E=29*10**6 #Modulus of Elasticity in psi
#Length of each member in inches
L_AB=5*12
L_BC=4*12
L_CD=4*12
#Diameter of each member in inches
D_AB=0.5
D_BC=0.75
D_CD=0.75
#Calculation
#Area Calculation of each member in square inches
A_AB=(pi*D_AB**2)/4
A_BC=(pi*D_BC**2)/4
A_CD=(pi*D_CD**2)/4
#Using relation delta=(PL/AE) to compute strain
#As stress in Member CD is compression
delta=(E**-1)*((P_AB*L_AB*A_AB**-1)+(P_BC*L_BC*A_BC**-1)-(P_CD*L_CD*A_CD**-1))
#Result
print "The elongation in the total structure is",round(delta,5),"in"
```

In [10]:

```
import math
from scipy.integrate import quad
#Variable Decleration
E=200*10**9 #Modulus of elasticity in Pa
P=10**5 #Force acting in N
#Calculations
#Using quad integration
#Area has been defined as a quadratic equation to integrate
def integrand(x, a, b):
return 1/(a * x + b)
a = 160
b = 800
I = quad(integrand, 0, 10, args=(a,b))
#Using delta=(P/E)*I where I is the integrand
delta=(P*E**-1)*10**6*I[0]
#Result
print "The elongation in the member is",round(delta*1000,2),"mm"
```

In [14]:

```
import math
#Variable Decelration
A_AC=0.25 #Cross Sectional Area in square inch
Load=2000 #Load at point C in lb
E=29*10**6 #Modulus of elasticity in psi
theta=(pi*40)/180 #Angle in radians
L_BC=8 #Length in ft
#Calculations
#Using sum of forces
P_AC=Load/sin(theta) #Force in cable AC in lb
L_AC=(L_BC*12)/cos(theta) #Length of cable AC in in
delta_AC=(P_AC*L_AC)/(E*A_AC) #elongation in inches
delta_C=delta_AC/sin(theta) #displacement of point C in inches
#Result
print "The displacement of point C is",round(delta_C,4),"in"
```

In [1]:

```
import math
#Variable Decleration
d=0.05 #Diameter of the rod in mm
P=8000 #Load on the bar in N
E=40*10**6 #Modulus of elasticity in Pa
v=0.45 #Poisson Ratio
L=300 #Length of the rod in mm
#Calculation
A=((pi*d**2)/4) #Area of the bar in mm^2
sigma_x=-P/A #Axial Stress in the bar in Pa
#As contact pressure resists the force
p=(v*sigma_x)/(1-v)
#Using Axial Strain formula
e_x=(sigma_x-(v*2*p))/E
#Corresponding change in length
delta=e_x*L #contraction in mm
#Without constrains of the wall
delta_w=(-P*(L*10**-3))/(E*A) #Elongation in m
#Result
print "The elongation in the bar is",-round(delta,2),"mm contraction"
```

In [5]:

```
import math
#Variable Decleration
E=500 #Modulus of elasticity in psi
v=0.48 #Poisson ratio
V=600 #Force in lb
w=5 #Width of the plate in inches
l=9 #Length of the plate in inches
t=1.75 #Thickness of the rubber layer in inches
#Calculations
tau=V*(w*l)**-1 #Shear stress in rubber in psi
G=E/(2*(1+v)) #Bulk modulus in psi
gamma=tau/G #Shear Modulus
disp=t*gamma #Diplacement in inches
#Result
print "The displacement of the rubber layer is",round(disp,4),"in"
```

In [10]:

```
import math
#Variable Decleration
P=10**6 #Force on the member in N
Es=200 #Modulus of elasticity of steel in GPa
Ec=14 #Modulus of elasticity concrete in GPa
As=900*10**-6 #Area of steel in m^2
Ac=0.3**2 #Area of concrete block in m^2
#Calculation
#Cross Sectional Areas
Ast=4*As #Cross Sectional Area in m^2 of Steel
Act=Ac-Ast #Cross Sectional Area of Concrete in m^2
#Applying equilibrium to the structure
#Using the ratio of stress and modulii of elasticity we obtain the following eq
sigma_ct=P/(((Es*Ec**-1)*Ast)+Act) #Stress in Concrete in Pa
sigma_st=sigma_ct*Es*Ec**-1 #Stress in Steel in Pa
#Result
print "The stress in steel and concrete is as follows",round(sigma_st*10**-6,1),"MPa and",round(sigma_ct*10**-6,3),"Mpa respectively"
```

In [11]:

```
import math
#Variable Decleration
#Say the ratio of stress in steel to concrete is R
R=14.286
sigma_co=6*10**6 #Stress in concrete in Pa
Ast=3.6*10**-3 #Area of steel in m^2
Aco=86.4*10**-3 #Area of Concrete in m^2
#Calculation
sigma_st=R*sigma_co #Stress in steel in Pa
#Here stress is below the allowable hence safe
P=sigma_st*Ast+sigma_co*Aco #Allowable force in N
#Result
print "The maximum allowable force is",round(P*10**-3),"kN"
```

In [34]:

```
import math
#NOTE:The NOtation has been changed to ease coding
#Variable Decleration
d=0.005 #difference in length in inch
L=10 #Length in inch
#Area of copper and aluminium in sq.in
Ac=2 #Area of copper
Aa=3 #Area of aluminium
#Modulus of elasticity of copper and aluminium in psi
Ec=17000000 #Copper
Ea=10**7 #Aluminium
#Allowable Stress in psi
Sc=20*10**3 #Copper
Sa=10*10**3 #Aluminium
#Calculation
#Equilibrium is Pc+Pa=P
#Hookes Law is delta_c=delta_a+0.005
#Simplfying the solution we have constants we can directly compute
A=d*Ec*(L+d)**-1
B=Ec*Ea**-1
C=L*B*(L+d)**-1
sigma_a=(Sc-A)*C**-1
#Using equilibrium equation
P=Sc*Ac+sigma_a*Aa #Safe load in lb
#Result
print "The safe load on the structure is",round(P),"lb"
#NOTE:Answer in the textbook has been rounded off and hence the discrepancy
```

In [49]:

```
import math
import numpy as np
#Variable Decleration
P=50*10**3 #Load applied in N
x1=0.6 #Length in m
x2=1.6 #Length in m
L1=1 #Length of steel cable in m
L2=2 #Length of bronze cable in m
L=2.4 #Length in m
#Area in m^2
Ast=600*10**-6 #Steel
Abr=300*10**-6 #Bronze
#Modulus of elasticity in GPa
Est=200 #Steel
Ebr=83 #Bronze
#Calculations
#Applying the equilibrium and Hookes law we solve by matrix method
a=np.array([[x1,x2],[1,-((x1*Est*Ast*L2)/(x2*Ebr*Abr))]])
b=np.array([L*P,0])
y=np.linalg.solve(a,b)
#Stresses in Pa
sigma_st=y[0]*Ast**-1 #Stress in steel
sigma_br=y[1]/Abr #Stress in bronze
#Result
print "The stresses in steel and bronze are as follows"
print round(sigma_st*10**-6,1),"MPa and",round(sigma_br*10**-6,1),"MPa respectively"
```

In [53]:

```
import math
#Variable Decleration
L=2.5 #Length in m
A=1200 #Cross sectional Area in mm^2
delta_T=40 #Temperature drop in degree C
delta=0.5*10**-3 #Movement of the walls in mm
alpha=11.7*10**-6 #Coefficient of thermal expansion in /degreeC
E=200*10**9 #Modulus of elasticity in Pa
#Calculation
#Part(1)
sigma_1=alpha*delta_T*E #Stress in the rod in Pa
#Part(2)
#Using Hookes Law
sigma_2=E*((alpha*delta_T)-(delta*L**-1)) #Stress in the rod in Pa
print "The Stress in part 1 in the rod is",round(sigma_1*10**-6,1),"MPa"
print "The Stress in part 2 in the rod is",round(sigma_2*10**-6,1),"MPa"
```

In [58]:

```
import math
#Variable Decleration
delta=100 #Increase in the temperature in degreeF
Load=12000 #Load on the beam in lb
#Length in inch
Ls=2*12 #Steel
Lb=3*12 #Bronze
#Area in sq.in
As=0.75 #Steel
Ab=1.5 #Bronze
#Modulus of elasticity in psi
Es=29*10**6 #Steel
Eb=12*10**6 #Bronze
#Coefficient of thermal expansion in /degree C
alpha_s=6.5*10**-6 #Steel
alpha_b=10**-5 #Bronze
#Calculations
#Applying the Hookes Law and equilibrium we get two equations
a=np.array([[Ls*(Es*As)**-1,-Lb*(Eb*Ab)**-1],[2,1]])
b=np.array([(alpha_b*delta*Lb-alpha_s*delta*Ls),Load])
y=np.linalg.solve(a,b)
#Stresses
sigma_st=y[0]*As**-1 #Stress in steel in psi (T)
sigma_br=y[1]*Ab**-1 #Stress in bronze in psi (C)
#Result
print "The Stress in steel and bronze are as follows"
print sigma_st,"psi (T) and", -sigma_br,"psi (C)"
```

In [60]:

```
import math
#Variable Decleration
P=6000 #Force in lb
Est=29*10**6 #Modulus of elasticity of steel in psi
L1=24 #Length in inches
L2=36 #Length in inches
alpha_1=6.5*10**-6 #coefficient of thermal expansion in /degree F of steel
alpha_2=10**-5 #coefficient of thermal expansion in /degree F of bronze
As=0.75 #Area os steel in sq.in
#Calculations
delta_T=((P*L1)/(Est*As))/(alpha_2*L2-alpha_1*L1) #Change in temperature in degree F
print "The change in the Temperature is",round(delta_T,1),"F"
```