Question: Flat truss to solve in pyhton E = 2 1 0 8 k N m 2 I want you to add the following explicitly step

Flat truss to solve in pyhton
E=2108kNm2
I want you to add the following explicitly step by step, indicating the equation that was used to solve in comments. It is to solve the exercise using the stiffness method of a truss in Python and the instructions to solve are a) print on the screen the system of equations in local coordinates of each element using Python.
b) print on the screen the system of equations of each element in global coordinates in python.
c) Print on the screen in python the Calculation of local displacements indicating node 1 local displacement in x is:
node 1 local displacement in y is:
d) prints on the screen the displacement in global coordinates of each bar. indicating the 1 x global node is:
node 1 and global is:
e) Print the reactions on the screen indicating the restricted degree of freedom in python.
f) Print on the screen the calculation of axial forces in each element per bar in local coordinates indicating the axial forces of bar number 1 is: .
g) Print on the screen the calculation of axial forces in each element per bar in global coordinates indicating the axial forces of bar number 1 in global x is:
axial force of bar 1 in y global is:
h) Plot the axial force of the complete structure
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
'Code to solve 2D trusses'
'Units are consistent and depend on the user'
#%% Geometry of the structure
#Input nodes and coordinates#
#Initializing node names matrix
ID =[1,2,3,4,5]
#Enter the coordinates
CoordinatesX =[0,5,15,5,15]
CoordinatesY =[0,8.5,8.5,0,0]
#%% Input supports
U_X =[1,0,0,0,0] #####X Restriction
U_Y =[1,0,0,0,1] #####Y Restriction
#%% Input connectivity
Node_i =[1,2,2,2,1,4,3]
Node_j =[2,3,5,4,4,5,5]
#%% Input properties
A =[0.03,0.03,0.03,0.03,0.03,0.03,0.03]
E =[2*10**11,2*10**11,2*10**11,2*10**11,2*10**11,2*10**11,2*10**11]
#%% Input nodal loads
Fx =[4250,4250,10000,0,0]
Fy =[-2500,-3333.333,-1666.67,-20000,0]
#%% Scale factor for deformations
esc =10000
#%%
############################ Function definitions ###################
#%% Plot function
def Plot(Node_i, Node_j, ID, CoordinatesX, CoordinatesY):
fig = plt.figure()
for i in range(len(Node_i)):
ni = Node_i[i]
nf = Node_j[i]
XX =[]
YY =[]
for j in range(len(ID)):
if ni == ID[j]:
XX.append(CoordinatesX[j])
YY.append(CoordinatesY[j])
if nf == ID[j]:
XX.append(CoordinatesX[j])
YY.append(CoordinatesY[j])
plt.plot(XX, YY, marker='o', color='black')
plt.show()
#%%
################################################################
############## Calculations begin ############################
################################################################
#%% Plotting the structure
Plot(Node_i, Node_j, ID, CoordinatesX, CoordinatesY)
#%% GENERATING THE GLOBAL STIFFNESS MATRIX
# Generate the global DOF (Degrees of Freedom) vector
n_nodes = len(CoordinatesX)
Indices =[] # Vector of indices ordered by DOF and ID in alphanumeric, used for assembling
for i in range(n_nodes):
Indices.append('x'+ str(ID[i]))
Indices.append('y'+ str(ID[i]))
print('The DOFs of the structure are', Indices)
Indices_num =[] # Numeric indices vector for each DOF, used to identify rows and columns to remove
for i in range(n_nodes *2):
Indices_num.append(i)
# Identify the restricted DOFs
Restriction =[]
for i in range(n_nodes):
if U_X[i]==1:
Restriction.append('x'+ str(ID[i]))
if U_Y[i]==1:
Restriction.append('y'+ str(ID[i]))
print('The restricted DOFs are', Restriction)
# Create the same restriction vector but in numeric form
Restriction_num =[]
for i in range(len(Restriction)):
for j in range(n_nodes *2):
if Restriction[i]== Indices[j]:
Restriction_num.append(Indices_num[j])
# Calculating the local and assembled matrices
# A loop is created to iterate through the number of elements,
# since local matrices are element-specific
L =[] # Initialize the length vector
num_el = len(Node_i) # The length of connectivity equals the number of elements
# Initialize the global stiffness matrix
K = np.asmatrix(np.zeros([n_nodes*2, n_nodes*2]))
for i in range(num_el):
# Extracting coordinates
xi = CoordinatesX[Node_i[i]-1]
xj = CoordinatesX[Node_j[i]-1]
yi = CoordinatesY[Node_i[i]-1]
yj = CoordinatesY[Node_j[i]-1]
# Calculating length
L.append(((xi - xj)**2+(yi - yj)**2)**0.5)
# Generating local DOF alphanumeric indices
IL =[]
IL.append('x'+ str(Node_i[i]))
IL.append('y'+ str(Node_i[i]))
IL.append('x'+ str(Node_j[i]))
IL.append('y
Flat truss to solve in pyhton E = 2 1 0 8 k N m 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!