In [8]:

```
#Given
#Virtual loading
p_ab = -0.833 #lb The recorded virtual loading
p_bc = + 0.833 #lb The recorded virtual loading
F_ab = 2500 #lb
F_bc = -2500 #lb
l_ab = 60 #in - The length of the rod
l_bc = 60 #in - The length of the rod
A_ab = 0.15 #in2 the areaof ab
A_bc = 0.25 #in2 the areaof bc
E = 30*(10**6) #psi The youngs modulus of the material
#Part_a
e_a =p_ab*l_ab*F_ab/(A_ab*E) + p_bc*l_bc*F_bc/(A_bc*E) #in the deflection
if e_a<0:
print "a) The deflection is downwards",round(-e_a,3),"in"
else:
print "a) The deflection is upwards",round(e_a,3),"in"
#part-b
x = 0.125 #Shortening of member Ab
e_b = p_ab*(-x) + p_bc*0 #in - in
if e_b<0:
print "b) The deflection is downwards",round(-e_b,3),"in"
else:
print "b) The deflection is upwards",round(e_b,3),"in"
#Part-c
S = 6.5*(10**-6) #Thermal specific heat
T = 120 #F - The cahnge in temperature
e_t = -S*T*l_ab #in - The change in length of member
e_c = p_bc*e_t #in the deflection
if e_c<0:
print "c) The deflection is downwards",round(-e_c,3),"in"
else:
print "c) The deflection is upwards",round(e_c,3),"in"
```

In [7]:

```
#Given
#Virtual loading
#Two parts
#Part -1
p_ab = 5 #KN The recorded virtual loading
p_bc = -4 #KN The recorded virtual loading
F_ab = 10 #KN
F_bc = -8 #KN
l_ab = 2.5 #mt - The length of the rod
l_bc = 2 #mt - The length of the rod
A_ab = 5*(10**-4) #mt2 the areaof ab
A_bc = 5*(10**-3) #mt2 the areaof bc
E = 70 #Gpa The youngs modulus of the material
e_a =(p_ab*l_ab*F_ab/(A_ab*E) + p_bc*l_bc*F_bc/(A_bc*E))*(10**-6) #KN-m
#Part -2 due to flexure
I = 60*10**6 #mm4 - the moment of inertia
#After solving the integration
e_b = 0.01525 #KN-m
#Total
e = (e_a+e_b)*1 #m
print "The point C deflects",round(e,3),"mt down"
```

In [6]:

```
#Given
#Virtual loading Without f_d
p_ab = -0.833 #lb The recorded virtual loading
p_bc = + 0.833 #lb The recorded virtual loading
F_ab = 2500 #lb
F_bc = -2500 #lb
l_ab = 60 #in - The length of the rod
l_bc = 60 #in - The length of the rod
A_ab = 0.15 #in2 the areaof ab
A_bc = 0.25 #in2 the areaof bc
E = 30*(10**6) #psi The youngs modulus of the material
#Part_a
e_a =p_ab*l_ab*F_ab/(A_ab*E) + p_bc*l_bc*F_bc/(A_bc*E) #lb-in the deflection
#With f_d
p_bd = 1 #lb The recorded virtual loading
F_bd = 1 #lb
l_bd = 40 #in - The length of the rod
A_bd = 0.1 #in2 the areaof ab
e_a_1 =p_ab*p_ab*l_ab/(A_ab*E) + p_bc*p_bc*l_bc/(A_bc*E) +p_bd*p_bd*l_bd/(A_bd*E) #lb-in the deflection
#Since the produced defelection should compensate the other one
x_d = e_a/e_a_1
print "The reaction force at D is",round(-x_d,2),"lb"
#Part - B
e_b = -x_d*l_bd/(A_bd*E ) #in - The deflection of nodal point B
print"The deflection of nodal point B",round(e_b,4),"in"
```

In [10]:

```
#Given
#Virtual loading
import numpy as np
p_ab = -0.833 #lb The recorded virtual loading
p_bc = + 0.833 #lb The recorded virtual loading
l_ab = 60 #in - The length of the rod
l_bc = 60 #in - The length of the rod
A_ab = 0.15 #in2 the areaof ab
A_bc = 0.25 #in2 the areaof bc
E = 30*(10**6) #psi The youngs modulus of the material
K_1 = A_ab*E/l_ab #k/in - Stiffness
K_2 = A_bc*E/l_bc #k/in - Stiffness
#soving for e_1 and e_2 gives a liner euations to solve
# 128*e_1 + 24*e_2 = 0
#24*e_1 + 72*e_2 = -3
#Solving for e_1,e_2
a = np.array([[128,24], [24,72]])
b = np.array([0,-3])
x = np.linalg.solve(a, b)
e_1 = x[0] #in
e_2 = x[1] #in
u_1 = 0.8*e_1 - 0.6*e_2 #Taking each components
F_1 = K_1*u_1*(10**-3) #k The reaction at A Force = stiffness x dislacement
u_2 = 0.8*e_1 + 0.6*e_2 #Taking each components
F_2 = K_2*u_2*(10**-3) #k The reaction at B Force
print "The reaction at A ",F_1,"k"
print "The reaction at B ",F_2,"k"
```

In [9]:

```
#Virtual loading
import numpy as np
p_ab = -0.833 #lb The recorded virtual loading
p_bc = + 0.833 #lb The recorded virtual loading
l_ab = 60 #in - The length of the rod
l_bc = 60 #in - The length of the rod
A_ab = 0.15 #in2 the areaof ab
A_bc = 0.25 #in2 the areaof bc
E = 30*(10**6) #psi The youngs modulus of the material
K_1 = A_ab*E/l_ab #k/in - Stiffness
K_2 = A_bc*E/l_bc #k/in - Stiffness
p_bd = 1 #lb The recorded virtual loading
F_bd = 1 #lb
l_bd = 40 #in - The length of the rod
A_bd = 0.1 #in2 the areaof ab
K_3 = A_ab*E/l_ab #k/in - Stiffness
#soving for e_1 and e_2 gives a liner euations to solve
# 128*e_1 + 24*e_2 = 0
#24*e_1 + 72*e_2 = -3
#Solving for e_1,e_2
a = np.array([[128,24], [24,147]])
b = np.array([0,-3])
x = np.linalg.solve(a, b)
e_1 = x[0] #in
e_2 = x[1] #in
u_1 = 0.8*e_1 - 0.6*e_2 #Taking each components
F_1 = K_1*u_1*(10**-3) #k The reaction at A Force = stiffness x dislacement
u_2 = 0.8*e_1 + 0.6*e_2 #Taking each components
F_2 = K_2*u_2*(10**-3) #k The reaction at B Force
u_3 = e_2 #Taking each components
F_3 = K_3*u_3*(10**-3) #k The reaction at D Force
print "The reaction at A ",round(F_1,2),"k"
print "The reaction at B ",round(F_2,2),"k"
print "The reaction at D ",round(F_3,2),"k"
```

In [3]:

```
#Given
#First we will solve part B
import numpy as np
u_1 =5 #L/AE, elastic elongation
u_2 =25 #L/AE,elastic elongation
f_1 = u_1#, Units got neutralized , Constitutive relation for elastic bars
f_2 = u_2# Units got neutralized
#u_1 = 0.8*e_1 - 0.6*e_2
#u_2 = 0.8*e_1 + 0.6*e_2
#u = A*e Matric multiplication
A = np.array([[0.8,-0.6],[0.8,0.6]]) #The matrix form of A
F = np.array([[f_1],[f_2]])
P = np.dot((A.T),F) #Nodal forces matrix
print "b) The vertical component of the nodal force is",P[1],""
print "b) The vertical component of the nodal force is",P[0],""
#Part A
#F_1 = (5/8.0)*P_1 - (5/6.0)*p_2 , From statics
#F_1 = (5/8.0)*P_1 + (5/6.0)*p_2
#F = BP ,Matric multiplication
B = np.array([[(5/8.0),-(5/6.0)],[(5/8.0),(5/6.0)]]) #The matrix form of A
U = np.array([[u_1],[u_2]])
e = P = np.dot((B.T),U) #L/AE, Nodal forces matrix
print "a) The components of displacement of point B are",round(e[0],2),"L/AE and",round(e[1],2),"L/AE"
```

In [1]:

```
#Given
A_1 = 0.125 #in2 , The area of the crossection of AB
A_2 = 0.219 #in2 , The area of the crossection of BC
l_1 = 3*(5**0.5) #in , The length of AB
l_2 = 6*(2**0.5) #in , The length of BC
p = 3 #k , Force acting on the system
E = 10.6*(10**3) #Ksi - youngs modulus of the material
p_1 = (5**0.5)*p/3 #P, The component of p on AB
p_2 = -2*(2**0.5)*p/3 #P, The component of p on AB
e = p_1*l_1*p_1/(p*E*A_1) + p_2*l_2*p_2/(p*E*A_2) #in, By virtual deflection method
print "The deflection is",round(e,3),"in"
```

In [ ]:

```
```