Structural dynamics
Structural dynamics
FRAME ANALYSIS
# Dependencies
import copy # Allows us to create copies of objects in memory
import math # Math functionality
import numpy as np # Numpy for working with arrays
import matplotlib.pyplot as plt # Plotting functionality
# Constants
E=29000 #(kilopounds per square inch)
Ar=[16,12] #(in^2)
In=[800,400] #(in^4)
# #Supports
restrainedDOF=[1, 2, 3, 7, 8, 9] #The degrees of freedom restrained by supports
# #Loading
forceVector=np.array([[0,-30,0,0,-30,2700,0,0,0]]).T
fig = plt.figure()
axes = fig.add_axes([0.1,0.1,2,2])
fig.gca().set_aspect('equal', adjustable='box')
#Plot members
for mbr in members:
node_i = mbr[0] #Node number for node i of this member
node_j = mbr[1] #Node number for node j of this member
axes.plot([ix,jx],[iy,jy],'b') #Member
#Plot nodes
for node in nodes:
axes.plot([node[0]],[node[1]],'bo')
axes.set_xlabel('Distance (m)')
axes.set_ylabel('Distance (m)')
axes.set_title('Structure to analyse')
axes.grid()
plt.show()
Calculate member orientation and length
#Need to capture quadrant first then appropriate reference axis and offset angle
if(dx>0 and dy==0):
theta = 0
elif(dx==0 and dy>0):
theta = math.pi/2
elif(dx<0 and dy==0):
theta = math.pi
elif(dx==0 and dy<0):
theta = 3*math.pi/2
elif(dx>0 and dy>0):
# 0<theta<90
refVector = np.array([1,0]) # Vector describing the positive x-axis
theta = math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between two vectors
elif(dx<0 and dy>0):
# 90<theta<180
refVector = np.array([0,1]) # Vector describing the positive y-axis
theta = (math.pi/2) + math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between two
elif(dx<0 and dy<0):
# 180<theta<270
refVector = np.array([-1,0]) # Vector describing the negative x-axis
theta = math.pi + math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between two vec
else:
# 270<theta<360
refVector = np.array([0,-1]) # Vector describing the negative y-axis
theta = (3*math.pi/2) + math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between t
theta = orientations[memberNo-1]
L = lengths[memberNo-1]*12
A=Ar[memberNo-1]
I=In[memberNo-1]
c = math.cos(theta)
s = math.sin(theta)
#Calculate the quadrants of the global stiffness matrix for the member
[K11, K12, K21,K22] = calculateKg(n+1)
#Reduce to structure stiffness matrix by deleting rows and columns for restrained DoF
Ks = np.delete(Kp,restrainedIndex,0) #Delete rows
Ks = np.delete(Ks,restrainedIndex,1) #Delete columns
Ks = np.matrix(Ks) # Convert Ks from numpy.ndarray to numpy.matrix to use build in inverter function
print("structure sti¤ness matrix:")
print(Ks)
Displacements:
[[-0.017888 ]
[-0.0479176 ]
[ 0.00650229]]
#Transformation matrix
c = math.cos(theta)
s = math.sin(theta)
F_axial = (A*E/L)*(disp_local[3]-disp_local[0])[0]
#Calculate the quadrants of the global stiffness matrix for the member
[K11, K12, K21,K22] = calculateKg(n+1)
mbrShears[n,0] = Fy_i
mbrShears[n,1] = Fy_j
mbrMoments[n,0] = Mi
mbrMoments[n,1] = Mj
fig = plt.figure()
axes = fig.add_axes([0.1,0.1,2,2])
fig.gca().set_aspect('equal', adjustable='box')
#Plot members
for mbr in members:
node_i = mbr[0] #Node number for node i of this member
node_j = mbr[1] #Node number for node j of this member
axes.plot([ix,jx],[iy,jy],'b') #Member
axes.plot([ix + UG[ia,0]*xFac, jx + UG[ja,0]*xFac], [iy + UG[ia+1,0]*xFac, jy + UG[ja+1,0]*xFac],'--r') #Deformed
#Plot nodes
for node in nodes:
axes.plot([node[0]],[node[1]],'bo')
axes.set_xlabel('Distance (m)')
axes.set_ylabel('Distance (m)')
axes.set_title('Deflected shape')
axes.grid()
plt.show()
Result Summary
print("")
print("MEMBER AXIAL FORCES")
for n, mbr in enumerate(members):
print("- Force in member {one} (nodes {two} to {three}) is {four} k".format(one = n+1, two=mbr[0], three=mbr[1],
print("")
print("MEMBER SHEAR FORCES")
for n, mbr in enumerate(members):
print("- Shear force in member {one} (nodes {two}/{three}) is {four}/{five} k".format(one = n+1, two=mbr[0], thre
print("")
print("MEMBER BENDING MOMENTS")
for n, mbr in enumerate(members):
print("- Bending moment in member {one} (nodes {two}/{three}) is {four}/{five} kin".format(one = n+1, two=mbr[0
print("")
print("NODAL DISPLACEMENTS")
for n, node in enumerate(nodes):
ix = 3*(n+1)-3 #horizontal DoF for this node
iy = ix+1 #vertical DoF for this node
iz = ix+2 #rotational DoF for this node
REACTIONS
- Reaction at DoF 1: 23.06 k
- Reaction at DoF 2: 37.27 k
- Reaction at DoF 3: 2689.54 k-in
- Reaction at DoF 7: -23.06 k
- Reaction at DoF 8: 22.73 k
- Reaction at DoF 9: 469.54 k-in
NODAL DISPLACEMENTS
- Node 1: Ux = 0.0 in, Uy = 0.0 in, theta = 0.0 radians
- Node 2: Ux = -0.01789 in, Uy = -0.04792 in, theta = 0.0065 radians
- Node 3: Ux = 0.0 in, Uy = 0.0 in, theta = 0.0 radians
Loading [MathJax]/extensions/Safe.js
Beam Analysis
# Dependencies
import copy # Allows us to create copies of objects in memory
import math # Math functionality
import numpy as np # Numpy for working with arrays
import matplotlib.pyplot as plt # Plotting functionality
# Constants
E=1 #()
Ar=[1,1,1] #(in^2)
In=[1,1,1] #(in^4)
# #Supports
restrainedDOF=[1, 2, 3,4,5, 7, 8, 10,11,12] #The degrees of freedom restrained by supports
# #Loading
forceVector=np.array([[0,28.16,76.8,0,171.84,-84.8,0,120,200,0,0,0]]).T
fig = plt.figure()
axes = fig.add_axes([0.1,0.1,2,2])
fig.gca().set_aspect('equal', adjustable='box')
#Plot members
for mbr in members:
node_i = mbr[0] #Node number for node i of this member
node_j = mbr[1] #Node number for node j of this member
axes.plot([ix,jx],[iy,jy],'b') #Member
#Plot nodes
for node in nodes:
axes.plot([node[0]],[node[1]-1],'bo')
axes.set_xlabel('Distance (m)')
axes.set_ylabel('Distance (m)')
axes.set_title('Structure to analyse')
axes.grid()
plt.show()
#Need to capture quadrant first then appropriate reference axis and offset angle
if(dx>0 and dy==0):
theta = 0
elif(dx==0 and dy>0):
theta = math.pi/2
elif(dx<0 and dy==0):
theta = math.pi
elif(dx==0 and dy<0):
theta = 3*math.pi/2
elif(dx>0 and dy>0):
# 0<theta<90
refVector = np.array([1,0]) # Vector describing the positive x-axis
theta = math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between two vectors
elif(dx<0 and dy>0):
# 90<theta<180
refVector = np.array([0,1]) # Vector describing the positive y-axis
theta = (math.pi/2) + math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between two
elif(dx<0 and dy<0):
# 180<theta<270
refVector = np.array([-1,0]) # Vector describing the negative x-axis
theta = math.pi + math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between two vec
else:
# 270<theta<360
refVector = np.array([0,-1]) # Vector describing the negative y-axis
theta = (3*math.pi/2) + math.acos(refVector.dot(memberVector)/(mag))#Standard formula for the angle between t
#Define a function to calculate the global stiffness matrix for a beam element
def calculateKg(memberNo):
theta = orientations[memberNo-1]
L = lengths[memberNo-1]
A=Ar[memberNo-1]
I=In[memberNo-1]
c = math.cos(theta)
s = math.sin(theta)
#Calculate the quadrants of the global stiffness matrix for the member
[K11, K12, K21,K22] = calculateKg(n+1)
restrainedIndex = [x - 1 for x in restrainedDOF] #Index for each restrained DoF (list comprehension)
#Reduce to structure stiffness matrix by deleting rows and columns for restrained DoF
Ks = np.delete(Kp,restrainedIndex,0) #Delete rows
Ks = np.delete(Ks,restrainedIndex,1) #Delete columns
Ks = np.matrix(Ks) # Convert Ks from numpy.ndarray to numpy.matrix to use build in inverter function
print("structure sti¤ness matrix:")
print(Ks)
forceVectorRed = copy.copy(forceVector)# Make a copy of forceVector so the copy can be edited, leaving the original u
forceVectorRed = np.delete(forceVectorRed,restrainedIndex,0) #Delete rows corresponding to restrained DoF
U = Ks.I*forceVectorRed
print('Displacements:')
print(U)
Displacements:
[[-154.08695652]
[ 192.34782609]]
FG = np.matmul(Kp,UG)
forceVector=np.array([[0,28.16,76.8,0,171.84,-84.8,0,120,200,0,0,0]]).T
FG=FG+forceVector
#Transformation matrix
c = math.cos(theta)
s = math.sin(theta)
F_axial = (A*E/L)*(disp_local[3]-disp_local[0])[0]
#Calculate the quadrants of the global stiffness matrix for the member
[K11, K12, K21,K22] = calculateKg(n+1)
mbrShears[n,0] = Fy_i
mbrShears[n,1] = Fy_j
mbrMoments[n,0] = Mi
mbrMoments[n,1] = Mj
fig = plt.figure()
axes = fig.add_axes([0.1,0.1,2,2])
fig.gca().set_aspect('equal', adjustable='box')
#Plot members
for mbr in members:
node_i = mbr[0] #Node number for node i of this member
node_j = mbr[1] #Node number for node j of this member
axes.plot([ix,jx],[iy,jy],'b') #Member
axes.plot([ix + UG[ia,0]*xFac, jx + UG[ja,0]*xFac], [iy + UG[ia+1,0]*xFac, jy + UG[ja+1,0]*xFac],'--r') #Deformed
#Plot nodes
for node in nodes:
axes.plot([node[0]],[node[1]-1],'bo')
axes.set_xlabel('Distance (m)')
axes.set_ylabel('Distance (m)')
axes.set_title('Deflected shape')
axes.grid()
plt.show()
print("")
print("MEMBER AXIAL FORCES")
for n, mbr in enumerate(members):
print("- Force in member {one} (nodes {two} to {three}) is {four} KN".format(one = n+1, two=mbr[0], three=mbr[1
print("")
print("MEMBER SHEAR FORCES")
for n, mbr in enumerate(members):
print("- Shear force in member {one} (nodes {two}/{three}) is {four}/{five} KN".format(one = n+1, two=mbr[0], thr
print("")
print("MEMBER BENDING MOMENTS")
for n, mbr in enumerate(members):
print("- Bending moment in member {one} (nodes {two}/{three}) is {four}/{five} KN-m".format(one = n+1, two=mbr[
print("")
print("NODAL DISPLACEMENTS")
for n, node in enumerate(nodes):
ix = 3*(n+1)-3 #horizontal DoF for this node
iy = ix+1 #vertical DoF for this node
iz = ix+2 #rotational DoF for this node
NODAL DISPLACEMENTS
- Node 1: Ux = 0.0 in, Uy = 0.0 in, theta = 0.0 radians
- Node 2: Ux = 0.0 in, Uy = 0.0 in, theta = -154.08696 radians
- Node 3: Ux = 0.0 in, Uy = 0.0 in, theta = 192.34783 radians
- Node 4: Ux = 0.0 in, Uy = 0.0 in, theta = 0.0 radians
Loading [MathJax]/jax/output/CommonHTML/fonts/TeX/fontdata.js